### Eclipse Workspace Patch 1.0
#P org.eclipse.jdt.core
Index: model/org/eclipse/jdt/internal/core/builder/CompilationParticipantResult.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/CompilationParticipantResult.java,v
retrieving revision 1.7
diff -u -r1.7 CompilationParticipantResult.java
--- model/org/eclipse/jdt/internal/core/builder/CompilationParticipantResult.java 27 Jun 2008 16:04:08 -0000 1.7
+++ model/org/eclipse/jdt/internal/core/builder/CompilationParticipantResult.java 1 Sep 2008 11:29:03 -0000
@@ -15,7 +15,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.jdt.core.compiler.*;
-public class CompilationParticipantResult {
+public class CompilationParticipantResult extends BuildContext {
protected SourceFile sourceFile;
protected boolean hasAnnotations; // only set during processAnnotations
protected IFile[] addedFiles; // added/changed generated source files that need to be compiled
@@ -32,6 +32,105 @@
this.dependencies = null;
}
+/**
+ * Returns the contents of the compilation unit.
+ *
+ * @return the contents of the compilation unit
+ */
+public char[] getContents() {
+ return this.sourceFile.getContents();
+}
+
+/**
+ * Returns the IFile
representing the compilation unit.
+ *
+ * @return the IFile
representing the compilation unit
+ */
+public IFile getFile() {
+ return this.sourceFile.resource;
+}
+
+/**
+ * Returns whether the compilation unit contained any annotations when it was compiled.
+ *
+ * NOTE: This is only valid during {@link CompilationParticipant#processAnnotations(BuildContext[])}.
+ *
+ * @return whether the compilation unit contained any annotations when it was compiled
+ */
+public boolean hasAnnotations() {
+ return this.hasAnnotations; // only set during processAnnotations
+}
+
+/**
+ * Record the added/changed generated files that need to be compiled.
+ *
+ * @param addedGeneratedFiles the added/changed files
+ */
+public void recordAddedGeneratedFiles(IFile[] addedGeneratedFiles) {
+ int length2 = addedGeneratedFiles.length;
+ if (length2 == 0) return;
+
+ int length1 = this.addedFiles == null ? 0 : this.addedFiles.length;
+ IFile[] merged = new IFile[length1 + length2];
+ if (length1 > 0) // always make a copy even if currently empty
+ System.arraycopy(this.addedFiles, 0, merged, 0, length1);
+ System.arraycopy(addedGeneratedFiles, 0, merged, length1, length2);
+ this.addedFiles = merged;
+}
+
+/**
+ * Record the generated files that need to be deleted.
+ *
+ * @param deletedGeneratedFiles the files that need to be deleted
+ */
+public void recordDeletedGeneratedFiles(IFile[] deletedGeneratedFiles) {
+ int length2 = deletedGeneratedFiles.length;
+ if (length2 == 0) return;
+
+ int length1 = this.deletedFiles == null ? 0 : this.deletedFiles.length;
+ IFile[] merged = new IFile[length1 + length2];
+ if (length1 > 0) // always make a copy even if currently empty
+ System.arraycopy(this.deletedFiles, 0, merged, 0, length1);
+ System.arraycopy(deletedGeneratedFiles, 0, merged, length1, length2);
+ this.deletedFiles = merged;
+}
+
+/**
+ * Record the fully-qualified type names of any new dependencies, each name is of the form "p1.p2.A.B".
+ *
+ * @param typeNameDependencies the fully-qualified type names of new dependencies
+ */
+public void recordDependencies(String[] typeNameDependencies) {
+ int length2 = typeNameDependencies.length;
+ if (length2 == 0) return;
+
+ int length1 = this.dependencies == null ? 0 : this.dependencies.length;
+ String[] merged = new String[length1 + length2];
+ if (length1 > 0) // always make a copy even if currently empty
+ System.arraycopy(this.dependencies, 0, merged, 0, length1);
+ System.arraycopy(typeNameDependencies, 0, merged, length1, length2);
+ this.dependencies = merged;
+}
+
+/**
+ * Record new problems to report against this compilationUnit.
+ * Markers are persisted for these problems only for the declared managed marker type
+ * (see the 'compilationParticipant' extension point).
+ *
+ * @param newProblems the problems to report
+ */
+public void recordNewProblems(CategorizedProblem[] newProblems) {
+ int length2 = newProblems.length;
+ if (length2 == 0) return;
+
+ int length1 = this.problems == null ? 0 : this.problems.length;
+ CategorizedProblem[] merged = new CategorizedProblem[length1 + length2];
+ if (length1 > 0) // always make a copy even if currently empty
+ System.arraycopy(this.problems, 0, merged, 0, length1);
+ System.arraycopy(newProblems, 0, merged, length1, length2);
+ this.problems = merged;
+}
+
void reset(boolean detectedAnnotations) {
// called prior to processAnnotations
this.hasAnnotations = detectedAnnotations;
Index: model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java,v
retrieving revision 1.122
diff -u -r1.122 AbstractImageBuilder.java
--- model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java 27 Jun 2008 16:04:09 -0000 1.122
+++ model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java 1 Sep 2008 11:29:03 -0000
@@ -283,7 +283,7 @@
this.filesWithAnnotations.clear();
// notify CompilationParticipants which source files are about to be compiled
- BuildContext[] participantResults = this.javaBuilder.participants == null ? null : notifyParticipants(units);
+ CompilationParticipantResult[] participantResults = this.javaBuilder.participants == null ? null : notifyParticipants(units);
if (participantResults != null && participantResults.length > units.length) {
units = new SourceFile[participantResults.length];
for (int i = participantResults.length; --i >= 0;)
@@ -539,10 +539,10 @@
return newCompiler;
}
-protected BuildContext[] notifyParticipants(SourceFile[] unitsAboutToCompile) {
- BuildContext[] results = new BuildContext[unitsAboutToCompile.length];
+protected CompilationParticipantResult[] notifyParticipants(SourceFile[] unitsAboutToCompile) {
+ CompilationParticipantResult[] results = new CompilationParticipantResult[unitsAboutToCompile.length];
for (int i = unitsAboutToCompile.length; --i >= 0;)
- results[i] = new BuildContext(unitsAboutToCompile[i]);
+ results[i] = new CompilationParticipantResult(unitsAboutToCompile[i]);
// TODO (kent) do we expect to have more than one participant?
// and if so should we pass the generated files from the each processor to the others to process?
@@ -572,7 +572,7 @@
uniqueFiles.add(unitsAboutToCompile[f]);
}
if (uniqueFiles.addIfNotIncluded(sourceFile) == sourceFile) {
- CompilationParticipantResult newResult = new BuildContext(sourceFile);
+ CompilationParticipantResult newResult = new CompilationParticipantResult(sourceFile);
// is there enough room to add all the addedGeneratedFiles.length ?
if (toAdd == null) {
toAdd = new CompilationParticipantResult[addedGeneratedFiles.length];
@@ -589,7 +589,7 @@
if (added >0 ) {
int length = results.length;
- System.arraycopy(results, 0, results = new BuildContext[length + added], 0 , length);
+ System.arraycopy(results, 0, results = new CompilationParticipantResult[length + added], 0 , length);
System.arraycopy(toAdd, 0, results, length, added);
}
return results;
@@ -597,7 +597,7 @@
protected abstract void processAnnotationResults(CompilationParticipantResult[] results);
-protected void processAnnotations(BuildContext[] results) {
+protected void processAnnotations(CompilationParticipantResult[] results) {
boolean hasAnnotationProcessor = false;
for (int i = 0, l = this.javaBuilder.participants.length; !hasAnnotationProcessor && i < l; i++)
hasAnnotationProcessor = this.javaBuilder.participants[i].isAnnotationProcessor();
@@ -605,7 +605,7 @@
boolean foundAnnotations = this.filesWithAnnotations != null && this.filesWithAnnotations.elementSize > 0;
for (int i = results.length; --i >= 0;)
- ((CompilationParticipantResult) results[i]).reset(foundAnnotations && this.filesWithAnnotations.includes(results[i].sourceFile));
+ results[i].reset(foundAnnotations && this.filesWithAnnotations.includes(results[i].sourceFile));
// even if no files have annotations, must still tell every annotation processor in case the file used to have them
for (int i = 0, l = this.javaBuilder.participants.length; i < l; i++)
Index: model/org/eclipse/jdt/core/compiler/BuildContext.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/compiler/BuildContext.java,v
retrieving revision 1.8
diff -u -r1.8 BuildContext.java
--- model/org/eclipse/jdt/core/compiler/BuildContext.java 1 Sep 2008 08:40:58 -0000 1.8
+++ model/org/eclipse/jdt/core/compiler/BuildContext.java 1 Sep 2008 11:29:03 -0000
@@ -13,8 +13,6 @@
package org.eclipse.jdt.core.compiler;
import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.internal.core.builder.CompilationParticipantResult;
-import org.eclipse.jdt.internal.core.builder.SourceFile;
/**
* The context of a build event that is notified to interested compilation
@@ -25,17 +23,7 @@
* @noinstantiate This class is not intended to be instantiated by clients.
* @noextend This class is not intended to be subclassed by clients.
*/
-public class BuildContext extends CompilationParticipantResult {
-
-/**
- * Creates a build context for the given source file.
- *
- * @param sourceFile the source file being built
- * @noreference This constructor is not intended to be called by clients.
- */
-public BuildContext(SourceFile sourceFile) {
- super(sourceFile);
-}
+public class BuildContext {
/**
* Returns the contents of the compilation unit.
@@ -43,7 +31,7 @@
* @return the contents of the compilation unit
*/
public char[] getContents() {
- return this.sourceFile.getContents();
+ return null; // default overridden by concrete implementation
}
/**
@@ -52,7 +40,7 @@
* @return the IFile
representing the compilation unit
*/
public IFile getFile() {
- return this.sourceFile.resource;
+ return null; // default overridden by concrete implementation
}
/**
@@ -63,7 +51,7 @@
* @return whether the compilation unit contained any annotations when it was compiled
*/
public boolean hasAnnotations() {
- return this.hasAnnotations; // only set during processAnnotations
+ return false; // default overridden by concrete implementation
}
/**
@@ -72,15 +60,7 @@
* @param addedGeneratedFiles the added/changed files
*/
public void recordAddedGeneratedFiles(IFile[] addedGeneratedFiles) {
- int length2 = addedGeneratedFiles.length;
- if (length2 == 0) return;
-
- int length1 = this.addedFiles == null ? 0 : this.addedFiles.length;
- IFile[] merged = new IFile[length1 + length2];
- if (length1 > 0) // always make a copy even if currently empty
- System.arraycopy(this.addedFiles, 0, merged, 0, length1);
- System.arraycopy(addedGeneratedFiles, 0, merged, length1, length2);
- this.addedFiles = merged;
+ // default overridden by concrete implementation
}
/**
@@ -89,15 +69,7 @@
* @param deletedGeneratedFiles the files that need to be deleted
*/
public void recordDeletedGeneratedFiles(IFile[] deletedGeneratedFiles) {
- int length2 = deletedGeneratedFiles.length;
- if (length2 == 0) return;
-
- int length1 = this.deletedFiles == null ? 0 : this.deletedFiles.length;
- IFile[] merged = new IFile[length1 + length2];
- if (length1 > 0) // always make a copy even if currently empty
- System.arraycopy(this.deletedFiles, 0, merged, 0, length1);
- System.arraycopy(deletedGeneratedFiles, 0, merged, length1, length2);
- this.deletedFiles = merged;
+ // default overridden by concrete implementation
}
/**
@@ -106,15 +78,7 @@
* @param typeNameDependencies the fully-qualified type names of new dependencies
*/
public void recordDependencies(String[] typeNameDependencies) {
- int length2 = typeNameDependencies.length;
- if (length2 == 0) return;
-
- int length1 = this.dependencies == null ? 0 : this.dependencies.length;
- String[] merged = new String[length1 + length2];
- if (length1 > 0) // always make a copy even if currently empty
- System.arraycopy(this.dependencies, 0, merged, 0, length1);
- System.arraycopy(typeNameDependencies, 0, merged, length1, length2);
- this.dependencies = merged;
+ // default overridden by concrete implementation
}
/**
@@ -125,15 +89,7 @@
* @param newProblems the problems to report
*/
public void recordNewProblems(CategorizedProblem[] newProblems) {
- int length2 = newProblems.length;
- if (length2 == 0) return;
-
- int length1 = this.problems == null ? 0 : this.problems.length;
- CategorizedProblem[] merged = new CategorizedProblem[length1 + length2];
- if (length1 > 0) // always make a copy even if currently empty
- System.arraycopy(this.problems, 0, merged, 0, length1);
- System.arraycopy(newProblems, 0, merged, length1, length2);
- this.problems = merged;
+ // default overridden by concrete implementation
}
}