-
Notifications
You must be signed in to change notification settings - Fork 764
Fix references code lens to include imports as references #2368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
When finding references for an exported symbol, the import specifier
(e.g., `abc` in `import { abc } from "./abc"`) should be counted as
a reference to the export. This change:
1. Adds the import location as a reference to the export symbol in
searchForImportsOfExport for non-aliased imports.
2. Skips duplicate addition of import specifiers when the search
is coming from an export context, since they're already added
by the explicit addRef call.
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
jakebailey
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot whatever you add, make sure it actually has a basis in the original implementation, and not something made up
| // === findAllReferences === | ||
| // === /myproject/a/index.ts === | ||
| // import { [|B|] } from "../b/lib"; | ||
| // import { [|[|B|]|] } from "../b/lib"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot this range is being doubled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in aaefcb7 - reverted the changes that caused the doubled ranges.
| -// import {Foo} from './foo' | ||
| +// import {[|Foo|]} from './foo' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot this is regressing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in aaefcb7 - reverted the changes that caused the regression.
| -// import { Interface } from "./def"; | ||
| -// const c: I/*GOTO IMPL*/nterface = [|{ P: 2 }|]; | ||
| +// <|import { [|Interface|] } from "./def";|> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot this is regressing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in aaefcb7 - reverted the changes that caused the regression.
The previous fix was adding imports to singleReferences and adding skip logic in getReferencesAtLocation, but this approach was not based on the original TypeScript implementation and caused: - Doubled reference ranges like [|[|B|]|] - Regressions in goToImplementation tests This reverts to the original behavior while keeping the fourslash test that demonstrates the issue (showing 0 references for now). Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Reverted the incorrect fix in commit aaefcb7. The test is kept to demonstrate the issue, but the baseline now shows the current behavior (0 references). A proper fix requires more careful analysis of how TypeScript handles |
Status
The fourslash test
codeLensReferencesIncludeImports_test.gois kept to demonstrate the issue. The baseline shows0 referenceswhich is the current (incorrect) behavior.A proper fix requires more careful analysis of how TypeScript handles the difference between
isDefinitionmarking vs Go's per-entry declaration filtering.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.