public class NBinding
extends java.lang.Object
implements java.lang.Comparable<java.lang.Object>
NBinding
collects information about a fully qualified name (qname) in the code graph.
Each qname has an associated NType
. When a particular qname is assigned values of
different types at different locations, its type is represented as a NUnionType
.
Each qname has a set of one or more definitions, and a set of zero or more references. Definitions and references correspond to code locations.
Modifier and Type | Class and Description |
---|---|
static class |
NBinding.Kind
In addition to its type, each binding has a
NBinding.Kind enumeration that
attempts to represent the structural role the name plays in the code. |
Constructor and Description |
---|
NBinding(java.lang.String id,
Def def,
NType type,
NBinding.Kind kind) |
NBinding(java.lang.String id,
NNode node,
NType type,
NBinding.Kind kind) |
Modifier and Type | Method and Description |
---|---|
void |
addDef(Def def)
Adds
def as a definition for this binding. |
void |
addDef(NNode node)
Adds
node as a definition for this binding. |
void |
addDefs(java.util.Collection<NNode> nodes) |
void |
addRef(NNode node) |
void |
addRef(Ref ref) |
int |
compareTo(java.lang.Object o)
Bindings can be sorted by their location for outlining purposes.
|
NType |
followType()
Returns the type, first calling
NUnknownType.follow(org.python.indexer.types.NType) on it. |
java.util.List<Def> |
getDefs()
Return the (possibly empty) set of definitions for this binding.
|
java.lang.String |
getFirstFile()
Returns a filename associated with this binding, for debug
messages.
|
NBinding.Kind |
getKind() |
java.lang.String |
getName()
Returns the unqualified name.
|
int |
getNumDefs()
Returns the number of definitions found for this binding.
|
int |
getNumRefs() |
java.lang.String |
getQname()
Returns the qualified name.
|
java.util.Set<Ref> |
getRefs()
Returns the set of references to this binding.
|
Def |
getSignatureNode()
Returns the first definition, which by convention is treated as
the one that introduced the binding.
|
NType |
getType() |
boolean |
hasRefs() |
boolean |
isBuiltin() |
boolean |
isDeprecated() |
boolean |
isProvisional() |
boolean |
isReadOnly() |
boolean |
isStatic() |
boolean |
isSynthetic() |
void |
markBuiltin() |
void |
markDeprecated() |
void |
markReadOnly() |
void |
markStatic() |
void |
markSynthetic() |
void |
removeRef(Ref node) |
void |
setKind(NBinding.Kind kind) |
void |
setName(java.lang.String name)
Sets the binding's simple (unqualified) name.
|
void |
setProvisional(boolean isProvisional) |
void |
setQname(java.lang.String qname)
Sets the binding's qualified name.
|
void |
setType(NType type) |
java.lang.String |
toString() |
public NBinding(java.lang.String id, NNode node, NType type, NBinding.Kind kind)
public NBinding(java.lang.String id, Def def, NType type, NBinding.Kind kind)
public void setName(java.lang.String name)
public java.lang.String getName()
public void setQname(java.lang.String qname)
binding.getType().getTable().getPath()
.public java.lang.String getQname()
public void addDef(NNode node)
node
as a definition for this binding. This is called
automatically (when appropriate) by adding the binding to a
Scope
.public void addDefs(java.util.Collection<NNode> nodes)
public void addDef(Def def)
public void addRef(NNode node)
public void addRef(Ref ref)
public void removeRef(Ref node)
public Def getSignatureNode()
public void setType(NType type)
public NType getType()
public NType followType()
NUnknownType.follow(org.python.indexer.types.NType)
on it.
For external consumers of the index, this is usually preferable
to calling getType()
.public void setKind(NBinding.Kind kind)
public NBinding.Kind getKind()
public void markStatic()
public boolean isStatic()
public void markSynthetic()
public boolean isSynthetic()
public void markReadOnly()
public boolean isReadOnly()
public boolean isDeprecated()
public void markDeprecated()
public boolean isBuiltin()
public void markBuiltin()
public void setProvisional(boolean isProvisional)
public boolean isProvisional()
public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable<java.lang.Object>
public java.util.List<Def> getDefs()
public int getNumDefs()
public boolean hasRefs()
public int getNumRefs()
public java.util.Set<Ref> getRefs()
public java.lang.String getFirstFile()
public java.lang.String toString()
toString
in class java.lang.Object