Add versions of get*Diagostics that allow passing in an array of files.#4552
Open
dragomirtitian wants to merge 2 commits into
Open
Add versions of get*Diagostics that allow passing in an array of files.#4552dragomirtitian wants to merge 2 commits into
dragomirtitian wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the native-preview API’s get*Diagnostics methods to accept multiple files in a single request, reducing IPC overhead when diagnostics are needed for a selected set of files in a project.
Changes:
- Refactors server-side diagnostics handlers to share a common
getDiagnosticsimplementation and accept afilesarray. - Updates native-preview async/sync
Program.get*Diagnosticsmethods to accept aDocumentIdentifieror an array of them. - Adds new async/sync tests covering multi-file diagnostics calls (but currently missing an explicit empty-array behavior test).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/api/session.go | Refactors diagnostics handlers and adds files-based diagnostics retrieval. |
| internal/api/proto.go | Changes diagnostics request params from single file to files array. |
| _packages/native-preview/src/api/sync/api.ts | Updates sync API surface to accept single file or file array for diagnostics calls. |
| _packages/native-preview/src/api/async/api.ts | Updates async API surface to accept single file or file array for diagnostics calls. |
| _packages/native-preview/test/sync/api.test.ts | Adds sync tests for multi-file diagnostics requests. |
| _packages/native-preview/test/async/api.test.ts | Adds async tests for multi-file diagnostics requests. |
Comment on lines
1107
to
1111
| type GetDiagnosticsParams struct { | ||
| Snapshot SnapshotID `json:"snapshot"` | ||
| Project ProjectID `json:"project"` | ||
| File *DocumentIdentifier `json:"file,omitempty"` | ||
| Snapshot SnapshotID `json:"snapshot"` | ||
| Project ProjectID `json:"project"` | ||
| Files []DocumentIdentifier `json:"files,omitempty"` | ||
| } |
Author
There was a problem hiding this comment.
Since the API is unstable and unreleased, do we care about backward compatibility?
Comment on lines
1106
to
1111
| // GetDiagnosticsParams are parameters for per-file diagnostic methods. | ||
| type GetDiagnosticsParams struct { | ||
| Snapshot SnapshotID `json:"snapshot"` | ||
| Project ProjectID `json:"project"` | ||
| File *DocumentIdentifier `json:"file,omitempty"` | ||
| Snapshot SnapshotID `json:"snapshot"` | ||
| Project ProjectID `json:"project"` | ||
| Files []DocumentIdentifier `json:"files,omitempty"` | ||
| } |
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.
This PR allows passing multiple files to the
get*Diagnosticfunctions in the API.Motivation: We use these functions to get diagnostics for files that are of interest to us. These are all files that are in the current project (regular and declaration files) but not declaration files that come from a trusted source. Right now calling these once for file introduces substantial overhead. We would like to be able to request diagnostics for a specific set of files in one API call to reduce the IPC overhead.