MCPcopy
hub / github.com/hashicorp/hcl / OutermostExprAtPos

Method OutermostExprAtPos

structure_at_pos.go:89–101  ·  view source on GitHub ↗

OutermostExprAtPos attempts to find an expression in the receiving file that contains the given position. This is a best-effort method that may not be able to produce a result for all positions or for all HCL syntaxes. Since expressions are often nested inside one another, this method returns the o

(pos Pos)

Source from the content-addressed store, hash-verified

87//
88// The result is nil if no single expression could be selected for any reason.
89func (f *File) OutermostExprAtPos(pos Pos) Expression {
90 // The root body of the file must implement this interface in order
91 // to support OutermostExprAtPos.
92 type Interface interface {
93 OutermostExprAtPos(pos Pos) Expression
94 }
95
96 impl, ok := f.Body.(Interface)
97 if !ok {
98 return nil
99 }
100 return impl.OutermostExprAtPos(pos)
101}
102
103// AttributeAtPos attempts to find an attribute definition in the receiving
104// file that contains the given position. This is a best-effort method that may

Callers

nothing calls this directly

Calls 1

OutermostExprAtPosMethod · 0.65

Tested by

no test coverage detected