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


Java Statement.parent方法代碼示例

本文整理匯總了Java中org.aikodi.chameleon.oo.statement.Statement.parent方法的典型用法代碼示例。如果您正苦於以下問題:Java Statement.parent方法的具體用法?Java Statement.parent怎麽用?Java Statement.parent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.aikodi.chameleon.oo.statement.Statement的用法示例。


在下文中一共展示了Statement.parent方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: analyze

import org.aikodi.chameleon.oo.statement.Statement; //導入方法依賴的package包/類
@Override
protected void analyze(AssignmentExpression assignment) throws LookupException {
	Verification result = Valid.create();
		final Method method = assignment.nearestAncestor(Method.class);
		if(method != null && method.isTrue(method.language(Java7.class).PUBLIC)) {
			Variable v = assignment.variable();
			if(v instanceof RegularMemberVariable) {
				Expression e = assignment.getValue();
				if(e instanceof CrossReference) {
					final Declaration rhs = ((CrossReference) e).getElement();
					if(rhs instanceof FormalParameter) {
						Type booleanType = assignment.view(JavaView.class).primitiveType("boolean");
						if(! ((FormalParameter) rhs).getType().sameAs(booleanType)) {
							boolean notMentioned = true;
							Statement stat = assignment.lexical().farthestAncestor(new UniversalPredicate<Statement,Nothing>(Statement.class) {
								@Override
								public boolean uncheckedEval(Statement s) {
									// If s.parent() == the implementation object, then we have reached the
									// block of the implementation, so we have to stop before that to object
									// the child statement of the block of the implementation
									return (! (s.parent() instanceof Implementation)) && s.nearestAncestor(Method.class) == method;
								}
							});
							Block b = (Block) stat.parent();
							List<Statement> befores = b.statementsBefore(stat);
							for(Statement before : befores) {
								List<CrossReference> crefs = before.descendants(CrossReference.class, cref -> cref.getElement().sameAs(rhs));
								if(! crefs.isEmpty()) {
									notMentioned = false; 
								}
							}
							if(notMentioned) {
								result = new NonDefensiveFieldAssignmentResult((FormalParameter)rhs,v);
							}
						}
					}
				}
			}
		}
	setResult(result().and(result));
}
 
開發者ID:markovandooren,項目名稱:jnome,代碼行數:42,代碼來源:NonDefensiveFieldAssignment.java


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