mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 23:15:26 +02:00
feat(ssh_config): Add unknown option to indexes
This commit is contained in:
parent
d9f7e3cbaf
commit
bf54705e93
@ -32,6 +32,7 @@ func analyzeValuesAreValid(
|
||||
Severity: &common.SeverityError,
|
||||
},
|
||||
)
|
||||
ctx.document.Indexes.UnknownOptions = append(ctx.document.Indexes.UnknownOptions, info)
|
||||
|
||||
continue
|
||||
}
|
||||
|
@ -23,6 +23,14 @@ ThisOptionDoesNotExist okay
|
||||
if !(len(ctx.diagnostics) == 1) {
|
||||
t.Errorf("Expected 1 error, got %v", len(ctx.diagnostics))
|
||||
}
|
||||
|
||||
if !(len(ctx.document.Indexes.UnknownOptions) == 1) {
|
||||
t.Errorf("Expected 1 unknown option, got %v", len(ctx.document.Indexes.UnknownOptions))
|
||||
}
|
||||
|
||||
if !(ctx.document.Indexes.UnknownOptions[0].Option.Key.Value.Value == "ThisOptionDoesNotExist") {
|
||||
t.Errorf("Expected 'ThisOptionDoesNotExist', got %v", ctx.document.Indexes.UnknownOptions[0].Option.Key.Value.Value)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnknownOptionButIgnoredExample(
|
||||
@ -40,7 +48,11 @@ ThisOptionDoesNotExist okay
|
||||
analyzeValuesAreValid(ctx)
|
||||
|
||||
if len(ctx.diagnostics) > 0 {
|
||||
t.Errorf("Expected no errors, but got %v", len(ctx.diagnostics))
|
||||
t.Fatalf("Expected no errors, but got %v", len(ctx.diagnostics))
|
||||
}
|
||||
|
||||
if !(len(ctx.document.Indexes.UnknownOptions) == 0) {
|
||||
t.Errorf("Expected 0 unknown options, got %v", len(ctx.document.Indexes.UnknownOptions))
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,4 +73,12 @@ IgnoreUnknown ThisOptionDoesNotExist
|
||||
if !(len(ctx.diagnostics) == 1) {
|
||||
t.Errorf("Expected 1 error, got %v", len(ctx.diagnostics))
|
||||
}
|
||||
|
||||
if !(len(ctx.document.Indexes.UnknownOptions) == 1) {
|
||||
t.Errorf("Expected 1 unknown option, got %v", len(ctx.document.Indexes.UnknownOptions))
|
||||
}
|
||||
|
||||
if !(ctx.document.Indexes.UnknownOptions[0].Option.Key.Value.Value == "ThisOptionDoesNotExist") {
|
||||
t.Errorf("Expected 'ThisOptionDoesNotExist', got %v", ctx.document.Indexes.UnknownOptions[0].Option.Key.Value.Value)
|
||||
}
|
||||
}
|
||||
|
@ -40,4 +40,9 @@ type SSHIndexes struct {
|
||||
|
||||
// Map of <block|nil (for global)> to a list of ignored options
|
||||
IgnoredOptions map[ast.SSHBlock]SSHIndexIgnoredUnknowns
|
||||
|
||||
// This is used for code actions.
|
||||
// This stores a list of unknown option, so that we can provide
|
||||
// a code action to add them to a "IgnoreUnknown" option
|
||||
UnknownOptions []ast.AllOptionInfo
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ func NewSSHIndexes() *SSHIndexes {
|
||||
AllOptionsPerName: make(map[fields.NormalizedOptionName](map[ast.SSHBlock]([]*ast.SSHOption)), 0),
|
||||
Includes: make([]*SSHIndexIncludeLine, 0),
|
||||
IgnoredOptions: make(map[ast.SSHBlock]SSHIndexIgnoredUnknowns),
|
||||
UnknownOptions: make([]ast.AllOptionInfo, 0),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user