Index sequence assembly and history lookups
This commit is contained in:
@@ -564,11 +564,12 @@ func importedVersionClaim(documents []*document.Node, composed *composedDocument
|
||||
if composed == nil || rule == nil {
|
||||
return nil
|
||||
}
|
||||
ranges := indexSequenceRanges(composed.sequenceRanges)
|
||||
for index, contribution := range documents {
|
||||
if index == mainIndex {
|
||||
continue
|
||||
}
|
||||
if node := fragmentVersionClaimProjected(contribution, rule, index, composed.sequenceRanges); node != nil {
|
||||
if node := fragmentVersionClaimWithIndex(contribution, rule, index, ranges); node != nil {
|
||||
location := publicLocation(node.Location)
|
||||
return &Diagnostic{
|
||||
Code: CodeImportVersion, Severity: SeverityError, Path: rule.Path.clone(),
|
||||
@@ -595,18 +596,13 @@ func projectNestedEvidence(composed *composedDocument, scope acquisitionScope) {
|
||||
}
|
||||
applications := composed.applications
|
||||
projectedApplications := make([]historyApplication, 0, len(applications))
|
||||
ranges := indexSequenceRanges(composed.sequenceRanges)
|
||||
for sourceIndex, contribution := range scope.contributions {
|
||||
if contribution.nested == nil {
|
||||
projectedApplications = append(projectedApplications, applications[sourceIndex])
|
||||
continue
|
||||
}
|
||||
start := 0
|
||||
for _, assigned := range composed.sequenceRanges {
|
||||
if assigned.sourceIndex == sourceIndex && assigned.path.String() == contribution.destination.String() {
|
||||
start = assigned.start
|
||||
break
|
||||
}
|
||||
}
|
||||
start := ranges[sequenceRangeKey{sourceIndex: sourceIndex, path: contribution.destination.String()}].start
|
||||
prefix := contribution.destination.Index(start)
|
||||
if sourceIndex < len(applications) {
|
||||
outer := applications[sourceIndex]
|
||||
@@ -622,6 +618,7 @@ func projectNestedEvidence(composed *composedDocument, scope acquisitionScope) {
|
||||
projected := nested
|
||||
projected.path = appendDestination(prefix, nested.path)
|
||||
projected.sequences = cloneSequenceHistoryContributions(nested.sequences)
|
||||
projected.sequencesByPath = indexSequenceHistoryContributions(projected.sequences)
|
||||
projectedApplications = append(projectedApplications, projected)
|
||||
}
|
||||
}
|
||||
@@ -656,19 +653,14 @@ func projectAcquiredDestinations(composed *composedDocument, scope acquisitionSc
|
||||
}
|
||||
var projectScope func(*composedDocument, acquisitionScope, Path, bool, string)
|
||||
projectScope = func(currentComposition *composedDocument, current acquisitionScope, prefix Path, insideItem bool, parentSourceID string) {
|
||||
ranges := indexSequenceRanges(currentComposition.sequenceRanges)
|
||||
for sourceIndex, contribution := range current.contributions {
|
||||
if contribution.source.ID == parentSourceID {
|
||||
continue
|
||||
}
|
||||
contributionPrefix := prefix
|
||||
contributionInsideItem := insideItem
|
||||
start := 0
|
||||
for _, assigned := range currentComposition.sequenceRanges {
|
||||
if assigned.sourceIndex == sourceIndex && assigned.path.String() == contribution.destination.String() {
|
||||
start = assigned.start
|
||||
break
|
||||
}
|
||||
}
|
||||
start := ranges[sequenceRangeKey{sourceIndex: sourceIndex, path: contribution.destination.String()}].start
|
||||
if contribution.source.placementMode == placementModeSequenceItem {
|
||||
container := appendDestination(contributionPrefix, contribution.destination)
|
||||
contribution.source.Destination = container.clone()
|
||||
@@ -692,7 +684,7 @@ func projectAcquiredDestinations(composed *composedDocument, scope acquisitionSc
|
||||
}
|
||||
projectSourceVersionEvidence(contribution.processing, exactDestination, nil, sourceIndex)
|
||||
} else {
|
||||
projectSourceVersionEvidence(contribution.processing, contribution.destination, currentComposition.sequenceRanges, sourceIndex)
|
||||
projectSourceVersionEvidence(contribution.processing, contribution.destination, ranges, sourceIndex)
|
||||
}
|
||||
if contribution.nested != nil && contribution.nested.acquisition != nil {
|
||||
for _, nestedScope := range contribution.nested.acquisition {
|
||||
@@ -704,7 +696,7 @@ func projectAcquiredDestinations(composed *composedDocument, scope acquisitionSc
|
||||
projectScope(composed, scope, Path{}, false, "")
|
||||
}
|
||||
|
||||
func projectSourceVersionEvidence(processing *sourceVersionProcessingResult, destination Path, ranges []sequenceRange, sourceIndex int) {
|
||||
func projectSourceVersionEvidence(processing *sourceVersionProcessingResult, destination Path, ranges sequenceRangeIndex, sourceIndex int) {
|
||||
if processing != nil && processing.evidence != nil {
|
||||
evidence := processing.evidence
|
||||
evidence.destination = destination.clone()
|
||||
@@ -713,11 +705,12 @@ func projectSourceVersionEvidence(processing *sourceVersionProcessingResult, des
|
||||
evidence.projectedPaths = nil
|
||||
paths := evidence.sensitivityPaths()
|
||||
for index, path := range paths {
|
||||
for _, assigned := range ranges {
|
||||
if assigned.sourceIndex != sourceIndex || !pathContains(assigned.path, path) || len(path.segments) <= len(assigned.path.segments) {
|
||||
for position := range path.segments {
|
||||
prefix := Path{segments: path.segments[:position]}
|
||||
assigned, found := ranges[sequenceRangeKey{sourceIndex: sourceIndex, path: prefix.String()}]
|
||||
if !found {
|
||||
continue
|
||||
}
|
||||
position := len(assigned.path.segments)
|
||||
item, ok := schemaIndex(path.segments[position])
|
||||
if ok && path.segments[position].kind != pathSegmentKey {
|
||||
path.segments[position] = pathSegment{kind: pathSegmentIndex, index: assigned.start + item}
|
||||
|
||||
Reference in New Issue
Block a user