Skip to content

feat(lsp): add quick fix for misspelled @namespace references - #87

Merged
monga-puneet merged 2 commits into
salesforce:mainfrom
BichengWang:feat/lsp-undefined-reference-quick-fix
Oct 9, 2026
Merged

monga-puneet merged 2 commits into
salesforce:mainfrom
BichengWang:feat/lsp-undefined-reference-quick-fix

Conversation

@BichengWang

Copy link
Copy Markdown
Contributor

What

Adds a "Change to ''" quick fix in the LSP for undefined-reference diagnostics, so @variables.custmer_name can be fixed to @variables.customer_name from the lightbulb menu. Misspelled namespaces (@varibles.x -> @variables.x) are handled too.

Why

The lint pass already works out a "Did you mean ...?" suggestion and puts it in data.suggestion, but the editor only shows it in the message text. invalid-modifier and unknown-type already have this kind of fix.

How

  • undefinedReferenceDiagnostic takes a new found argument (the misspelled segment) and stores it in data.found, the same key the other diagnostics use. All callers in language and the agentfabric dialect are updated, and the docs signature is too.
  • code-actions.ts replaces only that segment: the namespace right after the @, or the last member. It checks that the text at that position matches found before offering the fix. It skips multi-line ranges and @foo.foo, where the namespace and member can't be told apart.

Test Plan

  • New tests in code-actions.test.ts: misspelled member, misspelled namespace, no close match (no action)
  • pnpm test passes in packages/language, packages/lsp, dialect/agentscript, dialect/agentforce and dialect/agentfabric
  • pnpm typecheck and prettier pass for the touched packages

The undefined-reference lint already computes a "did you mean" suggestion
but the editor only showed it in the message. Add a "Change to '<name>'"
quick fix that replaces just the misspelled segment (the namespace or the
last member) of the reference.

To know which segment was misspelled, undefinedReferenceDiagnostic now
records it in data.found, matching what invalid-modifier and unknown-type
diagnostics already do.
@monga-puneet
monga-puneet merged commit f96ff81 into salesforce:main Oct 9, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants