aboutsummaryrefslogtreecommitdiffstats
path: root/ajde
diff options
context:
space:
mode:
authormkersten <mkersten>2003-08-05 16:24:05 +0000
committermkersten <mkersten>2003-08-05 16:24:05 +0000
commit5594a6579a215af6f9db9c806f4e331ec6259136 (patch)
tree83de3d2a7967780c03221f3a1d53dd68c3dc2e39 /ajde
parent6c1ca40c54c11315aa5caadf23c8f439b26c41e4 (diff)
downloadaspectj-5594a6579a215af6f9db9c806f4e331ec6259136.tar.gz
aspectj-5594a6579a215af6f9db9c806f4e331ec6259136.zip
Revised and added tests for ASM containment hierarchy.
Diffstat (limited to 'ajde')
-rw-r--r--ajde/src/org/aspectj/ajde/ui/AbstractIconRegistry.java8
-rw-r--r--ajde/testdata/examples/coverage/ModelCoverage.java55
-rw-r--r--ajde/testdata/examples/coverage/coverage.ajsymbin12825 -> 19080 bytes
-rw-r--r--ajde/testsrc/org/aspectj/ajde/AjdeTestCase.java3
-rw-r--r--ajde/testsrc/org/aspectj/ajde/AjdeTests.java2
-rw-r--r--ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java141
-rw-r--r--ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java6
-rw-r--r--ajde/testsrc/org/aspectj/ajde/StructureModelTest.java6
8 files changed, 202 insertions, 19 deletions
diff --git a/ajde/src/org/aspectj/ajde/ui/AbstractIconRegistry.java b/ajde/src/org/aspectj/ajde/ui/AbstractIconRegistry.java
index 97bdf4622..1b281d1ed 100644
--- a/ajde/src/org/aspectj/ajde/ui/AbstractIconRegistry.java
+++ b/ajde/src/org/aspectj/ajde/ui/AbstractIconRegistry.java
@@ -107,7 +107,11 @@ public abstract class AbstractIconRegistry {
return ASPECT;
} else if (kind == ProgramElementNode.Kind.INITIALIZER) {
return INITIALIZER;
- } else if (kind == ProgramElementNode.Kind.INTRODUCTION) {
+ } else if (kind == ProgramElementNode.Kind.INTER_TYPE_CONSTRUCTOR) {
+ return INTRODUCTION;
+ } else if (kind == ProgramElementNode.Kind.INTER_TYPE_FIELD) {
+ return INTRODUCTION;
+ } else if (kind == ProgramElementNode.Kind.INTER_TYPE_METHOD) {
return INTRODUCTION;
} else if (kind == ProgramElementNode.Kind.CONSTRUCTOR) {
return CONSTRUCTOR;
@@ -127,6 +131,8 @@ public abstract class AbstractIconRegistry {
return DECLARE_ERROR;
} else if (kind == ProgramElementNode.Kind.DECLARE_SOFT) {
return DECLARE_SOFT;
+ } else if (kind == ProgramElementNode.Kind.DECLARE_PRECEDENCE) {
+ return DECLARE_SOFT;
} else if (kind == ProgramElementNode.Kind.CODE) {
return CODE;
} else if (kind == ProgramElementNode.Kind.ERROR) {
diff --git a/ajde/testdata/examples/coverage/ModelCoverage.java b/ajde/testdata/examples/coverage/ModelCoverage.java
index 81891abed..6fa3255d6 100644
--- a/ajde/testdata/examples/coverage/ModelCoverage.java
+++ b/ajde/testdata/examples/coverage/ModelCoverage.java
@@ -15,6 +15,11 @@ class Point {
public void setX(int x) { this.x = x; }
+ public int changeX(int x) {
+ this.x = x;
+ return x;
+ }
+
void doIt() {
try {
File f = new File(".");
@@ -27,6 +32,10 @@ class Point {
}
}
+class SubPoint extends Point { }
+
+class Line { }
+
aspect AdvisesRelationCoverage {
before(): execution(*..*.new(..)) { }
before(): get(int *.*) { }
@@ -40,27 +49,47 @@ aspect AdvisesRelationCoverage {
before(): within(*) && execution(Point.new()) { }
}
+aspect AdviceNamingCoverage {
+ pointcut named(): call(* *.mumble());
+ pointcut namedWithOneArg(int i): call(int Point.changeX(int)) && args(i);
+ pointcut namedWithArgs(int i, int j): set(int Point.x) && args(i, j);
+
+ after(): named() { }
+ after(int i, int j) returning: namedWithArgs(i, j) { }
+ after() throwing: named() { }
+ after(): named() { }
+
+ before(): named() { }
+
+ int around(int i): namedWithOneArg(i) { return i;}
+ int around(int i) throws SizeException: namedWithOneArg(i) { return proceed(i); }
+
+ before(): named() { }
+
+ before(): call(* *.mumble()) { }
+
+}
+
aspect InterTypeDecCoverage {
pointcut illegalNewFigElt(): call(Point.new(..)) && !withincode(* *.doIt(..));
- declare error: illegalNewFigElt():
- "Illegal figure element constructor call.";
-
- declare warning: illegalNewFigElt():
- "Illegal figure element constructor call.";
+ declare error: illegalNewFigElt(): "Illegal constructor call.";
+ declare warning: illegalNewFigElt(): "Illegal constructor call.";
declare parents: Point extends java.io.Serializable;
-
- declare parents: Point implements java.util.Observable;
-
- //declare soft: Point: call(* *(..));
-
- public String Point.getName() { return "xxx"; }
-
- public int Point.xxx = 0;
+ declare parents: Point+ implements java.util.Observable;
+ declare parents: Point && Line implements java.util.Observable;
+ declare soft: SizeException : call(* Point.getX());
+ declare precedence: AdviceCoverage, InterTypeDecCoverage, *;
+
+ public int Point.xxx = 0;
+ public int Point.check(int i, Line l) { return 1 + i; }
+// public Line.new(String s) { }
}
+class SizeException extends Exception { }
+
aspect AdviceCoverage {
}
diff --git a/ajde/testdata/examples/coverage/coverage.ajsym b/ajde/testdata/examples/coverage/coverage.ajsym
index 775161e48..324199378 100644
--- a/ajde/testdata/examples/coverage/coverage.ajsym
+++ b/ajde/testdata/examples/coverage/coverage.ajsym
Binary files differ
diff --git a/ajde/testsrc/org/aspectj/ajde/AjdeTestCase.java b/ajde/testsrc/org/aspectj/ajde/AjdeTestCase.java
index d0179dac3..c280b68dc 100644
--- a/ajde/testsrc/org/aspectj/ajde/AjdeTestCase.java
+++ b/ajde/testsrc/org/aspectj/ajde/AjdeTestCase.java
@@ -36,7 +36,7 @@ public class AjdeTestCase extends TestCase {
/**
* Waits on the build complete.
*/
- protected void doSynchronousBuild(String configFilePath) {
+ protected boolean doSynchronousBuild(String configFilePath) {
testerBuildListener.reset();
File configFile = openFile(configFilePath);
Ajde.getDefault().getBuildManager().build(configFile.getAbsolutePath());
@@ -45,6 +45,7 @@ public class AjdeTestCase extends TestCase {
Thread.sleep(300);
} catch (InterruptedException ie) { }
}
+ return testerBuildListener.getBuildSucceeded();
}
protected void setUp(String testDataPath) throws Exception {
diff --git a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java
index fcdfd5a8b..ecaba129d 100644
--- a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java
+++ b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java
@@ -27,6 +27,8 @@ public class AjdeTests extends TestCase {
suite.addTestSuite(StructureModelTest.class);
suite.addTestSuite(VersionTest.class);
suite.addTestSuite(CompilerMessagesTest.class);
+ suite.addTestSuite(AsmDeclarationsTest.class);
+
//$JUnit-END$
return suite;
}
diff --git a/ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java b/ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java
new file mode 100644
index 000000000..4f2a82bbe
--- /dev/null
+++ b/ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java
@@ -0,0 +1,141 @@
+
+/* *******************************************************************
+ * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
+ * 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
+ *
+ * ******************************************************************/
+
+package org.aspectj.ajde;
+
+import java.util.Iterator;
+
+import org.aspectj.ajdt.internal.core.builder.AsmNodeFormatter;
+import org.aspectj.asm.*;
+import org.aspectj.asm.ProgramElementNode.Kind;
+
+
+public class AsmDeclarationsTest extends AjdeTestCase {
+
+ private StructureModel model = null;
+ private static final String CONFIG_FILE_PATH = "../examples/coverage/coverage.lst";
+ private static final int DEC_MESSAGE_LENGTH = AsmNodeFormatter.MAX_MESSAGE_LENGTH;
+
+ public AsmDeclarationsTest(String name) {
+ super(name);
+ }
+
+ public void testDeclares() {
+ ProgramElementNode node = (ProgramElementNode)model.getRoot();
+ assertNotNull(node);
+
+ ProgramElementNode aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "InterTypeDecCoverage");
+ assertNotNull(aspect);
+
+ String decErrMessage = "declare error: Illegal construct..";
+ ProgramElementNode decErrNode = model.findNode(aspect, ProgramElementNode.Kind.DECLARE_ERROR, decErrMessage);
+ assertNotNull(decErrNode);
+ assertEquals(decErrNode.getName(), decErrMessage);
+
+ String decWarnMessage = "declare warning: Illegal construct..";
+ ProgramElementNode decWarnNode = model.findNode(aspect, ProgramElementNode.Kind.DECLARE_WARNING, decWarnMessage);
+ assertNotNull(decWarnNode);
+ assertEquals(decWarnNode.getName(), decWarnMessage);
+
+ String decParentsMessage = "declare parents: Point";
+ ProgramElementNode decParentsNode = model.findNode(aspect, ProgramElementNode.Kind.DECLARE_PARENTS, decParentsMessage);
+ assertNotNull(decParentsNode);
+ assertEquals(decParentsNode.getName(), decParentsMessage);
+
+ String decParentsPtnMessage = "declare parents: Point+";
+ ProgramElementNode decParentsPtnNode = model.findNode(aspect, ProgramElementNode.Kind.DECLARE_PARENTS, decParentsPtnMessage);
+ assertNotNull(decParentsPtnNode);
+ assertEquals(decParentsPtnNode.getName(), decParentsPtnMessage);
+
+ String decParentsTPMessage = "declare parents: <type pattern>";
+ ProgramElementNode decParentsTPNode = model.findNode(aspect, ProgramElementNode.Kind.DECLARE_PARENTS, decParentsTPMessage);
+ assertNotNull(decParentsTPNode);
+ assertEquals(decParentsTPNode.getName(), decParentsTPMessage);
+
+ String decSoftMessage = "declare soft: SizeException";
+ ProgramElementNode decSoftNode = model.findNode(aspect, ProgramElementNode.Kind.DECLARE_SOFT, decSoftMessage);
+ assertNotNull(decSoftNode);
+ assertEquals(decSoftNode.getName(), decSoftMessage);
+
+ String decPrecMessage = "declare precedence: AdviceCoverage, InterTypeDecCoverage, <type pattern>";
+ ProgramElementNode decPrecNode = model.findNode(aspect, ProgramElementNode.Kind.DECLARE_PRECEDENCE, decPrecMessage);
+ assertNotNull(decPrecNode);
+ assertEquals(decPrecNode.getName(), decPrecMessage);
+ }
+
+ public void testInterTypeMemberDeclares() {
+ ProgramElementNode node = (ProgramElementNode)model.getRoot();
+ assertNotNull(node);
+
+ ProgramElementNode aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "InterTypeDecCoverage");
+ assertNotNull(aspect);
+
+ String fieldMsg = "Point.xxx";
+ ProgramElementNode fieldNode = model.findNode(aspect, ProgramElementNode.Kind.INTER_TYPE_FIELD, fieldMsg);
+ assertNotNull(fieldNode);
+ assertEquals(fieldNode.getName(), fieldMsg);
+
+ String methodMsg = "Point.check(int, Line)";
+ ProgramElementNode methodNode = model.findNode(aspect, ProgramElementNode.Kind.INTER_TYPE_METHOD, methodMsg);
+ assertNotNull(methodNode);
+ assertEquals(methodNode.getName(), methodMsg);
+
+ // TODO: enable
+// String constructorMsg = "Point.new(int, int, int)";
+// ProgramElementNode constructorNode = model.findNode(aspect, ProgramElementNode.Kind.INTER_TYPE_CONSTRUCTOR, constructorMsg);
+// assertNotNull(constructorNode);
+// assertEquals(constructorNode.getName(), constructorMsg);
+ }
+
+ public void testPointcuts() {
+ ProgramElementNode node = (ProgramElementNode)model.getRoot();
+ assertNotNull(node);
+
+ ProgramElementNode aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "AdviceNamingCoverage");
+ assertNotNull(aspect);
+
+ String ptct = "named()";
+ ProgramElementNode ptctNode = model.findNode(aspect, ProgramElementNode.Kind.POINTCUT, ptct);
+ assertNotNull(ptctNode);
+ assertEquals(ptctNode.getName(), ptct);
+
+ String params = "namedWithArgs(int, int)";
+ ProgramElementNode paramsNode = model.findNode(aspect, ProgramElementNode.Kind.POINTCUT, params);
+ assertNotNull(paramsNode);
+ assertEquals(paramsNode.getName(), params);
+
+
+ }
+
+ public void testAdvice() {
+ ProgramElementNode node = (ProgramElementNode)model.getRoot();
+ assertNotNull(node);
+
+ ProgramElementNode aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "AdviceNamingCoverage");
+ assertNotNull(aspect);
+
+// String anon = "<anonymous pointcut>";
+// ProgramElementNode anonNode = model.findNode(aspect, ProgramElementNode.Kind.POINTCUT, anon);
+// assertNotNull(anonNode);
+// assertEquals(anonNode.getName(), anon);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp("examples");
+ assertTrue("build success", doSynchronousBuild(CONFIG_FILE_PATH));
+ model = StructureModelManager.getDefault().getStructureModel();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+}
diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java b/ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java
index 3647a33fa..239c02cff 100644
--- a/ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java
+++ b/ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java
@@ -43,15 +43,15 @@ public class NullIdeTaskListManager implements TaskListManager {
if (!hasWarning && IMessage.WARNING.isSameOrLessThan(message.getKind())) {
hasWarning = true;
}
-// System.out.println("> added sourceline task: " + message + ", file: " + sourceLocation.getSourceFile().getAbsolutePath()
-// + ": " + sourceLocation.getLine());
+ System.out.println("> added sourceline task: " + message + ", file: " + message.getISourceLocation().getSourceFile().getAbsolutePath()
+ + ": " + message.getISourceLocation().getLine());
}
public void addProjectTask(String message, IMessage.Kind kind) {
if (!hasWarning && IMessage.WARNING.isSameOrLessThan(kind)) {
hasWarning = true;
}
-// System.out.println("> added project task: " + message + ", kind: " + kind);
+ System.out.println("> added project task: " + message + ", kind: " + kind);
}
public boolean hasWarning() {
diff --git a/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java b/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java
index d11a5a611..9eec9987d 100644
--- a/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java
+++ b/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java
@@ -100,8 +100,12 @@ public class StructureModelTest extends AjdeTestCase {
ProgramElementNode pNode = (ProgramElementNode)((ProgramElementNode)node).getChildren().get(1);
ProgramElementNode pointcut = (ProgramElementNode)pNode.getChildren().get(0);
assertTrue("kind", pointcut.getProgramElementKind().equals(ProgramElementNode.Kind.POINTCUT));
- assertTrue("found node: " + pointcut.getName(), pointcut.getName().equals("testptct"));
+ assertTrue("found node: " + pointcut.getName(), pointcut.getName().equals("testptct()"));
+ }
+ public void testDeclare() {
+
+
}
public void testFileNodeFind() throws IOException {