in src/ulsp/entity/ulsp-plugin/ulsp_plugin.go [108:257]
func (m *PluginInfo) Validate() error {
// Required fields.
if len(m.Priorities) == 0 {
return fmt.Errorf(_errorMissingField, "Priorities")
} else if m.Methods == nil {
return fmt.Errorf(_errorMissingField, "Methods")
} else if m.NameKey == "" {
return fmt.Errorf(_errorMissingField, "NameKey")
} else if m.Methods.PluginNameKey != m.NameKey {
return fmt.Errorf(_errorMissingField, "Methods.SourcePlugin")
}
// Each configuration key must have a matching entry in Methods.
for key := range m.Priorities {
switch key {
// Lifecycle related methods.
case protocol.MethodInitialize:
if m.Methods.Initialize == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodInitialized:
if m.Methods.Initialized == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodShutdown:
if m.Methods.Shutdown == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodExit:
if m.Methods.Exit == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
// Document related methods.
case protocol.MethodTextDocumentDidChange:
if m.Methods.DidChange == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodWorkspaceDidChangeWatchedFiles:
if m.Methods.DidChangeWatchedFiles == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodTextDocumentDidOpen:
if m.Methods.DidOpen == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodTextDocumentDidClose:
if m.Methods.DidClose == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodTextDocumentWillSave:
if m.Methods.WillSave == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodTextDocumentWillSaveWaitUntil:
if m.Methods.WillSaveWaitUntil == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodTextDocumentDidSave:
if m.Methods.DidSave == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodWillRenameFiles:
if m.Methods.WillRenameFiles == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodDidRenameFiles:
if m.Methods.DidRenameFiles == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodWillCreateFiles:
if m.Methods.WillCreateFiles == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodDidCreateFiles:
if m.Methods.DidCreateFiles == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodWillDeleteFiles:
if m.Methods.WillDeleteFiles == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodDidDeleteFiles:
if m.Methods.DidDeleteFiles == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodTextDocumentCodeAction:
if m.Methods.CodeAction == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodTextDocumentCodeLens:
if m.Methods.CodeLens == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodCodeLensRefresh:
if m.Methods.CodeLensRefresh == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodCodeLensResolve:
if m.Methods.CodeLensResolve == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodTextDocumentDeclaration:
if m.Methods.GotoDeclaration == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodTextDocumentDefinition:
if m.Methods.GotoDefinition == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodTextDocumentTypeDefinition:
if m.Methods.GotoTypeDefinition == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodTextDocumentImplementation:
if m.Methods.GotoImplementation == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodTextDocumentReferences:
if m.Methods.References == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodTextDocumentHover:
if m.Methods.Hover == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodTextDocumentDocumentSymbol:
if m.Methods.DocumentSymbol == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodWorkspaceExecuteCommand:
if m.Methods.ExecuteCommand == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case protocol.MethodWorkDoneProgressCancel:
if m.Methods.WorkDoneProgressCancel == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
case MethodEndSession:
if m.Methods.EndSession == nil {
return fmt.Errorf(_errorMissingMethod, key)
}
default:
return fmt.Errorf(_errorUnrecognizedMethod, key)
}
}
return nil
}