Detect inheritance directives without paths

This commit is contained in:
2026-10-09 03:20:24 +00:00
parent a2084df11a
commit edc6660654
3 changed files with 40 additions and 8 deletions

View File

@@ -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 {