Share declaring import assembly
This commit is contained in:
@@ -48,36 +48,22 @@ func acquireContextlessInput(input assembledInput, request inputAcquisitionReque
|
||||
}
|
||||
return input, diagnostics
|
||||
}
|
||||
key := importKeyForMainSource(parsed.source)
|
||||
info := cloneSourceInfo(*parsed.source)
|
||||
accounting := input.accounting
|
||||
accounting.sources++
|
||||
accounting.bytes += parsed.bytes
|
||||
accounting.nodes += countInputNodes(parsed.document)
|
||||
limits := policy.importLimits
|
||||
if accounting.sources > limits.sources || accounting.bytes > limits.bytes || accounting.nodes > limits.nodes {
|
||||
return input, []Diagnostic{importDiagnostic(CodeImportLimitExceeded, "configuration exceeds the aggregate input limit", nil)}
|
||||
accounting, limits := input.accounting, policy.importLimits
|
||||
if diagnostic := chargeDeclaringImport(parsed, accounting, limits); diagnostic != nil {
|
||||
return input, []Diagnostic{*diagnostic}
|
||||
}
|
||||
contribution := acquiredContribution{source: info, payload: body, identity: key, role: importRoleMain, scopeOwner: key, processing: processing, sequenceDeclarations: sequences}
|
||||
var scope acquisitionScope
|
||||
if request.input.placementMode == PlacementModeSequenceItem {
|
||||
contribution.document = body
|
||||
local := acquisitionScope{owner: key, contributions: []acquiredContribution{contribution}}
|
||||
scope = acquisitionScope{owner: key, destination: destination.clone(), contributions: []acquiredContribution{{source: info, payload: body, identity: key, role: importRoleMain, scopeOwner: key, destination: destination.clone(), processing: processing, sequenceDeclarations: sequences, pendingItem: &local}}}
|
||||
if diagnostic := reservePendingItemPlacements(&scope, limits, accounting); diagnostic != nil {
|
||||
return input, []Diagnostic{*diagnostic}
|
||||
}
|
||||
} else {
|
||||
_, placed, err := placeDocument(body, destination, body.Location, maxDocumentDepth, maxDocumentNodes)
|
||||
if err != nil {
|
||||
return input, []Diagnostic{sourceDiagnostic(CodeSourceLimitExceeded, info.ID, "configuration exceeds the source depth or node limit after destination placement")}
|
||||
}
|
||||
accounting.nodes += destinationWrapperNodeCount(destination)
|
||||
if accounting.nodes > limits.nodes {
|
||||
return input, []Diagnostic{importDiagnostic(CodeImportLimitExceeded, "configuration exceeds the aggregate node limit", nil)}
|
||||
}
|
||||
contribution.document, contribution.destination = placed, destination.clone()
|
||||
scope = acquisitionScope{owner: key, destination: destination.clone(), contributions: []acquiredContribution{contribution}}
|
||||
key := importKeyForMainSource(parsed.source)
|
||||
root := acquiredContribution{
|
||||
source: cloneSourceInfo(*parsed.source), payload: body, identity: key,
|
||||
role: importRoleMain, scopeOwner: key, processing: processing, sequenceDeclarations: sequences,
|
||||
}
|
||||
scope, diagnostic := prepareDeclaringImportScope(root, accounting, limits)
|
||||
if diagnostic != nil {
|
||||
return input, []Diagnostic{*diagnostic}
|
||||
}
|
||||
scope, diagnostic = finalizeDeclaringImportScope(scope, root, accounting, limits)
|
||||
if diagnostic != nil {
|
||||
return input, []Diagnostic{*diagnostic}
|
||||
}
|
||||
input.document = body
|
||||
input.composition = &composedDocument{acquisition: []acquisitionScope{scope}, importGraph: newImportInclusionGraph(), inputBytes: accounting.bytes, inputNodes: accounting.nodes}
|
||||
|
||||
Reference in New Issue
Block a user