当前位置: 首页>>代码示例>>Java>>正文


Java Node.putBooleanProp方法代码示例

本文整理汇总了Java中com.google.javascript.rhino.Node.putBooleanProp方法的典型用法代码示例。如果您正苦于以下问题:Java Node.putBooleanProp方法的具体用法?Java Node.putBooleanProp怎么用?Java Node.putBooleanProp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.javascript.rhino.Node的用法示例。


在下文中一共展示了Node.putBooleanProp方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseAndRecordTypeNode

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Looks for a parameter type expression at the current token and if found,
 * returns it. Note that this method consumes input.
 *
 * @param token The current token.
 * @param lineno The line of the type expression.
 * @param startCharno The starting character position of the type expression.
 * @param matchingLC Whether the type expression starts with a "{".
 * @param onlyParseSimpleNames If true, only simple type names are parsed
 *     (via a call to parseTypeNameAnnotation instead of
 *     parseTypeExpressionAnnotation).
 * @return The type expression found or null if none.
 */
private Node parseAndRecordTypeNode(JsDocToken token, int lineno,
                                    int startCharno,
                                    boolean matchingLC,
                                    boolean onlyParseSimpleNames) {
  Node typeNode = null;

  if (onlyParseSimpleNames) {
    typeNode = parseTypeNameAnnotation(token);
  } else {
    typeNode = parseTypeExpressionAnnotation(token);
  }

  if (typeNode != null && !matchingLC) {
    typeNode.putBooleanProp(Node.BRACELESS_TYPE, true);
  }

  int endCharno = stream.getCharno();

  jsdocBuilder.markTypeNode(typeNode, lineno, startCharno, endCharno,
      matchingLC);

  return typeNode;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:37,代码来源:JsDocInfoParser.java

示例2: makeVarDeclNode

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Creates a simple namespace variable declaration
 * (e.g. <code>var foo = {};</code>).
 *
 * @param namespace A simple namespace (must be a valid js identifier)
 * @param sourceNode The node to get source information from.
 */
private Node makeVarDeclNode(String namespace, Node sourceNode) {
  Node name = Node.newString(Token.NAME, namespace);
  name.addChildToFront(new Node(Token.OBJECTLIT));

  Node decl = new Node(Token.VAR, name);
  decl.putBooleanProp(Node.IS_NAMESPACE, true);

  // TODO(nicksantos): ew ew ew. Create a mutator package.
  if (compiler.getCodingConvention().isConstant(namespace)) {
    name.putBooleanProp(Node.IS_CONSTANT_NAME, true);
  }

  Preconditions.checkState(isNamespacePlaceholder(decl));
  decl.copyInformationFromForTree(sourceNode);
  return decl;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:24,代码来源:ProcessClosurePrimitives.java

示例3: addStubsForUndeclaredProperties

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Adds global variable "stubs" for any properties of a global name that are
 * only set in a local scope or read but never set.
 *
 * @param n An object representing a global name (e.g. "a", "a.b.c")
 * @param alias The flattened name of the object whose properties we are
 *     adding stubs for (e.g. "a$b$c")
 * @param parent The node to which new global variables should be added
 *     as children
 * @param addAfter The child of after which new
 *     variables should be added (may be null)
 * @return The number of variables added
 */
private int addStubsForUndeclaredProperties(
    Name n, String alias, Node parent, Node addAfter) {
  Preconditions.checkArgument(NodeUtil.isStatementBlock(parent));
  int numStubs = 0;
  if (n.props != null) {
    for (Name p : n.props) {
      if (p.needsToBeStubbed()) {
        String propAlias = appendPropForAlias(alias, p.name);
        Node nameNode = Node.newString(Token.NAME, propAlias);
        Node newVar = new Node(Token.VAR, nameNode);
        if (addAfter == null) {
          parent.addChildToFront(newVar);
        } else {
          parent.addChildAfter(newVar, addAfter);
          addAfter = newVar;
        }
        numStubs++;
        compiler.reportCodeChange();

        // Determine if this is a constant var by checking the first
        // reference to it. Don't check the declaration, as it might be null.
        if (p.refs.get(0).node.getLastChild().getBooleanProp(
              Node.IS_CONSTANT_NAME)) {
          nameNode.putBooleanProp(Node.IS_CONSTANT_NAME, true);
        }
      }
    }
  }
  return numStubs;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:44,代码来源:CollapseProperties.java

示例4: transformAsString

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Transforms the given node and then sets its type to Token.STRING if it
 * was Token.NAME. If its type was already Token.STRING, then quotes it.
 * Used for properties, as the old AST uses String tokens, while the new one
 * uses Name tokens for unquoted strings. For example, in
 * var o = {'a' : 1, b: 2};
 * the string 'a' is quoted, while the name b is turned into a string, but
 * unquoted.
 */
private Node transformAsString(AstNode n) {
  Node ret = transform(n);
  if (ret.getType() == Token.STRING) {
    ret.putBooleanProp(Node.QUOTED_PROP, true);
  } else if (ret.getType() == Token.NAME) {
    ret.setType(Token.STRING);
  }
  return ret;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:19,代码来源:IRFactory.java

示例5: processUnaryExpression

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
@Override
Node processUnaryExpression(UnaryExpression exprNode) {
  Node node = new Node(transformTokenType(exprNode.getType()),
                       transform(exprNode.getOperand()));
  if (exprNode.isPostfix()) {
    node.putBooleanProp(Node.INCRDECR_PROP, true);
  }
  return node;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:10,代码来源:IRFactory.java

示例6: visit

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
  // Note: Constant properties annotations are not propagated.
  if (n.getType() == Token.NAME) {
    if (n.getString().isEmpty()) {
      return;
    }

    JSDocInfo info = null;
    // Find the JSDocInfo for a top level variable.
    Var var = t.getScope().getVar(n.getString());
    if (var != null) {
      info = var.getJSDocInfo();
    }

    if ((info != null && info.isConstant()) &&
        !n.getBooleanProp(Node.IS_CONSTANT_NAME)) {
      n.putBooleanProp(Node.IS_CONSTANT_NAME, true);
      if (assertOnChange) {
        String name = n.getString();
        throw new IllegalStateException(
            "Unexpected const change.\n" +
            "  name: "+ name + "\n" +
            "  gramps:" + n.getParent().getParent().toStringTree());
      }
      // Even though the AST has changed (an annotation was added),
      // the annotations are not compared so don't report the change.
      // reportCodeChange("constant annotation");
    }
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:32,代码来源:Normalize.java

示例7: makeAssignmentExprNode

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Creates a dotted namespace assignment expression
 * (e.g. <code>foo.bar = {};</code>).
 *
 * @param namespace A dotted namespace
 * @param node A node from which to copy source info.
 */
private Node makeAssignmentExprNode(String namespace, Node node) {
  Node decl = new Node(Token.EXPR_RESULT,
      new Node(Token.ASSIGN,
        NodeUtil.newQualifiedNameNode(namespace, node, namespace),
          new Node(Token.OBJECTLIT)));
  decl.putBooleanProp(Node.IS_NAMESPACE, true);
  Preconditions.checkState(isNamespacePlaceholder(decl));
  decl.copyInformationFromForTree(node);
  return decl;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:18,代码来源:ProcessClosurePrimitives.java

示例8: copyNameAnnotations

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Copy any annotations that follow a named value.
 * @param source
 * @param destination
 */
static void copyNameAnnotations(Node source, Node destination) {
  if (source.getBooleanProp(Node.IS_CONSTANT_NAME)) {
    destination.putBooleanProp(Node.IS_CONSTANT_NAME, true);
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:11,代码来源:NodeUtil.java

示例9: updateObjLitOrFunctionDeclarationAtAssignNode

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Updates the first initialization (a.k.a "declaration") of a global name
 * that occurs at an ASSIGN node. See comment for
 * {@link #updateObjLitOrFunctionDeclaration}.
 *
 * @param n An object representing a global name (e.g. "a", "a.b.c")
 * @param alias The flattened name for {@code n} (e.g. "a", "a$b$c")
 */
private void updateObjLitOrFunctionDeclarationAtAssignNode(
    Name n, String alias) {
  // NOTE: It's important that we don't add additional nodes
  // (e.g. a var node before the exprstmt) because the exprstmt might be
  // the child of an if statement that's not inside a block).

  Ref ref = n.declaration;
  Node rvalue = ref.node.getNext();
  Node varNode = new Node(Token.VAR);
  Node varParent = ref.node.getAncestor(3);
  Node gramps = ref.node.getAncestor(2);
  boolean isObjLit = rvalue.getType() == Token.OBJECTLIT;

  if (isObjLit && n.canEliminate()) {
    // Eliminate the object literal altogether.
    varParent.replaceChild(gramps, varNode);
    ref.node = null;

  } else {
    if (rvalue.getType() == Token.FUNCTION) {
      checkForHosedThisReferences(rvalue, n.docInfo, n);
    }

    ref.node.getParent().removeChild(rvalue);

    Node nameNode = NodeUtil.newName(
        alias, ref.node.getAncestor(2), n.fullName());

    if (ref.node.getLastChild().getBooleanProp(Node.IS_CONSTANT_NAME)) {
      nameNode.putBooleanProp(Node.IS_CONSTANT_NAME, true);
    }

    varNode.addChildToBack(nameNode);
    nameNode.addChildToFront(rvalue);
    varParent.replaceChild(gramps, varNode);

    // Update the node ancestry stored in the reference.
    ref.node = nameNode;
  }

  if (isObjLit) {
    boolean discardKeys = n.aliasingGets == 0;
    declareVarsForObjLitValues(
        n, alias, rvalue,
        varNode, varParent.getChildBefore(varNode), varParent,
        discardKeys);
  }

  addStubsForUndeclaredProperties(n, alias, varParent, varNode);

  if (!varNode.hasChildren()) {
    varParent.removeChild(varNode);
  }

  compiler.reportCodeChange();
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:65,代码来源:CollapseProperties.java


注:本文中的com.google.javascript.rhino.Node.putBooleanProp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。