Top Fields Constructors Methods
org.python.indexer.ast

public Class NAttribute

extends NNode
Class Inheritance
Imports
org.python.indexer.Indexer, .NBinding, .Scope, org.python.indexer.types.NType, .NUnionType, .NUnknownType

Field Summary

Modifier and TypeField and Description
public NName
pack-priv static final long
public NNode
Inherited from org.python.indexer.ast.NNode:
parent

Constructor Summary

AccessConstructor and Description
public
NAttribute(NNode target, NName attr)

public
NAttribute(NNode target, NName attr, int start, int end)

Method Summary

Modifier and TypeMethod and Description
public NName
public String
public NNode
private NBinding
makeProvisionalBinding(NType targetType)

If we can't find the attribute in the target type, create a temp binding for the attribute.

public NType
resolve(Scope s)

Overrides org.python.indexer.ast.NNode.resolve.

Node should set the resolved type in its type field and also return it.

private void
public void
setAttr(NName attr)

Sets the attribute node.

public void
setAttr(Scope s, NType v)

Assign some definite value to the attribute.

public void
setTarget(NNode target)

Sets the target node.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
visit(NNodeVisitor
the object to call with this node. If the visitor returns true, the node also passes its children to the visitor.
v
)

Implements abstract org.python.indexer.ast.NNode.visit.

Visits this node and optionally its children.

Inherited from org.python.indexer.ast.NNode:
addChildrenaddChildrenaddErroraddErroraddTypeaddWarningaddWarningbindNamesbindsNameendgetAstRootgetDeepestNodeAtOffsetgetEnclosingNamespacegetFilegetParentgetTablegetTypeisCallisClassDefisFunctionDefisLambdaisModuleisNamelengthresolveExprresolveListresolveListAsUnionsetEndsetParentsetStartsetTypestartvisitNodevisitNodeList

Field Detail

attrback to summary
public NName attr
serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Hides org.python.indexer.ast.NNode.serialVersionUID.

targetback to summary
public NNode target

Constructor Detail

NAttributeback to summary
public NAttribute(NNode target, NName attr)
NAttributeback to summary
public NAttribute(NNode target, NName attr, int start, int end)

Method Detail

getAttrback to summary
public NName getAttr()
getAttributeNameback to summary
public String getAttributeName()
getTargetback to summary
public NNode getTarget()
makeProvisionalBindingback to summary
private NBinding makeProvisionalBinding(NType targetType)

If we can't find the attribute in the target type, create a temp binding for the attribute. If later on the target type defines the attribute, that definition replaces the temp binding, and any references to the temp binding are updated to refer to the new definition.

We never create temp bindings for attributes of native types, as the attributes of native types are expected to be fully resolved.

This strategy is a temporary solution for inferring the types of attributes on targets that are not yet resolved. This whole approach needs to be replaced by dataflow analysis.

resolveback to summary
public NType resolve(Scope s) throws Exception

Overrides org.python.indexer.ast.NNode.resolve.

Doc from org.python.indexer.ast.NNode.resolve.

Node should set the resolved type in its type field and also return it.

Annotations
@Override
resolveAttributeOnTypeback to summary
private void resolveAttributeOnType(NType targetType)
setAttrback to summary
public void setAttr(NName attr)

Sets the attribute node. Used when constructing the AST.

Exceptions
IllegalArgumentException:
if the param is null
setAttrback to summary
public void setAttr(Scope s, NType v) throws Exception

Assign some definite value to the attribute. Used during the name resolution pass. This method is called when this node is in the lvalue of an assignment, in which case it is called in lieu of resolve.

setTargetback to summary
public void setTarget(NNode target)

Sets the target node. Used when constructing the AST.

Exceptions
IllegalArgumentException:
if the param is null
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

visitback to summary
public void visit(NNodeVisitor v)

Implements abstract org.python.indexer.ast.NNode.visit.

Doc from org.python.indexer.ast.NNode.visit.

Visits this node and optionally its children.

Parameters
v:NNodeVisitor

the object to call with this node. If the visitor returns true, the node also passes its children to the visitor.

Annotations
@Override