本文整理汇总了Java中com.google.javascript.rhino.Node.toStringTree方法的典型用法代码示例。如果您正苦于以下问题:Java Node.toStringTree方法的具体用法?Java Node.toStringTree怎么用?Java Node.toStringTree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.javascript.rhino.Node
的用法示例。
在下文中一共展示了Node.toStringTree方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: declareNameInScope
import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
* Declares a refined type in {@code scope} for the name represented by
* {@code node}. It must be possible to refine the type of the given node in
* the given scope, as determined by {@link #getTypeIfRefinable}.
*/
protected void declareNameInScope(FlowScope scope, Node node, JSType type) {
switch (node.getType()) {
case Token.NAME:
scope.inferSlotType(node.getString(), type);
break;
case Token.GETPROP:
String qualifiedName = node.getQualifiedName();
Preconditions.checkNotNull(qualifiedName);
JSType origType = node.getJSType();
origType = origType == null ? getNativeType(UNKNOWN_TYPE) : origType;
scope.inferQualifiedSlot(qualifiedName, origType, type);
break;
default:
throw new IllegalArgumentException("Node cannot be refined. \n" +
node.toStringTree());
}
}
示例2: maybeDecomposeExpression
import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
* If required, rewrite the statement containing the expression.
* @param expression The expression to be exposed.
* @see #canExposeExpression
*/
void maybeDecomposeExpression(Node expression) {
// If the expression needs to exposed.
int i = 0;
while (DecompositionType.DECOMPOSABLE == canExposeExpression(expression)) {
exposeExpression(expression);
if (i > MAX_INTERATIONS) {
throw new IllegalStateException(
"DecomposeExpression depth exceeded on :\n" +
expression.toStringTree());
}
}
}
示例3: createAssignmentActions
import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
* Returns an action for assigning the right-hand-side to the left or null
* if this assignment should be ignored.
*/
private List<Action> createAssignmentActions(
Node lhs, Node rhs, Node parent) {
switch (lhs.getType()) {
case Token.NAME:
ConcreteSlot var = (ConcreteSlot) scope.getSlot(lhs.getString());
Preconditions.checkState(var != null,
"Type tightener could not find variable with name %s",
lhs.getString());
return Lists.<Action>newArrayList(
new VariableAssignAction(var, rhs));
case Token.GETPROP:
Node receiver = lhs.getFirstChild();
return Lists.<Action>newArrayList(
new PropertyAssignAction(receiver, rhs));
case Token.GETELEM:
return Lists.newArrayList();
case Token.GET_REF:
// We ignore ref specials as their types should not be computed.
if (lhs.getFirstChild().getType() == Token.REF_SPECIAL) {
return Lists.newArrayList();
} else {
throw new AssertionError(
"Bad LHS for getref: " + parent.toStringTree());
}
default:
throw new AssertionError(
"Bad LHS for assignment: " + parent.toStringTree());
}
}