当前位置: 首页>>代码示例>>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;未经允许,请勿转载。