mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 23:15:26 +02:00
50 lines
852 B
Go
50 lines
852 B
Go
package analyzer
|
|
|
|
import (
|
|
"config-lsp/common"
|
|
"config-lsp/handlers/aliases/ast"
|
|
|
|
ers "errors"
|
|
)
|
|
|
|
func analyzeValuesAreValid(
|
|
p ast.AliasesParser,
|
|
) []common.LSPError {
|
|
errors := make([]common.LSPError, 0)
|
|
|
|
it := p.Aliases.Iterator()
|
|
|
|
for it.Next() {
|
|
entry := it.Value().(*ast.AliasEntry)
|
|
|
|
if entry.Key == nil {
|
|
errors = append(errors, common.LSPError{
|
|
Range: entry.Location,
|
|
Err: ers.New("A name is required"),
|
|
})
|
|
|
|
continue
|
|
}
|
|
|
|
if entry.Separator == nil {
|
|
errors = append(errors, common.LSPError{
|
|
Range: entry.Location,
|
|
Err: ers.New("The separator is required"),
|
|
})
|
|
|
|
continue
|
|
}
|
|
|
|
if entry.Values == nil || len(entry.Values.Values) == 0 {
|
|
errors = append(errors, common.LSPError{
|
|
Range: entry.Location,
|
|
Err: ers.New("A value is required"),
|
|
})
|
|
|
|
continue
|
|
}
|
|
}
|
|
|
|
return errors
|
|
}
|