Limit inheritance policy work to the relevant scope
This commit is contained in:
@@ -47,9 +47,10 @@ func analyzeInheritanceGraphWithCollectionRules(scope *document.Node, scopePath
|
||||
}}
|
||||
}
|
||||
|
||||
policyIndex := newInheritancePolicyIndex(policies)
|
||||
graph := &inheritanceGraph{
|
||||
scope: scope, scopePath: scopePath,
|
||||
collectionPolicies: cloneCollectionPolicyScopeForInheritance(policies), applicationPolicy: applicationPolicy,
|
||||
collectionPolicies: policyIndex.absoluteScope(scopePath), applicationPolicy: applicationPolicy,
|
||||
byName: make(map[string]int, len(scope.Mapping)),
|
||||
}
|
||||
entries := make(map[string]document.Entry, len(scope.Mapping))
|
||||
@@ -69,7 +70,7 @@ func analyzeInheritanceGraphWithCollectionRules(scope *document.Node, scopePath
|
||||
graph.byName[name] = index
|
||||
graph.nodes = append(graph.nodes, inheritanceTemplate{
|
||||
name: name, entry: entries[name], path: scopePath.Key(name),
|
||||
collectionPolicies: inheritancePolicyScopeAtPath(policies, scopePath.Key(name)),
|
||||
collectionPolicies: policyIndex.localize(scopePath.Key(name)),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -355,6 +356,7 @@ func applyInheritanceScopeTemplates(adapter inheritanceScopeAdapter, order []int
|
||||
root := adapter.rebuild(resolved)
|
||||
result.collectionPolicies = collectionPolicyScope{}
|
||||
result.origins = directInheritanceOrigins(&document.Node{Kind: root.Kind, Location: root.Location}, adapter.scopePath(), inputOrigins)
|
||||
policyIndex := newInheritancePolicyIndex(adapter.collectionPolicies())
|
||||
for _, slot := range adapter.slots() {
|
||||
if slot.hasTemplate {
|
||||
index := slot.template
|
||||
@@ -364,7 +366,7 @@ func applyInheritanceScopeTemplates(adapter inheritanceScopeAdapter, order []int
|
||||
}
|
||||
continue
|
||||
}
|
||||
localPolicies := inheritancePolicyScopeAtPath(adapter.collectionPolicies(), slot.path)
|
||||
localPolicies := policyIndex.localize(slot.path)
|
||||
projectInheritancePolicyRoots(&result.collectionPolicies, localPolicies, slot.path)
|
||||
for pointer, origin := range directInheritanceOrigins(slot.value, slot.path, inputOrigins) {
|
||||
result.origins[pointer] = origin
|
||||
|
||||
Reference in New Issue
Block a user