Ejemplo n.º 1
0
  public static List<Node> getArgumentNodesFromFunctionCall(IArgumentNode iVisited) {
    List<Node> arguments = new ArrayList<Node>();
    Node argsNode = iVisited.getArgsNode();

    Iterator<Node> iter = null;
    if (argsNode != null) {
      iter = argsNode.childNodes().iterator();
    } else {
      // block?
      Node iterNode = null;
      if (iVisited instanceof FCallNode) {
        iterNode = ((FCallNode) iVisited).getIterNode();
      } else if (iVisited instanceof CallNode) {
        iterNode = ((CallNode) iVisited).getIterNode();
      }

      if (iterNode == null) {
        return arguments;
      }
      if (iterNode instanceof IterNode) {
        // yup, it has a block
        IterNode yeah = (IterNode) iterNode;
        Node varNode = yeah.getVarNode();
        if (varNode instanceof DAsgnNode) {
          // single variable in the block
          arguments.add(varNode);
        } else if (varNode instanceof MultipleAsgnNode) {
          // multiple variables in the block
          MultipleAsgnNode multi = (MultipleAsgnNode) varNode;
          ListNode list = multi.getHeadNode();
          if (list != null) {
            iter = list.childNodes().iterator();
          } else {
            Node multiArgsNode = multi.getArgsNode();
            if (multiArgsNode instanceof DAsgnNode) {
              arguments.add(multiArgsNode);
            }
          }
        }
      }
    }
    if (iter == null) {
      return arguments;
    }
    while (iter.hasNext()) {
      arguments.add(iter.next());
    }
    return arguments;
  }
Ejemplo n.º 2
0
 public static List<String> getArguments(ListNode argList) {
   if (argList == null) {
     return new ArrayList<String>();
   }
   List<String> arguments = new ArrayList<String>();
   List<Node> childNodes = argList.childNodes();
   for (Node node : childNodes) {
     if (node instanceof ArgumentNode) {
       arguments.add(((ArgumentNode) node).getName());
     } else if (node instanceof LocalAsgnNode) {
       LocalAsgnNode local = (LocalAsgnNode) node;
       arguments.add(
           MessageFormat.format(
               "{0} = {1}",
               local.getName(),
               getStringRepresentation(
                   local //$NON-NLS-1$
                       .getValueNode())));
     }
   }
   return arguments;
 }