### Eclipse Workspace Patch 1.0
#P org.eclipse.jdt.apt.core
Index: src/org/eclipse/jdt/apt/core/internal/env/BaseProcessorEnv.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/BaseProcessorEnv.java,v
retrieving revision 1.34
diff -u -r1.34 BaseProcessorEnv.java
--- src/org/eclipse/jdt/apt/core/internal/env/BaseProcessorEnv.java 2 Sep 2008 16:49:00 -0000 1.34
+++ src/org/eclipse/jdt/apt/core/internal/env/BaseProcessorEnv.java 24 Nov 2009 18:19:26 -0000
@@ -853,6 +853,7 @@
p.setBindingsRecovery(true);
p.setProject( javaProject );
p.setKind( ASTParser.K_COMPILATION_UNIT );
+ p.ignoreMethodBodies();
p.createASTs( parseUnits, keys, requestor, null);
}
#P org.eclipse.jdt.apt.tests
Index: src/org/eclipse/jdt/apt/tests/AptBuilderTests.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptBuilderTests.java,v
retrieving revision 1.27
diff -u -r1.27 AptBuilderTests.java
--- src/org/eclipse/jdt/apt/tests/AptBuilderTests.java 3 Apr 2008 20:47:18 -0000 1.27
+++ src/org/eclipse/jdt/apt/tests/AptBuilderTests.java 24 Nov 2009 18:19:26 -0000
@@ -371,8 +371,8 @@
// parse the source, parsing runs through the compiler, and this registers the
// file a second time with the Compiler#DebugRequestor
//
- expectingCompiledClasses(new String[]{"p1.p2.p3.p4.C", "p1.p2.p3.p4.A", "p1.p2.p3.p4.A"}); //$NON-NLS-1$ //$NON-NLS-2$
- expectingCompilingOrder(new String[]{"p1.p2.p3.p4.C", "p1.p2.p3.p4.A", "p1.p2.p3.p4.A"}); //$NON-NLS-1$ //$NON-NLS-2$
+ expectingCompiledClasses(new String[]{"p1.p2.p3.p4.C", "p1.p2.p3.p4.A"}); //$NON-NLS-1$ //$NON-NLS-2$
+ expectingCompilingOrder(new String[]{"p1.p2.p3.p4.C", "p1.p2.p3.p4.A"}); //$NON-NLS-1$ //$NON-NLS-2$
//
// now make sure that p1.p2.p3.p4.C is not compiled when A uses NoOp Annotation
@@ -448,14 +448,14 @@
fullBuild( project.getFullPath() );
expectingNoProblems();
- expectingCompiledClasses(new String[] {"p1.A", "p1.A", "generatedfilepackage.GeneratedFileTest"}); //$NON-NLS-1 //$NON_NLS-2$
+ expectingCompiledClasses(new String[] {"p1.A", "generatedfilepackage.GeneratedFileTest"}); //$NON-NLS-1 //$NON_NLS-2$
// touch A - make sure its public shape changes.
env.addClass( srcRoot, "p1", "A", //$NON-NLS-1$ //$NON-NLS-2$
modifiedCode );
incrementalBuild( project.getFullPath() );
expectingNoProblems();
- expectingCompiledClasses(new String[]{"p1.A", "p1.A"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ expectingCompiledClasses(new String[]{"p1.A"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
/**
#P org.eclipse.jdt.core
Index: .settings/.api_filters
===================================================================
RCS file: .settings/.api_filters
diff -N .settings/.api_filters
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ .settings/.api_filters 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,19 @@
+
+false
.
+ */
+ private boolean ignoreMethodBodies;
+ /**
* Request for a bindings recovery. Defaults to false
.
*/
private boolean bindingsRecovery;
@@ -226,6 +230,7 @@
this.rawSource = null;
this.typeRoot = null;
this.resolveBindings = false;
+ this.ignoreMethodBodies = false;
this.sourceLength = -1;
this.sourceOffset = 0;
this.workingCopyOwner = DefaultWorkingCopyOwner.PRIMARY;
@@ -564,6 +569,19 @@
public void setStatementsRecovery(boolean enabled) {
this.statementsRecovery = enabled;
}
+
+ /**
+ * Requests an abstract syntax tree without method bodies.
+ * If this functions is called, even the code analysis and generation are not done.
+ * If the function has anonymous classes, the method bodies will be retained.
+ * This flag is honored only when the source is a compilation unit and the full
+ * AST is required.
+ *
+ * @since 3.5.2
+ */
+ public void ignoreMethodBodies() {
+ this.ignoreMethodBodies = true;
+ }
/**
* Sets the working copy owner using when resolving bindings, where
@@ -730,6 +748,7 @@
try {
int flags = 0;
if (this.statementsRecovery) flags |= ICompilationUnit.ENABLE_STATEMENTS_RECOVERY;
+ if (this.ignoreMethodBodies) flags |= ICompilationUnit.IGNORE_METHOD_BODIES;
if (this.resolveBindings) {
if (this.project == null)
throw new IllegalStateException("project not specified"); //$NON-NLS-1$
@@ -790,6 +809,7 @@
int flags = 0;
if (this.statementsRecovery) flags |= ICompilationUnit.ENABLE_STATEMENTS_RECOVERY;
if (this.bindingsRecovery) flags |= ICompilationUnit.ENABLE_BINDINGS_RECOVERY;
+ if (this.ignoreMethodBodies) flags |= ICompilationUnit.IGNORE_METHOD_BODIES;
return CompilationUnitResolver.resolve(elements, this.apiLevel, this.compilerOptions, this.project, this.workingCopyOwner, flags, monitor);
} finally {
// re-init defaults to allow reuse (and avoid leaking)
@@ -900,6 +920,7 @@
}
int flags = 0;
if (this.statementsRecovery) flags |= ICompilationUnit.ENABLE_STATEMENTS_RECOVERY;
+ if (searcher == null && this.ignoreMethodBodies) flags |= ICompilationUnit.IGNORE_METHOD_BODIES;
if (needToResolveBindings) {
if (this.bindingsRecovery) flags |= ICompilationUnit.ENABLE_BINDINGS_RECOVERY;
try {
@@ -1034,7 +1055,7 @@
ast.setFlag(ICompilationUnit.ENABLE_STATEMENTS_RECOVERY);
}
converter.setAST(ast);
- CodeSnippetParsingUtil codeSnippetParsingUtil = new CodeSnippetParsingUtil();
+ CodeSnippetParsingUtil codeSnippetParsingUtil = new CodeSnippetParsingUtil(this.ignoreMethodBodies);
CompilationUnit compilationUnit = ast.newCompilationUnit();
if (this.sourceLength == -1) {
this.sourceLength = this.rawSource.length;
Index: dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java,v
retrieving revision 1.136
diff -u -r1.136 CompilationUnitResolver.java
--- dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java 27 Aug 2009 15:27:02 -0000 1.136
+++ dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java 24 Nov 2009 18:19:28 -0000
@@ -340,6 +340,7 @@
public static void parse(ICompilationUnit[] compilationUnits, ASTRequestor astRequestor, int apiLevel, Map options, int flags, IProgressMonitor monitor) {
try {
CompilerOptions compilerOptions = new CompilerOptions(options);
+ compilerOptions.ignoreMethodBodies = (flags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
Parser parser = new CommentRecorderParser(
new ProblemReporter(
DefaultErrorHandlingPolicies.proceedWithAllProblems(),
@@ -363,8 +364,9 @@
//real parse of the method....
org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = compilationUnitDeclaration.types;
if (types != null) {
- for (int j = 0, typeLength = types.length; j < typeLength; j++)
+ for (int j = 0, typeLength = types.length; j < typeLength; j++) {
types[j].parseMethods(parser, compilationUnitDeclaration);
+ }
}
// convert AST
@@ -393,6 +395,7 @@
boolean statementsRecovery = (flags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0;
compilerOptions.performMethodsFullRecovery = statementsRecovery;
compilerOptions.performStatementsRecovery = statementsRecovery;
+ compilerOptions.ignoreMethodBodies = (flags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
Parser parser = new CommentRecorderParser(
new ProblemReporter(
DefaultErrorHandlingPolicies.proceedWithAllProblems(),
@@ -435,13 +438,14 @@
}
}
} else {
- //fill the methods bodies in order for the code to be generated
- //real parse of the method....
- org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = compilationUnitDeclaration.types;
- if (types != null) {
- for (int i = 0, length = types.length; i < length; i++)
- types[i].parseMethods(parser, compilationUnitDeclaration);
- }
+ //fill the methods bodies in order for the code to be generated
+ //real parse of the method....
+ org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = compilationUnitDeclaration.types;
+ if (types != null) {
+ for (int j = 0, typeLength = types.length; j < typeLength; j++) {
+ types[j].parseMethods(parser, compilationUnitDeclaration);
+ }
+ }
}
return compilationUnitDeclaration;
}
@@ -466,15 +470,16 @@
}
environment = new CancelableNameEnvironment(((JavaProject) javaProject), owner, monitor);
problemFactory = new CancelableProblemFactory(monitor);
+ CompilerOptions compilerOptions = getCompilerOptions(options, (flags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0);
+ compilerOptions.ignoreMethodBodies = (flags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
CompilationUnitResolver resolver =
new CompilationUnitResolver(
environment,
getHandlingPolicy(),
- getCompilerOptions(options, (flags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0),
+ compilerOptions,
getRequestor(),
problemFactory,
monitor);
-
resolver.resolve(compilationUnits, bindingKeys, requestor, apiLevel, options, owner, flags);
if (NameLookup.VERBOSE) {
System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + environment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -509,23 +514,31 @@
try {
environment = new CancelableNameEnvironment(((JavaProject)javaProject), owner, monitor);
problemFactory = new CancelableProblemFactory(monitor);
+ CompilerOptions compilerOptions = getCompilerOptions(options, (flags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0);
+ boolean ignoreMethodBodies = (flags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
+ compilerOptions.ignoreMethodBodies = ignoreMethodBodies;
resolver =
new CompilationUnitResolver(
environment,
getHandlingPolicy(),
- getCompilerOptions(options, (flags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0),
+ compilerOptions,
getRequestor(),
problemFactory,
monitor);
-
+ boolean analyzeCode = true;
+ boolean generateCode = true;
+ if (ignoreMethodBodies) {
+ analyzeCode = false;
+ generateCode = false;
+ }
unit =
resolver.resolve(
null, // no existing compilation unit declaration
sourceUnit,
nodeSearcher,
true, // method verification
- true, // analyze code
- true); // generate code
+ analyzeCode, // analyze code
+ generateCode); // generate code
if (resolver.hasCompilationAborted) {
// the bindings could not be resolved due to missing types in name environment
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=86541
Index: model/org/eclipse/jdt/core/ICompilationUnit.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICompilationUnit.java,v
retrieving revision 1.71
diff -u -r1.71 ICompilationUnit.java
--- model/org/eclipse/jdt/core/ICompilationUnit.java 11 Nov 2009 14:35:11 -0000 1.71
+++ model/org/eclipse/jdt/core/ICompilationUnit.java 24 Nov 2009 18:19:28 -0000
@@ -63,6 +63,14 @@
public static final int ENABLE_BINDINGS_RECOVERY = 0x04;
/**
+ * Constant indicating that a reconcile operation could ignore to parse the method bodies.
+ * @see ASTParser#ignoreMethodBodies()
+ * @since 3.5.2
+ */
+public static final int IGNORE_METHOD_BODIES = 0x08;
+
+
+/**
* Applies a text edit to the compilation unit's buffer.
*
* Note that the edit is simply applied to the compilation unit's buffer.
Index: model/org/eclipse/jdt/core/compiler/ReconcileContext.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/compiler/ReconcileContext.java,v
retrieving revision 1.14
diff -u -r1.14 ReconcileContext.java
--- model/org/eclipse/jdt/core/compiler/ReconcileContext.java 1 Sep 2008 08:40:58 -0000 1.14
+++ model/org/eclipse/jdt/core/compiler/ReconcileContext.java 24 Nov 2009 18:19:28 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -94,6 +94,8 @@
parser.setStatementsRecovery((this.operation.reconcileFlags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0);
parser.setBindingsRecovery((this.operation.reconcileFlags & ICompilationUnit.ENABLE_BINDINGS_RECOVERY) != 0);
parser.setSource(this.workingCopy);
+ if ((this.operation.reconcileFlags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0)
+ parser.ignoreMethodBodies();
return (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(this.operation.progressMonitor);
}
return this.operation.makeConsistent(this.workingCopy);
Index: model/org/eclipse/jdt/internal/core/CompilationUnit.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java,v
retrieving revision 1.258
diff -u -r1.258 CompilationUnit.java
--- model/org/eclipse/jdt/internal/core/CompilationUnit.java 30 Sep 2009 18:57:18 -0000 1.258
+++ model/org/eclipse/jdt/internal/core/CompilationUnit.java 24 Nov 2009 18:19:28 -0000
@@ -145,10 +145,12 @@
// disable task tags checking to speed up parsing
options.put(JavaCore.COMPILER_TASK_TAGS, ""); //$NON-NLS-1$
}
+ CompilerOptions compilerOptions = new CompilerOptions(options);
+ compilerOptions.ignoreMethodBodies = (reconcileFlags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
SourceElementParser parser = new SourceElementParser(
requestor,
problemFactory,
- new CompilerOptions(options),
+ compilerOptions,
true/*report local declarations*/,
!createAST /*optimize string literals only if not creating a DOM AST*/);
parser.reportOnlyOneSyntaxError = !computeProblems;
Index: model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java,v
retrieving revision 1.63
diff -u -r1.63 CompilationUnitProblemFinder.java
--- model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java 27 Jun 2008 16:03:50 -0000 1.63
+++ model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java 24 Nov 2009 18:19:28 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -157,12 +157,21 @@
try {
environment = new CancelableNameEnvironment(project, workingCopyOwner, monitor);
problemFactory = new CancelableProblemFactory(monitor);
+ CompilerOptions compilerOptions = getCompilerOptions(project.getOptions(true), creatingAST, ((reconcileFlags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0));
+ boolean ignoreMethodBodies = (reconcileFlags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
+ compilerOptions.ignoreMethodBodies = ignoreMethodBodies;
problemFinder = new CompilationUnitProblemFinder(
environment,
getHandlingPolicy(),
- getCompilerOptions(project.getOptions(true), creatingAST, ((reconcileFlags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0)),
+ compilerOptions,
getRequestor(),
problemFactory);
+ boolean analyzeCode = true;
+ boolean generateCode = true;
+ if (ignoreMethodBodies) {
+ analyzeCode = false;
+ generateCode = false;
+ }
CompilationUnitDeclaration unit = null;
if (parser != null) {
problemFinder.parser = parser;
@@ -172,8 +181,8 @@
unit,
unitElement,
true, // verify methods
- true, // analyze code
- true); // generate code
+ analyzeCode, // analyze code
+ generateCode); // generate code
} catch (AbortCompilation e) {
problemFinder.handleInternalException(e, unit);
}
@@ -182,8 +191,8 @@
problemFinder.resolve(
unitElement,
true, // verify methods
- true, // analyze code
- true); // generate code
+ analyzeCode, // analyze code
+ generateCode); // generate code
}
CompilationResult unitResult = unit.compilationResult;
CategorizedProblem[] unitProblems = unitResult.getProblems();
Index: model/org/eclipse/jdt/internal/core/util/CodeSnippetParsingUtil.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CodeSnippetParsingUtil.java,v
retrieving revision 1.20
diff -u -r1.20 CodeSnippetParsingUtil.java
--- model/org/eclipse/jdt/internal/core/util/CodeSnippetParsingUtil.java 28 Apr 2009 16:53:02 -0000 1.20
+++ model/org/eclipse/jdt/internal/core/util/CodeSnippetParsingUtil.java 24 Nov 2009 18:19:28 -0000
@@ -32,6 +32,15 @@
public class CodeSnippetParsingUtil {
public RecordedParsingInformation recordedParsingInformation;
+ public boolean ignoreMethodBodies;
+
+ public CodeSnippetParsingUtil(boolean ignoreMethodBodies) {
+ this.ignoreMethodBodies = ignoreMethodBodies;
+ }
+
+ public CodeSnippetParsingUtil() {
+ this(false);
+ }
private RecordedParsingInformation getRecordedParsingInformation(CompilationResult compilationResult, int[][] commentPositions) {
int problemsCount = compilationResult.problemCount;
@@ -62,6 +71,7 @@
throw new IllegalArgumentException();
}
CompilerOptions compilerOptions = new CompilerOptions(settings);
+ compilerOptions.ignoreMethodBodies = this.ignoreMethodBodies;
final ProblemReporter problemReporter = new ProblemReporter(
DefaultErrorHandlingPolicies.proceedWithAllProblems(),
compilerOptions,
@@ -92,6 +102,7 @@
throw new IllegalArgumentException();
}
CompilerOptions compilerOptions = new CompilerOptions(settings);
+ compilerOptions.ignoreMethodBodies = this.ignoreMethodBodies;
CommentRecorderParser parser =
new CommentRecorderParser(
new ProblemReporter(
@@ -144,6 +155,7 @@
throw new IllegalArgumentException();
}
CompilerOptions compilerOptions = new CompilerOptions(settings);
+ // don't set ignoreMethodBodies
final ProblemReporter problemReporter = new ProblemReporter(
DefaultErrorHandlingPolicies.proceedWithAllProblems(),
compilerOptions,
@@ -182,6 +194,7 @@
throw new IllegalArgumentException();
}
CompilerOptions compilerOptions = new CompilerOptions(settings);
+ // don't set ignoreMethodBodies
final ProblemReporter problemReporter = new ProblemReporter(
DefaultErrorHandlingPolicies.proceedWithAllProblems(),
compilerOptions,
#P org.eclipse.jdt.core.tests.model
Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java,v
retrieving revision 1.166
diff -u -r1.166 ASTConverterTestAST3_2.java
--- src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 17 Aug 2009 17:45:43 -0000 1.166
+++ src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 24 Nov 2009 18:19:30 -0000
@@ -10425,4 +10425,75 @@
CompilationUnit unit = (CompilationUnit) root;
assertTrue("No problem reported", unit.getProblems().length != 0);
}
+ /**
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=288211
+ */
+ public void test0715() throws JavaModelException {
+ final char[] source = ("System.out.println()\nint i;\n").toCharArray();
+ ASTParser parser = ASTParser.newParser(AST.JLS3);
+ parser.setKind(ASTParser.K_STATEMENTS);
+ parser.setStatementsRecovery(true);
+ parser.ignoreMethodBodies();
+ parser.setSource(source);
+ ASTNode root = parser.createAST(null);
+ assertEquals("Not a block", ASTNode.BLOCK, root.getNodeType());
+ Block block = (Block) root;
+ List statements = block.statements();
+ assertEquals("Wrong size", 2, statements.size());
+ }
+ /**
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=288211
+ */
+ public void test0716() {
+ String src = "switch (state) {case 4:double M0,M1;}";
+ char[] source = src.toCharArray();
+ ASTParser parser = ASTParser.newParser(AST.JLS3);
+ parser.setKind (ASTParser.K_STATEMENTS);
+ parser.ignoreMethodBodies();
+ parser.setSource (source);
+ ASTNode result = parser.createAST (null);
+ assertNotNull("no result", result);
+ assertEquals("Wrong type", ASTNode.BLOCK, result.getNodeType());
+ Block block = (Block) result;
+ List statements = block.statements();
+ assertNotNull("No statements", statements);
+ assertEquals("Wrong size", 1, statements.size());
+ final ASTNode node = (ASTNode) statements.get(0);
+ assertEquals("Not a switch statement", ASTNode.SWITCH_STATEMENT, node.getNodeType());
+ SwitchStatement statement = (SwitchStatement) node;
+ statements = statement.statements();
+ assertEquals("wrong size", 2, statements.size());
+ assertEquals("Not a switch case", ASTNode.SWITCH_CASE, ((ASTNode) statements.get(0)).getNodeType());
+ assertEquals("Not a variable declaration statement", ASTNode.VARIABLE_DECLARATION_STATEMENT, ((ASTNode) statements.get(1)).getNodeType());
+ }
+ /**
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=288211
+ */
+ public void test0717() throws JavaModelException {
+ final char[] source = (" class MyCommand extends CompoundCommand\n" +
+ " {\n" +
+ " public void execute()\n" +
+ " {\n" +
+ " // ...\n" +
+ " appendAndExecute(new AddCommand());\n" +
+ " if (condition) appendAndExecute(new AddCommand());\n" +
+ " }\n" +
+ " }").toCharArray();
+ ASTParser parser = ASTParser.newParser(AST.JLS3);
+ parser.setKind(ASTParser.K_CLASS_BODY_DECLARATIONS);
+ parser.setStatementsRecovery(false);
+ parser.ignoreMethodBodies();
+ parser.setSource(source);
+ ASTNode root = parser.createAST(null);
+ assertEquals("Not a type declaration", ASTNode.TYPE_DECLARATION, root.getNodeType());
+ TypeDeclaration typeDeclaration = (TypeDeclaration) root;
+ typeDeclaration.accept(new ASTVisitor() {
+ public boolean visit(MethodDeclaration node) {
+ Block body = node.getBody();
+ assertNotNull(body);
+ assertTrue(body.statements().size() == 0);
+ return true;
+ }
+ });
+ }
}
\ No newline at end of file
Index: src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java,v
retrieving revision 1.84
diff -u -r1.84 BatchASTCreationTests.java
--- src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java 11 Feb 2009 15:53:26 -0000 1.84
+++ src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java 24 Nov 2009 18:19:30 -0000
@@ -2208,4 +2208,79 @@
},
"LA~B