@@ -73,7 +73,7 @@ public class AsmManager implements IStructureModel { | |||
private static boolean completingTypeBindings = false; | |||
private final List structureListeners = new ArrayList(); | |||
private final List<IHierarchyListener> structureListeners = new ArrayList<IHierarchyListener>(); | |||
// The model is 'manipulated' by the AjBuildManager.setupModel() code which | |||
// trashes all the | |||
@@ -95,7 +95,7 @@ public class AsmManager implements IStructureModel { | |||
private final CanonicalFilePathMap canonicalFilePathMap = new CanonicalFilePathMap(); | |||
// Record the Set<File> for which the model has been modified during the | |||
// last incremental build | |||
private final Set lastBuildChanges = new HashSet(); | |||
private final Set<File> lastBuildChanges = new HashSet<File>(); | |||
// Record the Set<File> of aspects that wove the files listed in lastBuildChanges | |||
final Set aspectsWeavingInLastBuild = new HashSet(); | |||
@@ -148,22 +148,22 @@ public class AsmManager implements IStructureModel { | |||
return null; | |||
} | |||
HashMap annotations = new HashMap(); | |||
HashMap<Integer, List<IProgramElement>> annotations = new HashMap<Integer, List<IProgramElement>>(); | |||
IProgramElement node = hierarchy.findElementForSourceFile(sourceFile); | |||
if (node == IHierarchy.NO_STRUCTURE) { | |||
return null; | |||
} else { | |||
IProgramElement fileNode = node; | |||
ArrayList peNodes = new ArrayList(); | |||
ArrayList<IProgramElement> peNodes = new ArrayList<IProgramElement>(); | |||
getAllStructureChildren(fileNode, peNodes, showSubMember, showMemberAndType); | |||
for (Iterator it = peNodes.iterator(); it.hasNext();) { | |||
IProgramElement peNode = (IProgramElement) it.next(); | |||
List entries = new ArrayList(); | |||
for (Iterator<IProgramElement> it = peNodes.iterator(); it.hasNext();) { | |||
IProgramElement peNode = it.next(); | |||
List<IProgramElement> entries = new ArrayList<IProgramElement>(); | |||
entries.add(peNode); | |||
ISourceLocation sourceLoc = peNode.getSourceLocation(); | |||
if (null != sourceLoc) { | |||
Integer hash = new Integer(sourceLoc.getLine()); | |||
List existingEntry = (List) annotations.get(hash); | |||
List<IProgramElement> existingEntry = annotations.get(hash); | |||
if (existingEntry != null) { | |||
entries.addAll(existingEntry); | |||
} | |||
@@ -174,14 +174,14 @@ public class AsmManager implements IStructureModel { | |||
} | |||
} | |||
private void getAllStructureChildren(IProgramElement node, List result, boolean showSubMember, boolean showMemberAndType) { | |||
List children = node.getChildren(); | |||
private void getAllStructureChildren(IProgramElement node, List<IProgramElement> result, boolean showSubMember, | |||
boolean showMemberAndType) { | |||
List<IProgramElement> children = node.getChildren(); | |||
if (node.getChildren() == null) { | |||
return; | |||
} | |||
for (Iterator it = children.iterator(); it.hasNext();) { | |||
IProgramElement next = (IProgramElement) it.next(); | |||
List rels = mapper.get(next); | |||
for (IProgramElement next : children) { | |||
List<IRelationship> rels = mapper.get(next); | |||
if (next != null | |||
&& ((next.getKind() == IProgramElement.Kind.CODE && showSubMember) || (next.getKind() != IProgramElement.Kind.CODE && showMemberAndType)) | |||
&& rels != null && rels.size() > 0) { | |||
@@ -208,8 +208,8 @@ public class AsmManager implements IStructureModel { | |||
} | |||
private void notifyListeners() { | |||
for (Iterator it = structureListeners.iterator(); it.hasNext();) { | |||
((IHierarchyListener) it.next()).elementsUpdated(hierarchy); | |||
for (IHierarchyListener listener : structureListeners) { | |||
listener.elementsUpdated(hierarchy); | |||
} | |||
} | |||
@@ -297,26 +297,26 @@ public class AsmManager implements IStructureModel { | |||
// // guards to ensure correctness and liveness | |||
// private boolean cacheInUse = false; | |||
// private boolean stopRequested = false; | |||
// | |||
// | |||
// private synchronized boolean isCacheInUse() { | |||
// return cacheInUse; | |||
// } | |||
// | |||
// | |||
// private synchronized void setCacheInUse(boolean val) { | |||
// cacheInUse = val; | |||
// if (val) { | |||
// notifyAll(); | |||
// } | |||
// } | |||
// | |||
// | |||
// private synchronized boolean isStopRequested() { | |||
// return stopRequested; | |||
// } | |||
// | |||
// | |||
// private synchronized void requestStop() { | |||
// stopRequested = true; | |||
// } | |||
// | |||
// | |||
// /** | |||
// * Begin prepopulating the map by adding an entry from | |||
// * file.getPath -> file.getCanonicalPath for each file in | |||
@@ -351,7 +351,7 @@ public class AsmManager implements IStructureModel { | |||
// } | |||
// }.start(); | |||
// } | |||
// | |||
// | |||
// /** | |||
// * Stop pre-populating the cache - our customers are ready to use it. | |||
// * If there are any cache misses from this point on, we'll populate | |||
@@ -552,7 +552,7 @@ public class AsmManager implements IStructureModel { | |||
boolean modelModified = false; | |||
Set deletedNodes = new HashSet(); | |||
Set<String> deletedNodes = new HashSet<String>(); | |||
for (Iterator iter = files.iterator(); iter.hasNext();) { | |||
File fileForCompilation = (File) iter.next(); | |||
String correctedPath = getCanonicalFilePath(fileForCompilation); | |||
@@ -595,7 +595,7 @@ public class AsmManager implements IStructureModel { | |||
Set filesToRemoveFromStructureModel = new HashSet(filesToBeCompiled); | |||
filesToRemoveFromStructureModel.addAll(files_deleted); | |||
Set deletedNodes = new HashSet(); | |||
Set<String> deletedNodes = new HashSet<String>(); | |||
for (Iterator iter = filesToRemoveFromStructureModel.iterator(); iter.hasNext();) { | |||
File fileForCompilation = (File) iter.next(); | |||
String correctedPath = getCanonicalFilePath(fileForCompilation); | |||
@@ -738,7 +738,7 @@ public class AsmManager implements IStructureModel { | |||
// type (since it will be readded | |||
// when the type is woven) | |||
Set sourcehandlesSet = mapper.getEntries(); | |||
List relationshipsToRemove = new ArrayList(); | |||
List<IRelationship> relationshipsToRemove = new ArrayList<IRelationship>(); | |||
for (Iterator keyiter = sourcehandlesSet.iterator(); keyiter.hasNext();) { | |||
String hid = (String) keyiter.next(); | |||
if (isPhantomHandle(hid)) { | |||
@@ -752,18 +752,17 @@ public class AsmManager implements IStructureModel { | |||
if (sourceElement == null || sameType(hid, sourceElement, typeNode)) { | |||
// worth continuing as there may be a relationship to remove | |||
relationshipsToRemove.clear(); | |||
List relationships = mapper.get(hid); | |||
for (Iterator reliter = relationships.iterator(); reliter.hasNext();) { | |||
IRelationship rel = (IRelationship) reliter.next(); | |||
if (rel.getKind() == IRelationship.Kind.USES_POINTCUT) { | |||
List<IRelationship> relationships = mapper.get(hid); | |||
for (IRelationship relationship : relationships) { | |||
if (relationship.getKind() == IRelationship.Kind.USES_POINTCUT) { | |||
continue; // these relationships are added at compile | |||
} | |||
// time, argh | |||
if (rel.isAffects()) { | |||
if (relationship.isAffects()) { | |||
continue; // we want 'affected by' relationships - (e.g. | |||
} | |||
// advised by) | |||
relationshipsToRemove.add(rel); // all the relationships can | |||
relationshipsToRemove.add(relationship); // all the relationships can | |||
// be removed, regardless of | |||
// the target(s) | |||
} | |||
@@ -1002,12 +1001,12 @@ public class AsmManager implements IStructureModel { | |||
nonExistingHandles.add(hid); // Speed up a bit you swine | |||
} else { | |||
// Ok, so the source is valid, what about the targets? | |||
List relationships = mapper.get(hid); | |||
List relationshipsToRemove = new ArrayList(); | |||
List<IRelationship> relationships = mapper.get(hid); | |||
List<IRelationship> relationshipsToRemove = new ArrayList<IRelationship>(); | |||
// Iterate through the relationships against this source | |||
// handle | |||
for (Iterator reliter = relationships.iterator(); reliter.hasNext();) { | |||
IRelationship rel = (IRelationship) reliter.next(); | |||
for (Iterator<IRelationship> reliter = relationships.iterator(); reliter.hasNext();) { | |||
IRelationship rel = reliter.next(); | |||
List targets = rel.getTargets(); | |||
List targetsToRemove = new ArrayList(); | |||
@@ -1,5 +1,5 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 2003 Contributors. | |||
* Copyright (c) 2003,2010 Contributors | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Eclipse Public License v1.0 | |||
@@ -8,12 +8,12 @@ | |||
* | |||
* Contributors: | |||
* Mik Kersten initial implementation | |||
* Andy Clement | |||
* ******************************************************************/ | |||
package org.aspectj.asm; | |||
import java.io.Serializable; | |||
import java.util.HashMap; | |||
import java.util.Iterator; | |||
import java.util.Set; | |||
import org.aspectj.asm.internal.ProgramElement; | |||
@@ -21,8 +21,10 @@ import org.aspectj.bridge.ISourceLocation; | |||
/** | |||
* @author Mik Kersten | |||
* @author Andy Clement | |||
*/ | |||
public interface IHierarchy extends Serializable { | |||
public static final IProgramElement NO_STRUCTURE = new ProgramElement(null, "<build to view structure>", | |||
IProgramElement.Kind.ERROR, null); | |||
@@ -32,11 +34,11 @@ public interface IHierarchy extends Serializable { | |||
public void setRoot(IProgramElement root); | |||
public void addToFileMap(Object key, Object value); | |||
public void addToFileMap(String canonicalFilePath, IProgramElement compilationUnitProgramElement); | |||
public boolean removeFromFileMap(Object key); | |||
public boolean removeFromFileMap(String canonicalFilePath); | |||
public void setFileMap(HashMap fileMap); | |||
public void setFileMap(HashMap<String, IProgramElement> fileMap); | |||
public Object findInFileMap(Object key); | |||
@@ -27,9 +27,9 @@ import org.aspectj.bridge.ISourceLocation; | |||
*/ | |||
public interface IProgramElement extends Serializable { | |||
public List/* IProgramElement */getChildren(); | |||
public List<IProgramElement> getChildren(); | |||
public void setChildren(List children); | |||
public void setChildren(List<IProgramElement> children); | |||
public void addChild(IProgramElement child); | |||
@@ -152,9 +152,9 @@ public interface IProgramElement extends Serializable { | |||
public String toLabelString(boolean getFullyQualifiedArgTypes); | |||
public List getParameterNames(); | |||
public List<String> getParameterNames(); | |||
public void setParameterNames(List list); | |||
public void setParameterNames(List<String> list); | |||
public List getParameterSignatures(); | |||
@@ -329,8 +329,9 @@ public interface IProgramElement extends Serializable { | |||
public static Kind getKindForString(String kindString) { | |||
for (int i = 0; i < ALL.length; i++) { | |||
if (ALL[i].toString().equals(kindString)) | |||
if (ALL[i].toString().equals(kindString)) { | |||
return ALL[i]; | |||
} | |||
} | |||
return ERROR; | |||
} | |||
@@ -345,8 +346,8 @@ public interface IProgramElement extends Serializable { | |||
return name; | |||
} | |||
public static List getNonAJMemberKinds() { | |||
List list = new ArrayList(); | |||
public static List<Kind> getNonAJMemberKinds() { | |||
List<Kind> list = new ArrayList<Kind>(); | |||
list.add(METHOD); | |||
list.add(ENUM_VALUE); | |||
list.add(FIELD); |
@@ -22,7 +22,7 @@ public interface IRelationship extends Serializable { | |||
public String getName(); | |||
public List/* String */getTargets(); | |||
public List<String> getTargets(); | |||
public String getSourceHandle(); | |||
@@ -16,76 +16,69 @@ import java.io.Serializable; | |||
import java.util.List; | |||
import java.util.Set; | |||
//import org.aspectj.asm.IRelationship.Kind; | |||
/** | |||
* Maps from a program element handles to a list of relationships between that element | |||
* and othe program elements. Each element in the list or relationships is | |||
* uniquely identified by a kind and a relationship name. For example, the advice affecting | |||
* a particular shadow (e.g. method call) can be retrieved by calling <CODE>get</CODE> on | |||
* the handle for that method. Symmetrically the method call shadows that an advice affects | |||
* can be retrieved. | |||
* Maps from a program element handles to a list of relationships between that element and othe program elements. Each element in | |||
* the list or relationships is uniquely identified by a kind and a relationship name. For example, the advice affecting a | |||
* particular shadow (e.g. method call) can be retrieved by calling <CODE>get</CODE> on the handle for that method. Symmetrically | |||
* the method call shadows that an advice affects can be retrieved. | |||
* | |||
* The elements can be stored and looked up as IProgramElement(s), in which cases the | |||
* element corresponding to the handle is looked up in the containment hierarchy. | |||
* The elements can be stored and looked up as IProgramElement(s), in which cases the element corresponding to the handle is looked | |||
* up in the containment hierarchy. | |||
* | |||
* put/get methods taking IProgramElement as a parameter are for convenience only. | |||
* They work identically to calling their counterparts with IProgramElement.getIdentifierHandle() | |||
* put/get methods taking IProgramElement as a parameter are for convenience only. They work identically to calling their | |||
* counterparts with IProgramElement.getIdentifierHandle() | |||
* | |||
* @author Mik Kersten | |||
* @author Andy Clement | |||
*/ | |||
public interface IRelationshipMap extends Serializable { | |||
/** | |||
* @return null if the element is not found. | |||
*/ | |||
public List/*IRelationship*/ get(IProgramElement source); | |||
/** | |||
* @return null if the element is not found. | |||
*/ | |||
public List/*IRelationship*/ get(String handle); | |||
* @return null if the element is not found. | |||
*/ | |||
public List<IRelationship> get(IProgramElement source); | |||
/** | |||
* Return a relationship matching the kind and name for the given element. | |||
* | |||
* @return null if the relationship is not found. | |||
* @return null if the element is not found. | |||
*/ | |||
public IRelationship get(IProgramElement source, IRelationship.Kind kind, | |||
String relationshipName,boolean runtimeTest, | |||
boolean createIfMissing); | |||
public List<IRelationship> get(String handle); | |||
/** | |||
* Return a relationship matching the kind and name for the given element. | |||
* Return a relationship matching the kind and name for the given element. | |||
* | |||
* @return null if the relationship is not found. | |||
* @return null if the relationship is not found. | |||
*/ | |||
public IRelationship get(IProgramElement source, IRelationship.Kind kind, | |||
String relationshipName); | |||
public IRelationship get(IProgramElement source, IRelationship.Kind kind, String relationshipName, boolean runtimeTest, | |||
boolean createIfMissing); | |||
/** | |||
* Return a relationship matching the kind and name for the given element. | |||
* Creates the relationship if not found. | |||
* | |||
* @return null if the relationship is not found. | |||
* @return null if the relationship is not found. | |||
*/ | |||
public IRelationship get(String source, IRelationship.Kind kind, | |||
String relationshipName, boolean runtimeTest, | |||
boolean createIfMissing); | |||
public IRelationship get(IProgramElement source, IRelationship.Kind kind, String relationshipName); | |||
/** | |||
* Return a relationship matching the kind and name for the given element. Creates the relationship if not found. | |||
* | |||
* @return null if the relationship is not found. | |||
*/ | |||
public IRelationship get(String source, IRelationship.Kind kind, String relationshipName, boolean runtimeTest, | |||
boolean createIfMissing); | |||
public void put(IProgramElement source, IRelationship relationship); | |||
public void put(String handle, IRelationship relationship); | |||
public boolean remove(String handle, IRelationship relationship); | |||
public void removeAll(String source); | |||
/** | |||
* Clear all of the relationships in the map. | |||
*/ | |||
public void clear(); | |||
public Set getEntries(); | |||
public Set<String> getEntries(); | |||
} |
@@ -43,7 +43,7 @@ public class AspectJElementHierarchy implements IHierarchy { | |||
// Access to the handleMap and typeMap are now synchronized - at least the find methods and the updateHandleMap function | |||
// see pr305788 | |||
private Map fileMap = null; | |||
private Map<String, IProgramElement> fileMap = null; | |||
private Map handleMap = new HashMap(); | |||
private Map typeMap = null; | |||
@@ -69,18 +69,15 @@ public class AspectJElementHierarchy implements IHierarchy { | |||
typeMap = new HashMap(); | |||
} | |||
public void addToFileMap(Object key, Object value) { | |||
public void addToFileMap(String key, IProgramElement value) { | |||
fileMap.put(key, value); | |||
} | |||
public boolean removeFromFileMap(Object key) { | |||
if (fileMap.containsKey(key)) { | |||
return (fileMap.remove(key) != null); | |||
} | |||
return true; | |||
public boolean removeFromFileMap(String canonicalFilePath) { | |||
return fileMap.remove(canonicalFilePath) != null; | |||
} | |||
public void setFileMap(HashMap fileMap) { | |||
public void setFileMap(HashMap<String, IProgramElement> fileMap) { | |||
this.fileMap = fileMap; | |||
} | |||
@@ -210,13 +207,13 @@ public class AspectJElementHierarchy implements IHierarchy { | |||
* @param packagename the packagename being searched for | |||
* @return a list of package nodes that match that name | |||
*/ | |||
public List/* IProgramElement */findMatchingPackages(String packagename) { | |||
List children = root.getChildren(); | |||
public List<IProgramElement> findMatchingPackages(String packagename) { | |||
List<IProgramElement> children = root.getChildren(); | |||
// The children might be source folders or packages | |||
if (children.size() == 0) { | |||
return Collections.EMPTY_LIST; | |||
return Collections.emptyList(); | |||
} | |||
if (((IProgramElement) children.get(0)).getKind() == IProgramElement.Kind.SOURCE_FOLDER) { | |||
if ((children.get(0)).getKind() == IProgramElement.Kind.SOURCE_FOLDER) { | |||
String searchPackageName = (packagename == null ? "" : packagename); // default package means match on "" | |||
// dealing with source folders | |||
List matchingPackageNodes = new ArrayList(); | |||
@@ -559,7 +556,7 @@ public class AspectJElementHierarchy implements IHierarchy { | |||
return null; | |||
} | |||
// | |||
// | |||
// private IProgramElement findElementForBytecodeInfo( | |||
// IProgramElement node, | |||
// String parentName, | |||
@@ -601,7 +598,7 @@ public class AspectJElementHierarchy implements IHierarchy { | |||
// TODO rename this method ... it does more than just the handle map | |||
public void updateHandleMap(Set deletedFiles) { | |||
// Only delete the entries we need to from the handle map - for performance reasons | |||
List forRemoval = new ArrayList(); | |||
List<String> forRemoval = new ArrayList<String>(); | |||
Set k = null; | |||
synchronized (this) { | |||
k = handleMap.keySet(); | |||
@@ -612,8 +609,7 @@ public class AspectJElementHierarchy implements IHierarchy { | |||
forRemoval.add(handle); | |||
} | |||
} | |||
for (Iterator iter = forRemoval.iterator(); iter.hasNext();) { | |||
String handle = (String) iter.next(); | |||
for (String handle : forRemoval) { | |||
handleMap.remove(handle); | |||
} | |||
forRemoval.clear(); | |||
@@ -625,22 +621,18 @@ public class AspectJElementHierarchy implements IHierarchy { | |||
forRemoval.add(typeName); | |||
} | |||
} | |||
for (Iterator iter = forRemoval.iterator(); iter.hasNext();) { | |||
String typeName = (String) iter.next(); | |||
for (String typeName : forRemoval) { | |||
typeMap.remove(typeName); | |||
} | |||
forRemoval.clear(); | |||
} | |||
k = fileMap.keySet(); | |||
for (Iterator iter = k.iterator(); iter.hasNext();) { | |||
String filePath = (String) iter.next(); | |||
IProgramElement ipe = (IProgramElement) fileMap.get(filePath); | |||
if (deletedFiles.contains(getCanonicalFilePath(ipe))) { | |||
for (Map.Entry<String, IProgramElement> entry : fileMap.entrySet()) { | |||
String filePath = entry.getKey(); | |||
if (deletedFiles.contains(getCanonicalFilePath(entry.getValue()))) { | |||
forRemoval.add(filePath); | |||
} | |||
} | |||
for (Iterator iter = forRemoval.iterator(); iter.hasNext();) { | |||
String filePath = (String) iter.next(); | |||
for (String filePath : forRemoval) { | |||
fileMap.remove(filePath); | |||
} | |||
} |
@@ -142,12 +142,16 @@ public class NameConvertor { | |||
*/ | |||
public static char[] createShortName(char[] c, boolean haveFullyQualifiedAtLeastOneThing, boolean needsFullyQualifiedFirstEntry) { | |||
if (c[0] == '[') { | |||
char[] ret = CharOperation.concat(new char[] { '\\', '[' }, createShortName(CharOperation.subarray(c, 1, c.length), | |||
haveFullyQualifiedAtLeastOneThing, needsFullyQualifiedFirstEntry)); | |||
char[] ret = CharOperation.concat( | |||
new char[] { '\\', '[' }, | |||
createShortName(CharOperation.subarray(c, 1, c.length), haveFullyQualifiedAtLeastOneThing, | |||
needsFullyQualifiedFirstEntry)); | |||
return ret; | |||
} else if (c[0] == '+') { | |||
char[] ret = CharOperation.concat(new char[] { '+' }, createShortName(CharOperation.subarray(c, 1, c.length), | |||
haveFullyQualifiedAtLeastOneThing, needsFullyQualifiedFirstEntry)); | |||
char[] ret = CharOperation.concat( | |||
new char[] { '+' }, | |||
createShortName(CharOperation.subarray(c, 1, c.length), haveFullyQualifiedAtLeastOneThing, | |||
needsFullyQualifiedFirstEntry)); | |||
return ret; | |||
} else if (c[0] == '*') { | |||
return c; // c is *>; | |||
@@ -195,8 +199,8 @@ public class NameConvertor { | |||
BACKSLASH_LESSTHAN); | |||
return CharOperation.concat(inclLT, createShortName(second, true, false)); | |||
} else if (smallest == gt) { | |||
char[] inclLT = CharOperation.concat(createShortName(first, haveFullyQualifiedAtLeastOneThing, | |||
needsFullyQualifiedFirstEntry), GREATER_THAN); | |||
char[] inclLT = CharOperation.concat( | |||
createShortName(first, haveFullyQualifiedAtLeastOneThing, needsFullyQualifiedFirstEntry), GREATER_THAN); | |||
return CharOperation.concat(inclLT, createShortName(second, true, false)); | |||
} else { | |||
// if c = 'Ljava/lang/Sting;LMyClass;' then first = 'Ljava/lang/String' | |||
@@ -212,8 +216,6 @@ public class NameConvertor { | |||
// return getTypeName(name, false); | |||
// } | |||
private static final char[] WILDCARD = new char[] { '+' }; | |||
/** | |||
* Convert a typename into its handle form. There are various cases to consider here - many are discussed in pr249216. The flag | |||
* allreadyFQd indicates if we've already included a fq'd name in what we are creating - if we have then further references |
@@ -53,25 +53,22 @@ public class ProgramElement implements IProgramElement { | |||
protected String name; | |||
private Kind kind; | |||
protected IProgramElement parent = null; | |||
protected List children = Collections.EMPTY_LIST; | |||
protected List<IProgramElement> children = Collections.emptyList(); | |||
public Map kvpairs = Collections.EMPTY_MAP; | |||
protected ISourceLocation sourceLocation = null; | |||
public int modifiers; | |||
private String handle = null; | |||
// --- ctors | |||
public AsmManager getModel() { | |||
return asm; | |||
} | |||
/** Used during de-externalization */ | |||
public ProgramElement() { | |||
int stop = 1; | |||
} | |||
/** Use to create program element nodes that do not correspond to source locations */ | |||
public ProgramElement(AsmManager asm, String name, Kind kind, List children) { | |||
public ProgramElement(AsmManager asm, String name, Kind kind, List<IProgramElement> children) { | |||
this.asm = asm; | |||
if (asm == null && !name.equals("<build to view structure>")) { | |||
throw new RuntimeException(); | |||
@@ -84,7 +81,7 @@ public class ProgramElement implements IProgramElement { | |||
} | |||
public ProgramElement(AsmManager asm, String name, IProgramElement.Kind kind, ISourceLocation sourceLocation, int modifiers, | |||
String comment, List children) { | |||
String comment, List<IProgramElement> children) { | |||
this(asm, name, kind, children); | |||
this.sourceLocation = sourceLocation; | |||
setFormalComment(comment); | |||
@@ -277,8 +274,8 @@ public class ProgramElement implements IProgramElement { | |||
return toLabelString(); | |||
} | |||
private static List genModifiers(int modifiers) { | |||
List modifiersList = new ArrayList(); | |||
private static List<IProgramElement.Modifiers> genModifiers(int modifiers) { | |||
List<IProgramElement.Modifiers> modifiersList = new ArrayList<IProgramElement.Modifiers>(); | |||
if ((modifiers & AccStatic) != 0) { | |||
modifiersList.add(IProgramElement.Modifiers.STATIC); | |||
} | |||
@@ -448,19 +445,19 @@ public class ProgramElement implements IProgramElement { | |||
return children; | |||
} | |||
public void setChildren(List children) { | |||
public void setChildren(List<IProgramElement> children) { | |||
this.children = children; | |||
if (children == null) { | |||
return; | |||
} | |||
for (Iterator it = children.iterator(); it.hasNext();) { | |||
((IProgramElement) it.next()).setParent(this); | |||
for (Iterator<IProgramElement> it = children.iterator(); it.hasNext();) { | |||
(it.next()).setParent(this); | |||
} | |||
} | |||
public void addChild(IProgramElement child) { | |||
if (children == null || children == Collections.EMPTY_LIST) { | |||
children = new ArrayList(); | |||
children = new ArrayList<IProgramElement>(); | |||
} | |||
children.add(child); | |||
child.setParent(this); | |||
@@ -468,7 +465,7 @@ public class ProgramElement implements IProgramElement { | |||
public void addChild(int position, IProgramElement child) { | |||
if (children == null || children == Collections.EMPTY_LIST) { | |||
children = new ArrayList(); | |||
children = new ArrayList<IProgramElement>(); | |||
} | |||
children.add(position, child); | |||
child.setParent(this); | |||
@@ -640,12 +637,12 @@ public class ProgramElement implements IProgramElement { | |||
this.handle = handle; | |||
} | |||
public List getParameterNames() { | |||
List parameterNames = (List) kvpairs.get("parameterNames"); | |||
public List<String> getParameterNames() { | |||
List<String> parameterNames = (List<String>) kvpairs.get("parameterNames"); | |||
return parameterNames; | |||
} | |||
public void setParameterNames(List list) { | |||
public void setParameterNames(List<String> list) { | |||
if (list == null || list.size() == 0) { | |||
return; | |||
} | |||
@@ -656,21 +653,21 @@ public class ProgramElement implements IProgramElement { | |||
// parameterNames = list; | |||
} | |||
public List getParameterTypes() { | |||
List l = getParameterSignatures(); | |||
public List<char[]> getParameterTypes() { | |||
List<char[]> l = getParameterSignatures(); | |||
if (l == null || l.isEmpty()) { | |||
return Collections.EMPTY_LIST; | |||
return Collections.emptyList(); | |||
} | |||
List params = new ArrayList(); | |||
for (Iterator iter = l.iterator(); iter.hasNext();) { | |||
char[] param = (char[]) iter.next(); | |||
List<char[]> params = new ArrayList<char[]>(); | |||
for (Iterator<char[]> iter = l.iterator(); iter.hasNext();) { | |||
char[] param = iter.next(); | |||
params.add(NameConvertor.convertFromSignature(param)); | |||
} | |||
return params; | |||
} | |||
public List getParameterSignatures() { | |||
List parameters = (List) kvpairs.get("parameterSigs"); | |||
public List<char[]> getParameterSignatures() { | |||
List<char[]> parameters = (List<char[]>) kvpairs.get("parameterSigs"); | |||
return parameters; | |||
} | |||
@@ -1,5 +1,5 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 2003 Contributors. | |||
* Copyright (c) 2003,2010 Contributors | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Eclipse Public License v1.0 | |||
@@ -18,39 +18,29 @@ import org.aspectj.asm.IRelationship; | |||
/** | |||
* @author Mik Kersten | |||
* @author Andy Clement | |||
*/ | |||
public class Relationship implements IRelationship { | |||
private static final long serialVersionUID = 3855166397957609120L; | |||
private String name; | |||
private Kind kind; | |||
private boolean isAffects; | |||
private String sourceHandle; | |||
private List targets; | |||
private List<String> targets; | |||
private boolean hasRuntimeTest; | |||
public Relationship( | |||
String name, | |||
Kind kind, | |||
String sourceHandle, | |||
List targets, | |||
boolean runtimeTest) { | |||
public Relationship(String name, Kind kind, String sourceHandle, List<String> targets, boolean runtimeTest) { | |||
this.name = name; | |||
this.isAffects = | |||
name.equals("advises") || | |||
name.equals("declares on") || | |||
name.equals("softens") || | |||
name.equals("matched by") || | |||
name.equals("declared on") || | |||
name.equals("annotates"); | |||
this.isAffects = name.equals("advises") || name.equals("declares on") || name.equals("softens") | |||
|| name.equals("matched by") || name.equals("declared on") || name.equals("annotates"); | |||
this.kind = kind; | |||
this.sourceHandle = sourceHandle; | |||
this.targets = targets; | |||
this.hasRuntimeTest = runtimeTest; | |||
} | |||
} | |||
public String getName() { | |||
return name; | |||
} | |||
@@ -61,29 +51,31 @@ public class Relationship implements IRelationship { | |||
public String toString() { | |||
return name; | |||
} | |||
} | |||
public String getSourceHandle() { | |||
return sourceHandle; | |||
} | |||
// TODO should be a Set and not a list | |||
public List getTargets() { | |||
public List<String> getTargets() { | |||
return targets; | |||
} | |||
public void addTarget(String handle) { | |||
if (targets.contains(handle)) return; | |||
if (targets.contains(handle)) { | |||
return; | |||
} | |||
targets.add(handle); | |||
} | |||
public boolean hasRuntimeTest() { | |||
return hasRuntimeTest; | |||
} | |||
/** | |||
* Return the direction of the relationship. It might be affects or affected-by. | |||
* The direction enables the incremental model repair code to do the right thing. | |||
* Return the direction of the relationship. It might be affects or affected-by. The direction enables the incremental model | |||
* repair code to do the right thing. | |||
* | |||
* @return true if is an affects relationship: advises/declareson/softens/matchedby/declaredon/annotates | |||
*/ |
@@ -1,5 +1,5 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 2003 Contributors. | |||
* Copyright (c) 2003,2010 Contributors | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Eclipse Public License v1.0 | |||
@@ -8,6 +8,7 @@ | |||
* | |||
* Contributors: | |||
* Mik Kersten initial implementation | |||
* Andy Clement | |||
* ******************************************************************/ | |||
package org.aspectj.asm.internal; | |||
@@ -21,16 +22,14 @@ import java.util.Set; | |||
import org.aspectj.asm.IHierarchy; | |||
import org.aspectj.asm.IProgramElement; | |||
import org.aspectj.asm.IRelationship; | |||
import org.aspectj.asm.IRelationshipMap; | |||
import org.aspectj.asm.IRelationship.Kind; | |||
import org.aspectj.asm.IRelationshipMap; | |||
/** | |||
* TODO: add a remove, and a clear all | |||
* | |||
* @author Mik Kersten | |||
* | |||
* @author Andy Clement | |||
*/ | |||
public class RelationshipMap extends HashMap implements IRelationshipMap { | |||
public class RelationshipMap extends HashMap<String, List<IRelationship>> implements IRelationshipMap { | |||
private static final long serialVersionUID = 496638323566589643L; | |||
@@ -50,8 +49,8 @@ public class RelationshipMap extends HashMap implements IRelationshipMap { | |||
// this.hierarchy = hierarchy; | |||
} | |||
public List get(String handle) { | |||
List relationships = (List) super.get(handle); | |||
public List<IRelationship> get(String handle) { | |||
List<IRelationship> relationships = super.get(handle); | |||
if (relationships == null) { | |||
return null; | |||
} else { | |||
@@ -59,25 +58,26 @@ public class RelationshipMap extends HashMap implements IRelationshipMap { | |||
} | |||
} | |||
public List get(IProgramElement source) { | |||
public List<IRelationship> get(IProgramElement source) { | |||
return get(source.getHandleIdentifier()); | |||
} | |||
public IRelationship get(String source, IRelationship.Kind kind, String relationshipName, boolean runtimeTest, | |||
boolean createIfMissing) { | |||
List relationships = get(source); | |||
List<IRelationship> relationships = get(source); | |||
if (relationships == null) { | |||
if (!createIfMissing) | |||
if (!createIfMissing) { | |||
return null; | |||
relationships = new ArrayList(); | |||
IRelationship rel = new Relationship(relationshipName, kind, source, new ArrayList(), runtimeTest); | |||
} | |||
relationships = new ArrayList<IRelationship>(); | |||
IRelationship rel = new Relationship(relationshipName, kind, source, new ArrayList<String>(), runtimeTest); | |||
relationships.add(rel); | |||
super.put(source, relationships); | |||
return rel; | |||
} else { | |||
for (Iterator it = relationships.iterator(); it.hasNext();) { | |||
IRelationship curr = (IRelationship) it.next(); | |||
for (Iterator<IRelationship> it = relationships.iterator(); it.hasNext();) { | |||
IRelationship curr = it.next(); | |||
if (curr.getKind() == kind && curr.getName().equals(relationshipName) && curr.hasRuntimeTest() == runtimeTest) { | |||
return curr; | |||
} | |||
@@ -85,7 +85,7 @@ public class RelationshipMap extends HashMap implements IRelationshipMap { | |||
if (createIfMissing) { | |||
// At this point we did find some relationships for 'source' but not one that looks like what we are | |||
// after (either the kind or the name or the dynamictests setting don't match) | |||
IRelationship rel = new Relationship(relationshipName, kind, source, new ArrayList(), runtimeTest); | |||
IRelationship rel = new Relationship(relationshipName, kind, source, new ArrayList<String>(), runtimeTest); | |||
relationships.add(rel); | |||
return rel; | |||
} | |||
@@ -103,7 +103,7 @@ public class RelationshipMap extends HashMap implements IRelationshipMap { | |||
} | |||
public boolean remove(String source, IRelationship relationship) { | |||
List list = (List) super.get(source); | |||
List<IRelationship> list = super.get(source); | |||
if (list != null) { | |||
return list.remove(relationship); | |||
// boolean matched = false; | |||
@@ -123,25 +123,19 @@ public class RelationshipMap extends HashMap implements IRelationshipMap { | |||
super.remove(source); | |||
} | |||
public Object put(Object o, Object p) { | |||
return super.put(o, p); | |||
} | |||
public void put(String source, IRelationship relationship) { | |||
// System.err.println(">> for: " + source + ", put::" + relationship); | |||
List list = (List) super.get(source); | |||
List<IRelationship> list = super.get(source); | |||
if (list == null) { | |||
list = new ArrayList(); | |||
list = new ArrayList<IRelationship>(); | |||
list.add(relationship); | |||
super.put(source, list); | |||
} else { | |||
boolean matched = false; | |||
for (Iterator it = list.iterator(); it.hasNext();) { | |||
IRelationship curr = (IRelationship) it.next(); | |||
for (IRelationship curr : list) { | |||
if (curr.getName().equals(relationship.getName()) && curr.getKind() == relationship.getKind()) { | |||
curr.getTargets().addAll(relationship.getTargets()); | |||
matched = true; | |||
@@ -151,8 +145,9 @@ public class RelationshipMap extends HashMap implements IRelationshipMap { | |||
// bug? | |||
System.err.println("matched = true"); | |||
} | |||
if (matched) | |||
if (matched) { | |||
list.add(relationship); // Is this a bug, will it give us double entries? | |||
} | |||
} | |||
} | |||
@@ -164,7 +159,7 @@ public class RelationshipMap extends HashMap implements IRelationshipMap { | |||
super.clear(); | |||
} | |||
public Set getEntries() { | |||
public Set<String> getEntries() { | |||
return keySet(); | |||
} | |||