Clarify load context and inheritance handoffs
This commit is contained in:
@@ -129,6 +129,55 @@ func applyInputLayers(source Source, filesystem *FilesystemContext, overlay stri
|
||||
return input, nil
|
||||
}
|
||||
|
||||
func completeOrdinaryResourceContexts(input assembledInput, main loadInput) (assembledInput, []Diagnostic) {
|
||||
baseSources := make([]SourceInfo, 0, len(input.sources))
|
||||
for _, source := range input.sources {
|
||||
if source.Layer == LayerBase {
|
||||
baseSources = append(baseSources, source)
|
||||
}
|
||||
}
|
||||
if len(baseSources) == 0 || input.contexts[baseSources[0].ID].FS != nil {
|
||||
return input, nil
|
||||
}
|
||||
if input.resolvedFilesystem == nil && (main.source.kind == sourceFile || main.filesystem != nil || nativeContext(main.source, main.filesystem)) {
|
||||
resolved, diagnostic := resolveFilesystemContext(main.source, main.filesystem, input.parsed, nil)
|
||||
if diagnostic != nil {
|
||||
return input, []Diagnostic{*diagnostic}
|
||||
}
|
||||
input.resolvedFilesystem = &resolved
|
||||
}
|
||||
contexts, diagnostic := contextsForResolvedSources(input.resolvedFilesystem, baseSources)
|
||||
if diagnostic != nil {
|
||||
return input, []Diagnostic{*diagnostic}
|
||||
}
|
||||
mergeResourceContexts(&input.contexts, contexts)
|
||||
return input, nil
|
||||
}
|
||||
|
||||
func expandStructuralInheritance(input assembledInput, protectionRule *VersionRule, policy sequencePolicy) (assembledInput, *VersionRule, bool, []Diagnostic) {
|
||||
if input.document == nil || !containsInheritanceDirective(input.document) {
|
||||
return input, nil, false, nil
|
||||
}
|
||||
composition, diagnostics := compositionForInput(input)
|
||||
if len(diagnostics) != 0 {
|
||||
return input, nil, false, diagnostics
|
||||
}
|
||||
expanded, diagnostics := expandInheritanceWithCollectionRules(
|
||||
composition.root, composition.origins, composition.collectionPolicies, policy, defaultProjectionLimits(),
|
||||
)
|
||||
if len(diagnostics) != 0 {
|
||||
return input, nil, false, diagnostics
|
||||
}
|
||||
effectiveVersion, diagnostic := projectInheritanceVersion(protectionRule, expanded)
|
||||
if diagnostic != nil {
|
||||
return input, nil, false, []Diagnostic{*diagnostic}
|
||||
}
|
||||
input.composition = composition
|
||||
input.inheritance = expanded
|
||||
input.document = expanded.root
|
||||
return input, effectiveVersion, true, nil
|
||||
}
|
||||
|
||||
// compositionForInput initializes the structural handoff used by inheritance
|
||||
// expansion. Raw source bytes and mapping keys retain their budgets.
|
||||
func compositionForInput(input assembledInput) (*composedDocument, []Diagnostic) {
|
||||
|
||||
Reference in New Issue
Block a user