Package org.mozilla.javascript

Examples of org.mozilla.javascript.Node$Symbol


  }
 
  protected boolean isDojoCall (Node functionCall) {
    boolean isDojoCall = false;
   
    Node propertyLookup = functionCall.getFirstChild();
   
    // Check node is a property name lookup from the "dojo" object.
    // Property Name Lookup -> Source, Property
    if (propertyLookup.getType() == Token.GETPROP && propertyLookup.getFirstChild().getType() == Token.NAME) {
        String functionName = propertyLookup.getFirstChild().getString();
        if ("dojo".equals(functionName)) {
          isDojoCall = true;
      }
    }
   
View Full Code Here


 
  // Try to find module paths expression in djConfig object literal. Merge results
  // into existing module paths map.
  protected void parseModulePathsExpr(Node objectLiteral) {
    if (objectLiteral.getType() == Token.OBJECTLIT) {
      Node modulePathsLiteral = findLiteralValue(objectLiteral, "modulePaths");
      if (modulePathsLiteral != null && modulePathsLiteral.getType() == Token.OBJECTLIT) {
        // Put out all String module path values and merge into existing map.
        Map<String, String> modulePaths = findLiteralStringValues(modulePathsLiteral);
        this.modulePaths.putAll(modulePaths);
      }
    }
View Full Code Here

    // Iterate through each literal key, extracting associated value. Ignore
    // any non-string values, we aren't attempting inner-resolution of references.
    if (propertyList != null) {
      int numArgs = 0;
      // Child nodes are linked list of object values
      Node propertyValue = objLiteral.getFirstChild();
     
      while (numArgs < propertyList.length) {
        // Convert key/value pairs into a handy format
        if (propertyValue.getType() == Token.STRING) {
          literalValues.put((String) propertyList[numArgs], propertyValue.getString());
        }
       
        propertyValue = propertyValue.getNext();
        numArgs++;
      }
    }
   
    return literalValues;
View Full Code Here

  }
 
  // Find an object literal's value for a given key. If not found,
  // return null.
  protected Node findLiteralValue(Node objLiteral, String key) {
    Node literalValueNode = null;
   
    // Get list of all properties
    Object[] propertyList = (Object[]) objLiteral.getProp(Token.EQ);
   
    // Iterate through key/values looking for a match
    if (propertyList != null) {
      Node propertyValue = objLiteral.getFirstChild();
      for(int index = 0; index < propertyList.length; index++) {
        if (key.equals(propertyList[index])) {
          literalValueNode = propertyValue;
          break;
        }
        propertyValue = propertyValue.getNext();
      }
    }
   
    return literalValueNode;
  }
View Full Code Here

  protected String functionPropertyName(Node propertyLookup) {
    String propertyName = null;
   
    // First argument is an object reference that lookup should be
    // performed against.
    Node objectReference = propertyLookup.getFirstChild();
   
    if (objectReference != null) {
      // Find property identifier we are retrieving...
      Node propertyNameNode = objectReference.getNext();
     
      // Only handle explicit string properties, we cannot resolve variables.
      if (propertyNameNode != null && propertyNameNode.getType() == Token.STRING) {
        propertyName = propertyNameNode.getString();
      }
    }
   
    return propertyName;
  }
View Full Code Here

  // the string value for the first argument. Ignore any complicated resolution.
  protected String functionCallArgument(Node functionCallNodes, int argIndex) {
    String fnCallArg = null;
   
    // Traverse argument nodes until we reach desired one.
    Node argument = functionCallNodes.getNext();
    while (argument != null && argIndex > 0) {
      argument = argument.getNext();
      argIndex--;
    };
   
    // Check we have a simple type value.
    if (argument != null && argument.getType() == Token.STRING) {
      fnCallArg = argument.getString();
    }
   
    return fnCallArg;
  }
View Full Code Here

    assertValues((ObjectLiteral) innerObjLit, getPrepopulatedMap("num", 1.0, "str", "str", "b", true));
  }     
 
  @Test(expected=InvalidLiteralNode.class)
  public void throwsExceptionWhenPassingNonLiteralNode() throws InvalidLiteralNode {         
    Node node = new Node(Token.SCRIPT);
    ObjectLiteral lit = new ObjectLiteral(node);   
  }
View Full Code Here

            sbParam.append(" ");
          }
        }
        sb.append("FUNCTION: " + fn.getFunctionName() + " [ " + sbParam + "]");
      } else if (cursor.getType() == Token.VAR) {
        Node vn = cursor.getFirstChild();
        sb.append("VAR: " + vn.getString());

      }
      apiMap.remove(jsFileName + sb);
    }
  }
View Full Code Here

              sbParam.append(" ");
            }
          }
          details.append("FUNCTION: " + fn.getFunctionName() + " [ " + sbParam + "]\n");
        } else if (cursor.getType() == Token.VAR) {
          Node vn = cursor.getFirstChild();
          details.append("VAR: " + vn.getString() + "\n");
        }
      }
    }
    return details.toString();
  }
View Full Code Here

     * in the child list, e.g. if this method is called after the code
     * generator begins the tree transformation.
     */
    public List<AstNode> getStatements() {
        List<AstNode> stmts = new ArrayList<AstNode>();
        Node n = getFirstChild();
        while (n != null) {
            stmts.add((AstNode)n);
            n = n.getNext();
        }
        return stmts;
    }
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.Node$Symbol

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.