diff --git a/handlers/ssh_config/analyzer/analyzer.go b/handlers/ssh_config/analyzer/analyzer.go index 83a230a..74d54b1 100644 --- a/handlers/ssh_config/analyzer/analyzer.go +++ b/handlers/ssh_config/analyzer/analyzer.go @@ -41,6 +41,7 @@ func Analyze( analyzeBlocks(ctx) analyzeMatchBlocks(ctx) analyzeHostBlock(ctx) + analyzeBlocks(ctx) return ctx.diagnostics } diff --git a/handlers/ssh_config/analyzer/tag.go b/handlers/ssh_config/analyzer/tag.go new file mode 100644 index 0000000..4208d31 --- /dev/null +++ b/handlers/ssh_config/analyzer/tag.go @@ -0,0 +1,28 @@ +package analyzer + +import ( + "config-lsp/common" + "config-lsp/handlers/ssh_config/fields" + "fmt" + + protocol "github.com/tliron/glsp/protocol_3_16" +) + +var tagOption = fields.CreateNormalizedName("Tag") + +func analyzeTags( + ctx *analyzerContext, +) { + // Check if the specified tags actually exist + for _, options := range ctx.document.Indexes.AllOptionsPerName[tagOption] { + for _, option := range options { + if _, found := ctx.document.Indexes.Tags[option.OptionValue.Value.Value]; !found { + ctx.diagnostics = append(ctx.diagnostics, protocol.Diagnostic{ + Range: option.OptionValue.ToLSPRange(), + Message: fmt.Sprintf("Unknown tag: %s", option.OptionValue.Value.Value), + Severity: &common.SeverityError, + }) + } + } + } +} diff --git a/handlers/ssh_config/fields/fields.go b/handlers/ssh_config/fields/fields.go index 1906f6d..59caccf 100644 --- a/handlers/ssh_config/fields/fields.go +++ b/handlers/ssh_config/fields/fields.go @@ -905,7 +905,6 @@ rsa-sha2-512,rsa-sha2-256 To disable TCP keepalive messages, the value should be set to no. See also ServerAliveInterval for protocol-level keepalives.`, Value: booleanEnumValue, }, - // TODO: Add "tag": { Documentation: `Specify a configuration tag name that may be later used by a Match directive to select a block of configuration.`, Value: docvalues.StringValue{},