feat(aliases): Add completion support for error values

This commit is contained in:
Myzel394 2024-09-07 23:19:44 +02:00
parent ad1a8e0d95
commit e1af64f2c0
No known key found for this signature in database
GPG Key ID: DEC4AAB876F73185

View File

@ -78,6 +78,38 @@ func GetCompletionsForEntry(
userValue.Value,
relativeCursor,
), nil
case ast.AliasValueError:
errorValue := (*value).(ast.AliasValueError)
isAtErrorCode := errorValue.Code == nil &&
relativeCursor >= errorValue.Location.Start.Character &&
(errorValue.Message == nil ||
relativeCursor <= errorValue.Message.Location.Start.Character)
if isAtErrorCode {
kind := protocol.CompletionItemKindValue
detail_4 := "4XX (TempFail)"
insertText_4 := "400"
detail_5 := "5XX (PermFail)"
insertText_5 := "500"
return []protocol.CompletionItem{
{
Label: "4XX",
InsertText: &insertText_4,
Kind: &kind,
Detail: &detail_4,
},
{
Label: "5XX",
InsertText: &insertText_5,
Kind: &kind,
Detail: &detail_5,
},
}, nil
}
}
return completions, nil