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)
| 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 |
| 303 | func 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 | |
| 326 | func extractNestedSubYAML(yamlContent string, nestedSection NestedSection) (string, int) { |
| 327 | lines := strings.Split(yamlContent, "\n") |
no test coverage detected