in src/ulsp/controller/quick-actions/quick_actions.go [140:174]
func (c *controller) initialize(ctx context.Context, params *protocol.InitializeParams, result *protocol.InitializeResult) error {
s, err := c.sessions.GetFromContext(ctx)
if err != nil {
return fmt.Errorf("getting session: %w", err)
}
supportedCodeActionKinds := []protocol.CodeActionKind{}
for kind := range action.SupportedCodeActionKinds {
supportedCodeActionKinds = append(supportedCodeActionKinds, kind)
}
if err := mapper.InitializeResultAppendCodeActionProvider(result, &protocol.CodeActionOptions{CodeActionKinds: supportedCodeActionKinds}); err != nil {
return fmt.Errorf("failed to append CodeActionProvider: %w", err)
}
if err := mapper.InitializeResultEnsureCodeLensProvider(result, false); err != nil {
return fmt.Errorf("failed to append CodeLensProvider: %w", err)
}
commands := []string{}
for _, action := range allActions {
if action.ShouldEnable(s, c.config[s.Monorepo]) {
c.enabledActions[s.UUID] = append(c.enabledActions[s.UUID], action)
if action.CommandName() != "" {
commands = append(commands, action.CommandName())
}
}
}
if err := mapper.InitializeResultAppendExecuteCommandProvider(result, &protocol.ExecuteCommandOptions{Commands: commands}); err != nil {
return fmt.Errorf("failed to append ExecuteCommandProvider: %w", err)
}
return nil
}