-
Notifications
You must be signed in to change notification settings - Fork 483
Analysis refactor for #8425 #8478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
fdaf766
b5f3b72
1cab964
9843819
09ca89a
5ad1af7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -530,6 +530,7 @@ and package = { | |
| suffix: string; | ||
| root_path: file_path; | ||
| project_files: File_set.t; | ||
| dependencies: string list; | ||
| dependencies_files: File_set.t; | ||
| paths_for_module: (file, paths) Hashtbl.t; | ||
| namespace: string option; | ||
|
|
@@ -965,3 +966,108 @@ let extract_exp_apply_args ~args = | |
| | [] -> List.rev acc | ||
| in | ||
| args |> process_args ~acc:[] | ||
|
|
||
| let state_to_yojson (state : state) = | ||
| let option_to_yojson f = function | ||
| | None -> `Null | ||
| | Some value -> f value | ||
| in | ||
|
|
||
| let string_set_to_yojson set = | ||
| `List (set |> File_set.elements |> List.map (fun value -> `String value)) | ||
| in | ||
|
|
||
| let path_to_yojson path = `List (List.map (fun item -> `String item) path) in | ||
|
|
||
| let paths_to_yojson = function | ||
| | Impl {cmt; res} -> | ||
| `Assoc | ||
| [("kind", `String "Impl"); ("cmt", `String cmt); ("res", `String res)] | ||
| | Namespace {cmt} -> | ||
| `Assoc [("kind", `String "Namespace"); ("cmt", `String cmt)] | ||
| | IntfAndImpl {cmti; resi; cmt; res} -> | ||
| `Assoc | ||
| [ | ||
| ("kind", `String "IntfAndImpl"); | ||
| ("cmti", `String cmti); | ||
| ("resi", `String resi); | ||
| ("cmt", `String cmt); | ||
| ("res", `String res); | ||
| ] | ||
| in | ||
|
|
||
| let paths_for_module_to_yojson paths_for_module = | ||
| paths_for_module |> Hashtbl.to_seq | ||
| |> Seq.map (fun (file, paths) -> (file, paths_to_yojson paths)) | ||
| |> List.of_seq | ||
| |> fun fields -> `Assoc fields | ||
| in | ||
|
|
||
| let autocomplete_to_yojson autocomplete = | ||
| autocomplete |> Misc.String_map.bindings | ||
| |> List.map (fun (name, files) -> | ||
| (name, `List (List.map (fun file -> `String file) files))) | ||
| |> fun fields -> `Assoc fields | ||
| in | ||
|
|
||
| let package_to_yojson (package : package) = | ||
| let major, minor = package.rescript_version in | ||
| `Assoc | ||
| [ | ||
| ( "generic_jsx_module", | ||
| option_to_yojson | ||
| (fun value -> `String value) | ||
| package.generic_jsx_module ); | ||
| ("suffix", `String package.suffix); | ||
| ("root_path", `String package.root_path); | ||
| ("project_files", string_set_to_yojson package.project_files); | ||
| ( "dependencies", | ||
| `List (package.dependencies |> List.map (fun x -> `String x)) ); | ||
| ("dependencies_files", string_set_to_yojson package.dependencies_files); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ("paths_for_module", paths_for_module_to_yojson package.paths_for_module); | ||
| ( "namespace", | ||
| option_to_yojson (fun value -> `String value) package.namespace ); | ||
| ("opens", `List (List.map path_to_yojson package.opens)); | ||
| ( "rescript_version", | ||
| `Assoc [("major", `Int major); ("minor", `Int minor)] ); | ||
| ("autocomplete", autocomplete_to_yojson package.autocomplete); | ||
| ] | ||
| in | ||
|
|
||
| let file_to_yojson (file : File.t) = | ||
| `Assoc | ||
| [ | ||
| ("uri", `String (file.uri |> Lsp.Uri.to_string)); | ||
| ("module_name", `String file.module_name); | ||
| ("stamps_count", `Int (List.length (Stamps.get_entries file.stamps))); | ||
| ("structure_name", `String file.structure.name); | ||
| ( "structure_docstring", | ||
| `List (List.map (fun value -> `String value) file.structure.docstring) | ||
| ); | ||
| ("structure_items_count", `Int (List.length file.structure.items)); | ||
| ] | ||
| in | ||
|
|
||
| let cmt_cache = | ||
| state.cmt_cache |> Hashtbl.to_seq | ||
| |> Seq.map (fun (file_path, file) -> (file_path, file_to_yojson file)) | ||
| |> List.of_seq | ||
| in | ||
|
|
||
| let root_for_uri = | ||
| state.root_for_uri |> Hashtbl.to_seq |> List.of_seq | ||
| |> List.map (fun (uri, str) -> [(Lsp.Uri.to_string uri, `String str)]) | ||
| |> List.flatten | ||
| in | ||
|
|
||
| let packages_by_root = | ||
| state.packages_by_root |> Hashtbl.to_seq |> List.of_seq | ||
| |> List.map (fun (root, package) -> (root, package_to_yojson package)) | ||
| in | ||
|
|
||
| `Assoc | ||
| [ | ||
| ("cmt_cache", `Assoc cmt_cache); | ||
| ("root_for_uri", `Assoc root_for_uri); | ||
| ("packages_by_root", `Assoc packages_by_root); | ||
| ] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
rescript.jsonuses the supported qualified dependency form like{ "name": "pkg", "features": [...] }, this filter keeps only JSON strings and silently omits that dependency from the analysis package state. The build config accepts both shorthand and qualified dependency entries (rewatch/src/config.rsdefinesDependencyas eitherShorthandorQualifiedand wires it todependencies), so server-side consumers of this new metadata will see an incomplete dependency list for feature-gated packages. Please extract thenamefield from object entries instead of dropping them.Useful? React with 👍 / 👎.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is currently supported, @fhammerschmidt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No clue, but feel free to create another issue for it.