aboutsummaryrefslogtreecommitdiffstats
path: root/org.aspectj.ajdt.core
diff options
context:
space:
mode:
authoraclement <aclement>2005-11-28 12:58:59 +0000
committeraclement <aclement>2005-11-28 12:58:59 +0000
commitbcabce0283aec3c44a99000b3970bd880fee72a0 (patch)
tree0b6ffe6c61b74fde737a60fb03de144582705392 /org.aspectj.ajdt.core
parent508dbcbc90bc7526fc8cef9fe924a97c166e5a0e (diff)
downloadaspectj-bcabce0283aec3c44a99000b3970bd880fee72a0.tar.gz
aspectj-bcabce0283aec3c44a99000b3970bd880fee72a0.zip
test and fix for 112736
Diffstat (limited to 'org.aspectj.ajdt.core')
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AbstractStateListener.java35
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java34
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/IStateListener.java6
3 files changed, 75 insertions, 0 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AbstractStateListener.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AbstractStateListener.java
new file mode 100644
index 000000000..b92f806e7
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AbstractStateListener.java
@@ -0,0 +1,35 @@
+/**
+ * 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) { }
+
+}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java
index 4e9c5552e..613b2baf5 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java
@@ -38,6 +38,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFormatExcepti
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;
@@ -147,11 +148,44 @@ public class AjState {
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);
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/IStateListener.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/IStateListener.java
index 6739aa958..f88501a83 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/IStateListener.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/IStateListener.java
@@ -32,6 +32,12 @@ public interface IStateListener {
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);