aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten <mkersten>2003-02-18 09:23:58 +0000
committermkersten <mkersten>2003-02-18 09:23:58 +0000
commit32a7e80fac54b553e98e5049e9f9f5b8bb765a60 (patch)
tree001112385a72b41c9751f2625ea8bab93b582304
parentab6b18d68794cfee99eaf1f2a914c501eb596f9d (diff)
downloadaspectj-32a7e80fac54b553e98e5049e9f9f5b8bb765a60.tar.gz
aspectj-32a7e80fac54b553e98e5049e9f9f5b8bb765a60.zip
Fixed source line mapping errors.
Fixed formatting of pointcuts. Added a few more tests for above.
-rw-r--r--ajde/testdata/examples/figures-coverage/figures/Main.java2
-rw-r--r--ajde/testsrc/org/aspectj/ajde/StructureModelTest.java22
-rw-r--r--asm/src/org/aspectj/asm/StructureModel.java34
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmBuilder.java24
4 files changed, 65 insertions, 17 deletions
diff --git a/ajde/testdata/examples/figures-coverage/figures/Main.java b/ajde/testdata/examples/figures-coverage/figures/Main.java
index bbb2869b7..189f05cee 100644
--- a/ajde/testdata/examples/figures-coverage/figures/Main.java
+++ b/ajde/testdata/examples/figures-coverage/figures/Main.java
@@ -42,6 +42,8 @@ class Main {
}
privileged aspect Test {
+ pointcut testptct(): call(* *.*(..));
+
before(Point p, int newval): target(p) && set(int Point.xx) && args(newval) {
System.err.println("> new value of x is: " + p.x + ", setting to: " + newval);
}
diff --git a/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java b/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java
index eb5834dd4..adf926665 100644
--- a/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java
+++ b/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java
@@ -76,6 +76,28 @@ public class StructureModelTest extends AjdeTestCase {
// assertTrue("matches", foundNode.getParent() == fieldNode.getParent());
// }
+
+ public void testRootForSourceFile() throws IOException {
+ File testFile = createFile("figures-coverage/figures/Figure.java");
+ StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findRootNodeForSourceFile(
+ testFile.getCanonicalPath());
+ assertTrue("find result", node != null) ;
+ ProgramElementNode pNode = (ProgramElementNode)node;
+ assertTrue("found child", ((StructureNode)pNode.getChildren().get(0)).getName().equals("Figure"));
+ }
+
+ public void testPointcutName() throws IOException {
+ File testFile = createFile("figures-coverage/figures/Main.java");
+ StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findRootNodeForSourceFile(
+ testFile.getCanonicalPath());
+ assertTrue("find result", node != null) ;
+ 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"));
+
+ }
+
public void testFileNodeFind() throws IOException {
File testFile = createFile("testdata/examples/figures-coverage/figures/Main.java");
StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine(
diff --git a/asm/src/org/aspectj/asm/StructureModel.java b/asm/src/org/aspectj/asm/StructureModel.java
index e58159087..263a32853 100644
--- a/asm/src/org/aspectj/asm/StructureModel.java
+++ b/asm/src/org/aspectj/asm/StructureModel.java
@@ -114,18 +114,22 @@ public class StructureModel implements Serializable {
* @param sourceFilePath modified to '/' delimited path for consistency
* @return a new structure node for the file if it was not found in the model
*/
- public StructureNode findRootNodeForSourceFile(String sourceFilePath) {
- if (!isValid() || sourceFilePath == null) {
- return StructureModel.NO_STRUCTURE;
- } else {
- String correctedPath = sourceFilePath;//.replace('\\', '/');
- StructureNode node = (StructureNode)getFileMap().get(correctedPath);//findFileNode(filePath, model);
- if (node != null) {
- return node;
- } else {
- return createFileStructureNode(sourceFilePath);
- }
- }
+ public StructureNode findRootNodeForSourceFile(String sourceFile) {
+ try {
+ if (!isValid() || sourceFile == null) {
+ return StructureModel.NO_STRUCTURE;
+ } else {
+ String correctedPath = new File(sourceFile).getCanonicalPath();//.replace('\\', '/');
+ StructureNode node = (StructureNode)getFileMap().get(correctedPath);//findFileNode(filePath, model);
+ if (node != null) {
+ return node;
+ } else {
+ return createFileStructureNode(correctedPath);
+ }
+ }
+ } catch (Exception e) {
+ return StructureModel.NO_STRUCTURE;
+ }
}
/**
@@ -175,6 +179,12 @@ public class StructureModel implements Serializable {
private boolean matches(StructureNode node, String sourceFilePath, int lineNumber) {
try {
+// if (node != null && node.getSourceLocation() != null)
+// System.err.println("====\n1: " +
+// sourceFilePath + "\n2: " +
+// node.getSourceLocation().getSourceFile().getCanonicalPath().equals(sourceFilePath)
+// );
+
return node != null
&& node.getSourceLocation() != null
&& node.getSourceLocation().getSourceFile().getCanonicalPath().equals(sourceFilePath)
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmBuilder.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmBuilder.java
index e705748f2..83be0af50 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmBuilder.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmBuilder.java
@@ -14,6 +14,7 @@
package org.aspectj.ajdt.internal.core.builder;
import java.io.File;
+import java.io.IOException;
import java.text.CollationElementIterator;
import java.util.*;
import java.util.List;
@@ -91,10 +92,12 @@ public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
stack.push(cuNode);
unit.traverse(this, unit.scope);
- StructureModelManager.INSTANCE.getStructureModel().getFileMap().put(
- file.getAbsolutePath().replace('\\', '/'),
- cuNode
- );
+ try {
+ StructureModelManager.INSTANCE.getStructureModel().getFileMap().put(
+ file.getCanonicalPath(),//.replace('\\', '/'),
+ cuNode
+ );
+ } catch (IOException ioe) { }
// if (currImports != null) peNode.addChild(0, currImports);
// currImports = null;
}
@@ -205,6 +208,7 @@ public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
label = translateAdviceName(label);
} else if (methodDeclaration instanceof PointcutDeclaration) {
kind = ProgramElementNode.Kind.POINTCUT;
+ label = translatePointcutName(label);
} else if (methodDeclaration instanceof DeclareDeclaration) {
DeclareDeclaration declare = (DeclareDeclaration)methodDeclaration;
label = translateDeclareName(declare.toString());
@@ -240,7 +244,6 @@ public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
return true;
}
-
public void endVisit(MethodDeclaration methodDeclaration, ClassScope scope) {
stack.pop();
}
@@ -373,4 +376,15 @@ public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
}
}
+ // !!! move or replace
+ private String translatePointcutName(String name) {
+ int index = name.indexOf("$$")+2;
+ int endIndex = name.lastIndexOf('$');
+ if (index != -1 && endIndex != -1) {
+ return name.substring(index, endIndex);
+ } else {
+ return name;
+ }
+ }
+
}