當前位置: 首頁>>代碼示例>>Java>>正文


Java While類代碼示例

本文整理匯總了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;
}
 
開發者ID:evant,項目名稱:android-retrolambda-lombok,代碼行數:17,代碼來源:SourcePrinter.java

示例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;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:11,代碼來源:JavaVisitor.java

示例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);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:63,代碼來源:SharedPrefsDetector.java

示例4: createWhileStatement

import lombok.ast.While; //導入依賴的package包/類
public Node createWhileStatement(Node condition, Node statement) {
	return posify(new While().rawCondition(condition).rawStatement(statement));
}
 
開發者ID:evant,項目名稱:android-retrolambda-lombok,代碼行數:4,代碼來源:StatementsActions.java

示例5: checkDeclarationsAsDirectChildWhile

import lombok.ast.While; //導入依賴的package包/類
public void checkDeclarationsAsDirectChildWhile(While node) {
	checkDeclarationsAsDirectChild(node, node.rawStatement());
}
 
開發者ID:evant,項目名稱:android-retrolambda-lombok,代碼行數:4,代碼來源:StatementChecks.java

示例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())));
}
 
開發者ID:evant,項目名稱:android-retrolambda-lombok,代碼行數:6,代碼來源:JcTreeBuilder.java

示例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())));
}
 
開發者ID:evant,項目名稱:android-retrolambda-lombok,代碼行數:7,代碼來源:JcTreeConverter.java


注:本文中的lombok.ast.While類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。