fix(ssh_config): Tag improvements

This commit is contained in:
Myzel394 2024-10-04 20:20:41 +02:00
parent eda3a0e771
commit 3a15739033
No known key found for this signature in database
GPG Key ID: ED20A1D1D423AF3F
3 changed files with 29 additions and 1 deletions

View File

@ -41,6 +41,7 @@ func Analyze(
analyzeBlocks(ctx)
analyzeMatchBlocks(ctx)
analyzeHostBlock(ctx)
analyzeBlocks(ctx)
return ctx.diagnostics
}

View File

@ -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,
})
}
}
}
}

View File

@ -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{},