当前位置: 首页>>代码示例>>Java>>正文


Java IfStatement.getExpression方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.dom.IfStatement.getExpression方法的典型用法代码示例。如果您正苦于以下问题:Java IfStatement.getExpression方法的具体用法?Java IfStatement.getExpression怎么用?Java IfStatement.getExpression使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.dom.IfStatement的用法示例。


在下文中一共展示了IfStatement.getExpression方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: preNext

import org.eclipse.jdt.core.dom.IfStatement; //导入方法依赖的package包/类
@Override
public boolean preNext(IfStatement curElement) {

	Statement thenStatement = curElement.getThenStatement();
	Statement elseStatement = curElement.getElseStatement();
	Expression condition = curElement.getExpression();

	if (elseStatement == null) {
		compiler.println("opt " + condition.toString());
		return true;
	} else {
		compiler.println("alt " + condition.toString());
		thenStatement.accept(compiler);
		if (elseStatement instanceof IfStatement) {
			processAltStatement((IfStatement) elseStatement);
		} else {
			compiler.println("else");
			elseStatement.accept(compiler);
		}
		return false;
	}
}
 
开发者ID:ELTE-Soft,项目名称:txtUML,代码行数:23,代码来源:OptAltFragment.java

示例2: processAltStatement

import org.eclipse.jdt.core.dom.IfStatement; //导入方法依赖的package包/类
private void processAltStatement(IfStatement statement) {
	Statement thenStatement = statement.getThenStatement();
	Statement elseStatement = statement.getElseStatement();
	Expression condition = statement.getExpression();

	compiler.println("else " + condition.toString());
	thenStatement.accept(compiler);
	if (elseStatement != null) {
		if (elseStatement instanceof IfStatement) {
			processAltStatement((IfStatement) elseStatement);
		} else {
			compiler.println("else");
			elseStatement.accept(compiler);
		}
	}
}
 
开发者ID:ELTE-Soft,项目名称:txtUML,代码行数:17,代码来源:OptAltFragment.java

示例3: IfStatementWrapper

import org.eclipse.jdt.core.dom.IfStatement; //导入方法依赖的package包/类
public IfStatementWrapper(IfStatement statement, int indentationLevel, Applicable applicable) {
    super(indentationLevel, applicable);
    this.expression = statement.getExpression();
    this.thenBlock = new LinkedList<>();
    this.elseBlock = new LinkedList<>();

    statementsFrom(statement.getThenStatement(), thenBlock);
    statementsFrom(statement.getElseStatement(), elseBlock);
    applicable.applyFeaturesToStatements(thenBlock);
    applicable.applyFeaturesToStatements(elseBlock);
}
 
开发者ID:opaluchlukasz,项目名称:junit2spock,代码行数:12,代码来源:IfStatementWrapper.java

示例4: visit

import org.eclipse.jdt.core.dom.IfStatement; //导入方法依赖的package包/类
public boolean visit(IfStatement node) {
	Statement thenStmt = node.getThenStatement();
	Statement elseStmt = node.getElseStatement();
	Expression condExpr = node.getExpression();

	String thenStr = (thenStmt.toString()).replace('\n', ' ');
	String elseStr = "";

	if (elseStmt != null) {
		elseStr = (elseStmt.toString()).replace('\n', ' ');
	}

	if (mtbStack.isEmpty()) // not part of a method
		return true;

	IMethodBinding mtb = mtbStack.peek();
	String methodStr = getQualifiedName(mtb);
	String condStr = condExpr.toString();

	condStr = edit_str(condStr);
	thenStr = edit_str(thenStr);
	elseStr = edit_str(elseStr);

	// make conditional fact
	try {
		facts.add(Fact.makeConditionalFact(condStr, thenStr, elseStr,
				methodStr));
	} catch (Exception e) {
		System.err.println("Cannot resolve conditional \""
				+ condExpr.toString() + "\"");
		System.out.println("ifStmt: " + thenStr);
		System.out.println("elseStmt: " + elseStr);
		System.err.println(e.getMessage());
	}
	return true;
}
 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:37,代码来源:ASTVisitorAtomicChange.java

示例5: visit

import org.eclipse.jdt.core.dom.IfStatement; //导入方法依赖的package包/类
public boolean visit(IfStatement node)
{
  Statement thenStmt = node.getThenStatement();
  Statement elseStmt = node.getElseStatement();
  Expression condExpr = node.getExpression();
  
  String thenStr = thenStmt.toString().replace('\n', ' ');
  String elseStr = "";
  if (elseStmt != null) {
    elseStr = elseStmt.toString().replace('\n', ' ');
  }
  if (this.mtbStack.isEmpty()) {
    return true;
  }
  IMethodBinding mtb = (IMethodBinding)this.mtbStack.peek();
  String methodStr = getQualifiedName(mtb);
  String condStr = condExpr.toString();
  
  condStr = edit_str(condStr);
  thenStr = edit_str(thenStr);
  elseStr = edit_str(elseStr);
  try
  {
    this.facts.add(Fact.makeConditionalFact(condStr, thenStr, elseStr, 
      methodStr));
  }
  catch (Exception e)
  {
    System.err.println("Cannot resolve conditional \"" + 
      condExpr.toString() + "\"");
    System.out.println("ifStmt: " + thenStr);
    System.out.println("elseStmt: " + elseStr);
    System.err.println(e.getMessage());
  }
  return true;
}
 
开发者ID:SEAL-UCLA,项目名称:Ref-Finder,代码行数:37,代码来源:ASTVisitorAtomicChange.java

示例6: processIfStatements

import org.eclipse.jdt.core.dom.IfStatement; //导入方法依赖的package包/类
private void processIfStatements(Statement st, Method tmlMethod) {
List<TestCase> testCases = tmlMethod.getTestCase();

if (st != null && st.getNodeType() == ASTNode.IF_STATEMENT) {

    IfStatement ifSt = (IfStatement) st;

    Expression expression = ifSt.getExpression();
    testCases.addAll(processIfExpressions(expression, tmlMethod));

    // add assertions for result variable
    for (TestCase tc : testCases) {
	if (tc.getAssertion().size() == 0
		&& tmlMethod.getResult() != null) {
	    Assertion assertion = of.createAssertion();
	    assertion.setType(AssertionType.EQUALS);
	    assertion.setBase("{result}");
	    assertion.setValue("");
	    tc.getAssertion().add(assertion);
	}
    }

    // process other statements
    processIfStatements(ifSt.getThenStatement(), tmlMethod);
    processIfStatements(ifSt.getElseStatement(), tmlMethod);
}
   }
 
开发者ID:junit-tools-team,项目名称:junit-tools,代码行数:28,代码来源:TestCasesGenerator.java

示例7: analyzeMethod

import org.eclipse.jdt.core.dom.IfStatement; //导入方法依赖的package包/类
private MethodAnalyzeResult analyzeMethod(CompilationUnit astCu,
    IMethod method) {
MethodAnalyzeResult mar = new MethodAnalyzeResult();
MethodDeclaration md = JDTUtils.createMethodDeclaration(astCu, method);
if (md == null) {
    return mar;
}

List<IfStatement> ifStatements = collectIfStatements(md);
int numberOfIfStatements = ifStatements.size();

mar.setIfStatements(ifStatements);

// check if only null checks
if (ifStatements.size() > 0) {
    boolean onlyNullChecks = true;

    for (IfStatement ifSt : ifStatements) {
	Expression expression = ifSt.getExpression();

	if (expression.getNodeType() == ASTNode.INFIX_EXPRESSION) {
	    InfixExpression infixEx = (InfixExpression) expression;
	    Expression leftOperand = infixEx.getLeftOperand();
	    Expression rightOperand = infixEx.getRightOperand();
	    Operator operator = infixEx.getOperator();

	    if (operator.equals(Operator.EQUALS)
		    || operator.equals(Operator.NOT_EQUALS)) {
		if (leftOperand.getNodeType() == ASTNode.NULL_LITERAL
			|| rightOperand.getNodeType() == ASTNode.NULL_LITERAL) {
		    continue;
		}
	    }

	}

	onlyNullChecks = false;
    }

    mar.setOnlyNullChecks(onlyNullChecks);
}

// define test priority
if (numberOfIfStatements > 6) {
    mar.setTestPrio(Testprio.HIGH);
} else if (numberOfIfStatements > 3) {
    mar.setTestPrio(Testprio.DEFAULT);
} else if (numberOfIfStatements > 0) {
    mar.setTestPrio(Testprio.LOW);
} else {
    mar.setTestPrio(null);
}

return mar;
   }
 
开发者ID:junit-tools-team,项目名称:junit-tools,代码行数:56,代码来源:MethodAnalyzer.java


注:本文中的org.eclipse.jdt.core.dom.IfStatement.getExpression方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。