Skip to content

Refactor analysis CLI helpers to use source input#8466

Open
aspeddro wants to merge 2 commits into
rescript-lang:masterfrom
aspeddro:refactor-analysis-take-three
Open

Refactor analysis CLI helpers to use source input#8466
aspeddro wants to merge 2 commits into
rescript-lang:masterfrom
aspeddro:refactor-analysis-take-three

Conversation

@aspeddro

@aspeddro aspeddro commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Refactor analysis CLI helpers to use source input

Move document symbols and interface generation behind CLI helpers that operate on source content instead of reading files internally. Thread parsed max inlay hint length as an option, pass preloaded CMT data into code actions.

Update the DocTemplate expected output for the new CMT lookup message emitted during non-compiled code action tests.

Some cases that are not done in #8426

Cherry-pick of #8425

Move document symbols and interface generation behind CLI helpers that
operate on source content instead of reading files internally. Thread
parsed max inlay hint length as an option, pass preloaded CMT data into
code actions.

Update the DocTemplate expected output for the new CMT lookup message
emitted during non-compiled code action tests.
@aspeddro aspeddro force-pushed the refactor-analysis-take-three branch from 5bf9e43 to 21f2294 Compare June 9, 2026 01:58
@aspeddro

aspeddro commented Jun 9, 2026

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: 21f2294231

ℹ️ 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/cli.ml
Xform.extract_code_actions ~state ~path ~start_pos ~end_pos ~source
~kind_file ~debug
~kind_file
~full:(Cmt.load_full_cmt_from_path ~state ~path)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3 Badge Avoid loading CMTs for interface-only code actions

When current_file is a .resi, Xform.extract_code_actions never uses full, but this eager call still tries to resolve a CMT for path before dispatching. In uncompiled/interface-only cases this now emits can't find module ... (as shown by the updated DocTemplate fixture) and does unnecessary package/CMT lookup for doc-template actions that work purely from source; compute full only for implementation actions that need type information.

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.

Fixed in 6d26568

@pkg-pr-new

pkg-pr-new Bot commented Jun 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

rescript

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

@rescript/darwin-arm64

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

@rescript/darwin-x64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit: 6d26568

@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 60.91%. Comparing base (b15413a) to head (6d26568).

Files with missing lines Patch % Lines
analysis/src/cmt.ml 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8466      +/-   ##
==========================================
- Coverage   60.91%   60.91%   -0.01%     
==========================================
  Files         374      374              
  Lines       54099    54100       +1     
==========================================
  Hits        32955    32955              
- Misses      21144    21145       +1     
Files with missing lines Coverage Δ
analysis/src/cmt.ml 29.41% <0.00%> (-0.59%) ⬇️
🚀 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.

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