Skip to content

Add versions of get*Diagostics that allow passing in an array of files.#4552

Open
dragomirtitian wants to merge 2 commits into
microsoft:mainfrom
dragomirtitian:add-batched-get-diagnostic-functions
Open

Add versions of get*Diagostics that allow passing in an array of files.#4552
dragomirtitian wants to merge 2 commits into
microsoft:mainfrom
dragomirtitian:add-batched-get-diagnostic-functions

Conversation

@dragomirtitian

Copy link
Copy Markdown

This PR allows passing multiple files to the get*Diagnostic functions 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.

Copilot AI review requested due to automatic review settings July 7, 2026 14:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 getDiagnostics implementation and accept a files array.
  • Updates native-preview async/sync Program.get*Diagnostics methods to accept a DocumentIdentifier or 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 thread internal/api/proto.go
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"`
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Since the API is unstable and unreleased, do we care about backward compatibility?

Comment thread internal/api/session.go Outdated
Comment thread _packages/native-preview/test/sync/api.test.ts
Comment thread _packages/native-preview/test/async/api.test.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread internal/api/proto.go
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"`
}
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.

2 participants