Skip to content

Add support for workspace #1238

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add support for workspace #1238

wants to merge 2 commits into from

Conversation

sheetalkamat
Copy link
Member

No description provided.

@Copilot Copilot AI review requested due to automatic review settings June 19, 2025 20:04
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 adds workspace support by introducing a new Workspace structure and integrating workspace-related operations into project and LSP services. Key changes include updating the Workspace API (adding SetRoot, AddFolder, and RemoveFolder), refactoring OpenFile calls to remove redundant parameters, and adapting tests and server logic to work with the new workspace management.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/project/workspace.go Introduces Workspace struct with helper functions for folder management.
internal/project/workspace_test.go Adds tests validating GetProjectRootPath and folder addition/removal in a workspace context.
internal/project/service.go and related tests Updates OpenFile signature and usage to derive project root path from Workspace instead of a parameter.
internal/lsp/server.go Integrates workspace updates in LSP initialization and folder change notifications.
Others (service_test.go, projectreferencesprogram_test.go, etc.) Adjust tests to accommodate removal of the redundant projectRootPath parameter in OpenFile calls.
Comments suppressed due to low confidence (1)

internal/lsp/server.go:646

  • The handler uses 's.workspace' for updating workspace folders, but elsewhere workspace operations are performed through 's.projectService.Workspace'. To ensure consistency and avoid potential nil pointer issues, consider using 's.projectService.Workspace' or ensuring 's.workspace' is properly initialized.
			s.workspace.AddFolder(ls.DocumentURIToFileName(lsproto.DocumentUri(folder.Uri)))

@sheetalkamat sheetalkamat marked this pull request as draft June 19, 2025 20:28
@sheetalkamat sheetalkamat marked this pull request as ready for review June 19, 2025 21:37
}
if s.initializeParams.WorkspaceFolders != nil {
for _, folder := range s.initializeParams.WorkspaceFolders.Value {
s.projectService.Workspace.AddFolder(ls.DocumentURIToFileName(lsproto.DocumentUri(folder.Uri)))
Copy link
Member

Choose a reason for hiding this comment

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

Do you know why we need to handle this kind of thing? Typically this stuff is only ever used if we plan to explicitly handle multi-root workspaces, but I don't think we have a reason to do that, since we're great at just accepting whatever gets opened anyway?

Copy link
Member Author

Choose a reason for hiding this comment

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

this was used for creating better inferred projects - thats when projectRootPath was introduced
It is also used to not lookup tsconfig beyond the project root locations. I added this because with multi project thing the search locations increase and wanted to make sure i am not going beyond the point it needs to.

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