mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 15:05:28 +02:00
52 lines
964 B
Go
52 lines
964 B
Go
package analyzer
|
|
|
|
import (
|
|
"config-lsp/common"
|
|
"config-lsp/handlers/wireguard"
|
|
"config-lsp/handlers/wireguard/indexes"
|
|
|
|
protocol "github.com/tliron/glsp/protocol_3_16"
|
|
)
|
|
|
|
type analyzerContext struct {
|
|
document *wireguard.WGDocument
|
|
diagnostics []protocol.Diagnostic
|
|
}
|
|
|
|
func Analyze(
|
|
d *wireguard.WGDocument,
|
|
) []protocol.Diagnostic {
|
|
ctx := &analyzerContext{
|
|
document: d,
|
|
diagnostics: make([]protocol.Diagnostic, 0),
|
|
}
|
|
|
|
analyzeStructureIsValid(ctx)
|
|
|
|
if len(ctx.diagnostics) > 0 {
|
|
return ctx.diagnostics
|
|
}
|
|
|
|
i, indexErrors := indexes.CreateIndexes(d.Config)
|
|
|
|
if len(indexErrors) > 0 {
|
|
return common.ErrsToDiagnostics(indexErrors)
|
|
}
|
|
|
|
d.Indexes = i
|
|
|
|
analyzeProperties(ctx)
|
|
|
|
if len(ctx.diagnostics) > 0 {
|
|
return ctx.diagnostics
|
|
}
|
|
|
|
analyzeInterfaceSection(ctx)
|
|
analyzeDNSPropertyContainsFallback(ctx)
|
|
analyzeKeepAlivePropertyIsSet(ctx)
|
|
analyzeSymmetricPropertiesSet(ctx)
|
|
analyzeDuplicateAllowedIPs(ctx)
|
|
|
|
return ctx.diagnostics
|
|
}
|