List of usage examples for org.eclipse.jdt.core.dom ExpressionStatement ExpressionStatement
ExpressionStatement(AST ast)
From source file:org.eclipse.jdt.core.dom.ASTConverter.java
License:Open Source License
public Statement convert(org.eclipse.jdt.internal.compiler.ast.Statement statement) { if (statement instanceof ForeachStatement) { return convert((ForeachStatement) statement); }/*from ww w . j a v a2s.c om*/ if (statement instanceof org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) { org.eclipse.jdt.internal.compiler.ast.LocalDeclaration localDeclaration = (org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) statement; return convertToVariableDeclarationStatement(localDeclaration); } if (statement instanceof org.eclipse.jdt.internal.compiler.ast.AssertStatement) { return convert((org.eclipse.jdt.internal.compiler.ast.AssertStatement) statement); } if (statement instanceof org.eclipse.jdt.internal.compiler.ast.Block) { return convert((org.eclipse.jdt.internal.compiler.ast.Block) statement); } if (statement instanceof org.eclipse.jdt.internal.compiler.ast.BreakStatement) { return convert((org.eclipse.jdt.internal.compiler.ast.BreakStatement) statement); } if (statement instanceof org.eclipse.jdt.internal.compiler.ast.ContinueStatement) { return convert((org.eclipse.jdt.internal.compiler.ast.ContinueStatement) statement); } if (statement instanceof org.eclipse.jdt.internal.compiler.ast.CaseStatement) { return convert((org.eclipse.jdt.internal.compiler.ast.CaseStatement) statement); } if (statement instanceof org.eclipse.jdt.internal.compiler.ast.DoStatement) { return convert((org.eclipse.jdt.internal.compiler.ast.DoStatement) statement); } if (statement instanceof org.eclipse.jdt.internal.compiler.ast.EmptyStatement) { return convert((org.eclipse.jdt.internal.compiler.ast.EmptyStatement) statement); } if (statement instanceof org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall) { return convert((org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall) statement); } if (statement instanceof org.eclipse.jdt.internal.compiler.ast.ForStatement) { return convert((org.eclipse.jdt.internal.compiler.ast.ForStatement) statement); } if (statement instanceof org.eclipse.jdt.internal.compiler.ast.IfStatement) { return convert((org.eclipse.jdt.internal.compiler.ast.IfStatement) statement); } if (statement instanceof org.eclipse.jdt.internal.compiler.ast.LabeledStatement) { return convert((org.eclipse.jdt.internal.compiler.ast.LabeledStatement) statement); } if (statement instanceof org.eclipse.jdt.internal.compiler.ast.ReturnStatement) { return convert((org.eclipse.jdt.internal.compiler.ast.ReturnStatement) statement); } if (statement instanceof org.eclipse.jdt.internal.compiler.ast.SwitchStatement) { return convert((org.eclipse.jdt.internal.compiler.ast.SwitchStatement) statement); } if (statement instanceof org.eclipse.jdt.internal.compiler.ast.SynchronizedStatement) { return convert((org.eclipse.jdt.internal.compiler.ast.SynchronizedStatement) statement); } if (statement instanceof org.eclipse.jdt.internal.compiler.ast.ThrowStatement) { return convert((org.eclipse.jdt.internal.compiler.ast.ThrowStatement) statement); } if (statement instanceof org.eclipse.jdt.internal.compiler.ast.TryStatement) { return convert((org.eclipse.jdt.internal.compiler.ast.TryStatement) statement); } if (statement instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) { ASTNode result = convert((org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) statement); if (result == null) { return createFakeEmptyStatement(statement); } // annotation and enum type declarations are not returned by the parser inside method bodies TypeDeclaration typeDeclaration = (TypeDeclaration) result; TypeDeclarationStatement typeDeclarationStatement = new TypeDeclarationStatement(this.ast); typeDeclarationStatement.setDeclaration(typeDeclaration); switch (this.ast.apiLevel) { case AST.JLS2_INTERNAL: TypeDeclaration typeDecl = typeDeclarationStatement.internalGetTypeDeclaration(); typeDeclarationStatement.setSourceRange(typeDecl.getStartPosition(), typeDecl.getLength()); break; default: AbstractTypeDeclaration typeDeclAST3 = typeDeclarationStatement.getDeclaration(); typeDeclarationStatement.setSourceRange(typeDeclAST3.getStartPosition(), typeDeclAST3.getLength()); break; } return typeDeclarationStatement; } if (statement instanceof org.eclipse.jdt.internal.compiler.ast.WhileStatement) { return convert((org.eclipse.jdt.internal.compiler.ast.WhileStatement) statement); } if (statement instanceof org.eclipse.jdt.internal.compiler.ast.Expression) { org.eclipse.jdt.internal.compiler.ast.Expression statement2 = (org.eclipse.jdt.internal.compiler.ast.Expression) statement; final Expression expr = convert(statement2); final ExpressionStatement stmt = new ExpressionStatement(this.ast); stmt.setExpression(expr); int sourceStart = expr.getStartPosition(); int sourceEnd = statement2.statementEnd; stmt.setSourceRange(sourceStart, sourceEnd - sourceStart + 1); return stmt; } return createFakeEmptyStatement(statement); }