github.com/v2fly/tools@v0.100.0/internal/lsp/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 namesInitializeError [int(UnknownProtocolVersion) + 1]string 14 namesMessageType [int(Log) + 1]string 15 namesFileChangeType [int(Deleted) + 1]string 16 namesWatchKind [int(WatchDelete) + 1]string 17 namesCompletionTriggerKind [int(TriggerForIncompleteCompletions) + 1]string 18 namesDiagnosticSeverity [int(SeverityHint) + 1]string 19 namesDiagnosticTag [int(Unnecessary) + 1]string 20 namesCompletionItemKind [int(TypeParameterCompletion) + 1]string 21 namesInsertTextFormat [int(SnippetTextFormat) + 1]string 22 namesDocumentHighlightKind [int(Write) + 1]string 23 namesSymbolKind [int(TypeParameter) + 1]string 24 namesTextDocumentSaveReason [int(FocusOut) + 1]string 25 ) 26 27 func init() { 28 namesTextDocumentSyncKind[int(None)] = "None" 29 namesTextDocumentSyncKind[int(Full)] = "Full" 30 namesTextDocumentSyncKind[int(Incremental)] = "Incremental" 31 32 namesInitializeError[int(UnknownProtocolVersion)] = "UnknownProtocolVersion" 33 34 namesMessageType[int(Error)] = "Error" 35 namesMessageType[int(Warning)] = "Warning" 36 namesMessageType[int(Info)] = "Info" 37 namesMessageType[int(Log)] = "Log" 38 39 namesFileChangeType[int(Created)] = "Created" 40 namesFileChangeType[int(Changed)] = "Changed" 41 namesFileChangeType[int(Deleted)] = "Deleted" 42 43 namesWatchKind[int(WatchCreate)] = "WatchCreate" 44 namesWatchKind[int(WatchChange)] = "WatchChange" 45 namesWatchKind[int(WatchDelete)] = "WatchDelete" 46 47 namesCompletionTriggerKind[int(Invoked)] = "Invoked" 48 namesCompletionTriggerKind[int(TriggerCharacter)] = "TriggerCharacter" 49 namesCompletionTriggerKind[int(TriggerForIncompleteCompletions)] = "TriggerForIncompleteCompletions" 50 51 namesDiagnosticSeverity[int(SeverityError)] = "Error" 52 namesDiagnosticSeverity[int(SeverityWarning)] = "Warning" 53 namesDiagnosticSeverity[int(SeverityInformation)] = "Information" 54 namesDiagnosticSeverity[int(SeverityHint)] = "Hint" 55 56 namesDiagnosticTag[int(Unnecessary)] = "Unnecessary" 57 58 namesCompletionItemKind[int(TextCompletion)] = "text" 59 namesCompletionItemKind[int(MethodCompletion)] = "method" 60 namesCompletionItemKind[int(FunctionCompletion)] = "func" 61 namesCompletionItemKind[int(ConstructorCompletion)] = "constructor" 62 namesCompletionItemKind[int(FieldCompletion)] = "field" 63 namesCompletionItemKind[int(VariableCompletion)] = "var" 64 namesCompletionItemKind[int(ClassCompletion)] = "type" 65 namesCompletionItemKind[int(InterfaceCompletion)] = "interface" 66 namesCompletionItemKind[int(ModuleCompletion)] = "package" 67 namesCompletionItemKind[int(PropertyCompletion)] = "property" 68 namesCompletionItemKind[int(UnitCompletion)] = "unit" 69 namesCompletionItemKind[int(ValueCompletion)] = "value" 70 namesCompletionItemKind[int(EnumCompletion)] = "enum" 71 namesCompletionItemKind[int(KeywordCompletion)] = "keyword" 72 namesCompletionItemKind[int(SnippetCompletion)] = "snippet" 73 namesCompletionItemKind[int(ColorCompletion)] = "color" 74 namesCompletionItemKind[int(FileCompletion)] = "file" 75 namesCompletionItemKind[int(ReferenceCompletion)] = "reference" 76 namesCompletionItemKind[int(FolderCompletion)] = "folder" 77 namesCompletionItemKind[int(EnumMemberCompletion)] = "enumMember" 78 namesCompletionItemKind[int(ConstantCompletion)] = "const" 79 namesCompletionItemKind[int(StructCompletion)] = "struct" 80 namesCompletionItemKind[int(EventCompletion)] = "event" 81 namesCompletionItemKind[int(OperatorCompletion)] = "operator" 82 namesCompletionItemKind[int(TypeParameterCompletion)] = "typeParam" 83 84 namesInsertTextFormat[int(PlainTextTextFormat)] = "PlainText" 85 namesInsertTextFormat[int(SnippetTextFormat)] = "Snippet" 86 87 namesDocumentHighlightKind[int(Text)] = "Text" 88 namesDocumentHighlightKind[int(Read)] = "Read" 89 namesDocumentHighlightKind[int(Write)] = "Write" 90 91 namesSymbolKind[int(File)] = "File" 92 namesSymbolKind[int(Module)] = "Module" 93 namesSymbolKind[int(Namespace)] = "Namespace" 94 namesSymbolKind[int(Package)] = "Package" 95 namesSymbolKind[int(Class)] = "Class" 96 namesSymbolKind[int(Method)] = "Method" 97 namesSymbolKind[int(Property)] = "Property" 98 namesSymbolKind[int(Field)] = "Field" 99 namesSymbolKind[int(Constructor)] = "Constructor" 100 namesSymbolKind[int(Enum)] = "Enum" 101 namesSymbolKind[int(Interface)] = "Interface" 102 namesSymbolKind[int(Function)] = "Function" 103 namesSymbolKind[int(Variable)] = "Variable" 104 namesSymbolKind[int(Constant)] = "Constant" 105 namesSymbolKind[int(String)] = "String" 106 namesSymbolKind[int(Number)] = "Number" 107 namesSymbolKind[int(Boolean)] = "Boolean" 108 namesSymbolKind[int(Array)] = "Array" 109 namesSymbolKind[int(Object)] = "Object" 110 namesSymbolKind[int(Key)] = "Key" 111 namesSymbolKind[int(Null)] = "Null" 112 namesSymbolKind[int(EnumMember)] = "EnumMember" 113 namesSymbolKind[int(Struct)] = "Struct" 114 namesSymbolKind[int(Event)] = "Event" 115 namesSymbolKind[int(Operator)] = "Operator" 116 namesSymbolKind[int(TypeParameter)] = "TypeParameter" 117 118 namesTextDocumentSaveReason[int(Manual)] = "Manual" 119 namesTextDocumentSaveReason[int(AfterDelay)] = "AfterDelay" 120 namesTextDocumentSaveReason[int(FocusOut)] = "FocusOut" 121 } 122 123 func formatEnum(f fmt.State, c rune, i int, names []string, unknown string) { 124 s := "" 125 if i >= 0 && i < len(names) { 126 s = names[i] 127 } 128 if s != "" { 129 fmt.Fprint(f, s) 130 } else { 131 fmt.Fprintf(f, "%s(%d)", unknown, i) 132 } 133 } 134 135 func parseEnum(s string, names []string) int { 136 for i, name := range names { 137 if s == name { 138 return i 139 } 140 } 141 return 0 142 } 143 144 func (e TextDocumentSyncKind) Format(f fmt.State, c rune) { 145 formatEnum(f, c, int(e), namesTextDocumentSyncKind[:], "TextDocumentSyncKind") 146 } 147 148 func ParseTextDocumentSyncKind(s string) TextDocumentSyncKind { 149 return TextDocumentSyncKind(parseEnum(s, namesTextDocumentSyncKind[:])) 150 } 151 152 func (e InitializeError) Format(f fmt.State, c rune) { 153 formatEnum(f, c, int(e), namesInitializeError[:], "InitializeError") 154 } 155 156 func ParseInitializeError(s string) InitializeError { 157 return InitializeError(parseEnum(s, namesInitializeError[:])) 158 } 159 160 func (e MessageType) Format(f fmt.State, c rune) { 161 formatEnum(f, c, int(e), namesMessageType[:], "MessageType") 162 } 163 164 func ParseMessageType(s string) MessageType { 165 return MessageType(parseEnum(s, namesMessageType[:])) 166 } 167 168 func (e FileChangeType) Format(f fmt.State, c rune) { 169 formatEnum(f, c, int(e), namesFileChangeType[:], "FileChangeType") 170 } 171 172 func ParseFileChangeType(s string) FileChangeType { 173 return FileChangeType(parseEnum(s, namesFileChangeType[:])) 174 } 175 176 func (e WatchKind) Format(f fmt.State, c rune) { 177 formatEnum(f, c, int(e), namesWatchKind[:], "WatchKind") 178 } 179 180 func ParseWatchKind(s string) WatchKind { 181 return WatchKind(parseEnum(s, namesWatchKind[:])) 182 } 183 184 func (e CompletionTriggerKind) Format(f fmt.State, c rune) { 185 formatEnum(f, c, int(e), namesCompletionTriggerKind[:], "CompletionTriggerKind") 186 } 187 188 func ParseCompletionTriggerKind(s string) CompletionTriggerKind { 189 return CompletionTriggerKind(parseEnum(s, namesCompletionTriggerKind[:])) 190 } 191 192 func (e DiagnosticSeverity) Format(f fmt.State, c rune) { 193 formatEnum(f, c, int(e), namesDiagnosticSeverity[:], "DiagnosticSeverity") 194 } 195 196 func ParseDiagnosticSeverity(s string) DiagnosticSeverity { 197 return DiagnosticSeverity(parseEnum(s, namesDiagnosticSeverity[:])) 198 } 199 200 func (e DiagnosticTag) Format(f fmt.State, c rune) { 201 formatEnum(f, c, int(e), namesDiagnosticTag[:], "DiagnosticTag") 202 } 203 204 func ParseDiagnosticTag(s string) DiagnosticTag { 205 return DiagnosticTag(parseEnum(s, namesDiagnosticTag[:])) 206 } 207 208 func (e CompletionItemKind) Format(f fmt.State, c rune) { 209 formatEnum(f, c, int(e), namesCompletionItemKind[:], "CompletionItemKind") 210 } 211 212 func ParseCompletionItemKind(s string) CompletionItemKind { 213 return CompletionItemKind(parseEnum(s, namesCompletionItemKind[:])) 214 } 215 216 func (e InsertTextFormat) Format(f fmt.State, c rune) { 217 formatEnum(f, c, int(e), namesInsertTextFormat[:], "InsertTextFormat") 218 } 219 220 func ParseInsertTextFormat(s string) InsertTextFormat { 221 return InsertTextFormat(parseEnum(s, namesInsertTextFormat[:])) 222 } 223 224 func (e DocumentHighlightKind) Format(f fmt.State, c rune) { 225 formatEnum(f, c, int(e), namesDocumentHighlightKind[:], "DocumentHighlightKind") 226 } 227 228 func ParseDocumentHighlightKind(s string) DocumentHighlightKind { 229 return DocumentHighlightKind(parseEnum(s, namesDocumentHighlightKind[:])) 230 } 231 232 func (e SymbolKind) Format(f fmt.State, c rune) { 233 formatEnum(f, c, int(e), namesSymbolKind[:], "SymbolKind") 234 } 235 236 func ParseSymbolKind(s string) SymbolKind { 237 return SymbolKind(parseEnum(s, namesSymbolKind[:])) 238 } 239 240 func (e TextDocumentSaveReason) Format(f fmt.State, c rune) { 241 formatEnum(f, c, int(e), namesTextDocumentSaveReason[:], "TextDocumentSaveReason") 242 } 243 244 func ParseTextDocumentSaveReason(s string) TextDocumentSaveReason { 245 return TextDocumentSaveReason(parseEnum(s, namesTextDocumentSaveReason[:])) 246 }