aboutsummaryrefslogtreecommitdiffstats
path: root/asm
diff options
context:
space:
mode:
authormkersten <mkersten>2003-08-08 21:10:32 +0000
committermkersten <mkersten>2003-08-08 21:10:32 +0000
commit4a1a347b2225e48fa4e9d617e7bf083680967a70 (patch)
tree7e7cc1b56212c86ce562cb7203c6dbf504eaa391 /asm
parent3289df4d8c5a8c8e3ada9c301a0b023dda8524a3 (diff)
downloadaspectj-4a1a347b2225e48fa4e9d617e7bf083680967a70.tar.gz
aspectj-4a1a347b2225e48fa4e9d617e7bf083680967a70.zip
Got advice relationships working.
Diffstat (limited to 'asm')
-rw-r--r--asm/src/org/aspectj/asm/IRelationship.java6
-rw-r--r--asm/src/org/aspectj/asm/IRelationshipMapper.java9
-rw-r--r--asm/src/org/aspectj/asm/StructureModel.java7
-rw-r--r--asm/src/org/aspectj/asm/StructureModelManager.java12
-rw-r--r--asm/src/org/aspectj/asm/internal/Relationship.java32
-rw-r--r--asm/src/org/aspectj/asm/internal/RelationshipMapper.java61
6 files changed, 44 insertions, 83 deletions
diff --git a/asm/src/org/aspectj/asm/IRelationship.java b/asm/src/org/aspectj/asm/IRelationship.java
index efcc1b969..892f50006 100644
--- a/asm/src/org/aspectj/asm/IRelationship.java
+++ b/asm/src/org/aspectj/asm/IRelationship.java
@@ -24,7 +24,9 @@ public interface IRelationship extends Serializable {
public String getName();
- public String getReverseName();
+ public List getTargets();
+
+ public IProgramElement getSource();
public Kind getKind();
@@ -34,8 +36,6 @@ public interface IRelationship extends Serializable {
public static class Kind implements Serializable {
public static final Kind ADVICE = new Kind("advice");
-// public static final Kind INHERITANCE = new Kind("inherits", "inherited by");
-// public static final Kind REFERENCE = new Kind("reference");
public static final Kind DECLARE = new Kind("declare");
public static final Kind[] ALL = { ADVICE, DECLARE };
private final String name;
diff --git a/asm/src/org/aspectj/asm/IRelationshipMapper.java b/asm/src/org/aspectj/asm/IRelationshipMapper.java
index eaf6653de..e7e7eb343 100644
--- a/asm/src/org/aspectj/asm/IRelationshipMapper.java
+++ b/asm/src/org/aspectj/asm/IRelationshipMapper.java
@@ -23,9 +23,10 @@ public interface IRelationshipMapper extends Serializable {
//
// public void putRelationshipForElement(String source, IRelationship kind, String target);
- public List getRelationshipsForElement(IProgramElement source, IRelationship relationship);
-
- public void putRelationshipForElement(IProgramElement source, IRelationship relationship, List targets);
+ public IRelationship get(IProgramElement source);
- public void putRelationshipForElement(IProgramElement source, IRelationship kind, IProgramElement target);
+// public void putRelationshipForElement(IProgramElement source, IRelationship relationship, List targets);
+
+ public void put(IProgramElement source, IRelationship relationship);
+
}
diff --git a/asm/src/org/aspectj/asm/StructureModel.java b/asm/src/org/aspectj/asm/StructureModel.java
index 472509b1a..60f48edcb 100644
--- a/asm/src/org/aspectj/asm/StructureModel.java
+++ b/asm/src/org/aspectj/asm/StructureModel.java
@@ -94,7 +94,7 @@ public class StructureModel implements Serializable {
* @param packageName if null default package is searched
* @param className can't be null
*/
- public IProgramElement findNodeForClass(String packageName, String className) {
+ public IProgramElement findNodeForType(String packageName, String typeName) {
IProgramElement packageNode = null;
if (packageName == null) {
packageNode = root;
@@ -111,7 +111,7 @@ public class StructureModel implements Serializable {
// this searches each file for a class
for (Iterator it = packageNode.getChildren().iterator(); it.hasNext(); ) {
IProgramElement fileNode = (IProgramElement)it.next();
- IProgramElement ret = findClassInNodes(fileNode.getChildren(), className);
+ IProgramElement ret = findClassInNodes(fileNode.getChildren(), typeName);
if (ret != null) return ret;
}
@@ -130,11 +130,8 @@ public class StructureModel implements Serializable {
innerName = name.substring(dollar+1);
}
-
for (Iterator j = nodes.iterator(); j.hasNext(); ) {
IProgramElement classNode = (IProgramElement)j.next();
-// System.err.println("checking: " + classNode + " for " + baseName);
-// System.err.println("children: " + classNode.getChildren());
if (baseName.equals(classNode.getName())) {
if (innerName == null) return classNode;
else return findClassInNodes(classNode.getChildren(), innerName);
diff --git a/asm/src/org/aspectj/asm/StructureModelManager.java b/asm/src/org/aspectj/asm/StructureModelManager.java
index acec44ab2..1e966bb01 100644
--- a/asm/src/org/aspectj/asm/StructureModelManager.java
+++ b/asm/src/org/aspectj/asm/StructureModelManager.java
@@ -33,15 +33,15 @@ public class StructureModelManager {
private List structureListeners = new ArrayList();
private IRelationshipMapper mapper;
- private static final IRelationship ADVICE = new Relationship("advises", "advised by", IRelationship.Kind.ADVICE);
+// public static final IRelationship ADVICE = new Relationship("advises", "advised by", IRelationship.Kind.ADVICE);
protected StructureModelManager() {
List relationships = new ArrayList();
- relationships.add(ADVICE);
- mapper = new RelationshipMapper(relationships);
+// relationships.add(ADVICE);
+ mapper = new RelationshipMapper();
}
- public StructureModel getStructureModel() {
+ public StructureModel getModel() {
return model;
}
@@ -168,5 +168,9 @@ public class StructureModelManager {
public static StructureModelManager getDefault() {
return INSTANCE;
}
+ public IRelationshipMapper getMapper() {
+ return mapper;
+ }
+
}
diff --git a/asm/src/org/aspectj/asm/internal/Relationship.java b/asm/src/org/aspectj/asm/internal/Relationship.java
index be86fd473..ef6d98683 100644
--- a/asm/src/org/aspectj/asm/internal/Relationship.java
+++ b/asm/src/org/aspectj/asm/internal/Relationship.java
@@ -24,28 +24,40 @@ import org.aspectj.asm.IRelationship.Kind;
public class Relationship implements IRelationship {
private String name;
- private String reverseName;
private Kind kind;
+ private IProgramElement source;
+ private List targets;
- public Relationship(String name, String reverseName, Kind kind) {
+ public Relationship(
+ String name,
+ Kind kind,
+ IProgramElement source,
+ List targets) {
+
this.name = name;
- this.reverseName = reverseName;
this.kind = kind;
+ this.source = source;
+ this.targets = targets;
}
public String getName() {
- return null;
+ return name;
}
public Kind getKind() {
- return null;
- }
-
- public String getReverseName() {
- return reverseName;
+ return kind;
}
public String toString() {
- return name + '/' + reverseName;
+ return name;
}
+
+ public IProgramElement getSource() {
+ return source;
+ }
+
+ public List getTargets() {
+ return targets;
+ }
+
}
diff --git a/asm/src/org/aspectj/asm/internal/RelationshipMapper.java b/asm/src/org/aspectj/asm/internal/RelationshipMapper.java
index f4929563b..70644ff03 100644
--- a/asm/src/org/aspectj/asm/internal/RelationshipMapper.java
+++ b/asm/src/org/aspectj/asm/internal/RelationshipMapper.java
@@ -16,44 +16,15 @@ import org.aspectj.asm.*;
*/
public class RelationshipMapper extends HashMap implements IRelationshipMapper {
- private Map/*IRelationship*/ relationships = new HashMap();
-
- public RelationshipMapper(List availableRelationships) {
- for (Iterator it = availableRelationships.iterator(); it.hasNext(); ) {
- IRelationship r = (IRelationship)it.next();
- relationships.put(r, new HashMap());
- }
- }
-
- public List getRelationshipsForElement(IProgramElement source, IRelationship relationship) {
- Map map = (Map)relationships.get(relationship);
- return (List)map.get(source);
+ public IRelationship get(IProgramElement source) {
+ return (IRelationship)super.get(source);
}
/**
* Creates the relationship if not present.
*/
- public void putRelationshipForElement(IProgramElement source, IRelationship relationship, List targets) {
- Map map = (Map)relationships.get(relationship);
- if (map == null) {
- map = new HashMap();
- relationships.put(relationship, map);
- }
- map.put(source, targets);
- }
-
- public void putRelationshipForElement(IProgramElement source, IRelationship relationship, IProgramElement target) {
- Map map = (Map)relationships.get(relationship);
- if (map == null) {
- map = new HashMap();
- relationships.put(relationship, map);
- }
- List targetList = (List)map.get(source);
- if (targetList == null) {
- targetList = new ArrayList();
- map.put(source, targetList);
- }
- targetList.add(target);
+ public void put(IProgramElement source, IRelationship relationship) {
+ super.put(source, relationship);
}
private static class RelationshipTable {
@@ -73,28 +44,4 @@ public class RelationshipMapper extends HashMap implements IRelationshipMapper {
return relationship;
}
}
-// public List getRelationshipsForElement(
-// IProgramElement source,
-// IRelationship relationship) {
-//
-// String signatureKey = (List)getRelationshipsForElement(source.getSignatureKey(), relationship);
-//
-// }
-//
-// public void putRelationshipForElement(
-// IProgramElement source,
-// IRelationship kind,
-// IProgramElement target) {
-//
-// }
-//
-// public void putRelationshipForElement(
-// IProgramElement source,
-// IRelationship relationship,
-// List targets) {
-//
-// }
-
-
-
}