Skip to content

Use Yojson and lsp types for analysis JSON output#8436

Draft
aspeddro wants to merge 16 commits into
rescript-lang:masterfrom
aspeddro:replace-json-with-yosjon
Draft

Use Yojson and lsp types for analysis JSON output#8436
aspeddro wants to merge 16 commits into
rescript-lang:masterfrom
aspeddro:replace-json-with-yosjon

Conversation

@aspeddro
Copy link
Copy Markdown
Contributor

@aspeddro aspeddro commented May 23, 2026

Replace the vendored JSON helpers with Yojson and the OCaml lsp types across analysis, reanalyze, and tools JSON handling.

This updates LSP response construction for completions, hovers, diagnostics, code actions, symbols, signature help, and related CLI commands, refreshes analysis snapshots, and adjusts extract-codeblocks decoding for the new serialized output.

TODO

  • Investigate null
  • Update CHANGELOG
  • Test analysis binary

Cherry-pick of #8425
Close #7456

aspeddro added 3 commits May 23, 2026 00:54
Replace the vendored JSON helpers with Yojson and the OCaml lsp types
across analysis, reanalyze, and tools JSON handling.

This updates LSP response construction for completions, hovers,
diagnostics, code actions, symbols, signature help, and related CLI
commands, refreshes analysis snapshots, and adjusts extract-codeblocks
decoding for the new serialized output.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 23, 2026

Codecov Report

❌ Patch coverage is 27.16049% with 59 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.08%. Comparing base (ecb1bba) to head (8e972be).

Files with missing lines Patch % Lines
analysis/src/FindFiles.ml 50.00% 13 Missing ⚠️
analysis/src/CompletionBackEnd.ml 0.00% 12 Missing ⚠️
analysis/src/SharedTypes.ml 0.00% 11 Missing ⚠️
analysis/src/Packages.ml 45.45% 6 Missing ⚠️
analysis/src/Uri.ml 28.57% 5 Missing ⚠️
analysis/src/Utils.ml 0.00% 5 Missing ⚠️
analysis/src/TypeUtils.ml 0.00% 3 Missing ⚠️
analysis/src/YojsonHelpers.ml 40.00% 3 Missing ⚠️
analysis/src/Loc.ml 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8436      +/-   ##
==========================================
+ Coverage   59.90%   60.08%   +0.17%     
==========================================
  Files         373      373              
  Lines       54228    54054     -174     
==========================================
- Hits        32487    32476      -11     
+ Misses      21741    21578     -163     
Files with missing lines Coverage Δ
analysis/src/Markdown.ml 0.00% <ø> (ø)
tests/ounit_tests/ounit_json_tests.ml 100.00% <ø> (ø)
tools/bin/main.ml 5.71% <ø> (-0.60%) ⬇️
tools/src/tools.ml 20.13% <ø> (+1.29%) ⬆️
analysis/src/Loc.ml 0.00% <0.00%> (ø)
analysis/src/TypeUtils.ml 0.00% <0.00%> (ø)
analysis/src/YojsonHelpers.ml 40.00% <40.00%> (ø)
analysis/src/Uri.ml 6.45% <28.57%> (-2.38%) ⬇️
analysis/src/Utils.ml 8.87% <0.00%> (-0.11%) ⬇️
analysis/src/Packages.ml 55.14% <45.45%> (-0.10%) ⬇️
... and 3 more
🚀 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 added 7 commits May 23, 2026 12:15
Serialize analysis command results with Yojson output helpers instead of
string extraction, fixing document symbols so they return JSON arrays
instead of crashing.

Also use typed LSP enum constructors for completion and inlay hint
kinds, clean up JSON config parsing, and update analysis test snapshots.
Replace the custom URI record with Lsp.Uri.t and delegate path/URI
conversion to the LSP library.

This fixes interface-aware analysis results so definitions, references,
and renames consistently target .resi files when an interface is
present,
and updates the analysis snapshots accordingly.
Comment thread tools/bin/main.ml
Comment on lines -163 to -172
match
Tools.ExtractCodeblocks.extractCodeblocksFromFile ~transformAssertEqual
~entryPointFile:path
with
| Ok _ as r ->
print_endline (Analysis.Protocol.stringifyResult r);
exit 0
| Error _ as r ->
print_endline (Analysis.Protocol.stringifyResult r);
exit 1)
Copy link
Copy Markdown
Contributor Author

@aspeddro aspeddro May 23, 2026

Choose a reason for hiding this comment

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

If is an error print to stderr

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 23, 2026

Open in StackBlitz

rescript

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

@rescript/darwin-arm64

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

@rescript/darwin-x64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit: 8e972be

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.

Replace Ext_json with yojson

1 participant