org.jrubyparser.ast
Class LocalAsgnNode

java.lang.Object
  extended by org.jrubyparser.ast.Node
      extended by org.jrubyparser.ast.AssignableNode
          extended by org.jrubyparser.ast.LocalAsgnNode
All Implemented Interfaces:
ILocalVariable, INameMatchable, INameNode, ISourcePositionHolder

public class LocalAsgnNode
extends AssignableNode
implements ILocalVariable

An assignment to a local variable.


Constructor Summary
LocalAsgnNode(SourcePosition position, String name, int location, Node valueNode)
           
 
Method Summary
 Object accept(NodeVisitor iVisitor)
          Accept for the visitor pattern.
 ILocalVariable getDeclaration()
          Return parameter if this local assignment is referring to a parameter since that clearly is the declaration.
 IScope getDefinedScope()
          Which Variable Scope does this variable belong to? Note that RootNode is a special ILocalScope for the implicit scope created at top-level.
 int getDepth()
          How many scopes should we burrow down to until we need to set the block variable value.
 int getIndex()
          Gets the index within the scope construct that actually holds the eval'd value of this local variable
 String getLexicalName()
          Get the name including any leading sigils.
 SourcePosition getLexicalNamePosition()
          The position of the name + any sigils that come with it.
 String getName()
          Name of the local assignment.
 SourcePosition getNamePosition()
          The position of just the name part of the node.
 NodeType getNodeType()
           
 List<ILocalVariable> getOccurrences()
          Find all occurences of this variable including itself.
 boolean isNameMatch(String name)
           
 boolean isSame(Node node)
          Checks node for 'sameness' for diffing.
 void setName(String name)
          Change the name of this local assignment (for refactoring)
 
Methods inherited from class org.jrubyparser.ast.AssignableNode
getLeftHandSidePosition, getValue, getValueNode, setValue, setValueNode
 
Methods inherited from class org.jrubyparser.ast.Node
adopt, adopt, adoptUsingNodesPosition, childNodes, comparePositionWith, createList, getClosestIScope, getClosestModule, getGrandParent, getInlineComment, getInnermostIter, getMethodFor, getNodeAt, getNodeName, getOutermostIter, getParent, getPosition, getPositionIncludingComments, getPreviousComments, insertAfter, insertAll, insertBefore, insertNode, isBlockParameter, isDescendentOf, isLeaf, isMethodParameter, setParent, setPosition, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocalAsgnNode

public LocalAsgnNode(SourcePosition position,
                     String name,
                     int location,
                     Node valueNode)
Method Detail

isSame

public boolean isSame(Node node)
Checks node for 'sameness' for diffing.

Overrides:
isSame in class AssignableNode
Parameters:
node - to be compared to
Returns:
Returns a boolean

getNodeType

public NodeType getNodeType()
Specified by:
getNodeType in class Node
Returns:
the nodeId

accept

public Object accept(NodeVisitor iVisitor)
Accept for the visitor pattern.

Specified by:
accept in class Node
Parameters:
iVisitor - the visitor

getLexicalName

public String getLexicalName()
Description copied from interface: INameNode
Get the name including any leading sigils.

Specified by:
getLexicalName in interface INameNode

getName

public String getName()
Name of the local assignment.

Specified by:
getName in interface INameNode

setName

public void setName(String name)
Change the name of this local assignment (for refactoring)

Specified by:
setName in interface INameNode
Parameters:
name -

isNameMatch

public boolean isNameMatch(String name)
Specified by:
isNameMatch in interface INameMatchable

getDepth

public int getDepth()
How many scopes should we burrow down to until we need to set the block variable value.

Returns:
0 for current scope, 1 for one down, ...

getIndex

public int getIndex()
Gets the index within the scope construct that actually holds the eval'd value of this local variable

Returns:
Returns an int offset into storage structure

getDefinedScope

public IScope getDefinedScope()
Description copied from interface: ILocalVariable
Which Variable Scope does this variable belong to? Note that RootNode is a special ILocalScope for the implicit scope created at top-level.

Specified by:
getDefinedScope in interface ILocalVariable

getOccurrences

public List<ILocalVariable> getOccurrences()
Description copied from interface: ILocalVariable
Find all occurences of this variable including itself.

Specified by:
getOccurrences in interface ILocalVariable

getDeclaration

public ILocalVariable getDeclaration()
Return parameter if this local assignment is referring to a parameter since that clearly is the declaration. In the case that it is not a parameter then we pick itself since current assignment is what most programmers will expect to be a declaration. Note: This is largely an arbitrary choice. In LocalVar node we always pick the closest LocalAsgn to the beginning of the scope whereas here we pick itself. Asking programmers what they thought was the declaration is why this choice was made. Also NetBeans also came to the same decision.

Specified by:
getDeclaration in interface ILocalVariable

getNamePosition

public SourcePosition getNamePosition()
Description copied from interface: INameNode
The position of just the name part of the node.

Specified by:
getNamePosition in interface INameNode

getLexicalNamePosition

public SourcePosition getLexicalNamePosition()
Description copied from interface: INameNode
The position of the name + any sigils that come with it.

Specified by:
getLexicalNamePosition in interface INameNode


Copyright © 2013. All Rights Reserved.