### 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.33.2.1
diff -u -r1.33.2.1 BaseProcessorEnv.java
--- src/org/eclipse/jdt/apt/core/internal/env/BaseProcessorEnv.java 2 Sep 2008 16:10:00 -0000 1.33.2.1
+++ src/org/eclipse/jdt/apt/core/internal/env/BaseProcessorEnv.java 27 Nov 2009 08:40:18 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 BEA Systems Inc. and others
+ * Copyright (c) 2005, 2009 BEA Systems Inc. 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
@@ -498,6 +498,7 @@
parser.setResolveBindings(true);
parser.setBindingsRecovery(true);
parser.setProject(_javaProject);
+ parser.setIgnoreMethodBodies(true);
ICompilationUnit[] units = unit == null ? NO_UNIT : new ICompilationUnit[]{unit};
parser.createASTs(units, new String[]{key}, requestor, null);
final IBinding result = requestor._result;
@@ -708,6 +709,7 @@
parser.setBindingsRecovery(true);
parser.setSource(unit);
parser.setFocalPosition(0);
+ parser.setIgnoreMethodBodies(true);
CompilationUnit resultUnit = (CompilationUnit)parser.createAST(null);
_modelCompUnit2astCompUnit.put(unit, resultUnit);
return resultUnit;
@@ -853,6 +855,7 @@
p.setBindingsRecovery(true);
p.setProject( javaProject );
p.setKind( ASTParser.K_COMPILATION_UNIT );
+ p.setIgnoreMethodBodies(true);
p.createASTs( parseUnits, keys, requestor, null);
}
@@ -881,6 +884,7 @@
p.setBindingsRecovery(true);
p.setProject( javaProject );
p.setKind( ASTParser.K_COMPILATION_UNIT );
+ p.setIgnoreMethodBodies(true);
p.createASTs( new ICompilationUnit[]{compilationUnit}, NO_KEYS, requestor, null);
if( AptPlugin.DEBUG ){
AptPlugin.trace("created DOM AST for " + compilationUnit.getElementName() ); //$NON-NLS-1$
#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 27 Nov 2009 08:40:22 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 BEA Systems, Inc.
+ * Copyright (c) 2005, 2009 BEA Systems, Inc.
* 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
@@ -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$
}
/**
Index: src/org/eclipse/jdt/apt/tests/ReadAnnotationTests2.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ReadAnnotationTests2.java,v
retrieving revision 1.8
diff -u -r1.8 ReadAnnotationTests2.java
--- src/org/eclipse/jdt/apt/tests/ReadAnnotationTests2.java 2 Jan 2008 02:28:43 -0000 1.8
+++ src/org/eclipse/jdt/apt/tests/ReadAnnotationTests2.java 27 Nov 2009 08:40:22 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 BEA Systems, Inc.
+ * Copyright (c) 2005, 2009 BEA Systems, Inc.
* 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
@@ -188,6 +188,7 @@
final ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setResolveBindings(true);
parser.setProject(javaProj);
+ parser.setIgnoreMethodBodies(true);
parser.createASTs(NO_UNIT, new String[]{key}, requestor, null);
return requestor._result;
}
#P org.eclipse.jdt.core
Index: compiler/org/eclipse/jdt/internal/compiler/Compiler.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java,v
retrieving revision 1.108
diff -u -r1.108 Compiler.java
--- compiler/org/eclipse/jdt/internal/compiler/Compiler.java 27 May 2008 22:21:14 -0000 1.108
+++ compiler/org/eclipse/jdt/internal/compiler/Compiler.java 27 Nov 2009 08:40:25 -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
@@ -745,14 +745,13 @@
long analyzeStart = System.currentTimeMillis();
this.stats.resolveTime += analyzeStart - resolveStart;
- // flow analysis
- unit.analyseCode();
+ // no need to analyse or generate code if method bodies are to be ignored
+ if (!this.options.ignoreMethodBodies) unit.analyseCode(); // flow analysis
long generateStart = System.currentTimeMillis();
this.stats.analyzeTime += generateStart - analyzeStart;
- // code generation
- unit.generateCode();
+ if (!this.options.ignoreMethodBodies) unit.generateCode(); // code generation
// reference info
if (options.produceReferenceInfo && unit.scope != null)
Index: compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java,v
retrieving revision 1.203
diff -u -r1.203 CompilerOptions.java
--- compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 14 Apr 2008 19:41:33 -0000 1.203
+++ compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 27 Nov 2009 08:40:26 -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
@@ -339,6 +339,9 @@
// Enable annotation processing by default only in batch mode
public boolean processAnnotations = false;
+ // Indicate if method bodies should be ignored
+ public boolean ignoreMethodBodies = false;
+
/**
* Initializing the compiler options with defaults
*/
Index: dom/org/eclipse/jdt/core/dom/ASTParser.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java,v
retrieving revision 1.80
diff -u -r1.80 ASTParser.java
--- dom/org/eclipse/jdt/core/dom/ASTParser.java 27 May 2008 22:24:50 -0000 1.80
+++ dom/org/eclipse/jdt/core/dom/ASTParser.java 27 Nov 2009 08:40:34 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * Copyright (c) 2004, 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
@@ -149,6 +149,11 @@
private boolean statementsRecovery;
/**
+ * Request to ignore parsing the method bodies. Defaults to false
.
+ */
+ private boolean ignoreMethodBodies;
+
+ /**
* Request for a bindings recovery. Defaults to false
.
*/
private boolean bindingsRecovery;
@@ -226,6 +231,7 @@
this.rawSource = null;
this.typeRoot = null;
this.resolveBindings = false;
+ this.ignoreMethodBodies = false;
this.sourceLength = -1;
this.sourceOffset = 0;
this.workingCopyOwner = DefaultWorkingCopyOwner.PRIMARY;
@@ -564,7 +570,19 @@
public void setStatementsRecovery(boolean enabled) {
this.statementsRecovery = enabled;
}
-
+
+ /**
+ * Requests an abstract syntax tree without method bodies.
+ *
When ignore method bodies is enabled, all method bodies are discarded. + * This has no impact on binding resolution.
+ *This settings is not used if the kind used in {@link #setKind(int)} is either + * {@link #K_EXPRESSION} or {@link #K_STATEMENTS}
+ * @since 3.5.2 + */ + public void setIgnoreMethodBodies(boolean enabled) { + this.ignoreMethodBodies = enabled; + } + /** * Sets the working copy owner using when resolving bindings, where *null
means the primary owner. Defaults to the primary owner.
@@ -729,6 +747,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$
@@ -789,6 +808,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)
@@ -872,6 +892,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 {
@@ -1006,7 +1027,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.131
diff -u -r1.131 CompilationUnitResolver.java
--- dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java 27 May 2008 22:24:49 -0000 1.131
+++ dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java 27 Nov 2009 08:40:34 -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
@@ -336,6 +336,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(),
@@ -389,6 +390,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(),
@@ -462,11 +464,13 @@
}
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);
@@ -505,23 +509,26 @@
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 analyzeAndGenerateCode = !ignoreMethodBodies;
unit =
resolver.resolve(
null, // no existing compilation unit declaration
sourceUnit,
nodeSearcher,
true, // method verification
- true, // analyze code
- true); // generate code
+ analyzeAndGenerateCode, // analyze code
+ analyzeAndGenerateCode); // 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.67
diff -u -r1.67 ICompilationUnit.java
--- model/org/eclipse/jdt/core/ICompilationUnit.java 27 May 2008 23:40:21 -0000 1.67
+++ model/org/eclipse/jdt/core/ICompilationUnit.java 27 Nov 2009 08:40:35 -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
@@ -63,6 +63,13 @@
public static final int ENABLE_BINDINGS_RECOVERY = 0x04;
/**
+ * Constant indicating that a reconcile operation could ignore to parse the method bodies.
+ * @see ASTParser#setIgnoreMethodBodies(boolean)
+ * @since 3.5.2
+ */
+public static final int IGNORE_METHOD_BODIES = 0x08;
+
+/**
* Applies a text edit to the compilation unit's buffer.
*
* @param edit the edit to apply
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.12
diff -u -r1.12 ReconcileContext.java
--- model/org/eclipse/jdt/core/compiler/ReconcileContext.java 27 May 2008 23:40:22 -0000 1.12
+++ model/org/eclipse/jdt/core/compiler/ReconcileContext.java 27 Nov 2009 08:40:35 -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
@@ -96,6 +96,7 @@
parser.setStatementsRecovery((this.operation.reconcileFlags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0);
parser.setBindingsRecovery((this.operation.reconcileFlags & ICompilationUnit.ENABLE_BINDINGS_RECOVERY) != 0);
parser.setSource(workingCopy);
+ parser.setIgnoreMethodBodies((this.operation.reconcileFlags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0);
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.250.2.1
diff -u -r1.250.2.1 CompilationUnit.java
--- model/org/eclipse/jdt/internal/core/CompilationUnit.java 26 Sep 2008 10:18:59 -0000 1.250.2.1
+++ model/org/eclipse/jdt/internal/core/CompilationUnit.java 27 Nov 2009 08:40:36 -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
@@ -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.62
diff -u -r1.62 CompilationUnitProblemFinder.java
--- model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java 27 May 2008 23:40:18 -0000 1.62
+++ model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java 27 Nov 2009 08:40:36 -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,13 +157,17 @@
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);
CompilationUnitDeclaration unit = null;
+ boolean analyzeAndGenerateCode = !ignoreMethodBodies;
if (parser != null) {
problemFinder.parser = parser;
try {
@@ -172,8 +176,8 @@
unit,
unitElement,
true, // verify methods
- true, // analyze code
- true); // generate code
+ analyzeAndGenerateCode, // analyze code
+ analyzeAndGenerateCode); // generate code
} catch (AbortCompilation e) {
problemFinder.handleInternalException(e, unit);
}
@@ -182,8 +186,8 @@
problemFinder.resolve(
unitElement,
true, // verify methods
- true, // analyze code
- true); // generate code
+ analyzeAndGenerateCode, // analyze code
+ analyzeAndGenerateCode); // 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.17
diff -u -r1.17 CodeSnippetParsingUtil.java
--- model/org/eclipse/jdt/internal/core/util/CodeSnippetParsingUtil.java 27 May 2008 23:40:19 -0000 1.17
+++ model/org/eclipse/jdt/internal/core/util/CodeSnippetParsingUtil.java 27 Nov 2009 08:40:36 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2008 IBM Corporation and others.
+ * Copyright (c) 2002, 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
@@ -33,6 +33,16 @@
public RecordedParsingInformation recordedParsingInformation;
+ public boolean ignoreMethodBodies;
+
+ public CodeSnippetParsingUtil(boolean ignoreMethodBodies) {
+ this.ignoreMethodBodies = ignoreMethodBodies;
+ }
+
+ public CodeSnippetParsingUtil() {
+ this(false);
+ }
+
private RecordedParsingInformation getRecordedParsingInformation(CompilationResult compilationResult, CommentRecorderParser parser) {
int problemsCount = compilationResult.problemCount;
CategorizedProblem[] problems = null;
@@ -56,6 +66,7 @@
throw new IllegalArgumentException();
}
CompilerOptions compilerOptions = new CompilerOptions(settings);
+ compilerOptions.ignoreMethodBodies = this.ignoreMethodBodies;
final ProblemReporter problemReporter = new ProblemReporter(
DefaultErrorHandlingPolicies.proceedWithAllProblems(),
compilerOptions,
@@ -86,6 +97,7 @@
throw new IllegalArgumentException();
}
CompilerOptions compilerOptions = new CompilerOptions(settings);
+ compilerOptions.ignoreMethodBodies = this.ignoreMethodBodies;
CommentRecorderParser parser =
new CommentRecorderParser(
new ProblemReporter(
@@ -137,7 +149,8 @@
if (source == null) {
throw new IllegalArgumentException();
}
- CompilerOptions compilerOptions = new CompilerOptions(settings);
+ CompilerOptions compilerOptions = new CompilerOptions(settings);
+ // in this case we don't want to ignore method bodies since we are parsing only an expression
final ProblemReporter problemReporter = new ProblemReporter(
DefaultErrorHandlingPolicies.proceedWithAllProblems(),
compilerOptions,
@@ -169,6 +182,7 @@
throw new IllegalArgumentException();
}
CompilerOptions compilerOptions = new CompilerOptions(settings);
+ // in this case we don't want to ignore method bodies since we are parsing only statements
final ProblemReporter problemReporter = new ProblemReporter(
DefaultErrorHandlingPolicies.proceedWithAllProblems(),
compilerOptions,
Index: compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java,v
retrieving revision 1.387.2.1
diff -u -r1.387.2.1 Parser.java
--- compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 3 Jul 2008 09:23:02 -0000 1.387.2.1
+++ compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 27 Nov 2009 08:40:33 -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
@@ -2588,7 +2588,9 @@
// now we know that the top of stack is a constructorDeclaration
ConstructorDeclaration cd = (ConstructorDeclaration) this.astStack[this.astPtr];
cd.constructorCall = constructorCall;
- cd.statements = statements;
+ if (!this.options.ignoreMethodBodies) {
+ cd.statements = statements;
+ }
//highlight of the implicit call on the method name
if (constructorCall != null && cd.constructorCall.sourceEnd == 0) {
@@ -4336,8 +4338,10 @@
// now we know that we have a method declaration at the top of the ast stack
MethodDeclaration md = (MethodDeclaration) this.astStack[this.astPtr];
- md.statements = statements;
md.explicitDeclarations = explicitDeclarations;
+ if (!this.options.ignoreMethodBodies) {
+ md.statements = statements;
+ }
// cannot be done in consumeMethodHeader because we have no idea whether or not there
// is a body when we reduce the method header
@@ -9377,35 +9381,39 @@
int length;
if (astLengthPtr > -1 && (length = this.astLengthStack[this.astLengthPtr--]) != 0) {
this.astPtr -= length;
- if (this.astStack[this.astPtr + 1] instanceof ExplicitConstructorCall)
- //avoid a isSomeThing that would only be used here BUT what is faster between two alternatives ?
- {
- System.arraycopy(
- this.astStack,
- this.astPtr + 2,
- cd.statements = new Statement[length - 1],
- 0,
- length - 1);
- cd.constructorCall = (ExplicitConstructorCall) this.astStack[this.astPtr + 1];
- } else { //need to add explicitly the super();
- System.arraycopy(
- this.astStack,
- this.astPtr + 1,
- cd.statements = new Statement[length],
- 0,
- length);
- cd.constructorCall = SuperReference.implicitSuperConstructorCall();
+ if (!this.options.ignoreMethodBodies) {
+ if (this.astStack[this.astPtr + 1] instanceof ExplicitConstructorCall)
+ //avoid a isSomeThing that would only be used here BUT what is faster between two alternatives ?
+ {
+ System.arraycopy(
+ this.astStack,
+ this.astPtr + 2,
+ cd.statements = new Statement[length - 1],
+ 0,
+ length - 1);
+ cd.constructorCall = (ExplicitConstructorCall) this.astStack[this.astPtr + 1];
+ } else { //need to add explicitly the super();
+ System.arraycopy(
+ this.astStack,
+ this.astPtr + 1,
+ cd.statements = new Statement[length],
+ 0,
+ length);
+ cd.constructorCall = SuperReference.implicitSuperConstructorCall();
+ }
}
} else {
- cd.constructorCall = SuperReference.implicitSuperConstructorCall();
+ if (!this.options.ignoreMethodBodies) {
+ cd.constructorCall = SuperReference.implicitSuperConstructorCall();
+ }
if (!containsComment(cd.bodyStart, cd.bodyEnd)) {
cd.bits |= ASTNode.UndocumentedEmptyBlock;
}
}
-
- if (cd.constructorCall.sourceEnd == 0) {
- cd.constructorCall.sourceEnd = cd.sourceEnd;
- cd.constructorCall.sourceStart = cd.sourceStart;
+ ExplicitConstructorCall explicitConstructorCall = cd.constructorCall;
+ if (explicitConstructorCall != null && explicitConstructorCall.sourceEnd == 0) {
+ explicitConstructorCall.sourceEnd = cd.sourceEnd;
+ explicitConstructorCall.sourceStart = cd.sourceStart;
}
}
// A P I
@@ -9615,12 +9623,17 @@
md.explicitDeclarations = this.realBlockStack[this.realBlockPtr--];
int length;
if (astLengthPtr > -1 && (length = this.astLengthStack[this.astLengthPtr--]) != 0) {
- System.arraycopy(
- this.astStack,
- (this.astPtr -= length) + 1,
- md.statements = new Statement[length],
- 0,
- length);
+ if (this.options.ignoreMethodBodies) {
+ // ignore statements
+ this.astPtr -= length;
+ } else {
+ System.arraycopy(
+ this.astStack,
+ (this.astPtr -= length) + 1,
+ md.statements = new Statement[length],
+ 0,
+ length);
+ }
} else {
if (!containsComment(md.bodyStart, md.bodyEnd)) {
md.bits |= ASTNode.UndocumentedEmptyBlock;
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,18 @@
+