本文整理汇总了Java中com.sun.tools.javac.tree.JCTree.JCForLoop类的典型用法代码示例。如果您正苦于以下问题:Java JCForLoop类的具体用法?Java JCForLoop怎么用?Java JCForLoop使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JCForLoop类属于com.sun.tools.javac.tree.JCTree包,在下文中一共展示了JCForLoop类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitForLoop
import com.sun.tools.javac.tree.JCTree.JCForLoop; //导入依赖的package包/类
@Override
public void visitForLoop(final JCForLoop node) {
print("for (");
if (node.init.nonEmpty()) {
if (node.init.head instanceof JCVariableDecl) {
handleVarDef((JCVariableDecl)node.init.head, false);
for (List<JCStatement> l = node.init.tail; l.nonEmpty(); l = l.tail) {
final JCVariableDecl decl = (JCVariableDecl)l.head;
print(", " + decl.name + " = ");
printExpr(decl.init);
}
} else {
printExprs(node.init);
}
}
print("; ");
if (node.cond != null) {
printExpr(node.cond);
}
print("; ");
printExprs(node.step);
print(") ");
printStat(node.body);
}
示例2: visitForLoop
import com.sun.tools.javac.tree.JCTree.JCForLoop; //导入依赖的package包/类
public void visitForLoop(JCForLoop tree) {
try {
print("for (");
if (tree.init.nonEmpty()) {
if (VARDEF.equals(treeTag(tree.init.head))) {
printExpr(tree.init.head);
for (List<JCStatement> l = tree.init.tail; l.nonEmpty(); l = l.tail) {
JCVariableDecl vdef = (JCVariableDecl)l.head;
print(", " + vdef.name + " = ");
printExpr(vdef.init);
}
} else {
printExprs(tree.init);
}
}
print("; ");
if (tree.cond != null) printExpr(tree.cond);
print("; ");
printExprs(tree.step);
print(") ");
printStat(tree.body);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例3: visitForLoop
import com.sun.tools.javac.tree.JCTree.JCForLoop; //导入依赖的package包/类
public void visitForLoop(JCForLoop tree) {
try {
print("for (");
if (tree.init.nonEmpty()) {
if (tree.init.head.getTag() == JCTree.VARDEF) {
printExpr(tree.init.head);
for (List<JCStatement> l = tree.init.tail; l.nonEmpty(); l = l.tail) {
JCVariableDecl vdef = (JCVariableDecl)l.head;
print(", " + vdef.name + " = ");
printExpr(vdef.init);
}
} else {
printExprs(tree.init);
}
}
print("; ");
if (tree.cond != null) printExpr(tree.cond);
print("; ");
printExprs(tree.step);
print(") ");
printStat(tree.body);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例4: visitForLoop
import com.sun.tools.javac.tree.JCTree.JCForLoop; //导入依赖的package包/类
public void visitForLoop(JCForLoop tree) {
try {
print("for (");
if (tree.init.nonEmpty()) {
if (getTag(tree.init.head) == VARDEF) {
printExpr(tree.init.head);
for (List<JCStatement> l = tree.init.tail; l.nonEmpty(); l = l.tail) {
JCVariableDecl vdef = (JCVariableDecl)l.head;
print(", " + vdef.name + " = ");
printExpr(vdef.init);
}
} else {
printExprs(tree.init);
}
}
print("; ");
if (tree.cond != null) printExpr(tree.cond);
print("; ");
printExprs(tree.step);
print(") ");
printStat(tree.body);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例5: visitForLoop
import com.sun.tools.javac.tree.JCTree.JCForLoop; //导入依赖的package包/类
public void visitForLoop(JCForLoop that) {
try {
print("JCForLoop:");
} catch (Exception e) {
}
super.visitForLoop(that);
}
示例6: inline
import com.sun.tools.javac.tree.JCTree.JCForLoop; //导入依赖的package包/类
@Override
public JCForLoop inline(Inliner inliner) throws CouldNotResolveImportException {
return inliner.maker().ForLoop(
inliner.inlineList(getInitializer()),
(getCondition() == null) ? null : getCondition().inline(inliner),
com.sun.tools.javac.util.List.convert(
JCExpressionStatement.class, inliner.inlineList(getUpdate())),
getStatement().inline(inliner));
}
示例7: visitForLoop
import com.sun.tools.javac.tree.JCTree.JCForLoop; //导入依赖的package包/类
@Override public void visitForLoop(JCForLoop tree) {
printNode(tree);
children("init", tree.init);
child("cond", tree.cond);
children("step", tree.step);
child("body", tree.body);
indent--;
}
示例8: visitForLoop
import com.sun.tools.javac.tree.JCTree.JCForLoop; //导入依赖的package包/类
@Override public void visitForLoop(JCForLoop node) {
For f = new For();
f.rawCondition(toTree(node.getCondition()));
f.rawStatement(toTree(node.getStatement()));
for (JCExpressionStatement upd : node.getUpdate()) {
Node updateNode = toTree(upd.getExpression());
setConversionPositionInfo(updateNode, "exec", getPosition(upd));
f.rawUpdates().addToEnd(updateNode);
}
List<JCStatement> initializers = node.getInitializer();
// Multiple vardefs in a row need to trigger the JCVD version AND be washed through fillList to be turned into 1 VD.
if (!initializers.isEmpty() && initializers.get(0) instanceof JCVariableDecl) {
Block tmp = new Block();
fillList(initializers, tmp.rawContents(), FlagKey.VARDEF_IS_DEFINITION);
Node varDecl = tmp.rawContents().first();
if (varDecl != null) varDecl.unparent();
f.rawVariableDeclaration(varDecl);
} else {
for (JCStatement init : initializers) {
if (init instanceof JCExpressionStatement) {
Node initNode = toTree(((JCExpressionStatement) init).getExpression());
setConversionPositionInfo(initNode, "exec", getPosition(init));
f.rawExpressionInits().addToEnd(initNode);
} else {
f.rawExpressionInits().addToEnd(toTree(init));
}
}
}
set(node, f);
}
示例9: visitForLoop
import com.sun.tools.javac.tree.JCTree.JCForLoop; //导入依赖的package包/类
@Override
public Choice<State<JCForLoop>> visitForLoop(final ForLoopTree node, State<?> state) {
return chooseSubtrees(
state,
s -> unifyStatements(node.getInitializer(), s),
s -> unifyExpression(node.getCondition(), s),
s -> unifyStatements(node.getUpdate(), s),
s -> unifyStatement(node.getStatement(), s),
(inits, cond, update, stmt) ->
maker().ForLoop(inits, cond, List.convert(JCExpressionStatement.class, update), stmt));
}
示例10: inline
import com.sun.tools.javac.tree.JCTree.JCForLoop; //导入依赖的package包/类
@Override
public JCForLoop inline(Inliner inliner) throws CouldNotResolveImportException {
return inliner
.maker()
.ForLoop(
UBlock.inlineStatementList(getInitializer(), inliner),
(getCondition() == null) ? null : getCondition().inline(inliner),
com.sun.tools.javac.util.List.convert(
JCExpressionStatement.class, inliner.<JCStatement>inlineList(getUpdate())),
getStatement().inline(inliner));
}
示例11: visitForLoop
import com.sun.tools.javac.tree.JCTree.JCForLoop; //导入依赖的package包/类
public void visitForLoop(JCForLoop tree) {
Env<AttrContext> loopEnv =
env.dup(env.tree, env.info.dup(env.info.scope.dup()));
attribStats(tree.init, loopEnv);
if (tree.cond != null) attribExpr(tree.cond, loopEnv, syms.booleanType);
loopEnv.tree = tree; // before, we were not in loop!
attribStats(tree.step, loopEnv);
attribStat(tree.body, loopEnv);
loopEnv.info.scope.leave();
result = null;
}
示例12: diffForLoop
import com.sun.tools.javac.tree.JCTree.JCForLoop; //导入依赖的package包/类
protected int diffForLoop(JCForLoop oldT, JCForLoop newT, int[] bounds) {
int localPointer;
// initializer
if (oldT.init.nonEmpty()) {
// there is something in the init section, using start offset
localPointer = getOldPos(oldT.init.head);
} else {
moveFwdToToken(tokenSequence, bounds[0], JavaTokenId.SEMICOLON);
localPointer = tokenSequence.offset();
}
copyTo(bounds[0], localPointer);
if (!listsMatch(oldT.init, newT.init)) {
boolean oldVariable = containsVariable(oldT.init);
boolean newVariable = containsVariable(newT.init);
if (oldVariable ^ newVariable) {
int oldPrec = printer.setPrec(TreeInfo.noPrec);
localPointer = diffParameterList(oldT.init, newT.init, null, localPointer, Measure.ARGUMENT);
printer.setPrec(oldPrec);
} else {
if (oldVariable) {
List<JCVariableDecl> oldInit = NbCollections.checkedListByCopy(oldT.init, JCVariableDecl.class, false);
FieldGroupTree old = new FieldGroupTree(oldInit);
List<JCVariableDecl> newInit = NbCollections.checkedListByCopy(newT.init, JCVariableDecl.class, false);
FieldGroupTree nue = new FieldGroupTree(newInit);
int[] initBounds = getBounds(oldT.init.head);
JCTree last = oldT.init.get(oldT.init.size() - 1);
long endPos = diffContext.trees.getSourcePositions().getEndPosition(oldTopLevel, last);
initBounds[1] = (int) endPos;
localPointer = diffTree(old, nue, initBounds);
} else {
localPointer = diffParameterList(oldT.init, newT.init, null, localPointer, Measure.ARGUMENT);
}
}
}
// condition
if (oldT.cond != null) {
copyTo(localPointer, localPointer = getOldPos(oldT.cond));
localPointer = diffTree(oldT.cond, newT.cond, getBounds(oldT.cond));
} else {
moveFwdToToken(tokenSequence, localPointer, JavaTokenId.SEMICOLON);
copyTo(localPointer, localPointer = tokenSequence.offset());
}
// steps
if (oldT.step.nonEmpty())
copyTo(localPointer, localPointer = getOldPos(oldT.step.head));
else {
moveFwdToToken(tokenSequence, localPointer, JavaTokenId.SEMICOLON);
tokenSequence.moveNext();
copyTo(localPointer, localPointer = tokenSequence.offset());
}
localPointer = diffParameterList(oldT.step, newT.step, null, localPointer, Measure.ARGUMENT);
// body
int[] bodyBounds = new int[] { localPointer, endPos(oldT.body) };
int oldIndent = newT.body.hasTag(Tag.BLOCK) ? -1 : printer.indent();
localPointer = diffTree(oldT.body, newT.body, bodyBounds, oldT.getKind());
if (!newT.body.hasTag(Tag.BLOCK))
printer.undent(oldIndent);
copyTo(localPointer, bounds[1]);
return bounds[1];
}
示例13: matchForLoop
import com.sun.tools.javac.tree.JCTree.JCForLoop; //导入依赖的package包/类
private boolean matchForLoop(JCForLoop t1, JCForLoop t2) {
return listsMatch(t1.init, t2.init) && treesMatch(t1.cond, t2.cond) &&
listsMatch(t1.step, t2.step) && treesMatch(t1.body, t2.body);
}
示例14: visitForLoop
import com.sun.tools.javac.tree.JCTree.JCForLoop; //导入依赖的package包/类
@Override
public void visitForLoop(JCForLoop tree) {
//skip body and var decl (to prevents same statements to be analyzed twice)
scan(tree.getCondition());
scan(tree.getUpdate());
}
示例15: visitForLoop
import com.sun.tools.javac.tree.JCTree.JCForLoop; //导入依赖的package包/类
@Override
public void visitForLoop(JCForLoop tree) {
scan(tree.getInitializer());
scan(tree.getCondition());
scan(tree.getUpdate());
}