Share indexed fallback locations during effective projection
This commit is contained in:
@@ -171,16 +171,23 @@ func documentWithMetadataLocations(root *document.Node, metadata Metadata, fallb
|
||||
if len(fallback) != 0 {
|
||||
fallbackRoot = fallback[0]
|
||||
}
|
||||
var lookup *documentLookup
|
||||
fallbackLocation := func(path Path) (document.Location, bool) {
|
||||
if lookup == nil {
|
||||
lookup = buildDocumentLookup(fallbackRoot)
|
||||
}
|
||||
return nearestDocumentLocationWithLookup(fallbackRoot, path, lookup)
|
||||
}
|
||||
var visit func(*document.Node, Path)
|
||||
visit = func(node *document.Node, path Path) {
|
||||
pointer := path.String()
|
||||
if info, exists := metadata.fields[pointer]; exists {
|
||||
if location, ok := metadataFieldLocation(metadata, pointer, info.Origin); ok {
|
||||
node.Location = location
|
||||
} else if location, ok := nearestDocumentLocation(fallbackRoot, path); ok {
|
||||
} else if location, ok := fallbackLocation(path); ok {
|
||||
node.Location = location
|
||||
}
|
||||
} else if location, ok := nearestDocumentLocation(fallbackRoot, path); ok {
|
||||
} else if location, ok := fallbackLocation(path); ok {
|
||||
node.Location = location
|
||||
}
|
||||
switch node.Kind {
|
||||
@@ -192,11 +199,11 @@ func documentWithMetadataLocations(root *document.Node, metadata Metadata, fallb
|
||||
if location, ok := metadataFieldLocation(metadata, childPath.String(), info.Origin); ok {
|
||||
entry.KeyLocation = location
|
||||
entry.ValueLocation = location
|
||||
} else if location, ok := nearestDocumentLocation(fallbackRoot, childPath); ok {
|
||||
} else if location, ok := fallbackLocation(childPath); ok {
|
||||
entry.KeyLocation = location
|
||||
entry.ValueLocation = location
|
||||
}
|
||||
} else if location, ok := nearestDocumentLocation(fallbackRoot, childPath); ok {
|
||||
} else if location, ok := fallbackLocation(childPath); ok {
|
||||
entry.KeyLocation = location
|
||||
entry.ValueLocation = location
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user