mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 23:15:26 +02:00
34 lines
749 B
Go
34 lines
749 B
Go
package analyzer
|
|
|
|
import (
|
|
"config-lsp/common"
|
|
"config-lsp/handlers/aliases"
|
|
"config-lsp/handlers/aliases/indexes"
|
|
"fmt"
|
|
|
|
ers "errors"
|
|
)
|
|
|
|
var RequiredAliases = []string{
|
|
indexes.NormalizeKey("mailer-daemon"),
|
|
indexes.NormalizeKey("hostmaster"),
|
|
indexes.NormalizeKey("postmaster"),
|
|
}
|
|
|
|
func analyzeContainsRequiredKeys(
|
|
d aliases.AliasesDocument,
|
|
) []common.LSPError {
|
|
errors := make([]common.LSPError, 0)
|
|
|
|
for _, requiredField := range RequiredAliases {
|
|
if _, found := d.Indexes.Keys[requiredField]; !found {
|
|
errors = append(errors, common.LSPError{
|
|
Range: common.GlobalLocationRange,
|
|
Err: ers.New(fmt.Sprintf("Please add the alias '%s'. It is required by the aliases file.", requiredField)),
|
|
})
|
|
}
|
|
}
|
|
|
|
return errors
|
|
}
|