本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}