Skip to content

findAllReferences inital port #882

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

Merged
merged 18 commits into from
Jun 5, 2025
Merged

Conversation

iisaduan
Copy link
Member

@iisaduan iisaduan commented May 20, 2025

This port focuses on the logic needed to resolving symbols within a single file.

Todos after this PR:

  • Search for references through module resolving
  • Search for references through imported and exported symbol resolving
    • Some imported and global symbols return references, but it is hard to test with the current lstestutil capabilities.
  • Jsdoc references (not sure how much of the currently un-ported parts will be needed, since @sandersn has been working to simplify jsdoc checking)
  • Special cases for object literals
  • Special cases for classes and keywords
  • String references

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ports the findAllReferences functionality and updates various components across the codebase. Key changes include:

  • Adding new APIs and handlers (e.g. ResolveTripleslashReference in the path package and handleReferences in the LSP server) to support reference lookup.
  • Replacing usage of older APIs (like GetAssignmentDeclarationKind) with new ones (GetJSDocAssignmentDeclarationKind) and renaming several utility functions for better export visibility.
  • Introducing new testing files for findAllReferences and new core utilities (FlatMap and CoalesceList).

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/tspath/path.go Added ResolveTripleslashReference for triple-slash path resolution.
internal/parser/reparser.go Updated assignment declaration kind calls to use GetJSDocAssignmentDeclarationKind.
internal/lsp/server.go Added handling for ReferenceParams and a new handleReferences function.
internal/ls/findallreferencesexport_test.go New test file for export reference lookups.
internal/ls/findallreferences_test.go New tests covering various findAllReferences scenarios.
internal/core/core.go Introduced FlatMap and CoalesceList utility functions.
internal/compiler/program.go Added functions for module resolution improvements and extension handling.
internal/checker/utilities.go Renamed internal helper functions (e.g. HasModifier, GetSingleVariableOfVariableStatement).
internal/checker/services.go Added GetSymbolsOfParameterPropertyDeclaration for parameter-property handling.
internal/checker/printer.go Updated modifier check call in expression printing.
internal/checker/exports.go Added exported helper functions for type operations and symbol merging.
internal/checker/checker.go Replaced legacy modifier and assignment kind calls with their updated versions.
internal/binder/nameresolver.go Updated internal module/enum checks and exported GetLocalSymbolForExportDefault.
internal/binder/binder.go Switched to use GetJSDocAssignmentDeclarationKind in assignment binding logic.
internal/astnav/tokens.go Added GetTouchingToken as an alternative for token retrieval in AST.
internal/ast/utilities.go Introduced several new AST helper functions and renamed utility methods.

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

I haven't read findallreferences.go yet but here are my comments for the rest. I focussed on changes needed for JS. I'll follow up with comments for the big file tomorrow.

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

Minor comments on findallreferences.go, nothing substantive.

@iisaduan iisaduan requested a review from andrewbranch June 4, 2025 21:55
@jakebailey
Copy link
Member

Seems like this fails to compile, probably due to more code getting added in other PRs.

@iisaduan iisaduan added this pull request to the merge queue Jun 5, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 5, 2025
@jakebailey jakebailey added this pull request to the merge queue Jun 5, 2025
Merged via the queue into microsoft:main with commit bdee372 Jun 5, 2025
57 of 63 checks passed
@iisaduan iisaduan deleted the findAllRef branch June 9, 2025 19:19
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.

None yet

5 participants