Skip to content
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

Subscribe to updates of module.calls data #909

Merged
merged 8 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions internal/langserver/handlers/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ func initializeResponse(t *testing.T, commandPrefix string) string {
"supported": true,
"changeNotifications": "workspace/didChangeWorkspaceFolders"
}
},
"experimental": {
"referenceCountCodeLens": false,
"refreshModuleProviders": false,
"refreshModuleCalls": false
radeksimko marked this conversation as resolved.
Show resolved Hide resolved
}
},
"serverInfo": {
Expand Down
16 changes: 10 additions & 6 deletions internal/langserver/handlers/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,22 @@ func (svc *service) Initialize(ctx context.Context, params lsp.InitializeParams)
}
}

expServerCaps := lsp.ExperimentalServerCapabilities{}

if _, ok := expClientCaps.ShowReferencesCommandId(); ok {
serverCaps.Capabilities.Experimental = lsp.ExperimentalServerCapabilities{
ReferenceCountCodeLens: true,
}
expServerCaps.ReferenceCountCodeLens = true
properties["experimentalCapabilities.referenceCountCodeLens"] = true
}
if _, ok := expClientCaps.RefreshModuleProvidersCommandId(); ok {
serverCaps.Capabilities.Experimental = lsp.ExperimentalServerCapabilities{
RefreshModuleProviders: true,
}
expServerCaps.RefreshModuleProviders = true
properties["experimentalCapabilities.refreshModuleProviders"] = true
}
if _, ok := expClientCaps.RefreshModuleProvidersCommandId(); ok {
expServerCaps.RefreshModuleCalls = true
properties["experimentalCapabilities.refreshModuleProviders"] = true
jpogran marked this conversation as resolved.
Show resolved Hide resolved
}

serverCaps.Capabilities.Experimental = expServerCaps
radeksimko marked this conversation as resolved.
Show resolved Hide resolved

err = ilsp.SetClientCapabilities(ctx, &clientCaps)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions internal/langserver/handlers/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,11 @@ func (svc *service) configureSessionDependencies(ctx context.Context, cfgOpts *s
refreshModuleProviders(svc.sessCtx, svc.server, svc.logger, commandId))
}

if commandId, ok := lsp.ExperimentalClientCapabilities(cc.Experimental).RefreshModuleCallsCommandId(); ok {
svc.stateStore.Modules.ChangeHooks = append(svc.stateStore.Modules.ChangeHooks,
refreshModuleProviders(svc.sessCtx, svc.server, svc.logger, commandId))
radeksimko marked this conversation as resolved.
Show resolved Hide resolved
}

if cc.Workspace.SemanticTokens.RefreshSupport {
svc.stateStore.Modules.ChangeHooks = append(svc.stateStore.Modules.ChangeHooks,
refreshSemanticTokens(ctx, svc.srvCtx, svc.logger))
Expand Down
10 changes: 10 additions & 0 deletions internal/protocol/experimental.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package protocol
type ExperimentalServerCapabilities struct {
ReferenceCountCodeLens bool `json:"referenceCountCodeLens"`
RefreshModuleProviders bool `json:"refreshModuleProviders"`
RefreshModuleCalls bool `json:"refreshModuleCalls"`
}

type ExpClientCapabilities map[string]interface{}
Expand Down Expand Up @@ -32,6 +33,15 @@ func (cc ExpClientCapabilities) RefreshModuleProvidersCommandId() (string, bool)
return cmdId, ok
}

func (cc ExpClientCapabilities) RefreshModuleCallsCommandId() (string, bool) {
if cc == nil {
return "", false
}

cmdId, ok := cc["refereshModuleCallsCommandId"].(string)
radeksimko marked this conversation as resolved.
Show resolved Hide resolved
return cmdId, ok
}

func (cc ExpClientCapabilities) TelemetryVersion() (int, bool) {
if cc == nil {
return 0, false
Expand Down