src/com/google/javascript/jscomp/NodeUtil.java
/**
   * Creates a node representing a qualified name.
   *
   * @param name A qualified name (e.g. "foo" or "foo.bar.baz")
   * @return A NAME or GETPROP node
   */
Creates a node representing a qualified name.
@param name A qualified name
@return A NAME or GETPROP node
Creates a node representing a qualified name . @param name A qualified name @return A NAME or GETPROP node
public static Node newQName(
      AbstractCompiler compiler, String name) {
    int endPos = name.indexOf('.');
    if (endPos == -1) {
      return newName(compiler, name);
    }
    Node node;
    String nodeName = name.substring(0, endPos);
    if ("this".equals(nodeName)) {
      node = IR.thisNode();
    } else if ("super".equals(nodeName)) {
      node = IR.superNode();
    } else {
      node = newName(compiler, nodeName);
    }
    int startPos;
    do {
      startPos = endPos + 1;
      endPos = name.indexOf('.', startPos);
      String part = (endPos == -1 ? name.substring(startPos) : name.substring(startPos, endPos));
      Node propNode = IR.string(part);
      propNode.setLength(part.length());
      if (compiler.getCodingConvention().isConstantKey(part)) {
        propNode.putBooleanProp(Node.IS_CONSTANT_NAME, true);
      }
      int length = node.getLength() + ".".length() + part.length();
      node = IR.getprop(node, propNode);
      node.setLength(length);
    } while (endPos != -1);
    return node;
  }
public static Node newQName ( AbstractCompiler compiler , String name ) { int endPos = name . indexOf ( '.' ) ; if ( endPos == - 1 ) { return newName ( compiler , name ) ; } Node node ; String nodeName = name . substring ( 0 , endPos ) ; if ( "this" . equals ( nodeName ) ) { node = IR . thisNode ( ) ; } else if ( "super" . equals ( nodeName ) ) { node = IR . superNode ( ) ; } else { node = newName ( compiler , nodeName ) ; } int startPos ; do { startPos = endPos + 1 ; endPos = name . indexOf ( '.' , startPos ) ; String part = ( endPos == - 1 ? name . substring ( startPos ) : name . substring ( startPos , endPos ) ) ; Node propNode = IR . string ( part ) ; propNode . setLength ( part . length ( ) ) ; if ( compiler . getCodingConvention ( ) . isConstantKey ( part ) ) { propNode . putBooleanProp ( Node . IS_CONSTANT_NAME , true ) ; } int length = node . getLength ( ) + "." . length ( ) + part . length ( ) ; node = IR . getprop ( node , propNode ) ; node . setLength ( length ) ; } while ( endPos != - 1 ) ; return node ; }
Creates a node representing a qualified name.
Creates a node representing a qualified name .