Java Code Examples for org.eclipse.jdt.core.dom.IfStatement#getExpression()

The following examples show how to use org.eclipse.jdt.core.dom.IfStatement#getExpression() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OptAltFragmentExporter.java    From txtUML with Eclipse Public License 1.0 6 votes vote down vote up
@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;
	}
}
 
Example 2
Source File: OptAltFragmentExporter.java    From txtUML with Eclipse Public License 1.0 6 votes vote down vote up
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);
		}
	}
}