Add getSymbolOfSourceFile to the API - #4791
Open
dragomirtitian wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds direct source-file symbol lookup without transferring AST data to JavaScript clients.
Changes:
- Adds single and batched protocol handlers.
- Exposes synchronous and asynchronous checker APIs.
- Adds module, script, and batching tests.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
internal/api/session.go |
Implements request handlers. |
internal/api/proto.go |
Defines methods and parameters. |
internal/api/session_temporary_test.go |
Updates diagnostic test parameters. |
_packages/native-preview/src/api/sync/api.ts |
Adds synchronous checker API. |
_packages/native-preview/src/api/async/api.ts |
Adds asynchronous checker API. |
_packages/native-preview/test/sync/api.test.ts |
Tests synchronous behavior. |
_packages/native-preview/test/async/api.test.ts |
Tests asynchronous behavior. |
Comments suppressed due to low confidence (3)
internal/api/session_temporary_test.go:76
GetDiagnosticsParamshas noFilesfield; this causes a compile error. Use itsFile *DocumentIdentifierfield for the temporary file.
Files: []DocumentIdentifier{{FileName: fileName}},
internal/api/session_temporary_test.go:85
- This references a nonexistent
Filesfield onGetDiagnosticsParams, preventing the test package from compiling. Restore the pointer-valuedFilefield.
Files: []DocumentIdentifier{{FileName: fileName}},
internal/api/session_temporary_test.go:97
GetDiagnosticsParamsonly definesFile *DocumentIdentifier; usingFileshere is a compile error. Restore the single-file parameter.
Files: []DocumentIdentifier{{FileName: fileName}},
dragomirtitian
force-pushed
the
add-get-symbol-of-source-file
branch
from
July 29, 2026 18:06
8ef2f80 to
8881c67
Compare
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.
In our build tool we have a use case where we just walk over the exported symbols of a module to find all the ways a symbol can be accessed. In this case we don't really need the AST to be present on the JS side. Currently the only way to get the symbol for a file is to first have the
SourceFileobject usinggetSourceFile. But this triggers the transfer of the AST information which will be unused.This PR adds a dedicated
getSymbolOfSourceFilemethod that lets us get the symbol bypassing theSourceFileobjectAlternate solution:
getSymbolAtPositioncurrently never returns the symbol for the whole file. We could just changegetSymbolOfSourceFileto allowundefinedfor thepositionparameter and then it would return the symbol for the file itself.