Detect inheritance directives without paths
This commit is contained in:
@@ -3,14 +3,28 @@ package engine
|
||||
import "gitea.maximumdirect.net/eric/ConfigKit/internal/document"
|
||||
|
||||
func containsInheritanceDirective(root *document.Node) bool {
|
||||
found := false
|
||||
walkDocument(root, Path{}, func(path Path, _ *document.Node) {
|
||||
if len(path.segments) != 0 && path.segments[len(path.segments)-1].kind == pathSegmentKey &&
|
||||
path.segments[len(path.segments)-1].key == inheritanceKey {
|
||||
found = true
|
||||
var visit func(*document.Node) bool
|
||||
visit = func(node *document.Node) bool {
|
||||
if node == nil {
|
||||
return false
|
||||
}
|
||||
})
|
||||
return found
|
||||
switch node.Kind {
|
||||
case document.Mapping:
|
||||
for _, entry := range node.Mapping {
|
||||
if entry.Key == inheritanceKey || visit(entry.Value) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
case document.Sequence:
|
||||
for _, child := range node.Sequence {
|
||||
if visit(child) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
return visit(root)
|
||||
}
|
||||
|
||||
func inheritanceVersionDiagnostic(rule *VersionRule, expanded *inheritanceScope) *Diagnostic {
|
||||
|
||||
Reference in New Issue
Block a user