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


Java Node.putProp方法代码示例

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


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

示例1: addRead

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Determines whether this is a potentially bad read, and remembers the
 * location of the code.  A read clears out all this property's bad writes.
 * @param nameNode  the name of the property (a STRING node)
 * @param t  where we are in the code, so we can generate a useful report
 */
private void addRead(Node nameNode, NodeTraversal t) {
  String name = nameNode.getString();
  Property prop = getProperty(name);
  prop.readCount++;
  if (prop.writeCount == 0 && !isExternallyDefined(name)) {
    // We don't know about any writes yet, so this might be a bad read.
    if (checkReads.isOn()) {
      if (prop.reads == null) {
        prop.reads = new ArrayList<Node>(MAX_REPORTS_PER_PROPERTY);
      }
      if (prop.reads.size() < MAX_REPORTS_PER_PROPERTY) {
        nameNode.putProp(Node.SOURCENAME_PROP, t.getSourceName());
        prop.reads.add(nameNode);
      }
    }
  } else {
    // There are writes, or this is an extern, so null out reads.
    prop.reads = null;
  }

  // There's at least this one read, so there are no invalid writes.
  prop.writes = null;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:30,代码来源:SuspiciousPropertiesCheck.java

示例2: addWrite

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Determines whether this is a potentially bad write, and remembers the
 * location of the code.  A write clears out all this property's bad reads.
 * Setting an object literal key will not result in a bad-write warning,
 * because it was too noisy.  (Object literal keys are usually externs of
 * some kind, and they're only renamed by the compiler if they're used to
 * set a prototype's value.)
 * @param nameNode  the name of the property (a STRING node)
 * @param t  where we are in the code, so we can generate a useful report
 * @param objLit  true iff this property is a key in an object literal
 */
private void addWrite(Node nameNode, NodeTraversal t, boolean objLit) {
  String name = nameNode.getString();
  Property prop = getProperty(name);
  prop.writeCount++;
  if (prop.readCount == 0 && !isExported(name)) {
    // Don't count object-literal writes as possible bad writes.  We might
    // be writing a message for the user or the server.
    if (checkWrites.isOn() && !objLit) {
      // We haven't seen any reads, so this could be a bad write.
      if (prop.writes == null) {
        prop.writes = new ArrayList<Node>(MAX_REPORTS_PER_PROPERTY);
      }
      if (prop.writes.size() < MAX_REPORTS_PER_PROPERTY) {
        nameNode.putProp(Node.SOURCENAME_PROP, t.getSourceName());
        prop.writes.add(nameNode);
      }
    }
  } else {
    // There are reads, or this is an extern, so null out writes.
    prop.writes = null;
  }

  // There's at least this one write, so there are no invalid reads.
  prop.reads = null;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:37,代码来源:SuspiciousPropertiesCheck.java

示例3: visit

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
  // Annotate with the source file.
  if (sourceFile != null) {
    n.putProp(Node.SOURCEFILE_PROP, sourceFile);
  }

  // Annotate the original name.
  switch (n.getType()) {
    case Token.GETPROP:
      Node propNode = n.getFirstChild().getNext();
      if (propNode.getType() == Token.STRING) {
        n.putProp(Node.ORIGINALNAME_PROP, propNode.getString());
      }

      break;

    case Token.NAME:
      n.putProp(Node.ORIGINALNAME_PROP, n.getString());
      break;

    case Token.OBJECTLIT:
       for (Node key = n.getFirstChild(); key != null;
            key = key.getNext().getNext()) {
         // We only want keys that are strings (not numbers), and only keys
         // that were unquoted.
         if (key.getType() == Token.STRING) {
           if (!key.isQuotedString()) {
             key.putProp(Node.ORIGINALNAME_PROP, key.getString());
           }
         }
       }
      break;
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:36,代码来源:SourceInformationAnnotator.java

示例4: clearAst

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
@Override
public void clearAst() {
  root = new Node(Token.SCRIPT);
  root.putProp(Node.SOURCENAME_PROP, sourceName);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:6,代码来源:SyntheticAst.java

示例5: processFunctionNode

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
@Override
Node processFunctionNode(FunctionNode functionNode) {
    Name name = functionNode.getFunctionName();
    Boolean isUnnamedFunction = false;
    if (name == null) {
      name = new Name();
      name.setIdentifier("");
      isUnnamedFunction = true;
    }
    Node node = new com.google.javascript.rhino.FunctionNode(
        name.getIdentifier());
    node.putProp(Node.SOURCENAME_PROP, functionNode.getSourceName());
    Node newName = transform(name);
    if (isUnnamedFunction) {
      // Old Rhino tagged the empty name node with the line number of the
      // declaration.
      newName.setLineno(functionNode.getLineno());
      // TODO(user) Mark line number of paren correctly.
      // Same problem as below - the left paren might not be on the
      // same line as the function keyword.
      int lpColumn = functionNode.getAbsolutePosition() +
          functionNode.getLp();
      newName.setCharno(position2charno(lpColumn));
    }

    node.addChildToBack(newName);
    Node lp = new Node(Token.LP);
    // The left paren's complicated because it's not represented by an
    // AstNode, so there's nothing that has the actual line number that it
    // appeared on.  We know the paren has to appear on the same line as the
    // function name (or else a semicolon will be inserted.)  If there's no
    // function name, assume the paren was on the same line as the function.
    // TODO(user): Mark line number of paren correctly.
    Name fnName = functionNode.getFunctionName();
    if (fnName != null) {
      lp.setLineno(fnName.getLineno());
    } else {
      lp.setLineno(functionNode.getLineno());
    }
    int lparenCharno = functionNode.getLp() +
        functionNode.getAbsolutePosition();

    lp.setCharno(position2charno(lparenCharno));
    for (AstNode param : functionNode.getParams()) {
      lp.addChildToBack(transform(param));
    }
    node.addChildToBack(lp);

    Node bodyNode = transform(functionNode.getBody());
    parseDirectives(bodyNode);
    node.addChildToBack(bodyNode);
   return node;
  }
 
开发者ID:andyjko,项目名称:feedlack,代码行数:54,代码来源:IRFactory.java

示例6: processParenthesizedExpression

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
@Override
Node processParenthesizedExpression(ParenthesizedExpression exprNode) {
  Node node = transform(exprNode.getExpression());
  node.putProp(Node.PARENTHESIZED_PROP, Boolean.TRUE);
  return node;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:7,代码来源:IRFactory.java

示例7: testGetSourceName

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
public void testGetSourceName() {
  Node n = new Node(Token.BLOCK);
  Node parent = new Node(Token.BLOCK, n);
  parent.putProp(Node.SOURCENAME_PROP, "foo");
  assertEquals("foo", NodeUtil.getSourceName(n));
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:7,代码来源:NodeUtilTest.java

示例8: setDebugInformation

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Sets the debug information (source file info and orignal name)
 * on the given node.
 *
 * @param node The node on which to set the debug information.
 * @param basisNode The basis node from which to copy the source file info.
 * @param originalName The original name of the node.
 */
static void setDebugInformation(Node node, Node basisNode,
                                String originalName) {
  node.copyInformationFromForTree(basisNode);
  node.putProp(Node.ORIGINALNAME_PROP, originalName);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:14,代码来源:NodeUtil.java

示例9: newName

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Creates a new node representing an *existing* name, copying over the source
 * location information from the basis node and assigning the given original
 * name to the node.
 *
 * @param name The name for the new NAME node.
 * @param basisNode The node that represents the name as currently found in
 *     the AST.
 * @param originalName The original name of the item being represented by the
 *     NAME node. Used for debugging information.
 *
 * @return The node created.
 */
static Node newName(String name, Node basisNode, String originalName) {
  Node nameNode = newName(name, basisNode);
  nameNode.putProp(Node.ORIGINALNAME_PROP, originalName);
  return nameNode;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:19,代码来源:NodeUtil.java


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