本文整理汇总了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];
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:CasualDiff.java
示例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);
}
}
开发者ID:mobmead,项目名称:EasyMPermission,代码行数:20,代码来源:PrettyCommentsPrinter.java
示例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);
}
}
开发者ID:sebastianoe,项目名称:s4j,代码行数:20,代码来源:Pretty.java
示例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);
}
}
开发者ID:redundent,项目名称:lombok,代码行数:20,代码来源:PrettyCommentsPrinter.java
示例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);
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:14,代码来源:PrettyPrinter.java
示例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);
}
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:8,代码来源:PrintAstVisitor.java
示例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);
}
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:16,代码来源:JcTreeConverter.java
示例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)));
}
开发者ID:google,项目名称:error-prone,代码行数:9,代码来源:PlaceholderUnificationVisitor.java
示例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);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:CasualDiff.java
示例10: visitSwitch
import com.sun.tools.javac.tree.JCTree.JCSwitch; //导入依赖的package包/类
@Override
public void visitSwitch(JCSwitch tree) {
scan(tree.getExpression());
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:Analyzer.java
示例11: Switch
import com.sun.tools.javac.tree.JCTree.JCSwitch; //导入依赖的package包/类
public JCSwitch Switch(JCExpression selector, List<JCCase> cases) {
return invoke(Switch, selector, cases);
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:4,代码来源:JavacTreeMaker.java
示例12: AJCSwitch
import com.sun.tools.javac.tree.JCTree.JCSwitch; //导入依赖的package包/类
public AJCSwitch(JCSwitch ltree) {
super(ltree.selector, ltree.cases);
}
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:4,代码来源:AJCSwitch.java
示例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--;
}
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:7,代码来源:JcTreePrinter.java
示例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;
}
开发者ID:sebastianoe,项目名称:s4j,代码行数:63,代码来源:Attr.java
注:本文中的com.sun.tools.javac.tree.JCTree.JCSwitch类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论