org.python.indexer
Class NBinding
- java.lang.Object
-
- org.python.indexer.NBinding
-
- All Implemented Interfaces:
- java.lang.Comparable<java.lang.Object>
public class NBinding extends java.lang.Object implements java.lang.Comparable<java.lang.Object>AnNBindingcollects 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 aNUnionType.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classNBinding.KindIn addition to its type, each binding has aNBinding.Kindenumeration that attempts to represent the structural role the name plays in the code.
-
Constructor Summary
Constructors 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)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddDef(Def def)Addsdefas a definition for this binding.voidaddDef(NNode node)Addsnodeas a definition for this binding.voidaddDefs(java.util.Collection<NNode> nodes)voidaddRef(NNode node)voidaddRef(Ref ref)intcompareTo(java.lang.Object o)Bindings can be sorted by their location for outlining purposes.NTypefollowType()Returns the type, first callingNUnknownType.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.StringgetFirstFile()Returns a filename associated with this binding, for debug messages.NBinding.KindgetKind()java.lang.StringgetName()Returns the unqualified name.intgetNumDefs()Returns the number of definitions found for this binding.intgetNumRefs()java.lang.StringgetQname()Returns the qualified name.java.util.Set<Ref>getRefs()Returns the set of references to this binding.DefgetSignatureNode()Returns the first definition, which by convention is treated as the one that introduced the binding.NTypegetType()booleanhasRefs()booleanisBuiltin()booleanisDeprecated()booleanisProvisional()booleanisReadOnly()booleanisStatic()booleanisSynthetic()voidmarkBuiltin()voidmarkDeprecated()voidmarkReadOnly()voidmarkStatic()voidmarkSynthetic()voidremoveRef(Ref node)voidsetKind(NBinding.Kind kind)voidsetName(java.lang.String name)Sets the binding's simple (unqualified) name.voidsetProvisional(boolean isProvisional)voidsetQname(java.lang.String qname)Sets the binding's qualified name.voidsetType(NType type)java.lang.StringtoString()
-
-
-
Constructor Detail
-
NBinding
public NBinding(java.lang.String id, NNode node, NType type, NBinding.Kind kind)
-
NBinding
public NBinding(java.lang.String id, Def def, NType type, NBinding.Kind kind)
-
-
Method Detail
-
setName
public void setName(java.lang.String name)
Sets the binding's simple (unqualified) name.
-
getName
public java.lang.String getName()
Returns the unqualified name.
-
setQname
public void setQname(java.lang.String qname)
Sets the binding's qualified name. This should in general be the same asbinding.getType().getTable().getPath().
-
getQname
public java.lang.String getQname()
Returns the qualified name.
-
addDef
public void addDef(NNode node)
Addsnodeas a definition for this binding. This is called automatically (when appropriate) by adding the binding to aScope.
-
addDefs
public void addDefs(java.util.Collection<NNode> nodes)
-
addDef
public void addDef(Def def)
-
addRef
public void addRef(NNode node)
-
addRef
public void addRef(Ref ref)
-
removeRef
public void removeRef(Ref node)
-
getSignatureNode
public Def getSignatureNode()
Returns the first definition, which by convention is treated as the one that introduced the binding.
-
setType
public void setType(NType type)
-
getType
public NType getType()
-
followType
public NType followType()
Returns the type, first callingNUnknownType.follow(org.python.indexer.types.NType)on it. For external consumers of the index, this is usually preferable to callinggetType().
-
setKind
public void setKind(NBinding.Kind kind)
-
getKind
public NBinding.Kind getKind()
-
markStatic
public void markStatic()
-
isStatic
public boolean isStatic()
-
markSynthetic
public void markSynthetic()
-
isSynthetic
public boolean isSynthetic()
-
markReadOnly
public void markReadOnly()
-
isReadOnly
public boolean isReadOnly()
-
isDeprecated
public boolean isDeprecated()
-
markDeprecated
public void markDeprecated()
-
isBuiltin
public boolean isBuiltin()
-
markBuiltin
public void markBuiltin()
-
setProvisional
public void setProvisional(boolean isProvisional)
-
isProvisional
public boolean isProvisional()
-
compareTo
public int compareTo(java.lang.Object o)
Bindings can be sorted by their location for outlining purposes.- Specified by:
compareToin interfacejava.lang.Comparable<java.lang.Object>
-
getDefs
public java.util.List<Def> getDefs()
Return the (possibly empty) set of definitions for this binding.- Returns:
- the defs
-
getNumDefs
public int getNumDefs()
Returns the number of definitions found for this binding.
-
hasRefs
public boolean hasRefs()
-
getNumRefs
public int getNumRefs()
-
getRefs
public java.util.Set<Ref> getRefs()
Returns the set of references to this binding.
-
getFirstFile
public java.lang.String getFirstFile()
Returns a filename associated with this binding, for debug messages.- Returns:
- the filename associated with the type (if present) or the first definition (if present), otherwise a string describing what is known about the binding's source.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-
DMelt 3.0 © DataMelt by jWork.ORG