Preserve inherited source origins and transfer evidence
This commit is contained in:
@@ -201,13 +201,25 @@ type Diagnostic struct {
|
||||
Related []Location
|
||||
}
|
||||
|
||||
// InheritanceStep identifies a concrete payload transfer controlled by a
|
||||
// relationship directive. Locations belong to that directive, not its value.
|
||||
type InheritanceStep struct {
|
||||
From Path
|
||||
To Path
|
||||
Reference Path
|
||||
Locations []Location
|
||||
}
|
||||
|
||||
// Origin describes where an effective definition came from. Multiple locations
|
||||
// represent a composite origin; resolution origins are synthetic and identify their
|
||||
// operation instead of a file location.
|
||||
// operation instead of a file location. Inheritance is projected from private
|
||||
// contributor traces at inspection boundaries.
|
||||
type Origin struct {
|
||||
Layer Layer
|
||||
Locations []Location
|
||||
Operation ChangeKind
|
||||
Layer Layer
|
||||
Locations []Location
|
||||
Operation ChangeKind
|
||||
Inheritance []InheritanceStep
|
||||
contributors []inheritanceContributor
|
||||
}
|
||||
|
||||
// FieldInfo describes an effective configuration path.
|
||||
@@ -261,9 +273,32 @@ func cloneSourceInfos(sources []SourceInfo) []SourceInfo {
|
||||
|
||||
func cloneOrigin(origin Origin) Origin {
|
||||
origin.Locations = cloneLocations(origin.Locations)
|
||||
origin.Inheritance = cloneInheritanceSteps(origin.Inheritance)
|
||||
if origin.contributors != nil {
|
||||
contributors := make([]inheritanceContributor, len(origin.contributors))
|
||||
for index, contributor := range origin.contributors {
|
||||
contributors[index] = contributor
|
||||
contributors[index].source = contributor.source.clone()
|
||||
}
|
||||
origin.contributors = contributors
|
||||
}
|
||||
return origin
|
||||
}
|
||||
|
||||
func cloneInheritanceSteps(steps []InheritanceStep) []InheritanceStep {
|
||||
if steps == nil {
|
||||
return nil
|
||||
}
|
||||
cloned := make([]InheritanceStep, len(steps))
|
||||
for index, step := range steps {
|
||||
cloned[index] = InheritanceStep{
|
||||
From: step.From.clone(), To: step.To.clone(), Reference: step.Reference.clone(),
|
||||
Locations: cloneLocations(step.Locations),
|
||||
}
|
||||
}
|
||||
return cloned
|
||||
}
|
||||
|
||||
func cloneFieldInfo(info FieldInfo) FieldInfo {
|
||||
info.Origin = cloneOrigin(info.Origin)
|
||||
return info
|
||||
|
||||
Reference in New Issue
Block a user