summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoraclement <aclement>2008-09-17 17:15:36 +0000
committeraclement <aclement>2008-09-17 17:15:36 +0000
commit3da59f2a4d5f426b2b34335076d8a2c06d74914e (patch)
treed001423b9a7080821e47a79484296fda6ecdfe89 /tests
parent282ba8f92b8c1c6061ae8e5fdd06a76b3d1b6801 (diff)
downloadaspectj-3da59f2a4d5f426b2b34335076d8a2c06d74914e.tar.gz
aspectj-3da59f2a4d5f426b2b34335076d8a2c06d74914e.zip
more jdt like handle fixes
Diffstat (limited to 'tests')
-rw-r--r--tests/model/expected/pr160469_1.txt4
-rw-r--r--tests/multiIncremental/AdviceHandles/base/src/Handles.aj45
-rw-r--r--tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestOutputLocationManager.java19
-rw-r--r--tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java57
4 files changed, 120 insertions, 5 deletions
diff --git a/tests/model/expected/pr160469_1.txt b/tests/model/expected/pr160469_1.txt
index 0a33af51b..7a0d90850 100644
--- a/tests/model/expected/pr160469_1.txt
+++ b/tests/model/expected/pr160469_1.txt
@@ -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
index 000000000..ffb9aef42
--- /dev/null
+++ b/tests/multiIncremental/AdviceHandles/base/src/Handles.aj
@@ -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) {
+
+ }
+
+}
+
diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestOutputLocationManager.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestOutputLocationManager.java
index 9d07d1ec7..dcaab43b6 100644
--- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestOutputLocationManager.java
+++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestOutputLocationManager.java
@@ -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);
+ }
}
}
diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java
index 6f143541d..6bf7a87f9 100644
--- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java
+++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java
@@ -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");