From 0257a246688ca6a6498532add862109c66123ff9 Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Tue, 8 Oct 2024 14:20:33 +0200 Subject: [PATCH] feat(ssh_config): Check doc values in options.go --- server/handlers/ssh_config/analyzer/options.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/server/handlers/ssh_config/analyzer/options.go b/server/handlers/ssh_config/analyzer/options.go index 34dc670..275b444 100644 --- a/server/handlers/ssh_config/analyzer/options.go +++ b/server/handlers/ssh_config/analyzer/options.go @@ -2,6 +2,7 @@ package analyzer import ( "config-lsp/common" + docvalues "config-lsp/doc-values" "config-lsp/handlers/ssh_config/ast" "config-lsp/handlers/ssh_config/fields" "config-lsp/utils" @@ -40,7 +41,7 @@ func checkOption( checkIsUsingDoubleQuotes(ctx, option.Key.Value, option.Key.LocationRange) checkQuotesAreClosed(ctx, option.Key.Value, option.Key.LocationRange) - _, found := fields.Options[option.Key.Key] + docOption, found := fields.Options[option.Key.Key] if !found { // Diagnostics will be handled by `values.go` @@ -61,6 +62,19 @@ func checkOption( if option.OptionValue != nil { checkIsUsingDoubleQuotes(ctx, option.OptionValue.Value, option.OptionValue.LocationRange) checkQuotesAreClosed(ctx, option.OptionValue.Value, option.OptionValue.LocationRange) + + invalidValues := docOption.DeprecatedCheckIsValid(option.OptionValue.Value.Value) + + for _, invalidValue := range invalidValues { + err := docvalues.LSPErrorFromInvalidValue(option.Start.Line, *invalidValue) + err.ShiftCharacter(option.OptionValue.Start.Character) + + ctx.diagnostics = append(ctx.diagnostics, protocol.Diagnostic{ + Range: err.Range.ToLSPRange(), + Message: err.Err.Error(), + Severity: &common.SeverityError, + }) + } } if option.Separator == nil || option.Separator.Value.Value == "" {