feat(ssh_config): Check doc values in options.go

This commit is contained in:
Myzel394 2024-10-08 14:20:33 +02:00
parent 558b9b7c98
commit 0257a24668
No known key found for this signature in database
GPG Key ID: ED20A1D1D423AF3F

View File

@ -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 == "" {