]> source.dussan.org Git - aspectj.git/commitdiff
231396: refactoring: removed WeaverMetrics/LTWeaver, changed UnwovenClassFile to...
authoraclement <aclement>
Tue, 13 May 2008 17:40:13 +0000 (17:40 +0000)
committeraclement <aclement>
Tue, 13 May 2008 17:40:13 +0000 (17:40 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/InterimCompilationResult.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/WeaverAdapter.java

index 0319a240c5b0bd2c265bb789aee0b448834f9bc6..8111238c77a598211c78e3d0d7a080acf0dcb3d8 100644 (file)
@@ -40,7 +40,7 @@ public class InterimCompilationResult {
                for (int i=0; i < ucfList.size(); i++) {
                        UnwovenClassFile element = (UnwovenClassFile) ucfList.get(i);
                        unwovenClassFiles[i] = element;
-                       AjClassFile ajcf = new AjClassFile(element.getClassName().replace('.', '/').toCharArray(),
+                       AjClassFile ajcf = new AjClassFile(element.getClassNameAsChars(),
                                                                                           element.getBytes());
                        result.record(ajcf.fileName(),ajcf); 
                }               
index 6ec34ab778f7eaa12cf9fa76eab6bb9fc4d4dedc..6d1e267d6d41438a5627ef14cbd1fce13c1553e4 100644 (file)
@@ -13,6 +13,8 @@ package org.aspectj.ajdt.internal.compiler;
 import java.util.Iterator;
 import java.util.Map;
 
+import org.aspectj.asm.internal.CharOperation;
+import org.aspectj.bridge.IMessage;
 import org.aspectj.bridge.IProgressListener;
 import org.aspectj.bridge.MessageUtil;
 import org.aspectj.org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
@@ -170,6 +172,7 @@ public class WeaverAdapter implements IClassFileProvider, IWeaveRequestor, Itera
                if ((lastReturnedResult != null) && (!lastReturnedResult.result().hasBeenAccepted)) {
                        finishedWith(lastReturnedResult);
                }
+               lastReturnedResult=null;
        }
        
 
@@ -178,30 +181,29 @@ public class WeaverAdapter implements IClassFileProvider, IWeaveRequestor, Itera
         * @see org.aspectj.weaver.IWeaveRequestor#acceptResult(org.aspectj.weaver.bcel.UnwovenClassFile)
         */
        public void acceptResult(UnwovenClassFile result) {
-               char[] key = result.getClassName().replace('.','/').toCharArray();
-               removeFromMap(lastReturnedResult.result().compiledTypes,key);
-               String className = result.getClassName().replace('.', '/');
-               AjClassFile ajcf = new AjClassFile(className.toCharArray(),
-                                                                                  result.getBytes());
+               char[] key = result.getClassNameAsChars();
+               removeFromMap(lastReturnedResult.result().compiledTypes, key);
+               AjClassFile ajcf = new AjClassFile(key, result.getBytes());
                lastReturnedResult.result().record(ajcf.fileName(),ajcf);
-               //System.err.println(progressPhasePrefix+result.getClassName()+" (from "+nowProcessing.fileName()+")");
-        StringBuffer msg = new StringBuffer();
-        msg.append(progressPhasePrefix).append(result.getClassName()).append(" (from ").append(nowProcessing.fileName()).append(")");
-        weaverMessageHandler.handleMessage(MessageUtil.info(msg.toString()));
-               if (progressListener != null) {
-                       progressCompletionCount++;
-                       
-                       // Smoothly take progress from 'fromPercent' to 'toPercent'
-                       recordProgress(
-                         fromPercent
-                         +((progressCompletionCount/(double)progressMaxTypes)*(toPercent-fromPercent)),
-                         msg.toString());
-            // progressPhasePrefix+result.getClassName()+" (from "+nowProcessing.fileName()+")");
-
-                       if (progressListener.isCancelledRequested()) {
-                     throw new AbortCompilation(true,new OperationCanceledException("Weaving cancelled as requested"));
+        if (!weaverMessageHandler.isIgnoring(IMessage.INFO) || progressListener!=null) {
+               StringBuffer msg = new StringBuffer();
+               msg.append(progressPhasePrefix).append(result.getClassName()).append(" (from ").append(nowProcessing.fileName()).append(")");
+               weaverMessageHandler.handleMessage(MessageUtil.info(msg.toString()));
+                       if (progressListener != null) {
+                               progressCompletionCount++;
+                               
+                               // Smoothly take progress from 'fromPercent' to 'toPercent'
+                               recordProgress(
+                                 fromPercent
+                                 +((progressCompletionCount/(double)progressMaxTypes)*(toPercent-fromPercent)),
+                                 msg.toString());
+                   // progressPhasePrefix+result.getClassName()+" (from "+nowProcessing.fileName()+")");
+       
+                               if (progressListener.isCancelledRequested()) {
+                             throw new AbortCompilation(true,new OperationCanceledException("Weaving cancelled as requested"));
+                               }
                        }
-               }
+        }
        }
 
        // helpers...
@@ -211,21 +213,28 @@ public class WeaverAdapter implements IClassFileProvider, IWeaveRequestor, Itera
                compilerAdapter.acceptResult(result.result());
        }
        
-       private void removeFromMap(Map aMap, char[] key) {
+       private boolean removeFromMap(Map aMap, char[] key) {
                // jdt uses char[] as a key in the hashtable, which is not very useful as equality is based on being
                // the same array, not having the same content.
-               String skey = new String(key);
+//             String skey = new String(key);
+               // OPTIMIZE what is this code for?
+               if (aMap.remove(key)!=null) {
+                       return true;
+               }
                char[] victim = null;
                for (Iterator iter = aMap.keySet().iterator(); iter.hasNext();) {
                        char[] thisKey = (char[]) iter.next();
-                       if (skey.equals(new String(thisKey))) {
+                       if (CharOperation.equals(thisKey,key)) {
+//                     if (skey.equals(new String(thisKey))) {
                                victim = thisKey;
                                break;
                        }
                }
                if (victim != null) {
                        aMap.remove(victim);
+                       return true;
                }
+               return false;
        }
        
        private void recordProgress(String message) {