Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
6 changes: 6 additions & 0 deletions demo-output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,12 @@
lineNumber: 1
variables:
file: file:///examples/nodejs/Component.tsx
- uri: file:///examples/nodejs/Component.tsx
message: Found React reference using nodejs provider
codeSnip: " 1 import React from 'react';\n 2 \n 3 export const MyComponent: React.FC = () => {\n 4 return <div>Hello from TypeScript React</div>;\n 5 };\n"
lineNumber: 3
variables:
file: file:///examples/nodejs/Component.tsx
- uri: file:///examples/nodejs/LegacyComponent.jsx
message: Found React reference using nodejs provider
codeSnip: " 1 import React from 'react';\n 2 \n 3 export const LegacyComponent = () => {\n 4 return <div>Hello from JavaScript React</div>;\n 5 };\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"path/filepath"
"strings"

"github.com/go-logr/logr"
Expand Down Expand Up @@ -45,7 +46,11 @@ func (n *NodeServiceClientBuilder) Init(ctx context.Context, log logr.Logger, c

params := protocol.InitializeParams{}

// treat location as the only workspace folder
if c.Location != "" {
if !strings.HasPrefix(c.Location, "file://") {
c.Location = "file://" + c.Location
}
sc.Config.WorkspaceFolders = []string{c.Location}
}

Expand All @@ -59,16 +64,37 @@ func (n *NodeServiceClientBuilder) Init(ctx context.Context, log logr.Logger, c
} else {
params.RootURI = sc.Config.WorkspaceFolders[0]
}
// var workspaceFolders []protocol.WorkspaceFolder
// for _, f := range sc.Config.WorkspaceFolders {
// workspaceFolders = append(workspaceFolders, protocol.WorkspaceFolder{
// URI: f,
// Name: f,
// })
// }
// params.WorkspaceFolders = workspaceFolders

params.Capabilities = protocol.ClientCapabilities{}
var workspaceFolders []protocol.WorkspaceFolder
seen := make(map[string]bool)
for _, f := range sc.Config.WorkspaceFolders {
if seen[f] {
continue
}
seen[f] = true
workspaceFolders = append(workspaceFolders, protocol.WorkspaceFolder{
URI: f,
Name: filepath.Base(strings.ReplaceAll(f, "file://", "")),
})
}
params.WorkspaceFolders = workspaceFolders

params.Capabilities = protocol.ClientCapabilities{
Copy link
Contributor

Choose a reason for hiding this comment

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

Either here or a follow up can note what each of these does and why we need them?

Workspace: &protocol.WorkspaceClientCapabilities{
WorkspaceFolders: true,
Diagnostics: &protocol.DiagnosticWorkspaceClientCapabilities{
RefreshSupport: true,
},
},
TextDocument: &protocol.TextDocumentClientCapabilities{
Definition: &protocol.DefinitionClientCapabilities{
LinkSupport: true,
},
DocumentSymbol: &protocol.DocumentSymbolClientCapabilities{
HierarchicalDocumentSymbolSupport: true,
},
},
}

var InitializationOptions map[string]any
err = json.Unmarshal([]byte(sc.Config.LspServerInitializationOptions), &InitializationOptions)
Expand Down Expand Up @@ -140,7 +166,7 @@ func (sc *NodeServiceClient) EvaluateReferenced(ctx context.Context, cap string,
}

// Query symbols once after all files are indexed
symbols := sc.GetAllDeclarations(ctx, query)
symbols := sc.GetAllDeclarations(ctx, query, false)
incidentsMap, err := sc.EvaluateSymbols(ctx, symbols)
if err != nil {
return resp{}, err
Expand Down
2 changes: 1 addition & 1 deletion lsp/base_service_client/base_capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func EvaluateReferenced[T base](t T, ctx ctx, cap string, info []byte) (resp, er
return resp{}, fmt.Errorf("unable to get query info")
}

symbols := sc.GetAllDeclarations(ctx, query)
symbols := sc.GetAllDeclarations(ctx, query, true)

incidents := []provider.IncidentContext{}
incidentsMap := make(map[string]provider.IncidentContext) // Remove duplicates
Expand Down
Loading
Loading