1
0
mirror of https://github.com/golang/go synced 2024-11-18 18:44:42 -07:00

internal/lsp: switch completion item tests to using the enum strings

Also change the enum values to match the prior string conversion routine.

Change-Id: I23ac6a72c8e116c5ee05e9324356481e519781e9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172410
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Ian Cottrell 2019-04-16 22:04:21 -04:00
parent aa385af2d9
commit 7b3e515a8c
3 changed files with 36 additions and 57 deletions

View File

@ -389,31 +389,10 @@ func (c completions) collect(src token.Position, expected []token.Pos) {
}
func (i completionItems) collect(pos token.Pos, label, detail, kind string) {
var k protocol.CompletionItemKind
switch kind {
case "struct":
k = protocol.StructCompletion
case "func":
k = protocol.FunctionCompletion
case "var":
k = protocol.VariableCompletion
case "type":
k = protocol.TypeParameterCompletion
case "field":
k = protocol.FieldCompletion
case "interface":
k = protocol.InterfaceCompletion
case "const":
k = protocol.ConstantCompletion
case "method":
k = protocol.MethodCompletion
case "package":
k = protocol.ModuleCompletion
}
i[pos] = &protocol.CompletionItem{
Label: label,
Detail: detail,
Kind: k,
Kind: protocol.ParseCompletionItemKind(kind),
}
}

View File

@ -53,31 +53,31 @@ func init() {
namesDiagnosticTag[int(Unnecessary)] = "Unnecessary"
namesCompletionItemKind[int(TextCompletion)] = "TextCompletion"
namesCompletionItemKind[int(MethodCompletion)] = "MethodCompletion"
namesCompletionItemKind[int(FunctionCompletion)] = "FunctionCompletion"
namesCompletionItemKind[int(ConstructorCompletion)] = "ConstructorCompletion"
namesCompletionItemKind[int(FieldCompletion)] = "FieldCompletion"
namesCompletionItemKind[int(VariableCompletion)] = "VariableCompletion"
namesCompletionItemKind[int(ClassCompletion)] = "ClassCompletion"
namesCompletionItemKind[int(InterfaceCompletion)] = "InterfaceCompletion"
namesCompletionItemKind[int(ModuleCompletion)] = "ModuleCompletion"
namesCompletionItemKind[int(PropertyCompletion)] = "PropertyCompletion"
namesCompletionItemKind[int(UnitCompletion)] = "UnitCompletion"
namesCompletionItemKind[int(ValueCompletion)] = "ValueCompletion"
namesCompletionItemKind[int(EnumCompletion)] = "EnumCompletion"
namesCompletionItemKind[int(KeywordCompletion)] = "KeywordCompletion"
namesCompletionItemKind[int(SnippetCompletion)] = "SnippetCompletion"
namesCompletionItemKind[int(ColorCompletion)] = "ColorCompletion"
namesCompletionItemKind[int(FileCompletion)] = "FileCompletion"
namesCompletionItemKind[int(ReferenceCompletion)] = "ReferenceCompletion"
namesCompletionItemKind[int(FolderCompletion)] = "FolderCompletion"
namesCompletionItemKind[int(EnumMemberCompletion)] = "EnumMemberCompletion"
namesCompletionItemKind[int(ConstantCompletion)] = "ConstantCompletion"
namesCompletionItemKind[int(StructCompletion)] = "StructCompletion"
namesCompletionItemKind[int(EventCompletion)] = "EventCompletion"
namesCompletionItemKind[int(OperatorCompletion)] = "OperatorCompletion"
namesCompletionItemKind[int(TypeParameterCompletion)] = "TypeParameterCompletion"
namesCompletionItemKind[int(TextCompletion)] = "text"
namesCompletionItemKind[int(MethodCompletion)] = "method"
namesCompletionItemKind[int(FunctionCompletion)] = "func"
namesCompletionItemKind[int(ConstructorCompletion)] = "constructor"
namesCompletionItemKind[int(FieldCompletion)] = "field"
namesCompletionItemKind[int(VariableCompletion)] = "var"
namesCompletionItemKind[int(ClassCompletion)] = "class"
namesCompletionItemKind[int(InterfaceCompletion)] = "interface"
namesCompletionItemKind[int(ModuleCompletion)] = "package"
namesCompletionItemKind[int(PropertyCompletion)] = "property"
namesCompletionItemKind[int(UnitCompletion)] = "unit"
namesCompletionItemKind[int(ValueCompletion)] = "value"
namesCompletionItemKind[int(EnumCompletion)] = "enum"
namesCompletionItemKind[int(KeywordCompletion)] = "keyword"
namesCompletionItemKind[int(SnippetCompletion)] = "snippet"
namesCompletionItemKind[int(ColorCompletion)] = "color"
namesCompletionItemKind[int(FileCompletion)] = "file"
namesCompletionItemKind[int(ReferenceCompletion)] = "reference"
namesCompletionItemKind[int(FolderCompletion)] = "folder"
namesCompletionItemKind[int(EnumMemberCompletion)] = "enumMember"
namesCompletionItemKind[int(ConstantCompletion)] = "const"
namesCompletionItemKind[int(StructCompletion)] = "struct"
namesCompletionItemKind[int(EventCompletion)] = "event"
namesCompletionItemKind[int(OperatorCompletion)] = "operator"
namesCompletionItemKind[int(TypeParameterCompletion)] = "type"
namesInsertTextFormat[int(PlainTextTextFormat)] = "PlainText"
namesInsertTextFormat[int(SnippetTextFormat)] = "Snippet"

View File

@ -29,16 +29,16 @@ func init() {
namesDiagnosticSeverity[SeverityError] = "Error"
namesCompletionItemKind[Unknown] = "Unknown"
namesCompletionItemKind[InterfaceCompletionItem] = "InterfaceCompletion"
namesCompletionItemKind[StructCompletionItem] = "StructCompletion"
namesCompletionItemKind[TypeCompletionItem] = "TypeCompletion"
namesCompletionItemKind[ConstantCompletionItem] = "ConstantCompletion"
namesCompletionItemKind[FieldCompletionItem] = "FieldCompletion"
namesCompletionItemKind[ParameterCompletionItem] = "ParameterCompletion"
namesCompletionItemKind[VariableCompletionItem] = "VariableCompletion"
namesCompletionItemKind[FunctionCompletionItem] = "FunctionCompletion"
namesCompletionItemKind[MethodCompletionItem] = "MethodCompletion"
namesCompletionItemKind[PackageCompletionItem] = "PackageCompletion"
namesCompletionItemKind[InterfaceCompletionItem] = "interface"
namesCompletionItemKind[StructCompletionItem] = "struct"
namesCompletionItemKind[TypeCompletionItem] = "type"
namesCompletionItemKind[ConstantCompletionItem] = "const"
namesCompletionItemKind[FieldCompletionItem] = "field"
namesCompletionItemKind[ParameterCompletionItem] = "parameter"
namesCompletionItemKind[VariableCompletionItem] = "var"
namesCompletionItemKind[FunctionCompletionItem] = "func"
namesCompletionItemKind[MethodCompletionItem] = "method"
namesCompletionItemKind[PackageCompletionItem] = "package"
}
func formatEnum(f fmt.State, c rune, i int, names []string, unknown string) {