Add custom/projectFiles LSP request#4179
Conversation
…o navyasingh/VS2757301
There was a problem hiding this comment.
Pull request overview
Adds a new custom/projectFiles LSP request to expose the server’s currently loaded projects along with their program source files, intended for VS clients to build a Roslyn workspace model.
Changes:
- Register a new server handler for
custom/projectFilesand implement project/file enumeration from the current session snapshot. - Add LSP-level tests covering configured, inferred, and “no projects loaded” scenarios.
- Extend the generated LSP protocol types and generator inputs to include the new request and result structures.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/lsp/server.go | Registers/implements handleProjectFiles to return loaded projects and their source file URIs. |
| internal/lsp/server_projectfiles_test.go | Adds integration tests for the new custom request. |
| internal/lsp/lsproto/lsp_generated.go | Adds generated protocol types + method/result unmarshalling and request mapping for custom/projectFiles. |
| internal/lsp/lsproto/_generate/generate.mts | Updates protocol generator inputs (structures + custom request entry). |
| sourceFiles := proj.Program.GetSourceFiles() | ||
| files := make([]lsproto.DocumentUri, 0, len(sourceFiles)) | ||
| for _, sf := range sourceFiles { | ||
| files = append(files, lsconv.FileNameToDocumentURI(sf.FileName())) | ||
| } |
| configFilePath := "" | ||
| if proj.Kind == project.KindConfigured { | ||
| configFilePath = proj.Name() | ||
| } |
|
How is that going to be used by VS exactly? The projects that we currently have on the snapshot are typically only the ones we need to know about given the current set of open files, so I'm just wondering if VS having only partial project information is ok. |
VS uses this to populate the Roslyn workspace for Task List (TODO comments). Roslyn's Task List only scans documents with active text buffers, so it only needs projects for currently open files — which is exactly what the snapshot provides. Partial project info is fine here since the client and the server are both scoped to open files. |
Adds a new custom/projectFiles request that returns all loaded projects and their source files. This enables VS clients to populate the Roslyn workspace with project structure information from tsgo, which is needed for features like Task List (TODO comments) that operate on workspace documents.
Protocol:
Request: custom/projectFiles
Params: none
Result: { projects: [{ configFilePath: string, files: string[] }] }
Each project entry contains the config file path (or inferred root) and an array of file URIs belonging to that project.