本文整理汇总了Java中jdk.nashorn.internal.parser.TokenType.getName方法的典型用法代码示例。如果您正苦于以下问题:Java TokenType.getName方法的具体用法?Java TokenType.getName怎么用?Java TokenType.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.internal.parser.TokenType
的用法示例。
在下文中一共展示了TokenType.getName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toString
import jdk.nashorn.internal.parser.TokenType; //导入方法依赖的package包/类
/**
* Creates the string representation of this unary node, delegating the creation of the string representation of its
* operand to a specified runnable.
* @param sb the string builder to use
* @param rhsStringBuilder the runnable that appends the string representation of the operand to the string builder
* @param printType should we print type
* when invoked.
*/
public void toString(final StringBuilder sb, final Runnable rhsStringBuilder, final boolean printType) {
final TokenType tokenType = tokenType();
final String name = tokenType.getName();
final boolean isPostfix = tokenType == DECPOSTFIX || tokenType == INCPOSTFIX;
if (isOptimistic()) {
sb.append(Expression.OPT_IDENTIFIER);
}
boolean rhsParen = tokenType.needsParens(getExpression().tokenType(), false);
if (!isPostfix) {
if (name == null) {
sb.append(tokenType.name());
rhsParen = true;
} else {
sb.append(name);
if (tokenType.ordinal() > BIT_NOT.ordinal()) {
sb.append(' ');
}
}
}
if (rhsParen) {
sb.append('(');
}
rhsStringBuilder.run();
if (rhsParen) {
sb.append(')');
}
if (isPostfix) {
sb.append(tokenType == DECPOSTFIX ? "--" : "++");
}
}
示例2: enterUnaryNode
import jdk.nashorn.internal.parser.TokenType; //导入方法依赖的package包/类
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
enterDefault(unaryNode);
final TokenType tokenType = unaryNode.tokenType();
if (tokenType == TokenType.NEW) {
type("NewExpression");
comma();
final CallNode callNode = (CallNode)unaryNode.getExpression();
property("callee");
callNode.getFunction().accept(this);
comma();
array("arguments", callNode.getArgs());
} else {
final String operator;
final boolean prefix;
switch (tokenType) {
case INCPOSTFIX:
prefix = false;
operator = "++";
break;
case DECPOSTFIX:
prefix = false;
operator = "--";
break;
case INCPREFIX:
operator = "++";
prefix = true;
break;
case DECPREFIX:
operator = "--";
prefix = true;
break;
default:
prefix = true;
operator = tokenType.getName();
break;
}
type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression");
comma();
property("operator", operator);
comma();
property("prefix", prefix);
comma();
property("argument");
unaryNode.getExpression().accept(this);
}
return leave();
}