aboutsummaryrefslogtreecommitdiffstats
path: root/asm/src
diff options
context:
space:
mode:
authoraclement <aclement>2010-07-14 21:01:58 +0000
committeraclement <aclement>2010-07-14 21:01:58 +0000
commit8b1628b65f7dc5931768859474bea963e404b4ed (patch)
tree41f58150c9008cb705c3c31d8259d2821c9d03b0 /asm/src
parente8de3dc7d910fec7065bdafd9c0a30e6a8f5e64a (diff)
downloadaspectj-8b1628b65f7dc5931768859474bea963e404b4ed.tar.gz
aspectj-8b1628b65f7dc5931768859474bea963e404b4ed.zip
generics
Diffstat (limited to 'asm/src')
-rw-r--r--asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java97
-rw-r--r--asm/src/org/aspectj/asm/internal/JDTLikeHandleProvider.java4
-rw-r--r--asm/src/org/aspectj/asm/internal/ProgramElement.java21
-rw-r--r--asm/src/org/aspectj/asm/internal/RelationshipMap.java3
4 files changed, 74 insertions, 51 deletions
diff --git a/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java b/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java
index 9d9ae930b..2f348fe02 100644
--- a/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java
+++ b/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java
@@ -18,7 +18,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -62,6 +61,26 @@ public class AspectJElementHierarchy implements IHierarchy {
public IProgramElement getRoot() {
return root;
}
+
+ public String toSummaryString() {
+ StringBuilder s = new StringBuilder();
+ s.append("FileMap has "+fileMap.size()+" entries\n");
+ s.append("HandleMap has "+handleMap.size()+" entries\n");
+ s.append("TypeMap has "+handleMap.size()+" entries\n");
+ s.append("FileMap:\n");
+ for (Map.Entry<String,IProgramElement> fileMapEntry: fileMap.entrySet()) {
+ s.append(fileMapEntry).append("\n");
+ }
+ s.append("TypeMap:\n");
+ for (Map.Entry<String,IProgramElement> typeMapEntry: typeMap.entrySet()) {
+ s.append(typeMapEntry).append("\n");
+ }
+ s.append("HandleMap:\n");
+ for (Map.Entry<String,IProgramElement> handleMapEntry: handleMap.entrySet()) {
+ s.append(handleMapEntry).append("\n");
+ }
+ return s.toString();
+ }
public void setRoot(IProgramElement root) {
this.root = root;
@@ -101,8 +120,7 @@ public class AspectJElementHierarchy implements IHierarchy {
* @return null if not found
*/
public IProgramElement findElementForSignature(IProgramElement parent, IProgramElement.Kind kind, String signature) {
- for (Iterator it = parent.getChildren().iterator(); it.hasNext();) {
- IProgramElement node = (IProgramElement) it.next();
+ for (IProgramElement node : parent.getChildren()) {
if (node.getKind() == kind && signature.equals(node.toSignatureString())) {
return node;
} else {
@@ -116,9 +134,7 @@ public class AspectJElementHierarchy implements IHierarchy {
}
public IProgramElement findElementForLabel(IProgramElement parent, IProgramElement.Kind kind, String label) {
-
- for (Iterator it = parent.getChildren().iterator(); it.hasNext();) {
- IProgramElement node = (IProgramElement) it.next();
+ for (IProgramElement node : parent.getChildren()) {
if (node.getKind() == kind && label.equals(node.toLabelString())) {
return node;
} else {
@@ -150,13 +166,11 @@ public class AspectJElementHierarchy implements IHierarchy {
return cachedValue;
}
- List packageNodes = findMatchingPackages(packageName);
+ List<IProgramElement> packageNodes = findMatchingPackages(packageName);
- for (Iterator iterator = packageNodes.iterator(); iterator.hasNext();) {
- IProgramElement pkg = (IProgramElement) iterator.next();
+ for (IProgramElement pkg : packageNodes) {
// this searches each file for a class
- for (Iterator it = pkg.getChildren().iterator(); it.hasNext();) {
- IProgramElement fileNode = (IProgramElement) it.next();
+ for (IProgramElement fileNode : pkg.getChildren()) {
IProgramElement cNode = findClassInNodes(fileNode.getChildren(), typeName, typeName);
if (cNode != null) {
typeMap.put(key, cNode);
@@ -245,8 +259,7 @@ public class AspectJElementHierarchy implements IHierarchy {
}
if (possiblePackage.getKind() == IProgramElement.Kind.SOURCE_FOLDER) { // might be 'binaries'
if (possiblePackage.getName().equals("binaries")) {
- for (Iterator iter2 = possiblePackage.getChildren().iterator(); iter2.hasNext();) {
- IProgramElement possiblePackage2 = (IProgramElement) iter2.next();
+ for (IProgramElement possiblePackage2 : possiblePackage.getChildren()) {
if (possiblePackage2.getKind() == IProgramElement.Kind.PACKAGE
&& possiblePackage2.getName().equals(packagename)) {
result.add(possiblePackage2);
@@ -257,14 +270,14 @@ public class AspectJElementHierarchy implements IHierarchy {
}
}
if (result.isEmpty()) {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
} else {
return result;
}
}
}
- private IProgramElement findClassInNodes(Collection nodes, String name, String typeName) {
+ private IProgramElement findClassInNodes(Collection<IProgramElement> nodes, String name, String typeName) {
String baseName;
String innerName;
int dollar = name.indexOf('$');
@@ -276,8 +289,7 @@ public class AspectJElementHierarchy implements IHierarchy {
innerName = name.substring(dollar + 1);
}
- for (Iterator j = nodes.iterator(); j.hasNext();) {
- IProgramElement classNode = (IProgramElement) j.next();
+ for (IProgramElement classNode : nodes) {
if (baseName.equals(classNode.getName())) {
if (innerName == null) {
return classNode;
@@ -429,8 +441,7 @@ public class AspectJElementHierarchy implements IHierarchy {
if (node == null || node.getChildren() == null) {
return null;
}
- for (Iterator childrenIter = node.getChildren().iterator(); childrenIter.hasNext();) {
- IProgramElement child = (IProgramElement) childrenIter.next();
+ for (IProgramElement child : node.getChildren()) {
ISourceLocation childLoc = child.getSourceLocation();
if (childLoc != null) {
if (childLoc.getLine() <= lineno && childLoc.getEndLine() >= lineno) {
@@ -459,8 +470,8 @@ public class AspectJElementHierarchy implements IHierarchy {
}
if (node != null) {
- for (Iterator it = node.getChildren().iterator(); it.hasNext();) {
- IProgramElement foundNode = findNodeForSourceLineHelper((IProgramElement) it.next(), sourceFilePath, lineno, offset);
+ for (IProgramElement child : node.getChildren()) {
+ IProgramElement foundNode = findNodeForSourceLineHelper(child, sourceFilePath, lineno, offset);
if (foundNode != null) {
return foundNode;
}
@@ -490,8 +501,7 @@ public class AspectJElementHierarchy implements IHierarchy {
}
private boolean hasMoreSpecificChild(IProgramElement node, String sourceFilePath, int lineNumber, int offSet) {
- for (Iterator it = node.getChildren().iterator(); it.hasNext();) {
- IProgramElement child = (IProgramElement) it.next();
+ for (IProgramElement child : node.getChildren()) {
if (matches(child, sourceFilePath, lineNumber, offSet)) {
return true;
}
@@ -522,7 +532,6 @@ public class AspectJElementHierarchy implements IHierarchy {
if (ipe != null) {
return ipe;
}
-
ipe = findElementForHandle(root, handle);
if (ipe == null && create) {
ipe = createFileStructureNode(getFilename(handle));
@@ -535,8 +544,7 @@ public class AspectJElementHierarchy implements IHierarchy {
}
private IProgramElement findElementForHandle(IProgramElement parent, String handle) {
- for (Iterator it = parent.getChildren().iterator(); it.hasNext();) {
- IProgramElement node = (IProgramElement) it.next();
+ for (IProgramElement node : parent.getChildren()) {
String nodeHid = node.getHandleIdentifier();
if (handle.equals(nodeHid)) {
return node;
@@ -591,16 +599,44 @@ public class AspectJElementHierarchy implements IHierarchy {
public void flushFileMap() {
fileMap.clear();
}
+
+ public void forget(IProgramElement compilationUnitNode,IProgramElement typeNode) {
+ String k = null;
+ synchronized (this) {
+ // handle map
+ // type map
+ for (Map.Entry<String,IProgramElement> typeMapEntry: typeMap.entrySet()) {
+ if (typeMapEntry.getValue()==typeNode) {
+ k = typeMapEntry.getKey();
+ break;
+ }
+ }
+ if (k!=null) {
+ typeMap.remove(k);
+ }
+ }
+
+ if (compilationUnitNode!=null) {
+ k = null;
+ for (Map.Entry<String,IProgramElement> entry: fileMap.entrySet()) {
+ if (entry.getValue()==compilationUnitNode) {
+ k = entry.getKey();break;
+ }
+ }
+ if (k!=null) {
+ fileMap.remove(k);
+ }
+ }
+ }
// TODO rename this method ... it does more than just the handle map
public void updateHandleMap(Set<String> deletedFiles) {
// Only delete the entries we need to from the handle map - for performance reasons
List<String> forRemoval = new ArrayList<String>();
- Set k = null;
+ Set<String> k = null;
synchronized (this) {
k = handleMap.keySet();
- for (Iterator iter = k.iterator(); iter.hasNext();) {
- String handle = (String) iter.next();
+ for (String handle : k) {
IProgramElement ipe = handleMap.get(handle);
if (deletedFiles.contains(getCanonicalFilePath(ipe))) {
forRemoval.add(handle);
@@ -611,8 +647,7 @@ public class AspectJElementHierarchy implements IHierarchy {
}
forRemoval.clear();
k = typeMap.keySet();
- for (Iterator iter = k.iterator(); iter.hasNext();) {
- String typeName = (String) iter.next();
+ for (String typeName : k) {
IProgramElement ipe = typeMap.get(typeName);
if (deletedFiles.contains(getCanonicalFilePath(ipe))) {
forRemoval.add(typeName);
diff --git a/asm/src/org/aspectj/asm/internal/JDTLikeHandleProvider.java b/asm/src/org/aspectj/asm/internal/JDTLikeHandleProvider.java
index 47c4eaf3b..bcf8fbf49 100644
--- a/asm/src/org/aspectj/asm/internal/JDTLikeHandleProvider.java
+++ b/asm/src/org/aspectj/asm/internal/JDTLikeHandleProvider.java
@@ -127,12 +127,12 @@ public class JDTLikeHandleProvider implements IElementHandleProvider {
if (ipe.getParameterSignatures() == null || ipe.getParameterSignatures().isEmpty()) {
return "";
}
- List sourceRefs = ipe.getParameterSignaturesSourceRefs();
+ List<String> sourceRefs = ipe.getParameterSignaturesSourceRefs();
List<char[]> parameterTypes = ipe.getParameterSignatures();
StringBuffer sb = new StringBuffer();
if (sourceRefs != null) {
for (int i = 0; i < sourceRefs.size(); i++) {
- String sourceRef = (String) sourceRefs.get(i);
+ String sourceRef = sourceRefs.get(i);
sb.append(HandleProviderDelimiter.getDelimiter(ipe));
sb.append(sourceRef);
}
diff --git a/asm/src/org/aspectj/asm/internal/ProgramElement.java b/asm/src/org/aspectj/asm/internal/ProgramElement.java
index 9d8ff660f..1bed76f0e 100644
--- a/asm/src/org/aspectj/asm/internal/ProgramElement.java
+++ b/asm/src/org/aspectj/asm/internal/ProgramElement.java
@@ -47,9 +47,9 @@ public class ProgramElement implements IProgramElement {
private final static int AccVolatile = 0x0040;
private final static int AccTransient = 0x0080;
private final static int AccNative = 0x0100;
- private final static int AccInterface = 0x0200;
+ // private final static int AccInterface = 0x0200;
private final static int AccAbstract = 0x0400;
- private final static int AccStrictfp = 0x0800;
+ // private final static int AccStrictfp = 0x0800;
protected String name;
private Kind kind;
@@ -213,18 +213,6 @@ public class ProgramElement implements IProgramElement {
}
}
- public List getRelations() {
- return (List) kvpairs.get("relations");
- }
-
- public void setRelations(List relations) {
- if (relations.size() > 0) {
- fixMap();
- kvpairs.put("relations", relations);
- // this.relations = relations;
- }
- }
-
public String getFormalComment() {
return (String) kvpairs.get("formalComment");
// return formalComment;
@@ -386,7 +374,7 @@ public class ProgramElement implements IProgramElement {
return name;
}
- public List getChildren() {
+ public List<IProgramElement> getChildren() {
return children;
}
@@ -427,8 +415,7 @@ public class ProgramElement implements IProgramElement {
public IProgramElement walk(HierarchyWalker walker) {
if (children != null) {
- for (Iterator it = children.iterator(); it.hasNext();) {
- IProgramElement child = (IProgramElement) it.next();
+ for (IProgramElement child : children) {
walker.process(child);
}
}
diff --git a/asm/src/org/aspectj/asm/internal/RelationshipMap.java b/asm/src/org/aspectj/asm/internal/RelationshipMap.java
index f6cdffe8c..1fea7bb85 100644
--- a/asm/src/org/aspectj/asm/internal/RelationshipMap.java
+++ b/asm/src/org/aspectj/asm/internal/RelationshipMap.java
@@ -119,7 +119,8 @@ public class RelationshipMap extends HashMap<String, List<IRelationship>> implem
} else {
boolean matched = false;
for (IRelationship existingRelationship : existingRelationships) {
- if (existingRelationship.getName().equals(relationship.getName()) && existingRelationship.getKind() == relationship.getKind()) {
+ if (existingRelationship.getName().equals(relationship.getName())
+ && existingRelationship.getKind() == relationship.getKind()) {
existingRelationship.getTargets().addAll(relationship.getTargets());
matched = true;
}