]> source.dussan.org Git - aspectj.git/commitdiff
chewed by formatter
authoraclement <aclement>
Thu, 4 Sep 2008 19:08:10 +0000 (19:08 +0000)
committeraclement <aclement>
Thu, 4 Sep 2008 19:08:10 +0000 (19:08 +0000)
asm/src/org/aspectj/asm/AsmManager.java
asm/src/org/aspectj/asm/IRelationship.java
asm/src/org/aspectj/asm/internal/CharOperation.java
asm/src/org/aspectj/asm/overview.html [deleted file]

index 5f47f958bb7654117ce1322386c5b3ec64124104..2d51f6358eeae6f4d155f01a223163f2f160b2a1 100644 (file)
@@ -50,24 +50,11 @@ import org.aspectj.bridge.ISourceLocation;
  */
 public class AsmManager {
 
-       /**
-        * @deprecated use getDefault() method instead
-        */
-       private static AsmManager INSTANCE = new AsmManager();
+       private static AsmManager instance = new AsmManager();
 
        private IElementHandleProvider handleProvider;
        private List structureListeners = new ArrayList();
 
-       // private boolean shouldSaveModel = true;
-
-       public void setRelationshipMap(IRelationshipMap irm) {
-               mapper = irm;
-       }
-
-       public void setHierarchy(IHierarchy ih) {
-               hierarchy = ih;
-       }
-
        // The model is 'manipulated' by the AjBuildManager.setupModel() code which trashes all the
        // fields when setting up a new model for a batch build.
        // Due to the requirements of incremental compilation we need to tie some of the info
@@ -90,6 +77,9 @@ public class AsmManager {
        private static boolean reporting = false;
 
        private static boolean completingTypeBindings = false;
+       private CanonicalFilePathMap canonicalFilePathMap = new CanonicalFilePathMap();
+       // Record the Set<File> for which the model has been modified during the last incremental build
+       private Set lastBuildChanges = new HashSet();
 
        // static {
        // setReporting("c:/model.nfo",true,true,true,true);
@@ -113,7 +103,7 @@ public class AsmManager {
        }
 
        public static AsmManager getDefault() {
-               return INSTANCE;
+               return instance;
        }
 
        public IRelationshipMap getRelationshipMap() {
@@ -207,9 +197,6 @@ public class AsmManager {
                this.handleProvider = handleProvider;
        }
 
-       /**
-        * Fails silently.
-        */
        public void writeStructureModel(String configFilePath) {
                try {
                        String filePath = genExternFilePath(configFilePath);
@@ -228,7 +215,6 @@ public class AsmManager {
        }
 
        /**
-        * @todo add proper handling of bad paths/suffixes/etc
         * @param configFilePath path to an ".lst" file
         */
        public void readStructureModel(String configFilePath) {
@@ -272,29 +258,10 @@ public class AsmManager {
                return configFilePath + ".ajsym";
        }
 
-       // public void setShouldSaveModel(boolean shouldSaveModel) {
-       // this.shouldSaveModel = shouldSaveModel;
-       // }
-
-       // ==== implementation of canonical file path map and accessors ==============
-
-       // a more sophisticated optimisation is left here commented out as the
-       // performance gains don't justify the disturbance this close to a release...
-       // can't call prepareForWeave until preparedForCompilation has completed...
-       // public synchronized void prepareForCompilation(List files) {
-       // canonicalFilePathMap.prepopulate(files);
-       // }
-       //      
-       // public synchronized void prepareForWeave() {
-       // canonicalFilePathMap.handover();
-       // }
-
        public String getCanonicalFilePath(File f) {
                return canonicalFilePathMap.get(f);
        }
 
-       private CanonicalFilePathMap canonicalFilePathMap = new CanonicalFilePathMap();
-
        private static class CanonicalFilePathMap {
                private static final int MAX_SIZE = 4000;
 
@@ -558,6 +525,7 @@ public class AsmManager {
                                        fw.write("Deleting " + progElem + " node for file " + fileForCompilation + "\n");
                                }
                                removeNode(progElem);
+                               lastBuildChanges.add(fileForCompilation);
                                deletedNodes.add(getCanonicalFilePath(progElem.getSourceLocation().getSourceFile()));
                                if (!model.removeFromFileMap(correctedPath))
                                        throw new RuntimeException("Whilst repairing model, couldn't remove entry for file: " + correctedPath
@@ -1169,4 +1137,23 @@ public class AsmManager {
                return completingTypeBindings;
        }
 
+       public void setRelationshipMap(IRelationshipMap irm) {
+               mapper = irm;
+       }
+
+       public void setHierarchy(IHierarchy ih) {
+               hierarchy = ih;
+       }
+
+       public void resetDeltaProcessing() {
+               lastBuildChanges.clear();
+       }
+
+       /**
+        * @return the Set of files for which the structure model was modified (they may have been removed or otherwise rebuilt)
+        */
+       public Set getModelChangesOnLastBuild() {
+               return lastBuildChanges;
+       }
+
 }
index b8c06a567fc76019e0cb25d0750440ac861292b3..d71a5f2b7077ad257b484405cdeca3b5d7e41d42 100644 (file)
@@ -11,7 +11,8 @@
  * ******************************************************************/
 package org.aspectj.asm;
 
-import java.io.*;
+import java.io.ObjectStreamException;
+import java.io.Serializable;
 import java.util.List;
 
 /**
@@ -20,64 +21,61 @@ import java.util.List;
 public interface IRelationship extends Serializable {
 
        public String getName();
-       
-       public List/*String*/ getTargets();
-       
+
+       public List/* String */getTargets();
+
        public String getSourceHandle();
-       
+
        public void addTarget(String handle);
-       
+
        public Kind getKind();
-       
+
        public boolean hasRuntimeTest();
-               
+
+       public boolean isAffects();
+
        public static class Kind implements Serializable { // typesafe enum
-               
+
                private static final long serialVersionUID = -2691351740214705220L;
-               
-               public static final Kind DECLARE_WARNING       = new Kind("declare warning");
-        public static final Kind DECLARE_ERROR         = new Kind("declare error");
-               public static final Kind ADVICE_AROUND         = new Kind("around advice");
+
+               public static final Kind DECLARE_WARNING = new Kind("declare warning");
+               public static final Kind DECLARE_ERROR = new Kind("declare error");
+               public static final Kind ADVICE_AROUND = new Kind("around advice");
                public static final Kind ADVICE_AFTERRETURNING = new Kind("after returning advice");
-               public static final Kind ADVICE_AFTERTHROWING  = new Kind("after throwing advice");
-               public static final Kind ADVICE_AFTER          = new Kind("after advice");
-               public static final Kind ADVICE_BEFORE         = new Kind("before advice");
-               public static final Kind ADVICE                = new Kind("advice");
-               public static final Kind DECLARE               = new Kind("declare");
-        public static final Kind DECLARE_INTER_TYPE    = new Kind("inter-type declaration");
-               public static final Kind USES_POINTCUT           = new Kind("uses pointcut");
-        public static final Kind DECLARE_SOFT          = new Kind("declare soft");
-               
-               public static final Kind[] ALL = { 
-                       DECLARE_WARNING, DECLARE_ERROR,
-                       ADVICE_AROUND,ADVICE_AFTERRETURNING,ADVICE_AFTERTHROWING,ADVICE_AFTER,ADVICE_BEFORE,
-                       ADVICE, DECLARE, DECLARE_INTER_TYPE, USES_POINTCUT, DECLARE_SOFT };
-                       
+               public static final Kind ADVICE_AFTERTHROWING = new Kind("after throwing advice");
+               public static final Kind ADVICE_AFTER = new Kind("after advice");
+               public static final Kind ADVICE_BEFORE = new Kind("before advice");
+               public static final Kind ADVICE = new Kind("advice");
+               public static final Kind DECLARE = new Kind("declare");
+               public static final Kind DECLARE_INTER_TYPE = new Kind("inter-type declaration");
+               public static final Kind USES_POINTCUT = new Kind("uses pointcut");
+               public static final Kind DECLARE_SOFT = new Kind("declare soft");
+
+               public static final Kind[] ALL = { DECLARE_WARNING, DECLARE_ERROR, ADVICE_AROUND, ADVICE_AFTERRETURNING,
+                               ADVICE_AFTERTHROWING, ADVICE_AFTER, ADVICE_BEFORE, ADVICE, DECLARE, DECLARE_INTER_TYPE, USES_POINTCUT, DECLARE_SOFT };
+
                private final String name;
-               
+
                public boolean isDeclareKind() {
-                       return this == DECLARE_WARNING
-                               || this == DECLARE_ERROR
-                               || this == DECLARE
-                               || this == DECLARE_INTER_TYPE
-                               || this == DECLARE_SOFT;
+                       return this == DECLARE_WARNING || this == DECLARE_ERROR || this == DECLARE || this == DECLARE_INTER_TYPE
+                                       || this == DECLARE_SOFT;
                }
-               
+
                private Kind(String name) {
-                       this.name = name; 
+                       this.name = name;
                }
-               
+
                public String toString() {
                        return name;
-               }       
+               }
 
                // The 4 declarations below are necessary for serialization
                private static int nextOrdinal = 0;
                private final int ordinal = nextOrdinal++;
+
                private Object readResolve() throws ObjectStreamException {
                        return ALL[ordinal];
                }
        }
 
-       public boolean isAffects();
 }
index 6432c3a88a82f6fdb51ecac5399fec2d2da6fca2..71ae5cafe30cc558c1316f2d3549a0c529bf9349 100644 (file)
  *******************************************************************/
 package org.aspectj.asm.internal;
 
-
 /**
  * Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation
- *
+ * 
  */
 public class CharOperation {
-       
+
        /**
         * Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation
-        */     
+        */
        public static final char[] subarray(char[] array, int start, int end) {
                if (end == -1)
                        end = array.length;
@@ -34,40 +33,30 @@ public class CharOperation {
                System.arraycopy(array, start, result, 0, end - start);
                return result;
        }
-       
+
        /**
         * Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation
-        */     
+        */
        public static final int lastIndexOf(char toBeFound, char[] array) {
                for (int i = array.length; --i >= 0;)
                        if (toBeFound == array[i])
                                return i;
                return -1;
        }
-       
-//     /**
-//      * Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation
-//      */     
-//     public static final boolean contains(char character, char[] array) {
-//             for (int i = array.length; --i >= 0;)
-//                     if (array[i] == character)
-//                             return true;
-//             return false;
-//     }
 
        /**
         * Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation
-        */     
+        */
        public static final int indexOf(char toBeFound, char[] array) {
                for (int i = 0; i < array.length; i++)
                        if (toBeFound == array[i])
                                return i;
                return -1;
        }
-       
+
        /**
         * Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation
-        */     
+        */
        public static final char[] concat(char[] first, char[] second) {
                if (first == null)
                        return second;
@@ -81,10 +70,10 @@ public class CharOperation {
                System.arraycopy(second, 0, result, length1, length2);
                return result;
        }
-       
+
        /**
         * Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation
-        */     
+        */
        public static final boolean equals(char[] first, char[] second) {
                if (first == second)
                        return true;
@@ -98,14 +87,11 @@ public class CharOperation {
                                return false;
                return true;
        }
-       
+
        /**
         * Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation
-        */     
-       public static final void replace(
-               char[] array,
-               char toBeReplaced,
-               char replacementChar) {
+        */
+       public static final void replace(char[] array, char toBeReplaced, char replacementChar) {
                if (toBeReplaced != replacementChar) {
                        for (int i = 0, max = array.length; i < max; i++) {
                                if (array[i] == toBeReplaced)
diff --git a/asm/src/org/aspectj/asm/overview.html b/asm/src/org/aspectj/asm/overview.html
deleted file mode 100644 (file)
index 3c5f614..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<p>
-</p>
-<p><b>Notes on using the Abstract Structure Model (ASM)</b></p>
-<ul>
-       <li>The ASM contains the declaration hierarchy up to the member signature 
-       level of granularity. In the case that an sub-method element is advised 
-       (e.g. a call site, field get/set, or exception handler) the advised element 
-       will also be present as a child of that member.</li>
-       <li>The structure model is built during the compilation process, after advice planning is done and before bytecodes are produced.  Here are the method calls involved with compiling and getting the model.  The org.aspectj.asm package contains the structure model APIs.
-  Ajde.getDefault().getConfigurationManager().setActiveConfigFile("foo.lst");
-Ajde.getDefault().getBuildManager().build(); Ajde.getDefault().getStructureModelManager().getStructureModel(); 
-<li>
-For examples of how to walk the model take a look at StructureModelTest in the test sources of the org.aspectj.ajde package.
-<li>
-If you're interested in being notified of when the model has been updated (i.e. when the user completed a compile) you can register a new listener with by calling the StructureModelManager.addListener method in the org.aspectj.asm package.  The org.aspectj.ajde package also has an API for creating views of the model, and you can look to the any IDE plug-in to see how they are used.  
-</ul>