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

Function LocateJSONPathForPathInfo

pkg/parser/json_path_locator.go:97–105  ·  view source on GitHub ↗

LocateJSONPathForPathInfo finds the line/column position in YAML source for a JSONPathInfo. It uses ErrorKind for structural property-name extraction when available, and falls back to regex parsing of the error message string for backward compatibility.

(yamlContent string, info JSONPathInfo)

Source from the content-addressed store, hash-verified

95// It uses ErrorKind for structural property-name extraction when available, and falls back to
96// regex parsing of the error message string for backward compatibility.
97func LocateJSONPathForPathInfo(yamlContent string, info JSONPathInfo) JSONPathLocation {
98 if names := additionalPropertyNamesFor(info); len(names) > 0 {
99 if info.Path == "" {
100 return findFirstAdditionalProperty(yamlContent, names)
101 }
102 return findAdditionalPropertyInNestedContext(yamlContent, info.Path, names)
103 }
104 return LocateJSONPathInYAML(yamlContent, info.Path)
105}
106
107// additionalPropertyNamesFor returns the disallowed property names for a JSONPathInfo.
108// It checks ErrorKind first (structural, no string parsing) and falls back to regex on Message.