org.jrubyparser.ast
Class MultipleAsgnNode

java.lang.Object
  extended by org.jrubyparser.ast.Node
      extended by org.jrubyparser.ast.AssignableNode
          extended by org.jrubyparser.ast.MultipleAsgnNode
All Implemented Interfaces:
ISourcePositionHolder

public class MultipleAsgnNode
extends AssignableNode


Constructor Summary
MultipleAsgnNode(SourcePosition position, ListNode pre, Node rest)
           
MultipleAsgnNode(SourcePosition position, ListNode pre, Node rest, ListNode post)
           
 
Method Summary
 Object accept(NodeVisitor iVisitor)
           
 List<NodePair> calculateStaticAssignments()
          In cases where some or all the the LHS to RHS assignments are known then return a list of known mappings.
 SourcePosition getLeftHandSidePosition()
           
 NodeType getNodeType()
           
 ListNode getPost()
           
 int getPostCount()
          Get total count of all post arguments (pre,*rest,{post}).
 ListNode getPre()
           
 int getPreCount()
          Get total count of all pre arguments ({pre},*rest,post).
 int getRequiredCount()
           
 Node getRest()
           
 boolean isSame(Node node)
          Checks node for 'sameness' for diffing.
 
Methods inherited from class org.jrubyparser.ast.AssignableNode
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

MultipleAsgnNode

public MultipleAsgnNode(SourcePosition position,
                        ListNode pre,
                        Node rest)

MultipleAsgnNode

public MultipleAsgnNode(SourcePosition position,
                        ListNode pre,
                        Node rest,
                        ListNode post)
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)
Specified by:
accept in class Node

getRest

public Node getRest()

getPre

public ListNode getPre()

getPreCount

public int getPreCount()
Get total count of all pre arguments ({pre},*rest,post).


getPostCount

public int getPostCount()
Get total count of all post arguments (pre,*rest,{post}).


getPost

public ListNode getPost()

getRequiredCount

public int getRequiredCount()

calculateStaticAssignments

public List<NodePair> calculateStaticAssignments()
In cases where some or all the the LHS to RHS assignments are known then return a list of known mappings. This will only work on a subset of simple static resolvable mappings. Something like:
   a, *b, c = 1,2,3,4
 
will work since all values can be computed simply ([a=1,b=[2,3],c=4]). For the case of b an ArrayNode will get constructed with proper range offsets as a computed node. This example used FixnumNodes but the node type can be anything which can be statically resolved. However:
   a, *b, c = random_call
   a, *b, c = *[1,2,3,4]
 
will not work since we cannot know what random_call will return. The splat case could be made to work since it is statically resolvable, but at this point we do not want to replicate too much of Ruby's semantics. So statically resolvable but compound static resolution is not currently in scope for this method (although it might be added later). Note, this will return a partial list when part of the list is statically resolvable and the unresolvable portions will have a null value to indicate they cannot be resolved:
   a, *b, c = 1, *foo
 
In this case we will get back [a=1,b=null,c=null]. Partial results are still useful for inference in an IDE.

Returns:
a list of nodepairs for known bindings and null for values not bound.

getLeftHandSidePosition

public SourcePosition getLeftHandSidePosition()
Overrides:
getLeftHandSidePosition in class AssignableNode


Copyright © 2013. All Rights Reserved.