Top Description Inners Fields Constructors Methods
org.python.indexer

public Class NBinding

extends Object
implements Comparable<Object>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable
Imports
org.python.indexer.ast.NNode, .NUrl, org.python.indexer.types.NModuleType, .NType, .NUnionType, .NUnknownType, java.util.ArrayList, .Collection, .LinkedHashSet, .List, .Set

An 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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
NBinding.Kind

In addition to its type, each binding has a Kind enumeration that attempts to represent the structural role the name plays in the code.

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private List<Def>
private static final int
pack-priv NBinding.Kind
pack-priv int
private String
private static final int
private String
private static final int
private static final int
private Set<Ref>
private static final int
private static final int
private NType

Constructor Summary

AccessConstructor and Description
public
NBinding(String id, NNode node, NType type, NBinding.Kind kind)

public
NBinding(String id, Def def, NType type, NBinding.Kind kind)

Method Summary

Modifier and TypeMethod and Description
public void
addDef(NNode node)

Adds node as a definition for this binding.

public void
addDef(Def def)

Adds def as a definition for this binding.

public void
public void
addRef(NNode node)

public void
addRef(Ref ref)

public int
compareTo(Object
the object to be compared.
o
)

Implements java.lang.Comparable.compareTo.

Bindings can be sorted by their location for outlining purposes.

public NType
followType()

Returns the type, first calling NUnknownType#follow on it.

public List<Def>

Returns:

the defs
getDefs
()

Return the (possibly empty) set of definitions for this binding.

public String

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.
getFirstFile
()

Returns a filename associated with this binding, for debug messages.

public NBinding.Kind
public String
getName()

Returns the unqualified name.

public int
getNumDefs()

Returns the number of definitions found for this binding.

public int
public String
getQname()

Returns the qualified name.

public Set<Ref>
getRefs()

Returns the set of references to this binding.

public Def
getSignatureNode()

Returns the first definition, which by convention is treated as the one that introduced the binding.

public NType
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public void
public void
public void
public void
public void
public void
removeRef(Ref node)

public void
public void
setName(String name)

Sets the binding's simple (unqualified) name.

public void
setProvisional(boolean isProvisional)

public void
setQname(String qname)

Sets the binding's qualified name.

public void
setType(NType type)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

BUILTINback to summary
private static final int BUILTIN
DEF_SET_INITIAL_CAPACITYback to summary
private static final int DEF_SET_INITIAL_CAPACITY
defsback to summary
private List<Def> defs
DEPRECATEDback to summary
private static final int DEPRECATED
kindback to summary
pack-priv NBinding.Kind kind
modifiersback to summary
pack-priv int modifiers
nameback to summary
private String name
PROVISIONALback to summary
private static final int PROVISIONAL
qnameback to summary
private String qname
READONLYback to summary
private static final int READONLY
REF_SET_INITIAL_CAPACITYback to summary
private static final int REF_SET_INITIAL_CAPACITY
refsback to summary
private Set<Ref> refs
STATICback to summary
private static final int STATIC
SYNTHETICback to summary
private static final int SYNTHETIC
typeback to summary
private NType type

Constructor Detail

NBindingback to summary
public NBinding(String id, NNode node, NType type, NBinding.Kind kind)
NBindingback to summary
public NBinding(String id, Def def, NType type, NBinding.Kind kind)

Method Detail

addDefback to summary
public void addDef(NNode node)

Adds node as a definition for this binding. This is called automatically (when appropriate) by adding the binding to a Scope.

addDefback to summary
public void addDef(Def def)

Adds def as a definition for this binding. This is called automatically (when appropriate) by adding the binding to a Scope. If node is an NUrl, and this is the binding's only definition, it will be marked as a builtin.

addDefsback to summary
public void addDefs(Collection<NNode> nodes)
addRefback to summary
public void addRef(NNode node)
addRefback to summary
public void addRef(Ref ref)
compareToback to summary
public int compareTo(Object o)

Implements java.lang.Comparable.compareTo.

Bindings can be sorted by their location for outlining purposes.

Parameters
o:Object

Doc from java.lang.Comparable.compareTo.

the object to be compared.

Returns:int

Doc from java.lang.Comparable.compareTo.

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Annotations
@Override

followTypeback to summary
public NType followType()

Returns the type, first calling NUnknownType#follow on it. For external consumers of the index, this is usually preferable to calling getType.

getDefsback to summary
public List<Def> getDefs()

Return the (possibly empty) set of definitions for this binding.

Returns:List<Def>

the defs

getFirstFileback to summary
public String getFirstFile()

Returns a filename associated with this binding, for debug messages.

Returns:String

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.

getKindback to summary
public NBinding.Kind getKind()
getNameback to summary
public String getName()

Returns the unqualified name.

getNumDefsback to summary
public int getNumDefs()

Returns the number of definitions found for this binding.

getNumRefsback to summary
public int getNumRefs()
getQnameback to summary
public String getQname()

Returns the qualified name.

getRefsback to summary
public Set<Ref> getRefs()

Returns the set of references to this binding.

getSignatureNodeback to summary
public Def getSignatureNode()

Returns the first definition, which by convention is treated as the one that introduced the binding.

getTypeback to summary
public NType getType()
hasRefsback to summary
public boolean hasRefs()
isBuiltinback to summary
public boolean isBuiltin()
isDeprecatedback to summary
public boolean isDeprecated()
isProvisionalback to summary
public boolean isProvisional()
isReadOnlyback to summary
public boolean isReadOnly()
isStaticback to summary
public boolean isStatic()
isSyntheticback to summary
public boolean isSynthetic()
markBuiltinback to summary
public void markBuiltin()
markDeprecatedback to summary
public void markDeprecated()
markReadOnlyback to summary
public void markReadOnly()
markStaticback to summary
public void markStatic()
markSyntheticback to summary
public void markSynthetic()
removeRefback to summary
public void removeRef(Ref node)
setKindback to summary
public void setKind(NBinding.Kind kind)
setNameback to summary
public void setName(String name)

Sets the binding's simple (unqualified) name.

setProvisionalback to summary
public void setProvisional(boolean isProvisional)
setQnameback to summary
public void setQname(String qname)

Sets the binding's qualified name. This should in general be the same as binding.getType().getTable().getPath().

setTypeback to summary
public void setType(NType type)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override

org.python.indexer back to summary

public final Enum NBinding.Kind

extends Enum<NBinding.Kind>
Class Inheritance

In addition to its type, each binding has a Kind enumeration that attempts to represent the structural role the name plays in the code. This is a rough categorization that takes into account type information, structural (AST) information, and possibly other semantics. It can help IDEs with presentation decisions, and can be useful to expose to users as a parameter for filtering queries on the graph.

Field Summary

Modifier and TypeField and Description
public static final NBinding.Kind
public static final NBinding.Kind
public static final NBinding.Kind
public static final NBinding.Kind
public static final NBinding.Kind
public static final NBinding.Kind
public static final NBinding.Kind
public static final NBinding.Kind
public static final NBinding.Kind

Constructor Summary

AccessConstructor and Description
private
Kind()

Method Summary

Modifier and TypeMethod and Description
public static NBinding.Kind
public static NBinding.Kind[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ATTRIBUTEback to summary
public static final NBinding.Kind ATTRIBUTE
CLASSback to summary
public static final NBinding.Kind CLASS
CONSTRUCTORback to summary
public static final NBinding.Kind CONSTRUCTOR
FUNCTIONback to summary
public static final NBinding.Kind FUNCTION
METHODback to summary
public static final NBinding.Kind METHOD
MODULEback to summary
public static final NBinding.Kind MODULE
PARAMETERback to summary
public static final NBinding.Kind PARAMETER
SCOPEback to summary
public static final NBinding.Kind SCOPE
VARIABLEback to summary
public static final NBinding.Kind VARIABLE

Constructor Detail

Kindback to summary
private Kind()

Method Detail

valueOfback to summary
public static NBinding.Kind valueOf(String name)
valuesback to summary
public static NBinding.Kind[] values()