本文整理汇总了Java中com.sun.tools.javac.tree.JCTree.JCSwitch类的典型用法代码示例。如果您正苦于以下问题:Java JCSwitch类的具体用法?Java JCSwitch怎么用?Java JCSwitch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JCSwitch类属于com.sun.tools.javac.tree.JCTree包,在下文中一共展示了JCSwitch类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: diffSwitch
import com.sun.tools.javac.tree.JCTree.JCSwitch; //导入依赖的package包/类
protected int diffSwitch(JCSwitch oldT, JCSwitch newT, int[] bounds) {
int localPointer = bounds[0];
// rename in switch
int[] selectorBounds = getBounds(oldT.selector);
copyTo(localPointer, selectorBounds[0]);
localPointer = diffTree(oldT.selector, newT.selector, selectorBounds);
tokenSequence.move(selectorBounds[1]);
do { } while (tokenSequence.moveNext() && JavaTokenId.LBRACE != tokenSequence.token().id());
tokenSequence.moveNext();
copyTo(localPointer, localPointer = tokenSequence.offset());
PositionEstimator est = EstimatorFactory.cases(oldT.getCases(), newT.getCases(), diffContext);
localPointer = diffList(oldT.cases, newT.cases, localPointer, est, Measure.MEMBER, printer);
copyTo(localPointer, bounds[1]);
return bounds[1];
}
示例2: visitSwitch
import com.sun.tools.javac.tree.JCTree.JCSwitch; //导入依赖的package包/类
public void visitSwitch(JCSwitch tree) {
try {
print("switch ");
if (PARENS.equals(treeTag(tree.selector))) {
printExpr(tree.selector);
} else {
print("(");
printExpr(tree.selector);
print(")");
}
print(" {");
println();
printStats(tree.cases);
align();
print("}");
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例3: visitSwitch
import com.sun.tools.javac.tree.JCTree.JCSwitch; //导入依赖的package包/类
public void visitSwitch(JCSwitch tree) {
try {
print("switch ");
if (tree.selector.getTag() == JCTree.PARENS) {
printExpr(tree.selector);
} else {
print("(");
printExpr(tree.selector);
print(")");
}
print(" {");
println();
printStats(tree.cases);
align();
print("}");
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例4: visitSwitch
import com.sun.tools.javac.tree.JCTree.JCSwitch; //导入依赖的package包/类
public void visitSwitch(JCSwitch tree) {
try {
print("switch ");
if (getTag(tree.selector) == PARENS) {
printExpr(tree.selector);
} else {
print("(");
printExpr(tree.selector);
print(")");
}
print(" {");
println();
printStats(tree.cases);
align();
print("}");
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例5: visitSwitch
import com.sun.tools.javac.tree.JCTree.JCSwitch; //导入依赖的package包/类
@Override public void visitSwitch(JCSwitch tree) {
aPrint("switch ");
if (tree.selector instanceof JCParens) {
print(tree.selector);
} else {
print("(");
print(tree.selector);
print(")");
}
println(" {");
print(tree.cases, "\n");
aPrintln("}", tree);
}
示例6: visitSwitch
import com.sun.tools.javac.tree.JCTree.JCSwitch; //导入依赖的package包/类
public void visitSwitch(JCSwitch that) {
try {
print("JCSwitch:");
} catch (Exception e) {
}
super.visitSwitch(that);
}
示例7: visitSwitch
import com.sun.tools.javac.tree.JCTree.JCSwitch; //导入依赖的package包/类
@Override public void visitSwitch(JCSwitch node) {
Switch s = new Switch();
JCExpression cond = node.getExpression();
setConversionPositionInfo(s, "()", getPosition(cond));
s.rawCondition(toTree(removeParens(cond)));
Block b = new Block();
s.astBody(b);
for (JCCase c : node.getCases()) {
JCExpression rawExpr = c.getExpression();
if (rawExpr == null) b.rawContents().addToEnd(setPos(c, new Default()));
else b.rawContents().addToEnd(setPos(c, new Case().rawCondition(toTree(rawExpr))));
fillList(c.getStatements(), b.rawContents());
}
set(node, s);
}
示例8: visitSwitch
import com.sun.tools.javac.tree.JCTree.JCSwitch; //导入依赖的package包/类
@Override
public Choice<State<JCSwitch>> visitSwitch(final SwitchTree node, State<?> state) {
return chooseSubtrees(
state,
s -> unifyExpression(node.getExpression(), s),
s -> unify(node.getCases(), s),
(expr, cases) -> maker().Switch(expr, List.convert(JCCase.class, cases)));
}
示例9: matchSwitch
import com.sun.tools.javac.tree.JCTree.JCSwitch; //导入依赖的package包/类
private boolean matchSwitch(JCSwitch t1, JCSwitch t2) {
return treesMatch(t1.selector, t2.selector) && listsMatch(t1.cases, t2.cases);
}
示例10: visitSwitch
import com.sun.tools.javac.tree.JCTree.JCSwitch; //导入依赖的package包/类
@Override
public void visitSwitch(JCSwitch tree) {
scan(tree.getExpression());
}
示例11: Switch
import com.sun.tools.javac.tree.JCTree.JCSwitch; //导入依赖的package包/类
public JCSwitch Switch(JCExpression selector, List<JCCase> cases) {
return invoke(Switch, selector, cases);
}
示例12: AJCSwitch
import com.sun.tools.javac.tree.JCTree.JCSwitch; //导入依赖的package包/类
public AJCSwitch(JCSwitch ltree) {
super(ltree.selector, ltree.cases);
}
示例13: visitSwitch
import com.sun.tools.javac.tree.JCTree.JCSwitch; //导入依赖的package包/类
@Override public void visitSwitch(JCSwitch tree) {
printNode(tree);
child("selector", tree.selector);
children("cases", tree.cases);
indent--;
}
示例14: visitSwitch
import com.sun.tools.javac.tree.JCTree.JCSwitch; //导入依赖的package包/类
public void visitSwitch(JCSwitch tree) {
Type seltype = attribExpr(tree.selector, env);
Env<AttrContext> switchEnv =
env.dup(tree, env.info.dup(env.info.scope.dup()));
boolean enumSwitch =
allowEnums &&
(seltype.tsym.flags() & Flags.ENUM) != 0;
boolean stringSwitch = false;
if (types.isSameType(seltype, syms.stringType)) {
if (allowStringsInSwitch) {
stringSwitch = true;
} else {
log.error(tree.selector.pos(), "string.switch.not.supported.in.source", sourceName);
}
}
if (!enumSwitch && !stringSwitch)
seltype = chk.checkType(tree.selector.pos(), seltype, syms.intType);
// Attribute all cases and
// check that there are no duplicate case labels or default clauses.
Set<Object> labels = new HashSet<Object>(); // The set of case labels.
boolean hasDefault = false; // Is there a default label?
for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
JCCase c = l.head;
Env<AttrContext> caseEnv =
switchEnv.dup(c, env.info.dup(switchEnv.info.scope.dup()));
if (c.pat != null) {
if (enumSwitch) {
Symbol sym = enumConstant(c.pat, seltype);
if (sym == null) {
log.error(c.pat.pos(), "enum.label.must.be.unqualified.enum");
} else if (!labels.add(sym)) {
log.error(c.pos(), "duplicate.case.label");
}
} else {
Type pattype = attribExpr(c.pat, switchEnv, seltype);
if (pattype.tag != ERROR) {
if (pattype.constValue() == null) {
log.error(c.pat.pos(),
(stringSwitch ? "string.const.req" : "const.expr.req"));
} else if (labels.contains(pattype.constValue())) {
log.error(c.pos(), "duplicate.case.label");
} else {
labels.add(pattype.constValue());
}
}
}
} else if (hasDefault) {
log.error(c.pos(), "duplicate.default.label");
} else {
hasDefault = true;
}
attribStats(c.stats, caseEnv);
caseEnv.info.scope.leave();
addVars(c.stats, switchEnv.info.scope);
}
switchEnv.info.scope.leave();
result = null;
}