import java.util.*;
import org.aspectj.asm.*;
-import org.aspectj.asm.IProgramElement.Kind;
import org.aspectj.bridge.*;
/**
protected String configFile = null;
private Map fileMap = null;
+ private Map handleMap = null;
public IProgramElement getElement(String handle) {
throw new RuntimeException("unimplemented");
public void setRoot(IProgramElement root) {
this.root = root;
+ handleMap = new HashMap();
}
public void addToFileMap( Object key, Object value ){
// TODO: optimize this lookup
public IProgramElement findElementForHandle(String handle) {
+ // try the cache first...
+ IProgramElement ret = (IProgramElement) handleMap.get(handle);
+ if (ret != null) return ret;
+
StringTokenizer st = new StringTokenizer(handle, ProgramElement.ID_DELIM);
String file = st.nextToken();
int line = new Integer(st.nextToken()).intValue();
int col = new Integer(st.nextToken()).intValue();
// TODO: use column number when available
- return findElementForSourceLine(file, line);
+ ret = findElementForSourceLine(file, line);
+ if (ret != null) {
+ cache(handle,(ProgramElement)ret);
+ }
+ return ret;
// IProgramElement parent = findElementForType(packageName, typeName);
// if (parent == null) return null;
// }
// return null;
// }
+
+ protected void cache(String handle, ProgramElement pe) {
+ handleMap.put(handle,pe);
+ }
}
this.formalComment = formalComment;
this.modifiers = genModifiers(modifiers);
this.accessibility = genAccessibility(modifiers);
+ cacheByHandle();
}
/**
this.packageName = packageName;
this.formalComment = formalComment;
this.relations = relations;
+ cacheByHandle();
}
public List getModifiers() {
} else {
label = parent.getName() + '.';
}
- } else if (kind == Kind.CLASS || kind == kind.ASPECT) {
+ } else if (kind == Kind.CLASS || kind == Kind.ASPECT) {
label = "";
} else {
label = parent.getName() + '.';
public void setDetails(String string) {
details = string;
}
+
+ /** AMC added to speed up findByHandle lookups in AspectJElementHierarchy */
+ private void cacheByHandle() {
+ String handle = getHandleIdentifier();
+ if (handle != null) {
+ AspectJElementHierarchy hierarchy = (AspectJElementHierarchy)
+ AsmManager.getDefault().getHierarchy();
+ hierarchy.cache(handle,this);
+ }
+ }
}