aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ajde/testdata/examples/coverage/ModelCoverage.java2
-rw-r--r--asm/src/org/aspectj/asm/IProgramElement.java6
-rw-r--r--asm/src/org/aspectj/asm/internal/ProgramElement.java16
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java5
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java54
5 files changed, 67 insertions, 16 deletions
diff --git a/ajde/testdata/examples/coverage/ModelCoverage.java b/ajde/testdata/examples/coverage/ModelCoverage.java
index 4d9302548..bbab87a2f 100644
--- a/ajde/testdata/examples/coverage/ModelCoverage.java
+++ b/ajde/testdata/examples/coverage/ModelCoverage.java
@@ -2,6 +2,8 @@
import java.io.*;
import java.util.List;
+interface I { }
+
class Point {
int x;
static int sx;
diff --git a/asm/src/org/aspectj/asm/IProgramElement.java b/asm/src/org/aspectj/asm/IProgramElement.java
index 8bf641ce8..ca6dac5bb 100644
--- a/asm/src/org/aspectj/asm/IProgramElement.java
+++ b/asm/src/org/aspectj/asm/IProgramElement.java
@@ -117,6 +117,12 @@ public interface IProgramElement extends Serializable {
public void setBytecodeName(String bytecodeName);
public void setBytecodeSignature(String bytecodeSignature);
+ /**
+ * @return the full signature of this element, as it appears in the source
+ */
+ public String getSourceSignature();
+ public void setSourceSignature(String string);
+
public IProgramElement walk(HierarchyWalker walker);
/**
diff --git a/asm/src/org/aspectj/asm/internal/ProgramElement.java b/asm/src/org/aspectj/asm/internal/ProgramElement.java
index 6f83e3be9..6141f600e 100644
--- a/asm/src/org/aspectj/asm/internal/ProgramElement.java
+++ b/asm/src/org/aspectj/asm/internal/ProgramElement.java
@@ -251,6 +251,8 @@ public class ProgramElement implements IProgramElement {
// private static int AccInterface = 0x0200;
private static int AccAbstract = 0x0400;
// private static int AccStrictfp = 0x0800;
+
+ private String sourceSignature;
public String getBytecodeName() {
@@ -268,14 +270,14 @@ public class ProgramElement implements IProgramElement {
public void setBytecodeSignature(String bytecodeSignature) {
this.bytecodeSignature = bytecodeSignature;
}
+
+ public String getSourceSignature() {
+ return sourceSignature;
+ }
-// public String getFullSignature() {
-// return fullSignature;
-// }
-//
-// public void setFullSignature(String string) {
-// fullSignature = string;
-// }
+ public void setSourceSignature(String string) {
+ sourceSignature = string;
+ }
public void setKind(Kind kind) {
this.kind = kind;
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java
index 14e89d232..1f8a81a7d 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java
@@ -6,6 +6,8 @@
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
+ * Contributors:
+ * PARC initial implementation
* ******************************************************************/
package org.aspectj.ajdt.internal.core.builder;
@@ -18,6 +20,9 @@ import org.aspectj.weaver.*;
import org.aspectj.weaver.patterns.*;
import org.eclipse.jdt.internal.compiler.ast.*;
+/**
+ * @author Mik Kersten
+ */
public class AsmElementFormatter {
public static final String DECLARE_PRECEDENCE = "precedence";
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
index 2aa2e07ca..674877a37 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
@@ -29,6 +29,9 @@ import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.problem.ProblemHandler;
+/**
+ * @author Mik Kersten
+ */
public class AsmHierarchyBuilder extends ASTVisitor {
public static void build(
@@ -169,7 +172,7 @@ public class AsmHierarchyBuilder extends ASTVisitor {
}
return addToNode;
}
-
+
public boolean visit(TypeDeclaration typeDeclaration, CompilationUnitScope scope) {
String name = new String(typeDeclaration.name);
IProgramElement.Kind kind = IProgramElement.Kind.CLASS;
@@ -183,6 +186,7 @@ public class AsmHierarchyBuilder extends ASTVisitor {
typeDeclaration.modifiers,
"",
new ArrayList());
+ peNode.setSourceSignature(genSourceSignature(typeDeclaration));
((IProgramElement)stack.peek()).addChild(peNode);
stack.push(peNode);
@@ -208,6 +212,7 @@ public class AsmHierarchyBuilder extends ASTVisitor {
memberTypeDeclaration.modifiers,
"",
new ArrayList());
+ peNode.setSourceSignature(genSourceSignature(memberTypeDeclaration));
((IProgramElement)stack.peek()).addChild(peNode);
stack.push(peNode);
@@ -228,10 +233,7 @@ public class AsmHierarchyBuilder extends ASTVisitor {
int dollar = fullName.indexOf('$');
fullName = fullName.substring(dollar+1);
-//
-// System.err.println("member type with name: " + name + ", " +
-// new String(fullName));
-
+
IProgramElement.Kind kind = IProgramElement.Kind.CLASS;
if (memberTypeDeclaration.isInterface()) kind = IProgramElement.Kind.INTERFACE;
@@ -242,6 +244,7 @@ public class AsmHierarchyBuilder extends ASTVisitor {
memberTypeDeclaration.modifiers,
"",
new ArrayList());
+ peNode.setSourceSignature(genSourceSignature(memberTypeDeclaration));
//??? we add this to the compilation unit
findEnclosingClass(stack).addChild(peNode);
@@ -252,6 +255,11 @@ public class AsmHierarchyBuilder extends ASTVisitor {
stack.pop();
}
+ private String genSourceSignature(TypeDeclaration typeDeclaration) {
+ StringBuffer output = new StringBuffer();
+ typeDeclaration.printHeader(0, output);
+ return output.toString();
+ }
private IProgramElement findEnclosingClass(Stack stack) {
for (int i = stack.size()-1; i >= 0; i--) {
@@ -277,7 +285,8 @@ public class AsmHierarchyBuilder extends ASTVisitor {
genBytecodeInfo(methodDeclaration, peNode);
peNode.setModifiers(methodDeclaration.modifiers);
peNode.setCorrespondingType(methodDeclaration.returnType.toString());
-
+ peNode.setSourceSignature(genSourceSignature(methodDeclaration));
+
// TODO: add return type test
if (peNode.getKind().equals(IProgramElement.Kind.METHOD)) {
if (peNode.toLabelString().equals("main(String[])")
@@ -291,6 +300,27 @@ public class AsmHierarchyBuilder extends ASTVisitor {
return true;
}
+ private String genSourceSignature(MethodDeclaration methodDeclaration) {
+ StringBuffer output = new StringBuffer();
+ methodDeclaration.printModifiers(methodDeclaration.modifiers, output);
+ methodDeclaration.printReturnType(0, output).append(methodDeclaration.selector).append('(');
+ if (methodDeclaration.arguments != null) {
+ for (int i = 0; i < methodDeclaration.arguments.length; i++) {
+ if (i > 0) output.append(", "); //$NON-NLS-1$
+ methodDeclaration.arguments[i].print(0, output);
+ }
+ }
+ output.append(')');
+ if (methodDeclaration.thrownExceptions != null) {
+ output.append(" throws "); //$NON-NLS-1$
+ for (int i = 0; i < methodDeclaration.thrownExceptions.length; i++) {
+ if (i > 0) output.append(", "); //$NON-NLS-1$
+ methodDeclaration.thrownExceptions[i].print(0, output);
+ }
+ }
+ return output.toString();
+ }
+
private void genBytecodeInfo(MethodDeclaration methodDeclaration, IProgramElement peNode) {
if (methodDeclaration.binding != null) {
String memberName = "";
@@ -301,8 +331,8 @@ public class AsmHierarchyBuilder extends ASTVisitor {
memberBytecodeSignature = member.getSignature();
} catch (NullPointerException npe) {
memberName = "<undefined>";
- }
-
+ }
+
peNode.setBytecodeName(memberName);
peNode.setBytecodeSignature(memberBytecodeSignature);
}
@@ -354,8 +384,8 @@ public class AsmHierarchyBuilder extends ASTVisitor {
fieldDeclaration.modifiers,
"",
new ArrayList());
-
peNode.setCorrespondingType(fieldDeclaration.type.toString());
+ peNode.setSourceSignature(genSourceSignature(fieldDeclaration));
((IProgramElement)stack.peek()).addChild(peNode);
stack.push(peNode);
@@ -364,6 +394,12 @@ public class AsmHierarchyBuilder extends ASTVisitor {
public void endVisit(FieldDeclaration fieldDeclaration, MethodScope scope) {
stack.pop();
}
+
+ private String genSourceSignature(FieldDeclaration fieldDeclaration) {
+ StringBuffer output = new StringBuffer();
+ fieldDeclaration.print(0, output);
+ return output.toString();
+ }
// public boolean visit(ImportReference importRef, CompilationUnitScope scope) {