本文整理匯總了Java中lombok.ast.While類的典型用法代碼示例。如果您正苦於以下問題:Java While類的具體用法?Java While怎麽用?Java While使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
While類屬於lombok.ast包,在下文中一共展示了While類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: visitWhile
import lombok.ast.While; //導入依賴的package包/類
@Override
public boolean visitWhile(While node) {
formatter.buildBlock(node);
formatter.keyword("while");
formatter.space();
formatter.append("(");
formatter.nameNextElement("condition");
visit(node.rawCondition());
formatter.append(")");
formatter.space();
formatter.startSuppressBlock();
visit(node.rawStatement());
formatter.endSuppressBlock();
formatter.closeBlock();
return true;
}
示例2: visitWhile
import lombok.ast.While; //導入依賴的package包/類
@Override
public boolean visitWhile(While node) {
List<VisitingDetector> list = mNodeTypeDetectors.get(While.class);
if (list != null) {
for (VisitingDetector v : list) {
v.getVisitor().visitWhile(node);
}
}
return false;
}
示例3: visitMethodInvocation
import lombok.ast.While; //導入依賴的package包/類
@Override
public boolean visitMethodInvocation(MethodInvocation node) {
if (node == mTarget) {
mSeenTarget = true;
} else if (mAllowCommitBeforeTarget || mSeenTarget || node.astOperand() == mTarget) {
String name = node.astName().astValue();
boolean isCommit = "commit".equals(name);
if (isCommit || "apply".equals(name)) { //$NON-NLS-1$ //$NON-NLS-2$
// TODO: Do more flow analysis to see whether we're really calling commit/apply
// on the right type of object?
mFound = true;
ResolvedNode resolved = mContext.resolve(node);
if (resolved instanceof JavaParser.ResolvedMethod) {
ResolvedMethod method = (ResolvedMethod) resolved;
JavaParser.ResolvedClass clz = method.getContainingClass();
if (clz.isSubclassOf("android.content.SharedPreferences.Editor", false)
&& mContext.getProject().getMinSdkVersion().getApiLevel() >= 9) {
// See if the return value is read: can only replace commit with
// apply if the return value is not considered
Node parent = node.getParent();
boolean returnValueIgnored = false;
if (parent instanceof MethodDeclaration ||
parent instanceof ConstructorDeclaration ||
parent instanceof ClassDeclaration ||
parent instanceof Block ||
parent instanceof ExpressionStatement) {
returnValueIgnored = true;
} else if (parent instanceof Statement) {
if (parent instanceof If) {
returnValueIgnored = ((If) parent).astCondition() != node;
} else if (parent instanceof Return) {
returnValueIgnored = false;
} else if (parent instanceof VariableDeclaration) {
returnValueIgnored = false;
} else if (parent instanceof For) {
returnValueIgnored = ((For) parent).astCondition() != node;
} else if (parent instanceof While) {
returnValueIgnored = ((While) parent).astCondition() != node;
} else if (parent instanceof DoWhile) {
returnValueIgnored = ((DoWhile) parent).astCondition() != node;
} else if (parent instanceof Case) {
returnValueIgnored = ((Case) parent).astCondition() != node;
} else if (parent instanceof Assert) {
returnValueIgnored = ((Assert) parent).astAssertion() != node;
} else {
returnValueIgnored = true;
}
}
if (returnValueIgnored && isCommit) {
String message = "Consider using `apply()` instead; `commit` writes "
+ "its data to persistent storage immediately, whereas "
+ "`apply` will handle it in the background";
mContext.report(ISSUE, node, mContext.getLocation(node), message);
}
}
}
}
}
return super.visitMethodInvocation(node);
}
示例4: createWhileStatement
import lombok.ast.While; //導入依賴的package包/類
public Node createWhileStatement(Node condition, Node statement) {
return posify(new While().rawCondition(condition).rawStatement(statement));
}
示例5: checkDeclarationsAsDirectChildWhile
import lombok.ast.While; //導入依賴的package包/類
public void checkDeclarationsAsDirectChildWhile(While node) {
checkDeclarationsAsDirectChild(node, node.rawStatement());
}
示例6: visitWhile
import lombok.ast.While; //導入依賴的package包/類
@Override
public boolean visitWhile(While node) {
JCExpression expr = reParen(node, toExpression(node.astCondition()));
return posSet(node, treeMaker.WhileLoop(expr, toStatement(node.astStatement())));
}
示例7: visitWhileLoop
import lombok.ast.While; //導入依賴的package包/類
@Override public void visitWhileLoop(JCWhileLoop node) {
While w = new While();
JCExpression cond = node.getCondition();
setConversionPositionInfo(w, "()", getPosition(cond));
set(node, w.rawCondition(toTree(removeParens(cond))).rawStatement(toTree(node.getStatement())));
}