-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathBindingFinder.java
More file actions
36 lines (31 loc) · 909 Bytes
/
BindingFinder.java
File metadata and controls
36 lines (31 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* Copyright 2009, Google Inc. All rights reserved.
* Licensed to PSF under a Contributor Agreement.
*/
package org.python.indexer.ast;
import org.python.indexer.Indexer;
import org.python.indexer.Scope;
/**
* A visitor that looks for name-binding constructs in a given scope.
*/
class BindingFinder extends GenericNodeVisitor {
private Scope scope; // starting scope
public BindingFinder(Scope scope) {
this.scope = scope;
}
@Override
public boolean dispatch(NNode n) {
if (n.bindsName()) {
try {
n.bindNames(scope);
} catch (Exception x) {
Indexer.idx.handleException("error binding names for " + n, x);
}
}
// Do not descend into new scopes.
if (n.isFunctionDef() || n.isClassDef()) {
return false;
}
return super.dispatch(n);
}
}