]> source.dussan.org Git - aspectj.git/commitdiff
more jdt like handle fixes
authoraclement <aclement>
Wed, 17 Sep 2008 17:15:36 +0000 (17:15 +0000)
committeraclement <aclement>
Wed, 17 Sep 2008 17:15:36 +0000 (17:15 +0000)
tests/model/expected/pr160469_1.txt
tests/multiIncremental/AdviceHandles/base/src/Handles.aj [new file with mode: 0644]
tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestOutputLocationManager.java
tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java

index 0a33af51bbe148f6797ed6bb2f98b694d4c25f24..7a0d9085052039a8e679ea51b2dd354fa51f9f76 100644 (file)
@@ -15,9 +15,9 @@
 === END OF MODEL REPORT =========
 === RELATIONSHIPS REPORT ========= After a batch build
 (targets=1) <pkg[AbstractBeanConfigurerAspect.class (binary)}AbstractBeanConfigurerAspect&afterReturning (advises) <test{Simple.java[Simple~Simple
-(targets=1) <pkg[AbstractBeanConfigurerAspect.class (binary)}AbstractBeanConfigurerAspect&before!2 (advises) <test{Simple.java[Simple~Simple
+(targets=1) <pkg[AbstractBeanConfigurerAspect.class (binary)}AbstractBeanConfigurerAspect&before (advises) <test{Simple.java[Simple~Simple
 (targets=2) <test{Simple.java[Simple~Simple (advised by) <pkg[AbstractBeanConfigurerAspect.class (binary)}AbstractBeanConfigurerAspect&afterReturning
-(targets=2) <test{Simple.java[Simple~Simple (advised by) <pkg[AbstractBeanConfigurerAspect.class (binary)}AbstractBeanConfigurerAspect&before!2
+(targets=2) <test{Simple.java[Simple~Simple (advised by) <pkg[AbstractBeanConfigurerAspect.class (binary)}AbstractBeanConfigurerAspect&before
 === END OF RELATIONSHIPS REPORT ==
 === Properties of the model and relationships map =====
 import reference=2
diff --git a/tests/multiIncremental/AdviceHandles/base/src/Handles.aj b/tests/multiIncremental/AdviceHandles/base/src/Handles.aj
new file mode 100644 (file)
index 0000000..ffb9aef
--- /dev/null
@@ -0,0 +1,45 @@
+package spacewar;
+
+//=Spacewar Example/src<spacewar*Handles.aj}Handles
+public aspect Handles {
+
+       // =Spacewar Example/src<spacewar*Handles.aj}Handles&before
+       before() : execution(* *..*()) {
+               
+       }
+       // =Spacewar Example/src<spacewar*Handles.aj}Handles&before!2
+       before() : execution(* *..*()) {
+               
+       }
+       // =Spacewar Example/src<spacewar*Handles.aj}Handles&before&I
+       before(int x) : execution(* *..*(int)) && args(x) {
+               
+       }
+       
+       // =Spacewar Example/src<spacewar*Handles.aj}Handles&before&I!2
+       before(int x) : execution(* *..*(int)) && args(x) {
+               
+       }
+
+       // =Spacewar Example/src<spacewar*Handles.aj}Handles&after
+       after() : execution(* *..*()) {
+               
+       }
+       
+       // =Spacewar Example/src<spacewar*Handles.aj}Handles&afterReturning
+       after() returning() : execution(* *..*()) {
+               
+       }
+
+       // =Spacewar Example/src<spacewar*Handles.aj}Handles&afterThrowing
+       after() throwing(): execution(* *..*()) {
+               
+       }
+
+       // =Spacewar Example/src<spacewar*Handles.aj}Handles&afterThrowing&I
+       after(int x) throwing(): execution(* *..*(int)) && args(x) {
+               
+       }
+
+}
+
index 9d07d1ec77fde2a6b78476ec01cacb8554ad375b..dcaab43b6ae396dc12a9ef9cf52093490528cd6b 100644 (file)
@@ -11,6 +11,7 @@
 package org.aspectj.systemtest.incremental.tools;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -77,7 +78,13 @@ public class MultiProjTestOutputLocationManager implements IOutputLocationManage
        }
        
        public void setSourceFolderFor(File sourceFile,String sourceFolder) {
-               sourceFolders.put(sourceFile.getPath(),sourceFolder);
+               try {
+                       System.out.println("Stored against "+sourceFile.getCanonicalPath());
+                       sourceFolders.put(sourceFile.getCanonicalPath(),sourceFolder);
+               } catch (IOException e) {
+                       e.printStackTrace();
+                       throw new RuntimeException(e);
+               }
        }
        
        public void setOutputLocForResource(File f) {
@@ -85,8 +92,14 @@ public class MultiProjTestOutputLocationManager implements IOutputLocationManage
        }
 
        public String getSourceFolderForFile(File sourceFile) {
-               String f = (String)sourceFolders.get(sourceFile.getPath());
-               return f;
+               try {
+                       System.out.println("Looked up against "+sourceFile.getCanonicalPath());
+                       String f = (String)sourceFolders.get(sourceFile.getCanonicalPath());
+                       return f;
+               } catch (IOException e) {
+                       e.printStackTrace();
+                       throw new RuntimeException(e);
+               }
        }
 
 }
index 6f143541d7dda4c1a035030d5285b7e0240c3314..6bf7a87f94547b25350acfdd97ad693734cf7a51 100644 (file)
@@ -33,6 +33,7 @@ import org.aspectj.asm.IRelationshipMap;
 import org.aspectj.asm.internal.JDTLikeHandleProvider;
 import org.aspectj.asm.internal.Relationship;
 import org.aspectj.bridge.IMessage;
+import org.aspectj.bridge.SourceLocation;
 import org.aspectj.tools.ajc.Ajc;
 import org.aspectj.util.FileUtil;
 
@@ -185,6 +186,62 @@ public class MultiProjectIncrementalTests extends
                dumptree(AsmManager.getDefault().getHierarchy().getRoot(), 0);
                // incomplete
        }
+       
+       public void testAdviceHandlesAreJDTCompatible() {
+               String p = "AdviceHandles";
+               initialiseProject(p);
+               addSourceFolderForSourceFile(p, getProjectRelativePath(p, "src/Handles.aj"), "src");
+               build(p);
+               IProgramElement root = AsmManager.getDefault().getHierarchy().getRoot();
+               IProgramElement typeDecl = findElementAtLine(root,4);
+               assertEquals("=AdviceHandles/src<spacewar*Handles.aj}Handles",typeDecl.getHandleIdentifier());
+               
+               IProgramElement advice1 = findElementAtLine(root,7);
+               assertEquals("=AdviceHandles/src<spacewar*Handles.aj}Handles&before",advice1.getHandleIdentifier());
+
+               IProgramElement advice2 = findElementAtLine(root,11);
+               assertEquals("=AdviceHandles/src<spacewar*Handles.aj}Handles&before!2",advice2.getHandleIdentifier());
+               
+               IProgramElement advice3 = findElementAtLine(root,15);
+               assertEquals("=AdviceHandles/src<spacewar*Handles.aj}Handles&before&I",advice3.getHandleIdentifier());
+               
+               IProgramElement advice4 = findElementAtLine(root,20);
+               assertEquals("=AdviceHandles/src<spacewar*Handles.aj}Handles&before&I!2",advice4.getHandleIdentifier());
+
+               IProgramElement advice5 = findElementAtLine(root,25);
+               assertEquals("=AdviceHandles/src<spacewar*Handles.aj}Handles&after",advice5.getHandleIdentifier());
+
+               IProgramElement advice6 = findElementAtLine(root,30);
+               assertEquals("=AdviceHandles/src<spacewar*Handles.aj}Handles&afterReturning",advice6.getHandleIdentifier());
+
+               IProgramElement advice7 = findElementAtLine(root,35);
+               assertEquals("=AdviceHandles/src<spacewar*Handles.aj}Handles&afterThrowing",advice7.getHandleIdentifier());
+
+               IProgramElement advice8 = findElementAtLine(root,40);
+               assertEquals("=AdviceHandles/src<spacewar*Handles.aj}Handles&afterThrowing&I",advice8.getHandleIdentifier());
+
+       }
+       
+       private IProgramElement findElementAtLine(IProgramElement whereToLook, int line) {
+               if (whereToLook == null) {
+                       return null;
+               }
+               if (whereToLook.getSourceLocation()!=null && whereToLook.getSourceLocation().getLine()==line) {
+                       return whereToLook;
+               }
+               List kids = whereToLook.getChildren();
+               for (Iterator iterator = kids.iterator(); iterator.hasNext();) {
+                       IProgramElement object = (IProgramElement) iterator.next();
+                       if (object.getSourceLocation()!=null && object.getSourceLocation().getLine()==line) {
+                               return object;
+                       }
+                       IProgramElement gotSomething = findElementAtLine(object,line);
+                       if (gotSomething!=null) {
+                               return gotSomething;
+                       }
+               }
+               return null;            
+       }
 
        public void testModelWithMultipleSourceFolders() {
                initialiseProject("MultiSource");