Package org.mozilla.javascript

Examples of org.mozilla.javascript.Node$Symbol


   * @param argIndex - Argument index to access
   * @return String argument value, null if not available or not a string.
   */
  protected String getFnCallArgumentStr(Node fnCallNode, int argIndex) {
    String fnCallArg = null;
    Node argument = getFnCallArgument(fnCallNode, argIndex);
   
    if (argument != null) {
      fnCallArg = getStringNodeLabel(argument);       
    }
   
View Full Code Here


   * @param fnCallNode - AST nodes containing function arguments
   * @param argIndex - Argument index to retrieve
   * @return Argument node, null if not found
   */
  protected Node getFnCallArgument(Node fnCallNode, int argIndex) {
    Node argument = fnCallNode.getNext();
    while (argument != null && argIndex > 0) {
      argument = argument.getNext();
      argIndex--;
    };   
   
    return argument;
  }
View Full Code Here

   * @param propertyLookup - Function reference to search
   * @return Function property name, null if value not found or not a string.
   */
  protected String getFunctionPropertyName(Node propertyLookup) {
    String propertyName = null;   
    Node objectReference = propertyLookup.getFirstChild();
   
    if (objectReference != null) {
      propertyName = getStringNodeLabel(objectReference.getNext());
    }
   
    return propertyName;
  }
View Full Code Here

   * @param node - Parent node
   * @return Available string labels for child nodes
   */
  protected List<String> getNodeStringChildren(Node node) {
    List<String> childStrings = new ArrayList<String>();
    Node child = node.getFirstChild();
   
    while (child != null) {     
      String nodeLabel = getStringNodeLabel(child);
      if (nodeLabel != null) {
        childStrings.add(nodeLabel);
      }
      child = child.getNext();
    };   
   
    return childStrings;
  }
View Full Code Here

   * @return All dependency arguments discovered or an empty list
   */
  protected List<String> retrieveRequireDependencyArguments(Node node) {
    List<String> dependencyArguments = new ArrayList<String>();
   
    Node firstFnArgument = getFnCallArgument(node.getFirstChild(), 0);
   
    if (firstFnArgument != null) {
      switch (firstFnArgument.getType()) {
        case Token.STRING:
          dependencyArguments.add(firstFnArgument.getString());
          break;
        case Token.ARRAYLIT:               
          dependencyArguments.addAll(getNodeStringChildren(firstFnArgument));
          break;
        case Token.OBJECTLIT:
          if (firstFnArgument.getNext() != null) {
            dependencyArguments.addAll(getNodeStringChildren(firstFnArgument.getNext()));
          }
        default:
          break;
      }
    }
View Full Code Here

   * @return All dependency arguments discovered or an empty list
   */
  protected List<String> retrieveDefineDependencyArguments (Node node) {
    List<String> dependencyArguments = new ArrayList<String>();
   
    Node firstFnArgument = getFnCallArgument(node.getFirstChild(), 0);
   
    if (firstFnArgument != null) {
      switch (firstFnArgument.getType()) {
        case Token.STRING:
          dependencyArguments.addAll(getNodeStringChildren(firstFnArgument.getNext()));
          break;
        case Token.ARRAYLIT:               
          dependencyArguments.addAll(getNodeStringChildren(firstFnArgument));
          break;
        default:
View Full Code Here

   */
  @Override
  protected List<String> retrieveDependencyArguments(Node node) {
    List<String> singleDependencyList = new ArrayList<String>();
   
    Node propertyResolution = node.getFirstChild();
   
    if (propertyResolution != null) {     
      String firstArg = getFnCallArgumentStr(propertyResolution, 0);
      if (firstArg != null) {
        singleDependencyList.add(firstArg);
View Full Code Here

   *
   * @param functionCall - Function call reference
   * @return Function call from main dojo object reference.
   */
  protected boolean isDojoObjectRef (Node functionCall) {
    Node propertyLookup = functionCall.getFirstChild();
   
    if (propertyLookup != null &&
      propertyLookup.getType() == Token.GETPROP
      && propertyLookup.getFirstChild().getType() == Token.NAME) {
        String functionName = propertyLookup.getFirstChild().getString();
        if (DOJO_OBJ_REF.equals(functionName)) {
          return true;
      }
    }
   
View Full Code Here

    assertValues((ObjectLiteral) innerLit, 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

    case Token.CALL:
      if (isDojoCall(node)) {
        // We are looking for dojo.some_function(...) calls, this means first
        // child of function call is property resolution of function in the
        // dojo object.
        Node propertyResolution = node.getFirstChild();
       
        if (propertyResolution != null) {
          // Find property label accessing object
          String propertyName = functionPropertyName(propertyResolution);
          // Single argument module functions, put out value and store in appropriate list.
          if ("require".equals(propertyName) || "provide".equals(propertyName) || "declare".equals(propertyName)) {
            String firstArg = functionCallArgument(propertyResolution, 0);
            List<String> moduleList = moduleLists.get(propertyName);
           
            if (!moduleList.contains(firstArg)) {
              moduleList.add(firstArg);
            }
          } else if ("registerModulePath".equals(propertyName)) {
            // Extract module identifier and module path, first two arguments to
            // dojo.registerModulePath();
            String modulePrefix = functionCallArgument(propertyResolution, 0);
            String modulePath = functionCallArgument(propertyResolution, 1);
           
            modulePaths.put(modulePrefix, modulePath);
          }
        }
       
      }
      break;
    // Global identifier token, check for djConfig assignment, djConfig = {...}
    case Token.SETNAME:
      // LHS is global name binding.
      Node bindName = node.getFirstChild();
     
      // LHS should be djConfig global assignment.
      if (bindName.getType() == Token.BINDNAME && "djConfig".equals(bindName.getString())) {
        // RHS of statement should be literal assignment.
        Node assignmentExpr = node.getLastChild();
        parseModulePathsExpr(assignmentExpr);
      }
     
      break;
    // Local identifier token, check for djConfig assignment, var djConfig = {...}
    case Token.NAME:
      // LHS is name token
      if ("djConfig".equals(node.getString())) {
        // Check for object literal assignment
        Node assignmentExpr = node.getFirstChild();
        parseModulePathsExpr(assignmentExpr);
      }
     
      break;
    }
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.