aboutsummaryrefslogtreecommitdiffstats
path: root/asm
diff options
context:
space:
mode:
authoraclement <aclement>2006-08-18 12:38:01 +0000
committeraclement <aclement>2006-08-18 12:38:01 +0000
commit9b03811333687b7a41baa1b9c9ff84344df86bbc (patch)
tree8b742fbcf63943597376024650a56174853b6f48 /asm
parent1619a751e2a4a8a38676d5c96697022bdc798710 (diff)
downloadaspectj-9b03811333687b7a41baa1b9c9ff84344df86bbc.tar.gz
aspectj-9b03811333687b7a41baa1b9c9ff84344df86bbc.zip
145963: binary entries in the model: various parts to the fix.
Diffstat (limited to 'asm')
-rw-r--r--asm/src/org/aspectj/asm/AsmManager.java24
-rw-r--r--asm/src/org/aspectj/asm/IModelFilter.java32
-rw-r--r--asm/src/org/aspectj/asm/IProgramElement.java1
-rw-r--r--asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java7
4 files changed, 60 insertions, 4 deletions
diff --git a/asm/src/org/aspectj/asm/AsmManager.java b/asm/src/org/aspectj/asm/AsmManager.java
index 08eff87d4..87b5a347a 100644
--- a/asm/src/org/aspectj/asm/AsmManager.java
+++ b/asm/src/org/aspectj/asm/AsmManager.java
@@ -61,6 +61,7 @@ public class AsmManager {
private static boolean dumpModel = false;
private static boolean dumpRelationships = false;
private static boolean dumpDeltaProcessing = false;
+ private static IModelFilter modelFilter = null;
private static String dumpFilename = "";
private static boolean reporting = false;
@@ -88,7 +89,6 @@ public class AsmManager {
}
public static AsmManager getDefault() {
- new RuntimeException("fetching asm").printStackTrace();
return INSTANCE;
}
@@ -380,10 +380,21 @@ public class AsmManager {
dumpFilename = filename;
}
+ public static void setReporting(String filename,boolean dModel,boolean dRels,boolean dDeltaProcessing,
+ boolean deletefile,IModelFilter aFilter) {
+ setReporting(filename,dModel,dRels,dDeltaProcessing,deletefile);
+ modelFilter = aFilter;
+ }
+
public static boolean isReporting() {
return reporting;
}
+ public static void setDontReport() {
+ reporting = false;
+ dumpDeltaProcessing=false;
+ }
+
public void reportModelInfo(String reasonForReport) {
@@ -422,8 +433,10 @@ public class AsmManager {
for (int i =0 ;i<indent;i++) w.write(" ");
String loc = "";
if (node!=null) {
- if (node.getSourceLocation()!=null)
+ if (node.getSourceLocation()!=null) {
loc = node.getSourceLocation().toString();
+ if (modelFilter!=null) loc = modelFilter.processFilelocation(loc);
+ }
}
w.write(node+" ["+(node==null?"null":node.getKind().toString())+"] "+loc+"\n");
if (node!=null)
@@ -458,9 +471,12 @@ public class AsmManager {
List targets = ir.getTargets();
for (Iterator iterator2 = targets.iterator();
iterator2.hasNext();
- ) {
+ ) {
String thid = (String) iterator2.next();
- w.write("Hid:"+(ctr++)+":(targets="+targets.size()+") "+hid+" ("+ir.getName()+") "+thid+"\n");
+ StringBuffer sb = new StringBuffer();
+ if (modelFilter==null || modelFilter.wantsHandleIds()) sb.append("Hid:"+(ctr++)+":");
+ sb.append("(targets="+targets.size()+") "+hid+" ("+ir.getName()+") "+thid+"\n");
+ w.write(sb.toString());
}
}
}
diff --git a/asm/src/org/aspectj/asm/IModelFilter.java b/asm/src/org/aspectj/asm/IModelFilter.java
new file mode 100644
index 000000000..a901e83a9
--- /dev/null
+++ b/asm/src/org/aspectj/asm/IModelFilter.java
@@ -0,0 +1,32 @@
+/* *******************************************************************
+ * Copyright (c) 2006 Contributors
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement IBM initial implementation
+ * ******************************************************************/
+package org.aspectj.asm;
+
+/**
+ * When dumping the model out (for debugging/testing), various parts of
+ * it can be passed through this filter. Currently it is used to ensure
+ * the source locations we dump out are independent of sandbox directory.
+ */
+public interface IModelFilter {
+ /**
+ * Called when about to dump out an absolute file location, enabling
+ * it to be altered (eg. c:/temp/ajcsSandbox/foo/ajctemp.12323/<BLAH>
+ * could become TEST_SANDBOX/<BLAH>
+ */
+ String processFilelocation(String loc);
+
+ /**
+ * When the relationship map is dumped, lines are prefixed with a handle ID.
+ * Return true if you want these, false if you dont.
+ */
+ boolean wantsHandleIds();
+}
diff --git a/asm/src/org/aspectj/asm/IProgramElement.java b/asm/src/org/aspectj/asm/IProgramElement.java
index 6fbc15b09..bc60fdbce 100644
--- a/asm/src/org/aspectj/asm/IProgramElement.java
+++ b/asm/src/org/aspectj/asm/IProgramElement.java
@@ -28,6 +28,7 @@ public interface IProgramElement extends Serializable {
public void setChildren(List children);
public void addChild(IProgramElement child);
+ public boolean removeChild(IProgramElement child);
// Extra stuff
// Could be just a string but may prove more useful as an object in the long run ...
diff --git a/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java b/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java
index e0bb070dd..31aad3f18 100644
--- a/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java
+++ b/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java
@@ -259,6 +259,13 @@ public class AspectJElementHierarchy implements IHierarchy {
if (lastSlash == -1) {
lastSlash = sourceFilePath.lastIndexOf('/');
}
+ // '!' is used like in URLs "c:/blahblah/X.jar!a/b.class"
+ int i = sourceFilePath.lastIndexOf('!');
+ int j = sourceFilePath.indexOf(".class");
+ if (i > lastSlash && i != -1 && j != -1) {
+ // we are a binary aspect in the default package
+ lastSlash = i;
+ }
String fileName = sourceFilePath.substring(lastSlash+1);
IProgramElement fileNode = new ProgramElement(fileName, IProgramElement.Kind.FILE_JAVA, new SourceLocation(new File(sourceFilePath), 1, 1),0,null,null);
//fileNode.setSourceLocation();