mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 23:15:26 +02:00
fix(aliases): Improvements
This commit is contained in:
parent
c3d1ec3b0f
commit
92187713da
@ -66,14 +66,14 @@ func GetCompletionsForEntry(
|
|||||||
return completions, nil
|
return completions, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (*value).(type) {
|
switch value.(type) {
|
||||||
case ast.AliasValueUser:
|
case ast.AliasValueUser:
|
||||||
return getUserCompletions(
|
return getUserCompletions(
|
||||||
i,
|
i,
|
||||||
excludedUsers,
|
excludedUsers,
|
||||||
), nil
|
), nil
|
||||||
case ast.AliasValueError:
|
case ast.AliasValueError:
|
||||||
errorValue := (*value).(ast.AliasValueError)
|
errorValue := value.(ast.AliasValueError)
|
||||||
|
|
||||||
isAtErrorCode := errorValue.Code == nil &&
|
isAtErrorCode := errorValue.Code == nil &&
|
||||||
errorValue.Location.IsPositionAfterStart(cursor) &&
|
errorValue.Location.IsPositionAfterStart(cursor) &&
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
func GetValueAtPosition(
|
func GetValueAtPosition(
|
||||||
position common.Position,
|
position common.Position,
|
||||||
entry *ast.AliasEntry,
|
entry *ast.AliasEntry,
|
||||||
) *ast.AliasValueInterface {
|
) ast.AliasValueInterface {
|
||||||
if entry.Values == nil || len(entry.Values.Values) == 0 {
|
if entry.Values == nil || len(entry.Values.Values) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -36,5 +36,5 @@ func GetValueAtPosition(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return &entry.Values.Values[index]
|
return entry.Values.Values[index]
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,7 @@ func TextDocumentCompletion(context *glsp.Context, params *protocol.CompletionPa
|
|||||||
|
|
||||||
entry := rawEntry.(*ast.AliasEntry)
|
entry := rawEntry.(*ast.AliasEntry)
|
||||||
|
|
||||||
if entry.Key == nil {
|
if entry.Key == nil || entry.Key.Location.ContainsPosition(cursor) {
|
||||||
return handlers.GetAliasesCompletions(d.Indexes), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if entry.Key.Location.ContainsPosition(cursor) {
|
|
||||||
return handlers.GetAliasesCompletions(d.Indexes), nil
|
return handlers.GetAliasesCompletions(d.Indexes), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,13 +36,9 @@ func TextDocumentCompletion(context *glsp.Context, params *protocol.CompletionPa
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if entry.Separator.IsPositionBeforeEnd(cursor) {
|
return handlers.GetCompletionsForEntry(
|
||||||
return handlers.GetCompletionsForEntry(
|
cursor,
|
||||||
cursor,
|
entry,
|
||||||
entry,
|
d.Indexes,
|
||||||
d.Indexes,
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, nil
|
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ func TextDocumentDefinition(context *glsp.Context, params *protocol.DefinitionPa
|
|||||||
|
|
||||||
return handlers.GetDefinitionLocationForValue(
|
return handlers.GetDefinitionLocationForValue(
|
||||||
*d.Indexes,
|
*d.Indexes,
|
||||||
*rawValue,
|
rawValue,
|
||||||
params.TextDocument.URI,
|
params.TextDocument.URI,
|
||||||
), nil
|
), nil
|
||||||
}
|
}
|
||||||
|
@ -49,10 +49,10 @@ func TextDocumentHover(
|
|||||||
}
|
}
|
||||||
|
|
||||||
contents := []string{}
|
contents := []string{}
|
||||||
contents = append(contents, handlers.GetAliasValueTypeInfo(*value)...)
|
contents = append(contents, handlers.GetAliasValueTypeInfo(value)...)
|
||||||
contents = append(contents, "")
|
contents = append(contents, "")
|
||||||
contents = append(contents, "#### Value")
|
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")
|
text := strings.Join(contents, "\n")
|
||||||
|
|
||||||
|
@ -34,9 +34,9 @@ func TextDocumentPrepareRename(context *glsp.Context, params *protocol.PrepareRe
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (*rawValue).(type) {
|
switch rawValue.(type) {
|
||||||
case ast.AliasValueUser:
|
case ast.AliasValueUser:
|
||||||
userValue := (*rawValue).(ast.AliasValueUser)
|
userValue := rawValue.(ast.AliasValueUser)
|
||||||
|
|
||||||
return userValue.Location.ToLSPRange(), nil
|
return userValue.Location.ToLSPRange(), nil
|
||||||
}
|
}
|
||||||
|
@ -44,9 +44,9 @@ func TextDocumentRename(context *glsp.Context, params *protocol.RenameParams) (*
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (*rawValue).(type) {
|
switch rawValue.(type) {
|
||||||
case ast.AliasValueUser:
|
case ast.AliasValueUser:
|
||||||
userValue := (*rawValue).(ast.AliasValueUser)
|
userValue := rawValue.(ast.AliasValueUser)
|
||||||
|
|
||||||
changes := handlers.RenameAlias(
|
changes := handlers.RenameAlias(
|
||||||
*d.Indexes,
|
*d.Indexes,
|
||||||
|
@ -14,7 +14,7 @@ func TextDocumentSignatureHelp(context *glsp.Context, params *protocol.Signature
|
|||||||
document := aliases.DocumentParserMap[params.TextDocument.URI]
|
document := aliases.DocumentParserMap[params.TextDocument.URI]
|
||||||
|
|
||||||
line := params.Position.Line
|
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 {
|
if _, found := document.Parser.CommentLines[line]; found {
|
||||||
// Comment
|
// Comment
|
||||||
@ -36,17 +36,15 @@ func TextDocumentSignatureHelp(context *glsp.Context, params *protocol.Signature
|
|||||||
if entry.Values != nil && entry.Values.Location.ContainsPosition(cursor) {
|
if entry.Values != nil && entry.Values.Location.ContainsPosition(cursor) {
|
||||||
value := handlers.GetValueAtPosition(cursor, entry)
|
value := handlers.GetValueAtPosition(cursor, entry)
|
||||||
|
|
||||||
if value == nil {
|
if value == nil || value.GetAliasValue().Value == "" {
|
||||||
// For some reason, this does not really work,
|
// For some reason, this does not really work,
|
||||||
// When we return all, and then a user value is entered
|
// When we return all, and then a user value is entered
|
||||||
// and the `GetValueSignatureHelp` is called, still the old
|
// and the `GetValueSignatureHelp` is called, still the old
|
||||||
// signatures with all signature are shown
|
// signatures with all signature are shown
|
||||||
// return handlers.GetAllValuesSignatureHelp(), nil
|
return handlers.GetAllValuesSignatureHelp(), nil
|
||||||
|
|
||||||
return nil, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return handlers.GetValueSignatureHelp(cursor, *value), nil
|
return handlers.GetValueSignatureHelp(cursor, value), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user