Repository navigation
Use the symbol name for the rename placeholder - #65535
Closed
Josué Barros (joshbarros) wants to merge 2 commits into
Closed
Josué Barros (joshbarros) wants to merge 2 commits into
Josué Barros (joshbarros) wants to merge 2 commits into
Conversation
getRenameInfoForNode passed SymbolToString to the rename placeholder. For a property declared with a quoted or computed name, SymbolToString prints the declaration form, so prepareRename prefilled 'b' or ['c'] instead of b or c. The classic implementation uses the symbol name, which is already unquoted. The trigger range was already correct and is unchanged. Adds an LSP test for obj.a, obj['a'], obj.b and obj.c.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Rename preparation for private identifiers prefills a class-specific internal key instead of the source name (e.g., #foo); use ast.SymbolName(symbol) and add an exact private-name placeholder assertion.
1 open issue
What changed in this PR
This PR addresses #65444 by using symbol names for language-server rename placeholders, removing declaration quotes and brackets while leaving trigger ranges unchanged.
Changes:
- Replaces symbol stringification with the stored symbol name.
- Adds an LSP regression test for ordinary, quoted, and computed property names.
| File | Description |
|---|---|
tsc/internal/lsp/server_rename_test.go |
Adds exact placeholder assertions for four property-access cases. |
tsc/internal/ls/rename.go |
Changes the name used in rename placeholders. |
Review effort: Balanced
symbol.Name() returns the class-specific internal key for a private identifier, so preparing a rename on #x returned that key instead of #x. Use SymbolToString for private identifiers and keep the symbol name for the quoted and computed property fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #65444
getRenameInfoForNodepassedSymbolToStringas the rename placeholder. For a property declared with a quoted or computed name,SymbolToStringprints the declaration form, soprepareRenameprefilled'b'or['c']instead ofborc. The classic implementation uses the symbol name, which is already unquoted. The trigger range was already correct and is unchanged.The new
TestPrepareRenamePlaceholderForQuotedPropertiescoversobj.a,obj['a'],obj.bandobj.c. On the unfixed server the last two placeholders are'b'and['c'].Validation:
go test ./tsc/internal/lsp -run TestPrepareRenamePlaceholderForQuotedProperties -count=1: fails without the change, passes with it.go test ./tsc/internal/ls ./tsc/internal/lsp -count=1: pass.go test ./tsc/internal/fourslash/tests -run 'Rename' -count=1: pass.gofmt: clean.Drafted with assistance from an AI assistant. I reviewed the diff and ran the tests above.