golang.org/x/tools/gopls@v0.15.3/internal/protocol/enums.go (about) 1 // Copyright 2018 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package protocol 6 7 import ( 8 "fmt" 9 ) 10 11 var ( 12 namesTextDocumentSyncKind [int(Incremental) + 1]string 13 namesMessageType [int(Log) + 1]string 14 namesFileChangeType [int(Deleted) + 1]string 15 namesWatchKind [int(WatchDelete) + 1]string 16 namesCompletionTriggerKind [int(TriggerForIncompleteCompletions) + 1]string 17 namesDiagnosticSeverity [int(SeverityHint) + 1]string 18 namesDiagnosticTag [int(Unnecessary) + 1]string 19 namesCompletionItemKind [int(TypeParameterCompletion) + 1]string 20 namesInsertTextFormat [int(SnippetTextFormat) + 1]string 21 namesDocumentHighlightKind [int(Write) + 1]string 22 namesSymbolKind [int(TypeParameter) + 1]string 23 namesTextDocumentSaveReason [int(FocusOut) + 1]string 24 ) 25 26 func init() { 27 namesTextDocumentSyncKind[int(None)] = "None" 28 namesTextDocumentSyncKind[int(Full)] = "Full" 29 namesTextDocumentSyncKind[int(Incremental)] = "Incremental" 30 31 namesMessageType[int(Error)] = "Error" 32 namesMessageType[int(Warning)] = "Warning" 33 namesMessageType[int(Info)] = "Info" 34 namesMessageType[int(Log)] = "Log" 35 36 namesFileChangeType[int(Created)] = "Created" 37 namesFileChangeType[int(Changed)] = "Changed" 38 namesFileChangeType[int(Deleted)] = "Deleted" 39 40 namesWatchKind[int(WatchCreate)] = "WatchCreate" 41 namesWatchKind[int(WatchChange)] = "WatchChange" 42 namesWatchKind[int(WatchDelete)] = "WatchDelete" 43 44 namesCompletionTriggerKind[int(Invoked)] = "Invoked" 45 namesCompletionTriggerKind[int(TriggerCharacter)] = "TriggerCharacter" 46 namesCompletionTriggerKind[int(TriggerForIncompleteCompletions)] = "TriggerForIncompleteCompletions" 47 48 namesDiagnosticSeverity[int(SeverityError)] = "Error" 49 namesDiagnosticSeverity[int(SeverityWarning)] = "Warning" 50 namesDiagnosticSeverity[int(SeverityInformation)] = "Information" 51 namesDiagnosticSeverity[int(SeverityHint)] = "Hint" 52 53 namesDiagnosticTag[int(Unnecessary)] = "Unnecessary" 54 55 namesCompletionItemKind[int(TextCompletion)] = "text" 56 namesCompletionItemKind[int(MethodCompletion)] = "method" 57 namesCompletionItemKind[int(FunctionCompletion)] = "func" 58 namesCompletionItemKind[int(ConstructorCompletion)] = "constructor" 59 namesCompletionItemKind[int(FieldCompletion)] = "field" 60 namesCompletionItemKind[int(VariableCompletion)] = "var" 61 namesCompletionItemKind[int(ClassCompletion)] = "type" 62 namesCompletionItemKind[int(InterfaceCompletion)] = "interface" 63 namesCompletionItemKind[int(ModuleCompletion)] = "package" 64 namesCompletionItemKind[int(PropertyCompletion)] = "property" 65 namesCompletionItemKind[int(UnitCompletion)] = "unit" 66 namesCompletionItemKind[int(ValueCompletion)] = "value" 67 namesCompletionItemKind[int(EnumCompletion)] = "enum" 68 namesCompletionItemKind[int(KeywordCompletion)] = "keyword" 69 namesCompletionItemKind[int(SnippetCompletion)] = "snippet" 70 namesCompletionItemKind[int(ColorCompletion)] = "color" 71 namesCompletionItemKind[int(FileCompletion)] = "file" 72 namesCompletionItemKind[int(ReferenceCompletion)] = "reference" 73 namesCompletionItemKind[int(FolderCompletion)] = "folder" 74 namesCompletionItemKind[int(EnumMemberCompletion)] = "enumMember" 75 namesCompletionItemKind[int(ConstantCompletion)] = "const" 76 namesCompletionItemKind[int(StructCompletion)] = "struct" 77 namesCompletionItemKind[int(EventCompletion)] = "event" 78 namesCompletionItemKind[int(OperatorCompletion)] = "operator" 79 namesCompletionItemKind[int(TypeParameterCompletion)] = "typeParam" 80 81 namesInsertTextFormat[int(PlainTextTextFormat)] = "PlainText" 82 namesInsertTextFormat[int(SnippetTextFormat)] = "Snippet" 83 84 namesDocumentHighlightKind[int(Text)] = "Text" 85 namesDocumentHighlightKind[int(Read)] = "Read" 86 namesDocumentHighlightKind[int(Write)] = "Write" 87 88 namesSymbolKind[int(File)] = "File" 89 namesSymbolKind[int(Module)] = "Module" 90 namesSymbolKind[int(Namespace)] = "Namespace" 91 namesSymbolKind[int(Package)] = "Package" 92 namesSymbolKind[int(Class)] = "Class" 93 namesSymbolKind[int(Method)] = "Method" 94 namesSymbolKind[int(Property)] = "Property" 95 namesSymbolKind[int(Field)] = "Field" 96 namesSymbolKind[int(Constructor)] = "Constructor" 97 namesSymbolKind[int(Enum)] = "Enum" 98 namesSymbolKind[int(Interface)] = "Interface" 99 namesSymbolKind[int(Function)] = "Function" 100 namesSymbolKind[int(Variable)] = "Variable" 101 namesSymbolKind[int(Constant)] = "Constant" 102 namesSymbolKind[int(String)] = "String" 103 namesSymbolKind[int(Number)] = "Number" 104 namesSymbolKind[int(Boolean)] = "Boolean" 105 namesSymbolKind[int(Array)] = "Array" 106 namesSymbolKind[int(Object)] = "Object" 107 namesSymbolKind[int(Key)] = "Key" 108 namesSymbolKind[int(Null)] = "Null" 109 namesSymbolKind[int(EnumMember)] = "EnumMember" 110 namesSymbolKind[int(Struct)] = "Struct" 111 namesSymbolKind[int(Event)] = "Event" 112 namesSymbolKind[int(Operator)] = "Operator" 113 namesSymbolKind[int(TypeParameter)] = "TypeParameter" 114 115 namesTextDocumentSaveReason[int(Manual)] = "Manual" 116 namesTextDocumentSaveReason[int(AfterDelay)] = "AfterDelay" 117 namesTextDocumentSaveReason[int(FocusOut)] = "FocusOut" 118 } 119 120 func formatEnum(f fmt.State, i int, names []string, unknown string) { 121 s := "" 122 if i >= 0 && i < len(names) { 123 s = names[i] 124 } 125 if s != "" { 126 fmt.Fprint(f, s) 127 } else { 128 fmt.Fprintf(f, "%s(%d)", unknown, i) 129 } 130 } 131 132 func (e TextDocumentSyncKind) Format(f fmt.State, c rune) { 133 formatEnum(f, int(e), namesTextDocumentSyncKind[:], "TextDocumentSyncKind") 134 } 135 136 func (e MessageType) Format(f fmt.State, c rune) { 137 formatEnum(f, int(e), namesMessageType[:], "MessageType") 138 } 139 140 func (e FileChangeType) Format(f fmt.State, c rune) { 141 formatEnum(f, int(e), namesFileChangeType[:], "FileChangeType") 142 } 143 144 func (e CompletionTriggerKind) Format(f fmt.State, c rune) { 145 formatEnum(f, int(e), namesCompletionTriggerKind[:], "CompletionTriggerKind") 146 } 147 148 func (e DiagnosticSeverity) Format(f fmt.State, c rune) { 149 formatEnum(f, int(e), namesDiagnosticSeverity[:], "DiagnosticSeverity") 150 } 151 152 func (e DiagnosticTag) Format(f fmt.State, c rune) { 153 formatEnum(f, int(e), namesDiagnosticTag[:], "DiagnosticTag") 154 } 155 156 func (e CompletionItemKind) Format(f fmt.State, c rune) { 157 formatEnum(f, int(e), namesCompletionItemKind[:], "CompletionItemKind") 158 } 159 160 func (e InsertTextFormat) Format(f fmt.State, c rune) { 161 formatEnum(f, int(e), namesInsertTextFormat[:], "InsertTextFormat") 162 } 163 164 func (e DocumentHighlightKind) Format(f fmt.State, c rune) { 165 formatEnum(f, int(e), namesDocumentHighlightKind[:], "DocumentHighlightKind") 166 } 167 168 func (e SymbolKind) Format(f fmt.State, c rune) { 169 formatEnum(f, int(e), namesSymbolKind[:], "SymbolKind") 170 } 171 172 func (e TextDocumentSaveReason) Format(f fmt.State, c rune) { 173 formatEnum(f, int(e), namesTextDocumentSaveReason[:], "TextDocumentSaveReason") 174 }