File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -565,34 +565,21 @@ func (r Root) GetLocations(path string) []diag.Location {
565565 if err != nil {
566566 return nil
567567 }
568- return r .locations .Nearest (p )
569- }
570-
571- // GetLocationOf is [Root.GetLocation] for a path node.
572- func (r Root ) GetLocationOf (path * structpath.PathNode ) diag.Location {
573- v , ok := r .valueOf (path )
574- if ! ok {
575- return diag.Location {}
576- }
577- return v .Location ()
568+ return r .GetLocationsOf (p )
578569}
579570
580571// GetLocationsOf is [Root.GetLocations] for a path node.
581572func (r Root ) GetLocationsOf (path * structpath.PathNode ) []diag.Location {
582- v , ok := r .valueOf (path )
583- if ! ok {
584- return nil
585- }
586- return v .Locations ()
573+ return r .locations .Nearest (path )
587574}
588575
589- func (r Root ) valueOf (path * structpath.PathNode ) (dyn.Value , bool ) {
590- p , ok := dyn .FromStructPath (path )
591- if ! ok {
592- return dyn .InvalidValue , false
576+ // GetLocationOf is [Root.GetLocation] for a path node.
577+ func (r Root ) GetLocationOf (path * structpath.PathNode ) diag.Location {
578+ locs := r .GetLocationsOf (path )
579+ if len (locs ) == 0 {
580+ return diag.Location {}
593581 }
594- v , err := dyn .GetByPath (r .value , p )
595- return v , err == nil
582+ return locs [0 ]
596583}
597584
598585// DefinitionLocation returns the primary location the value at path is defined at,
You can’t perform that action at this time.
0 commit comments