Java Code Examples for org.eclipse.jdt.core.dom.Statement#accept()

The following examples show how to use org.eclipse.jdt.core.dom.Statement#accept() . 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);
		}
	}
}
 
Example 3
Source File: ReadableFlattener.java    From junion with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public boolean visit(Block node) {
	tabs += 4;
	this.fBuffer.append("{"); //$NON-NLS-1$
	lineBreak();
	for (Iterator<Statement> it = node.statements().iterator(); it.hasNext();) {
		Statement s = it.next();
		s.accept(this);
	}
	tabs -= 4;
	lineBreak();
	this.fBuffer.append("}"); //$NON-NLS-1$
	return false;
}
 
Example 4
Source File: BindingSignature.java    From JDeodorant with MIT License 5 votes vote down vote up
public BindingSignature(Set<PDGNode> statements) {
	this.bindingKeys = new ArrayList<String>();
	for(PDGNode node : statements) {
		Statement statement = node.getASTStatement();
		BindingSignatureVisitor visitor = new BindingSignatureVisitor();
		statement.accept(visitor);
		this.bindingKeys.addAll(visitor.getBindingKeys());
	}
}
 
Example 5
Source File: ReplaceTypeCodeWithStateStrategy.java    From JDeodorant with MIT License 5 votes vote down vote up
private Set<ITypeBinding> getRequiredImportDeclarationsBasedOnBranch(ArrayList<Statement> statements) {
	Set<ITypeBinding> typeBindings = new LinkedHashSet<ITypeBinding>();
	for(Statement statement : statements) {
		TypeVisitor typeVisitor = new TypeVisitor();
		statement.accept(typeVisitor);
		typeBindings.addAll(typeVisitor.getTypeBindings());
	}
	Set<ITypeBinding> finalTypeBindings = new LinkedHashSet<ITypeBinding>();
	RefactoringUtility.getSimpleTypeBindings(typeBindings, finalTypeBindings);
       return finalTypeBindings;
}
 
Example 6
Source File: ReplaceConditionalWithPolymorphism.java    From JDeodorant with MIT License 5 votes vote down vote up
private Set<ITypeBinding> getRequiredImportDeclarationsBasedOnBranch(ArrayList<Statement> statements) {
	Set<ITypeBinding> typeBindings = new LinkedHashSet<ITypeBinding>();
	for(Statement statement : statements) {
		TypeVisitor typeVisitor = new TypeVisitor();
		statement.accept(typeVisitor);
		typeBindings.addAll(typeVisitor.getTypeBindings());
	}
	return typeBindings;
}