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


Java Node.setCharno方法代码示例

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


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

示例1: processCatchClause

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
@Override
Node processCatchClause(CatchClause clauseNode) {
  AstNode catchVar = clauseNode.getVarName();
  Node node = new Node(Token.CATCH, transform(catchVar));
  if (clauseNode.getCatchCondition() != null) {
    node.addChildToBack(transform(clauseNode.getCatchCondition()));
  } else {
    Node catchCondition = new Node(Token.EMPTY);
    // Old Rhino used the position of the catchVar as the position
    // for the (nonexistent) error being caught.
    catchCondition.setLineno(catchVar.getLineno());
    int clauseAbsolutePosition =
        position2charno(catchVar.getAbsolutePosition());
    catchCondition.setCharno(clauseAbsolutePosition);
    node.addChildToBack(catchCondition);
  }
  node.addChildToBack(transform(clauseNode.getBody()));
  return node;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:20,代码来源:IRFactory.java

示例2: processInfixExpression

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
@Override
Node processInfixExpression(InfixExpression exprNode) {
  Node n =  new Node(
      transformTokenType(exprNode.getType()),
      transform(exprNode.getLeft()),
      transform(exprNode.getRight()));
  // Set the line number here so we can fine-tune it in ways transform
  // doesn't do.
  n.setLineno(exprNode.getLineno());
  // Position in new ASTNode is to start of expression, but old-fashioned
  // line numbers from Node reference the operator token.  Add the offset
  // to the operator to get the correct character number.
  n.setCharno(position2charno(exprNode.getAbsolutePosition() +
      exprNode.getOperatorPosition()));
  return n;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:17,代码来源:IRFactory.java

示例3: transform

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
private Node transform(AstNode node) {
  String jsDoc = node.getJsDoc();
  NodeWithJsDoc nodeWithJsDoc = null;
  if (jsDoc != null) {
    nodeWithJsDoc = new NodeWithJsDoc();
    nodesWithJsDoc.put(jsDoc, nodeWithJsDoc);
  }

  Node irNode = justTransform(node);
  if (nodeWithJsDoc != null) {
    nodeWithJsDoc.node = irNode;
  }

  // If we have a named function, set the position to that of the name.
  if (irNode.getType() == Token.FUNCTION &&
      irNode.getFirstChild().getLineno() != -1) {
    irNode.setLineno(irNode.getFirstChild().getLineno());
    irNode.setCharno(irNode.getFirstChild().getCharno());
  } else {
    if (irNode.getLineno() == -1) {
      // If we didn't already set the line, then set it now.  This avoids
      // cases like ParenthesizedExpression where we just return a previous
      // node, but don't want the new node to get its parent's line number.
      int lineno = node.getLineno();
      irNode.setLineno(lineno);
      int charno = position2charno(node.getAbsolutePosition());
      irNode.setCharno(charno);
    }
  }
  return irNode;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:32,代码来源:IRFactory.java

示例4: processFunctionCall

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
@Override
Node processFunctionCall(FunctionCall callNode) {
  Node node = new Node(transformTokenType(callNode.getType()),
                       transform(callNode.getTarget()));
  for (AstNode child : callNode.getArguments()) {
    node.addChildToBack(transform(child));
  }

  int leftParamPos = callNode.getAbsolutePosition() + callNode.getLp();
  node.setLineno(callNode.getLineno());
  node.setCharno(position2charno(leftParamPos));
  return node;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:14,代码来源:IRFactory.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


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