| 34 | } |
| 35 | |
| 36 | func (w *variablesWalker) Enter(n Node) hcl.Diagnostics { |
| 37 | switch tn := n.(type) { |
| 38 | case *ScopeTraversalExpr: |
| 39 | t := tn.Traversal |
| 40 | |
| 41 | // Check if the given root name appears in any of the active |
| 42 | // local scopes. We don't want to return local variables here, since |
| 43 | // the goal of walking variables is to tell the calling application |
| 44 | // which names it needs to populate in the _root_ scope. |
| 45 | name := t.RootName() |
| 46 | for _, names := range w.localScopes { |
| 47 | if _, localized := names[name]; localized { |
| 48 | return nil |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | w.Callback(t) |
| 53 | case ChildScope: |
| 54 | w.localScopes = append(w.localScopes, tn.LocalNames) |
| 55 | } |
| 56 | return nil |
| 57 | } |
| 58 | |
| 59 | func (w *variablesWalker) Exit(n Node) hcl.Diagnostics { |
| 60 | switch n.(type) { |