Prepare resolution entry provenance view
This commit is contained in:
13
metadata.go
13
metadata.go
@@ -113,9 +113,8 @@ func (m Metadata) hasHistoricalPath(path Path) bool {
|
||||
}
|
||||
|
||||
func finalizeMetadataPaths(m *Metadata, final *document.Node, applications []historyApplication, earlier ...*document.Node) {
|
||||
m.effectivePaths = make(map[string]Path)
|
||||
m.effectivePaths = effectivePathIndex(final)
|
||||
m.historicalPaths = make(map[string][]Path)
|
||||
walkDocument(final, Path{}, func(path Path, _ *document.Node) { m.effectivePaths[path.String()] = path.clone() })
|
||||
add := func(path Path, _ *document.Node) {
|
||||
pointer := path.String()
|
||||
for _, prior := range m.historicalPaths[pointer] {
|
||||
@@ -138,3 +137,13 @@ func finalizeMetadataPaths(m *Metadata, final *document.Node, applications []his
|
||||
walkDocument(application.value, prefix, add)
|
||||
}
|
||||
}
|
||||
|
||||
// effectivePathIndex records document-derived paths with their contextual segment
|
||||
// kinds. Callers retain no aliases to the walked tree or its paths.
|
||||
func effectivePathIndex(final *document.Node) map[string]Path {
|
||||
paths := make(map[string]Path)
|
||||
walkDocument(final, Path{}, func(path Path, _ *document.Node) {
|
||||
paths[path.String()] = path.clone()
|
||||
})
|
||||
return paths
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user