Skip to content

Analysis refactor for #8425#8478

Open
aspeddro wants to merge 6 commits into
rescript-lang:masterfrom
aspeddro:analysis-omit-children-symbols
Open

Analysis refactor for #8425#8478
aspeddro wants to merge 6 commits into
rescript-lang:masterfrom
aspeddro:analysis-omit-children-symbols

Conversation

@aspeddro

@aspeddro aspeddro commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

This PR has five commits.

  • fdaf766: 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.
  • b5f3b72: Return optional codemod results. The LSP server needs to run codemods without exiting the process. Add an option-returning entry point and keep the existing CLI wrapper exiting on failure.
  • 1cab964: Serialize analysis state to JSON. Expose a JSON representation of the analysis state so server-side code can inspect packages, roots, CMT cache entries, and related package metadata.
  • 9843819: Track package dependencies in analysis state. Read package dependencies from rescript.json and store them on the analysis package state so server-side features can access dependency metadata.
  • 09ca89a: Update CHANGELOG.md

Cherry-pick of #8425

aspeddro added 4 commits June 17, 2026 12:42
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>
@aspeddro aspeddro changed the title Analysis omit children symbols Analysis refactor for #8425 Jun 17, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9843819886

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

("suffix", `String package.suffix);
("root_path", `String package.root_path);
("project_files", string_set_to_yojson package.project_files);
("dependencies_files", string_set_to_yojson package.dependencies_files);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include package dependencies in serialized state

When state_to_yojson serializes each package, it never emits the new package.dependencies field populated in Packages.new_bs_package; it jumps from project_files to dependencies_files. Server-side consumers calling this new JSON API can inspect dependency file paths but cannot see the dependency names/metadata this change adds, so packages with entries like "dependencies": ["@rescript/react"] are indistinguishable from packages with no dependency list. Please serialize package.dependencies here as its own field.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread analysis/src/packages.ml Outdated
|> List.map (fun path -> path @ ["place holder"])
in
let dependencies =
match config |> Yojson_helpers.get "dependencies" with

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve supported bs-dependencies aliases

For projects that still use the supported bs-dependencies alias, this new metadata is always empty because it only reads the dependencies key. The rest of analysis still treats bs-dependencies as an alias when resolving dependency files (analysis/src/find_files.ml:271-280), so server features using package.dependencies will report no dependencies even though the package is resolved and compiled with them. Please reuse the same alias-aware parsing for this field.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pkg-pr-new

pkg-pr-new Bot commented Jun 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript@8478

@rescript/darwin-arm64

npm i https://pkg.pr.new/@rescript/darwin-arm64@8478

@rescript/darwin-x64

npm i https://pkg.pr.new/@rescript/darwin-x64@8478

@rescript/linux-arm64

npm i https://pkg.pr.new/@rescript/linux-arm64@8478

@rescript/linux-x64

npm i https://pkg.pr.new/@rescript/linux-x64@8478

@rescript/runtime

npm i https://pkg.pr.new/@rescript/runtime@8478

@rescript/win32-x64

npm i https://pkg.pr.new/@rescript/win32-x64@8478

commit: 5ad1af7

@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 32.89474% with 51 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.37%. Comparing base (7004d36) to head (5ad1af7).

Files with missing lines Patch % Lines
analysis/src/shared_types.ml 0.00% 41 Missing ⚠️
analysis/src/codemod.ml 65.38% 9 Missing ⚠️
analysis/src/packages.ml 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8478      +/-   ##
==========================================
- Coverage   74.42%   74.37%   -0.06%     
==========================================
  Files         451      451              
  Lines       61459    61509      +50     
==========================================
+ Hits        45743    45749       +6     
- Misses      15716    15760      +44     
Files with missing lines Coverage Δ
analysis/src/document_symbol.ml 55.00% <100.00%> (+0.67%) ⬆️
analysis/src/packages.ml 76.52% <83.33%> (+0.15%) ⬆️
analysis/src/codemod.ml 68.96% <65.38%> (-6.04%) ⬇️
analysis/src/shared_types.ml 69.51% <0.00%> (-9.94%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aspeddro

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5ad1af7b19

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread analysis/src/packages.ml
with
| None, None -> []
| Some deps, None | _, Some deps ->
deps |> List.filter_map Yojson_helpers.string_opt

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve qualified dependency entries

When rescript.json uses 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.rs defines Dependency as either Shorthand or Qualified and wires it to dependencies), so server-side consumers of this new metadata will see an incomplete dependency list for feature-gated packages. Please extract the name field from object entries instead of dropping them.

Useful? React with 👍 / 👎.

@aspeddro aspeddro Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant