本文整理汇总了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())));
}