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

Function findNestedSection

pkg/parser/json_path_locator.go:377–386  ·  view source on GitHub ↗

findNestedSection locates the section of YAML that corresponds to the given JSON path

(yamlContent string, pathSegments []PathSegment)

Source from the content-addressed store, hash-verified

375
376// findNestedSection locates the section of YAML that corresponds to the given JSON path
377func findNestedSection(yamlContent string, pathSegments []PathSegment) NestedSection {
378 lines := strings.Split(yamlContent, "\n")
379
380 foundLine, baseIndentLevel := findNestedSectionStart(lines, pathSegments)
381 if foundLine == -1 {
382 return NestedSection{startLine: -1, endLine: -1, baseIndentLevel: 0}
383 }
384 endLine := findNestedSectionEnd(lines, foundLine, baseIndentLevel)
385 return NestedSection{startLine: foundLine, endLine: endLine, baseIndentLevel: baseIndentLevel}
386}
387
388func findNestedSectionStart(lines []string, pathSegments []PathSegment) (int, int) {
389 currentLevel := 0

Callers 1

Calls 2

findNestedSectionStartFunction · 0.85
findNestedSectionEndFunction · 0.85

Tested by

no test coverage detected