Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
sheetalkamat wants to merge2 commits intomain
base:main
Choose a base branch
Loading
fromworkspace
Open
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletioninternal/ls/completions_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2172,7 +2172,7 @@ func assertIncludesItem(t *testing.T, actual *lsproto.CompletionList, expected *

funccreateLanguageService(ctx context.Context,fileNamestring,filesmap[string]any) (*ls.LanguageService,func()) {
projectService,_:=projecttestutil.Setup(files,nil)
projectService.OpenFile(fileName,files[fileName].(string),core.GetScriptKindFromFileName(fileName),"")
projectService.OpenFile(fileName,files[fileName].(string),core.GetScriptKindFromFileName(fileName))
project:=projectService.Projects()[0]
returnproject.GetLanguageServiceForRequest(ctx)
}
Expand Down
37 changes: 35 additions & 2 deletionsinternal/lsp/server.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -141,6 +141,7 @@ type Server struct {

initializeParams *lsproto.InitializeParams
positionEncoding lsproto.PositionEncodingKind
workspace *project.Workspace

watchEnabled bool
watcherID atomic.Uint32
Expand DownExpand Up@@ -471,6 +472,8 @@ func (s *Server) handleRequestOrNotification(ctx context.Context, req *lsproto.R
return s.handleDidClose(ctx, req)
case *lsproto.DidChangeWatchedFilesParams:
return s.handleDidChangeWatchedFiles(ctx, req)
case *lsproto.DidChangeWorkspaceFoldersParams:
return s.handleDidChangeWorkspaceFolders(ctx, req)
case *lsproto.DocumentDiagnosticParams:
return s.handleDocumentDiagnostic(ctx, req)
case *lsproto.HoverParams:
Expand DownExpand Up@@ -566,6 +569,14 @@ func (s *Server) handleInitialize(req *lsproto.RequestMessage) {
FirstTriggerCharacter: "{",
MoreTriggerCharacter: &[]string{"}", ";", "\n"},
},
Workspace: &lsproto.WorkspaceOptions{
WorkspaceFolders: &lsproto.WorkspaceFoldersServerCapabilities{
Supported: ptrTo(true),
ChangeNotifications: ptrTo(lsproto.StringOrBoolean{
Boolean: ptrTo(true),
}),
},
},
},
})
}
Expand All@@ -591,12 +602,20 @@ func (s *Server) handleInitialized(ctx context.Context, req *lsproto.RequestMess
s.projectService.SetCompilerOptionsForInferredProjects(s.compilerOptionsForInferredProjects)
}

if s.initializeParams.RootUri.Value != "" {
s.projectService.Workspace.SetRoot(ls.DocumentURIToFileName(s.initializeParams.RootUri.Value))
}
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
MemberAuthor

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.

}
}
return nil
}

func (s *Server) handleDidOpen(ctx context.Context, req *lsproto.RequestMessage) error {
params := req.Params.(*lsproto.DidOpenTextDocumentParams)
s.projectService.OpenFile(ls.DocumentURIToFileName(params.TextDocument.Uri), params.TextDocument.Text, ls.LanguageKindToScriptKind(params.TextDocument.LanguageId), "")
s.projectService.OpenFile(ls.DocumentURIToFileName(params.TextDocument.Uri), params.TextDocument.Text, ls.LanguageKindToScriptKind(params.TextDocument.LanguageId))
return nil
}

Expand All@@ -622,6 +641,19 @@ func (s *Server) handleDidChangeWatchedFiles(ctx context.Context, req *lsproto.R
return s.projectService.OnWatchedFilesChanged(ctx, params.Changes)
}

func (s *Server) handleDidChangeWorkspaceFolders(ctx context.Context, req *lsproto.RequestMessage) error {
params := req.Params.(*lsproto.DidChangeWorkspaceFoldersParams)
if params.Event != nil {
for _, folder := range params.Event.Added {
s.workspace.AddFolder(ls.DocumentURIToFileName(lsproto.DocumentUri(folder.Uri)))
}
for _, folder := range params.Event.Removed {
s.workspace.RemoveFolder(ls.DocumentURIToFileName(lsproto.DocumentUri(folder.Uri)))
}
}
return nil
}

func (s *Server) handleDocumentDiagnostic(ctx context.Context, req *lsproto.RequestMessage) error {
params := req.Params.(*lsproto.DocumentDiagnosticParams)
project := s.projectService.EnsureDefaultProjectForURI(params.TextDocument.Uri)
Expand DownExpand Up@@ -827,7 +859,8 @@ func isBlockingMethod(method lsproto.Method) bool {
lsproto.MethodTextDocumentDidChange,
lsproto.MethodTextDocumentDidSave,
lsproto.MethodTextDocumentDidClose,
lsproto.MethodWorkspaceDidChangeWatchedFiles:
lsproto.MethodWorkspaceDidChangeWatchedFiles,
lsproto.MethodWorkspaceDidChangeWorkspaceFolders:
return true
}
return false
Expand Down
44 changes: 22 additions & 22 deletionsinternal/project/ata_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,7 @@ func TestAta(t *testing.T) {
TypesRegistry: []string{"config"},
},
})
service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS, "")
service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS)
assert.Equal(t, len(service.Projects()), 1)
_, p := service.EnsureDefaultProjectForFile("/user/username/projects/project/app.js")
assert.Equal(t, p.Kind(), project.KindConfigured)
Expand DownExpand Up@@ -70,7 +70,7 @@ func TestAta(t *testing.T) {
},
},
})
service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS, "")
service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS)
assert.Equal(t, len(service.Projects()), 1)
_, p := service.EnsureDefaultProjectForFile("/user/username/projects/project/app.js")
assert.Equal(t, p.Kind(), project.KindConfigured)
Expand DownExpand Up@@ -108,7 +108,7 @@ func TestAta(t *testing.T) {
},
},
})
service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS, "")
service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS)
assert.Equal(t, len(service.Projects()), 1)
_, p := service.EnsureDefaultProjectForFile("/user/username/projects/project/app.js")
assert.Equal(t, p.Kind(), project.KindInferred)
Expand DownExpand Up@@ -142,7 +142,7 @@ func TestAta(t *testing.T) {
TypesRegistry: []string{"jquery"},
},
})
service.OpenFile("/user/username/projects/project/jquery.js", files["/user/username/projects/project/jquery.js"].(string), core.ScriptKindJS, "")
service.OpenFile("/user/username/projects/project/jquery.js", files["/user/username/projects/project/jquery.js"].(string), core.ScriptKindJS)
assert.Equal(t, len(service.Projects()), 1)
_, p := service.EnsureDefaultProjectForFile("/user/username/projects/project/jquery.js")
assert.Equal(t, p.Kind(), project.KindConfigured)
Expand DownExpand Up@@ -170,7 +170,7 @@ func TestAta(t *testing.T) {
TypesRegistry: []string{"node"},
},
})
service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS, "")
service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS)
assert.Equal(t, len(service.Projects()), 1)
_, p := service.EnsureDefaultProjectForFile("/user/username/projects/project/app.js")
assert.Equal(t, p.Kind(), project.KindConfigured)
Expand DownExpand Up@@ -210,8 +210,8 @@ func TestAta(t *testing.T) {
},
})

service.OpenFile("/user/username/projects/project1/app.js", files["/user/username/projects/project1/app.js"].(string), core.ScriptKindJS, "")
service.OpenFile("/user/username/projects/project2/app.js", files["/user/username/projects/project2/app.js"].(string), core.ScriptKindJS, "")
service.OpenFile("/user/username/projects/project1/app.js", files["/user/username/projects/project1/app.js"].(string), core.ScriptKindJS)
service.OpenFile("/user/username/projects/project2/app.js", files["/user/username/projects/project2/app.js"].(string), core.ScriptKindJS)
_, p1 := service.EnsureDefaultProjectForFile("/user/username/projects/project1/app.js")
_, p2 := service.EnsureDefaultProjectForFile("/user/username/projects/project2/app.js")
var installStatuses []project.TypingsInstallerStatus
Expand DownExpand Up@@ -271,8 +271,8 @@ func TestAta(t *testing.T) {
}
}

service.OpenFile("/user/username/projects/project1/app.js", files["/user/username/projects/project1/app.js"].(string), core.ScriptKindJS, "")
service.OpenFile("/user/username/projects/project2/app.js", files["/user/username/projects/project2/app.js"].(string), core.ScriptKindJS, "")
service.OpenFile("/user/username/projects/project1/app.js", files["/user/username/projects/project1/app.js"].(string), core.ScriptKindJS)
service.OpenFile("/user/username/projects/project2/app.js", files["/user/username/projects/project2/app.js"].(string), core.ScriptKindJS)
_, p1 := service.EnsureDefaultProjectForFile("/user/username/projects/project1/app.js")
_, p2 := service.EnsureDefaultProjectForFile("/user/username/projects/project2/app.js")
// Order is determinate since second install will run only after completing first one
Expand DownExpand Up@@ -310,7 +310,7 @@ func TestAta(t *testing.T) {
},
})

service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS, "")
service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS)
_, p := service.EnsureDefaultProjectForFile("/user/username/projects/project/app.js")
// Order is determinate since second install will run only after completing first one
status := <-host.ServiceOptions.InstallStatus
Expand DownExpand Up@@ -352,7 +352,7 @@ func TestAta(t *testing.T) {
},
})

service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS, "")
service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS)
_, p := service.EnsureDefaultProjectForFile("/user/username/projects/project/app.js")
// Order is determinate since second install will run only after completing first one
status := <-host.ServiceOptions.InstallStatus
Expand DownExpand Up@@ -394,7 +394,7 @@ func TestAta(t *testing.T) {
},
})

service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS, "")
service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS)
_, p := service.EnsureDefaultProjectForFile("/user/username/projects/project/app.js")
// Order is determinate since second install will run only after completing first one
status := <-host.ServiceOptions.InstallStatus
Expand DownExpand Up@@ -436,7 +436,7 @@ func TestAta(t *testing.T) {
},
})

service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS, "")
service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS)
_, p := service.EnsureDefaultProjectForFile("/user/username/projects/project/app.js")
// Order is determinate since second install will run only after completing first one
status := <-host.ServiceOptions.InstallStatus
Expand All@@ -463,7 +463,7 @@ func TestAta(t *testing.T) {
},
})

service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS, "")
service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS)
_, p := service.EnsureDefaultProjectForFile("/user/username/projects/project/app.js")
// Order is determinate since second install will run only after completing first one
status := <-host.ServiceOptions.InstallStatus
Expand DownExpand Up@@ -495,7 +495,7 @@ func TestAta(t *testing.T) {
},
})

service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS, "")
service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS)
_, p := service.EnsureDefaultProjectForFile("/user/username/projects/project/app.js")
// Order is determinate since second install will run only after completing first one
status := <-host.ServiceOptions.InstallStatus
Expand All@@ -522,7 +522,7 @@ func TestAta(t *testing.T) {
},
})

service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS, "")
service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS)
_, p := service.EnsureDefaultProjectForFile("/user/username/projects/project/app.js")
// Order is determinate since second install will run only after completing first one
status := <-host.ServiceOptions.InstallStatus
Expand DownExpand Up@@ -571,7 +571,7 @@ func TestAta(t *testing.T) {
},
})

service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS, "")
service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS)
_, p := service.EnsureDefaultProjectForFile("/user/username/projects/project/app.js")
// Order is determinate since second install will run only after completing first one
status := <-host.ServiceOptions.InstallStatus
Expand DownExpand Up@@ -602,7 +602,7 @@ func TestAta(t *testing.T) {
},
})

service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS, "")
service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS)
_, p := service.EnsureDefaultProjectForFile("/user/username/projects/project/app.js")
// Order is determinate since second install will run only after completing first one
status := <-host.ServiceOptions.InstallStatus
Expand DownExpand Up@@ -651,7 +651,7 @@ func TestAta(t *testing.T) {
},
})

service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS, "")
service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS)
_, p := service.EnsureDefaultProjectForFile("/user/username/projects/project/app.js")
// Order is determinate since second install will run only after completing first one
status := <-host.ServiceOptions.InstallStatus
Expand DownExpand Up@@ -697,7 +697,7 @@ func TestAta(t *testing.T) {
},
})

service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS, "")
service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS)
_, p := service.EnsureDefaultProjectForFile("/user/username/projects/project/app.js")
// Order is determinate since second install will run only after completing first one
status := <-host.ServiceOptions.InstallStatus
Expand DownExpand Up@@ -745,7 +745,7 @@ func TestAta(t *testing.T) {
},
})

service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS, "")
service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS)
_, p := service.EnsureDefaultProjectForFile("/user/username/projects/project/app.js")
// Order is determinate since second install will run only after completing first one
status := <-host.ServiceOptions.InstallStatus
Expand DownExpand Up@@ -791,7 +791,7 @@ func TestAta(t *testing.T) {
},
})

service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS, "")
service.OpenFile("/user/username/projects/project/app.js", files["/user/username/projects/project/app.js"].(string), core.ScriptKindJS)
_, p := service.EnsureDefaultProjectForFile("/user/username/projects/project/app.js")
// Order is determinate since second install will run only after completing first one
status := <-host.ServiceOptions.InstallStatus
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp