Skip to content

Commit 2e91023

Browse files
Analysis refactor for rescript-lang#8425 (rescript-lang#8478)
* Omit empty document symbol children DocumentSymbol.children is optional, so only set it when a symbol has nested entries. This avoids serializing leaf symbols with an empty children array. Signed-off-by: Pedro Castro <aspeddro@gmail.com> * add transform_opt for server-side use * analysis: add state_to_yojson * packages: add dependencies * Update CHANGELOG.md * Apply codex review suggestions * Refactor cmt_viewer.dump for serve-side * Analysis cmt dump return a string instead a option --------- Signed-off-by: Pedro Castro <aspeddro@gmail.com> Co-authored-by: Florian Hammerschmidt <florianh89@gmail.com> Signed-off-by: Pedro Castro <aspeddro@gmail.com>
1 parent b875c04 commit 2e91023

3 files changed

Lines changed: 14 additions & 8 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
- Refactor analysis CLI helpers to use source input. https://github.com/rescript-lang/rescript/pull/8466
7070
- Include syntax, gentype, analysis, tools, and reanalyze tests in coverage reports. https://github.com/rescript-lang/rescript/pull/8467
7171
- Remove the unreachable `Longident.Lapply` constructor (OCaml's applicative-functor path syntax `F(X).t`, which ReScript's grammar cannot produce). https://github.com/rescript-lang/rescript/pull/8469
72+
- Refactor analysis for server side use. https://github.com/rescript-lang/rescript/pull/8478
7273
- Remove unused files. https://github.com/rescript-lang/rescript/pull/8481
7374

7475
# 13.0.0-alpha.4

‎analysis/src/packages.ml‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,17 @@ let new_bs_package ~root_path =
173173
|> List.map (fun path -> path @ ["place holder"])
174174
in
175175
let dependencies =
176-
match config |> Yojson_helpers.get "dependencies" with
177-
| Some (`List deps) ->
178-
deps
179-
|> List.filter_map (fun (x : Yojson.Safe.t) ->
180-
match x with
181-
| `String name -> Some name
182-
| _ -> None)
183-
| _ -> []
176+
match
177+
( config
178+
|> Yojson_helpers.get "dependencies"
179+
|> bind Yojson_helpers.to_list_opt,
180+
config
181+
|> Yojson_helpers.get "bs-dependencies"
182+
|> bind Yojson_helpers.to_list_opt )
183+
with
184+
| None, None -> []
185+
| Some deps, None | _, Some deps ->
186+
deps |> List.filter_map Yojson_helpers.string_opt
184187
in
185188
{
186189
generic_jsx_module;

‎analysis/src/shared_types.ml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,8 @@ let state_to_yojson (state : state) =
10211021
("suffix", `String package.suffix);
10221022
("root_path", `String package.root_path);
10231023
("project_files", string_set_to_yojson package.project_files);
1024+
( "dependencies",
1025+
`List (package.dependencies |> List.map (fun x -> `String x)) );
10241026
("dependencies_files", string_set_to_yojson package.dependencies_files);
10251027
("paths_for_module", paths_for_module_to_yojson package.paths_for_module);
10261028
( "namespace",

0 commit comments

Comments
 (0)