diff --git a/server/handlers/aliases/handlers/completions.go b/server/handlers/aliases/handlers/completions.go index b7d43a7..db9b0ef 100644 --- a/server/handlers/aliases/handlers/completions.go +++ b/server/handlers/aliases/handlers/completions.go @@ -66,14 +66,14 @@ func GetCompletionsForEntry( return completions, nil } - switch (*value).(type) { + switch value.(type) { case ast.AliasValueUser: return getUserCompletions( i, excludedUsers, ), nil case ast.AliasValueError: - errorValue := (*value).(ast.AliasValueError) + errorValue := value.(ast.AliasValueError) isAtErrorCode := errorValue.Code == nil && errorValue.Location.IsPositionAfterStart(cursor) && diff --git a/server/handlers/aliases/handlers/get-value.go b/server/handlers/aliases/handlers/get-value.go index ce6219b..1e658e7 100644 --- a/server/handlers/aliases/handlers/get-value.go +++ b/server/handlers/aliases/handlers/get-value.go @@ -9,7 +9,7 @@ import ( func GetValueAtPosition( position common.Position, entry *ast.AliasEntry, -) *ast.AliasValueInterface { +) ast.AliasValueInterface { if entry.Values == nil || len(entry.Values.Values) == 0 { return nil } @@ -36,5 +36,5 @@ func GetValueAtPosition( return nil } - return &entry.Values.Values[index] + return entry.Values.Values[index] } diff --git a/server/handlers/aliases/lsp/text-document-completion.go b/server/handlers/aliases/lsp/text-document-completion.go index 1d5d429..2b6da3a 100644 --- a/server/handlers/aliases/lsp/text-document-completion.go +++ b/server/handlers/aliases/lsp/text-document-completion.go @@ -28,11 +28,7 @@ func TextDocumentCompletion(context *glsp.Context, params *protocol.CompletionPa entry := rawEntry.(*ast.AliasEntry) - if entry.Key == nil { - return handlers.GetAliasesCompletions(d.Indexes), nil - } - - if entry.Key.Location.ContainsPosition(cursor) { + if entry.Key == nil || entry.Key.Location.ContainsPosition(cursor) { return handlers.GetAliasesCompletions(d.Indexes), nil } @@ -40,13 +36,9 @@ func TextDocumentCompletion(context *glsp.Context, params *protocol.CompletionPa return nil, nil } - if entry.Separator.IsPositionBeforeEnd(cursor) { - return handlers.GetCompletionsForEntry( - cursor, - entry, - d.Indexes, - ) - } - - return nil, nil + return handlers.GetCompletionsForEntry( + cursor, + entry, + d.Indexes, + ) } diff --git a/server/handlers/aliases/lsp/text-document-definition.go b/server/handlers/aliases/lsp/text-document-definition.go index 5976f5d..5018568 100644 --- a/server/handlers/aliases/lsp/text-document-definition.go +++ b/server/handlers/aliases/lsp/text-document-definition.go @@ -32,7 +32,7 @@ func TextDocumentDefinition(context *glsp.Context, params *protocol.DefinitionPa return handlers.GetDefinitionLocationForValue( *d.Indexes, - *rawValue, + rawValue, params.TextDocument.URI, ), nil } diff --git a/server/handlers/aliases/lsp/text-document-hover.go b/server/handlers/aliases/lsp/text-document-hover.go index a1c97fd..638f524 100644 --- a/server/handlers/aliases/lsp/text-document-hover.go +++ b/server/handlers/aliases/lsp/text-document-hover.go @@ -49,10 +49,10 @@ func TextDocumentHover( } contents := []string{} - contents = append(contents, handlers.GetAliasValueTypeInfo(*value)...) + contents = append(contents, handlers.GetAliasValueTypeInfo(value)...) contents = append(contents, "") contents = append(contents, "#### Value") - contents = append(contents, handlers.GetAliasValueHoverInfo(*document.Indexes, *value)) + contents = append(contents, handlers.GetAliasValueHoverInfo(*document.Indexes, value)) text := strings.Join(contents, "\n") diff --git a/server/handlers/aliases/lsp/text-document-prepare-rename.go b/server/handlers/aliases/lsp/text-document-prepare-rename.go index 56e2dd1..c44fc3e 100644 --- a/server/handlers/aliases/lsp/text-document-prepare-rename.go +++ b/server/handlers/aliases/lsp/text-document-prepare-rename.go @@ -34,9 +34,9 @@ func TextDocumentPrepareRename(context *glsp.Context, params *protocol.PrepareRe return nil, nil } - switch (*rawValue).(type) { + switch rawValue.(type) { case ast.AliasValueUser: - userValue := (*rawValue).(ast.AliasValueUser) + userValue := rawValue.(ast.AliasValueUser) return userValue.Location.ToLSPRange(), nil } diff --git a/server/handlers/aliases/lsp/text-document-rename.go b/server/handlers/aliases/lsp/text-document-rename.go index d51f092..61d1c69 100644 --- a/server/handlers/aliases/lsp/text-document-rename.go +++ b/server/handlers/aliases/lsp/text-document-rename.go @@ -44,9 +44,9 @@ func TextDocumentRename(context *glsp.Context, params *protocol.RenameParams) (* return nil, nil } - switch (*rawValue).(type) { + switch rawValue.(type) { case ast.AliasValueUser: - userValue := (*rawValue).(ast.AliasValueUser) + userValue := rawValue.(ast.AliasValueUser) changes := handlers.RenameAlias( *d.Indexes, diff --git a/server/handlers/aliases/lsp/text-document-signature-help.go b/server/handlers/aliases/lsp/text-document-signature-help.go index 913fe62..77ab565 100644 --- a/server/handlers/aliases/lsp/text-document-signature-help.go +++ b/server/handlers/aliases/lsp/text-document-signature-help.go @@ -14,7 +14,7 @@ func TextDocumentSignatureHelp(context *glsp.Context, params *protocol.Signature document := aliases.DocumentParserMap[params.TextDocument.URI] line := params.Position.Line - cursor := common.LSPCharacterAsCursorPosition(common.CursorToCharacterIndex(params.Position.Character)) + cursor := common.LSPCharacterAsCursorPosition(params.Position.Character) if _, found := document.Parser.CommentLines[line]; found { // Comment @@ -36,17 +36,15 @@ func TextDocumentSignatureHelp(context *glsp.Context, params *protocol.Signature if entry.Values != nil && entry.Values.Location.ContainsPosition(cursor) { value := handlers.GetValueAtPosition(cursor, entry) - if value == nil { + if value == nil || value.GetAliasValue().Value == "" { // For some reason, this does not really work, // When we return all, and then a user value is entered // and the `GetValueSignatureHelp` is called, still the old // signatures with all signature are shown - // return handlers.GetAllValuesSignatureHelp(), nil - - return nil, nil + return handlers.GetAllValuesSignatureHelp(), nil } - return handlers.GetValueSignatureHelp(cursor, *value), nil + return handlers.GetValueSignatureHelp(cursor, value), nil } return nil, nil