summaryrefslogtreecommitdiffstats
path: root/weaver/src
diff options
context:
space:
mode:
authoraclement <aclement>2006-08-25 12:37:49 +0000
committeraclement <aclement>2006-08-25 12:37:49 +0000
commit07e6e9a1767c860b483540ac165108983dc1e1f4 (patch)
treefd180b83ddb86ca9637df6afd9b1d75bb7c1a4a3 /weaver/src
parent5787d0e82f32648f30f4677c13aef68d4615e300 (diff)
downloadaspectj-07e6e9a1767c860b483540ac165108983dc1e1f4.tar.gz
aspectj-07e6e9a1767c860b483540ac165108983dc1e1f4.zip
last of the dreaded jdtlikehandleprovider changes - 141730#22
Diffstat (limited to 'weaver/src')
-rw-r--r--weaver/src/org/aspectj/weaver/AsmRelationshipProvider.java42
1 files changed, 35 insertions, 7 deletions
diff --git a/weaver/src/org/aspectj/weaver/AsmRelationshipProvider.java b/weaver/src/org/aspectj/weaver/AsmRelationshipProvider.java
index a353a845a..e2bd4d09d 100644
--- a/weaver/src/org/aspectj/weaver/AsmRelationshipProvider.java
+++ b/weaver/src/org/aspectj/weaver/AsmRelationshipProvider.java
@@ -243,15 +243,33 @@ public class AsmRelationshipProvider {
return true;
}
-
+ /**
+ * Finds or creates a code IProgramElement for the given shadow.
+ *
+ * The byteCodeName of the created node is set to 'shadowSig.getName() + "!" + counter',
+ * eg "println!3". The counter is the occurence count of children within
+ * the enclosingNode which have the same name. So, for example, if a method
+ * contains two System.out.println statements, the first one will have
+ * byteCodeName 'println!1' and the second will have byteCodeName 'println!2'.
+ * This is to ensure the two nodes have unique handles when the handles
+ * do not depend on sourcelocations.
+ *
+ * Currently the shadows are examined in the sequence they appear in the
+ * source file. This means that the counters are consistent over incremental
+ * builds. All aspects are compiled up front and any new aspect created will force
+ * a full build. Moreover, if the body of the enclosingShadow is changed, then
+ * the model for this is rebuilt from scratch.
+ */
private IProgramElement findOrCreateCodeNode(IProgramElement enclosingNode, Member shadowSig, Shadow shadow)
{
for (Iterator it = enclosingNode.getChildren().iterator(); it.hasNext(); ) {
IProgramElement node = (IProgramElement)it.next();
- if (shadowSig.getName().equals(node.getBytecodeName()) &&
- shadowSig.getSignature().equals(node.getBytecodeSignature()) &&
- sourceLinesMatch(node.getSourceLocation(),shadow.getSourceLocation()))
- {
+ int excl = node.getBytecodeName().lastIndexOf('!');
+ if (((excl != -1
+ && shadowSig.getName().equals(node.getBytecodeName().substring(0,excl)))
+ || shadowSig.getName().equals(node.getBytecodeName()))
+ && shadowSig.getSignature().equals(node.getBytecodeSignature())
+ && sourceLinesMatch(node.getSourceLocation(),shadow.getSourceLocation())){
return node;
}
}
@@ -265,8 +283,18 @@ public class AsmRelationshipProvider {
shadow.toString(),
IProgramElement.Kind.CODE,
peLoc,0,null,null);
-
- peNode.setBytecodeName(shadowSig.getName());
+
+ // check to see if the enclosing shadow already has children with the
+ // same name. If so we want to add a counter to the byteCodeName otherwise
+ // we wont get unique handles
+ int numberOfChildrenWithThisName = 0;
+ for (Iterator it = enclosingNode.getChildren().iterator(); it.hasNext(); ) {
+ IProgramElement child = (IProgramElement)it.next();
+ if (child.getName().equals(shadow.toString())) {
+ numberOfChildrenWithThisName++;
+ }
+ }
+ peNode.setBytecodeName(shadowSig.getName() + "!" + String.valueOf(numberOfChildrenWithThisName+1));
peNode.setBytecodeSignature(shadowSig.getSignature());
enclosingNode.addChild(peNode);
return peNode;