MCPcopy Create free account
hub / github.com/github/gh-aw / findAdditionalPropertyInNestedContext

Function findAdditionalPropertyInNestedContext

pkg/parser/json_path_locator.go:303–324  ·  view source on GitHub ↗

findAdditionalPropertyInNestedContext finds additional properties within a specific nested JSON path context It extracts the sub-YAML content for the JSON path and searches within it for better efficiency

(yamlContent string, jsonPath string, propertyNames []string)

Source from the content-addressed store, hash-verified

301// findAdditionalPropertyInNestedContext finds additional properties within a specific nested JSON path context
302// It extracts the sub-YAML content for the JSON path and searches within it for better efficiency
303func findAdditionalPropertyInNestedContext(yamlContent string, jsonPath string, propertyNames []string) JSONPathLocation {
304 jsonPathLog.Printf("Finding additional property in nested context: path=%s, properties=%v", jsonPath, propertyNames)
305
306 pathSegments := parseJSONPath(jsonPath)
307 if len(pathSegments) == 0 {
308 return findFirstAdditionalProperty(yamlContent, propertyNames)
309 }
310
311 nestedSection := findNestedSection(yamlContent, pathSegments)
312 if nestedSection.startLine == -1 {
313 jsonPathLog.Print("Nested section not found, falling back to global search")
314 return findFirstAdditionalProperty(yamlContent, propertyNames)
315 }
316
317 jsonPathLog.Printf("Found nested section: startLine=%d, endLine=%d", nestedSection.startLine, nestedSection.endLine)
318 subYAMLContent, baseIndent := extractNestedSubYAML(yamlContent, nestedSection)
319 subLocation := findFirstAdditionalProperty(subYAMLContent, propertyNames)
320 if !subLocation.Found {
321 return findFirstAdditionalProperty(yamlContent, propertyNames)
322 }
323 return mapNestedLocationToOriginal(subLocation, nestedSection, baseIndent)
324}
325
326func extractNestedSubYAML(yamlContent string, nestedSection NestedSection) (string, int) {
327 lines := strings.Split(yamlContent, "\n")

Callers 1

Calls 7

parseJSONPathFunction · 0.85
findNestedSectionFunction · 0.85
extractNestedSubYAMLFunction · 0.85
PrintMethod · 0.80
PrintfMethod · 0.45

Tested by

no test coverage detected