--- /dev/null
+/**
+ * Copyright (c) 2005 IBM and other contributors
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Common Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Andy Clement initial implementation
+ * ******************************************************************/
+package org.aspectj.ajdt.internal.core.builder;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * Subtypes can override whatever they want...
+ *
+ * @author AndyClement
+ *
+ */
+public abstract class AbstractStateListener implements IStateListener {
+
+ public void detectedClassChangeInThisDir(File f) { }
+
+ public void aboutToCompareClasspaths(List oldClasspath, List newClasspath) { }
+
+ public void pathChangeDetected() { }
+
+ public void detectedAspectDeleted(File f) { }
+
+ public void buildSuccessful(boolean wasFullBuild) { }
+
+}
import org.aspectj.org.eclipse.jdt.internal.core.builder.ReferenceCollection;
import org.aspectj.org.eclipse.jdt.internal.core.builder.StringSet;
import org.aspectj.util.FileUtil;
+import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.bcel.BcelWeaver;
import org.aspectj.weaver.bcel.BcelWorld;
import org.aspectj.weaver.bcel.UnwovenClassFile;
addedBinaryFiles.removeAll(oldBinaryFiles);
deletedBinaryFiles = new HashSet(oldBinaryFiles);
deletedBinaryFiles.removeAll(newBinaryFiles);
+
+ boolean couldStillBeIncremental = processDeletedFiles(deletedFiles);
+
+ if (!couldStillBeIncremental) return false;
this.newBuildConfig = newBuildConfig;
return true;
}
+
+ /**
+ * Checks if any of the files in the set passed in contains an aspect declaration. If one is found
+ * then we start the process of batch building, i.e. we remove all the results of the last build,
+ * call any registered listener to tell them whats happened and return false.
+ *
+ * @return false if we discovered an aspect declaration
+ */
+ private boolean processDeletedFiles(Set deletedFiles) {
+ for (Iterator iter = deletedFiles.iterator(); iter.hasNext();) {
+ File aDeletedFile = (File ) iter.next();
+ InterimCompilationResult cr = (InterimCompilationResult)resultsFromFile.get(aDeletedFile);
+ if (cr!=null) {
+ Map compiledTypes = cr.result().compiledTypes;
+ if (compiledTypes!=null) {
+ for (Iterator iterator = compiledTypes.keySet().iterator(); iterator.hasNext();) {
+ char[] className = (char[])iterator.next();
+ ResolvedType rt = world.resolve(new String(className).replace('/','.'));
+ if (rt.isAspect()) {
+ removeAllResultsOfLastBuild();
+ if (stateListener!=null) stateListener.detectedAspectDeleted(aDeletedFile);
+ return false;
+ }
+ }
+ }
+ }
+ }
+ return true;
+ }
private Collection getModifiedFiles() {
return getModifiedFiles(lastSuccessfulBuildTime);
public void aboutToCompareClasspaths(List oldClasspath, List newClasspath);
public void pathChangeDetected();
+
+ /**
+ * Called if state processing detects a file was deleted that contained an aspect declaration.
+ * Incremental compilation will not be attempted if this occurs.
+ */
+ public void detectedAspectDeleted(File f);
public void buildSuccessful(boolean wasFullBuild);
import junit.framework.Test;
+import org.aspectj.ajdt.internal.core.builder.AbstractStateListener;
import org.aspectj.ajdt.internal.core.builder.AjState;
-import org.aspectj.ajdt.internal.core.builder.IStateListener;
import org.aspectj.testing.XMLBasedAjcTestCase;
public class IncrementalTests extends org.aspectj.testing.XMLBasedAjcTestCase {
* being on the classpath. This test verifies the fix is OK
*/
public void testIncrementalOKWithOutputPathOnClasspath() throws Exception {
- class MyStateListener implements IStateListener {
+ class MyStateListener extends AbstractStateListener {
public boolean pathChange = false;
public void pathChangeDetected() {pathChange = true;}
public void aboutToCompareClasspaths(List oldClasspath, List newClasspath) {}
import org.aspectj.ajde.ErrorHandler;
import org.aspectj.ajde.ProjectPropertiesAdapter;
import org.aspectj.ajde.TaskListManager;
+import org.aspectj.ajdt.internal.core.builder.AbstractStateListener;
import org.aspectj.ajdt.internal.core.builder.AjState;
-import org.aspectj.ajdt.internal.core.builder.IStateListener;
import org.aspectj.ajdt.internal.core.builder.IncrementalStateManager;
import org.aspectj.asm.AsmManager;
import org.aspectj.bridge.IMessage;
}
}
- static class MyStateListener implements IStateListener {
+ static class MyStateListener extends AbstractStateListener {
private static MyStateListener _instance = new MyStateListener();
private MyStateListener() {reset();}
.getMessage());
}
-// public void testPr112736() {
-// AjdeInteractionTestbed.VERBOSE = true;
-// initialiseProject("PR112736");
-// build("PR112736");
-// checkWasFullBuild();
-// String fileC2 = getWorkingDir().getAbsolutePath() + File.separatorChar + "PR112736" + File.separatorChar + "src" + File.separatorChar + "pack" + File.separatorChar + "A.java";
-// (new File(fileC2)).delete();
-// alter("PR112736","inc1");
-// build("PR112736");
-// checkWasntFullBuild();
-// }
+ public void testPr112736() {
+ AjdeInteractionTestbed.VERBOSE = true;
+ initialiseProject("PR112736");
+ build("PR112736");
+ checkWasFullBuild();
+ String fileC2 = getWorkingDir().getAbsolutePath() + File.separatorChar + "PR112736" + File.separatorChar + "src" + File.separatorChar + "pack" + File.separatorChar + "A.java";
+ (new File(fileC2)).delete();
+ alter("PR112736","inc1");
+ build("PR112736");
+ checkWasFullBuild();
+ }
// other possible tests: