Example usage for org.eclipse.jdt.core.dom EnhancedForStatement EnhancedForStatement

List of usage examples for org.eclipse.jdt.core.dom EnhancedForStatement EnhancedForStatement

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom EnhancedForStatement EnhancedForStatement.

Prototype

EnhancedForStatement(AST ast) 

Source Link

Document

Creates a new AST node for an enchanced for statement owned by the given AST.

Usage

From source file:org.eclipse.jdt.core.dom.ASTConverter.java

License:Open Source License

public Statement convert(ForeachStatement statement) {
    switch (this.ast.apiLevel) {
    case AST.JLS2_INTERNAL:
        return createFakeEmptyStatement(statement);
    default:/*from   ww  w.  j ava 2 s .co  m*/
        EnhancedForStatement enhancedForStatement = new EnhancedForStatement(this.ast);
        enhancedForStatement.setParameter(convertToSingleVariableDeclaration(statement.elementVariable));
        org.eclipse.jdt.internal.compiler.ast.Expression collection = statement.collection;
        if (collection == null)
            return null;
        enhancedForStatement.setExpression(convert(collection));
        final Statement action = convert(statement.action);
        if (action == null)
            return null;
        enhancedForStatement.setBody(action);
        int start = statement.sourceStart;
        int end = statement.sourceEnd;
        enhancedForStatement.setSourceRange(start, end - start + 1);
        return enhancedForStatement;
    }
}