AjdeUIManager.getDefault().getOptionsFrame().addOptionsPanel(new BrowserOptionsPanel());
- StructureModelManager.getDefault().addListener(VIEW_LISTENER);
+ AsmManager.getDefault().addListener(VIEW_LISTENER);
//String lastOpenFilePath = browserProjectProperties.getLastOpenSourceFilePath();
//editorManager.showSourceLine(lastOpenFilePath, 1, false);
--- /dev/null
+/* *******************************************************************
+ * Copyright (c) 1999-2001 Xerox Corporation,
+ * 2002 Palo Alto Research Center, Incorporated (PARC).
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Common Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
+ * ******************************************************************/
+
+
+package org.aspectj.asm;
+
+import java.io.*;
+import java.util.*;
+
+import org.aspectj.asm.internal.*;
+
+/**
+ * @author Mik Kersten
+ */
+public class AsmManager {
+
+ /**
+ * @deprecated use getDefault() method instead
+ */
+ private static AsmManager INSTANCE = new AsmManager();
+ private boolean shouldSaveModel = true;
+ protected StructureModel model = new StructureModel();
+ private List structureListeners = new ArrayList();
+ private IRelationshipMapper mapper;
+
+ protected AsmManager() {
+ List relationships = new ArrayList();
+// relationships.add(ADVICE);
+ mapper = new RelationshipMapper();
+ }
+
+ public StructureModel getModel() {
+ return model;
+ }
+
+ public void fireModelUpdated() {
+ notifyListeners();
+ if (model.getConfigFile() != null) {
+ writeStructureModel(model.getConfigFile());
+ }
+ }
+
+ /**
+ * Constructs map each time it's called.
+ */
+ public HashMap getInlineAnnotations(
+ String sourceFile,
+ boolean showSubMember,
+ boolean showMemberAndType) {
+
+ throw new RuntimeException("unimplemented");
+
+// if (!model.isValid()) return null;
+//
+// HashMap annotations = new HashMap();
+// IProgramElement node = model.findRootNodeForSourceFile(sourceFile);
+// if (node == StructureModel.NO_STRUCTURE) {
+// return null;
+// } else {
+// IProgramElement fileNode = (IProgramElement)node;
+// ArrayList peNodes = new ArrayList();
+// getAllStructureChildren(fileNode, peNodes, showSubMember, showMemberAndType);
+// for (Iterator it = peNodes.iterator(); it.hasNext(); ) {
+// IProgramElement peNode = (IProgramElement)it.next();
+// List entries = new ArrayList();
+// entries.add(peNode);
+// ISourceLocation sourceLoc = peNode.getSourceLocation();
+// if (null != sourceLoc) {
+// Integer hash = new Integer(sourceLoc.getLine());
+// List existingEntry = (List)annotations.get(hash);
+// if (existingEntry != null) {
+// entries.addAll(existingEntry);
+// }
+// annotations.put(hash, entries);
+// }
+// }
+// return annotations;
+// }
+ }
+
+// private void getAllStructureChildren(IProgramElement node, List result, boolean showSubMember, boolean showMemberAndType) {
+// List children = node.getChildren();
+// for (Iterator it = children.iterator(); it.hasNext(); ) {
+// IProgramElement next = (IProgramElement)it.next();
+// if (next instanceof IProgramElement) {
+// IProgramElement pNode = (IProgramElement)next;
+// if (pNode != null
+// && ((pNode.isCode() && showSubMember) || (!pNode.isCode() && showMemberAndType))
+// && pNode.getRelations() != null
+// && pNode.getRelations().size() > 0) {
+// result.add(next);
+// }
+// getAllStructureChildren((IProgramElement)next, result, showSubMember, showMemberAndType);
+// }
+// }
+// }
+
+ public void addListener(IStructureModelListener listener) {
+ structureListeners.add(listener);
+ }
+
+ public void removeStructureListener(IStructureModelListener listener) {
+ structureListeners.remove(listener);
+ }
+
+ private void notifyListeners() {
+ for (Iterator it = structureListeners.iterator(); it.hasNext(); ) {
+ ((IStructureModelListener)it.next()).containmentHierarchyUpdated(model);
+ }
+ }
+
+ /**
+ * Fails silently.
+ */
+ public void writeStructureModel(String configFilePath) {
+ try {
+ String filePath = genExternFilePath(configFilePath);
+ ObjectOutputStream s = new ObjectOutputStream(new FileOutputStream(filePath));
+ s.writeObject(model);
+ s.flush();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ /**
+ * @todo add proper handling of bad paths/suffixes/etc
+ * @param configFilePath path to an ".lst" file
+ */
+ public void readStructureModel(String configFilePath) {
+ try {
+ if (configFilePath == null) {
+ model.setRoot(StructureModel.NO_STRUCTURE);
+ } else {
+ String filePath = genExternFilePath(configFilePath);
+ FileInputStream in = new FileInputStream(filePath);
+ ObjectInputStream s = new ObjectInputStream(in);
+ model = (StructureModel)s.readObject();
+ }
+ } catch (Exception e) {
+ //System.err.println("AJDE Message: could not read structure model: " + e);
+ model.setRoot(StructureModel.NO_STRUCTURE);
+ } finally {
+ notifyListeners();
+ }
+ }
+
+ private String genExternFilePath(String configFilePath) {
+ return configFilePath.substring(0, configFilePath.lastIndexOf(".lst")) + ".ajsym";
+ }
+
+ public void setShouldSaveModel(boolean shouldSaveModel) {
+ this.shouldSaveModel = shouldSaveModel;
+ }
+
+ public static AsmManager getDefault() {
+ return INSTANCE;
+ }
+
+ public IRelationshipMapper getMapper() {
+ return mapper;
+ }
+
+}
+
public interface IProgramElement extends Serializable {
public List/*IProgramElement*/ getChildren();
+
+ public void setChildren(List children);
public void addChild(IProgramElement child);
- public Kind getKind();
+
+ public IProgramElement getParent();
+ public void setParent(IProgramElement parent);
+
+ public String getName();
+ public void setName(String name);
+
+ public IProgramElement.Kind getKind();
+ public void setKind(Kind kind);
+
public List getModifiers();
+ public void setModifiers(int i);
+
public Accessibility getAccessibility();
- public String getDeclaringType();
+
+ public String getDeclaringType(); // TODO: remove (Emacs uses it)
public String getPackageName();
- public String getSignature();
- public String getName();
- public boolean isCode();
- public boolean isMemberKind();
+
+ public void setReturnType(String returnType);
+ public String getReturnType();
+
+ public String getFullSignature();
+ public void setFullSignature(String string);
+
public void setRunnable(boolean value);
public boolean isRunnable();
+
public boolean isImplementor();
public void setImplementor(boolean value);
+
public boolean isOverrider();
public void setOverrider(boolean value);
- public List getRelations();
- public void setRelations(List relations);
- public String getFormalComment();
+
+ public IMessage getMessage();
+ public void setMessage(IMessage message);
+
+ public ISourceLocation getSourceLocation();
+ public void setSourceLocation(ISourceLocation sourceLocation);
+
public String toString();
+
+ // public String getHandle() TODO: check IJavaElement
+
+ /**
+ * @return a string representation of this node and all of its children (recursive)
+ */
+ public String toLongString();
+
public String getBytecodeName();
public String getBytecodeSignature();
public void setBytecodeName(String bytecodeName);
public void setBytecodeSignature(String bytecodeSignature);
- public String getFullSignature();
- public void setFullSignature(String string);
- public void setKind(Kind kind);
- public void setReturnType(String returnType);
- public String getReturnType();
- public ISourceLocation getSourceLocation();
- public void setSourceLocation(ISourceLocation sourceLocation);
- public IMessage getMessage();
- public void setMessage(IMessage message);
- public IProgramElement getParent();
- public void setParent(IProgramElement parent);
+
public IProgramElement walk(HierarchyWalker walker);
- public void setName(String name);
- public void setChildren(List children);
- public void setModifiers(int i);
-// public String getSignatureKey();
/**
* Uses "typesafe enum" pattern.
* @author Mik Kersten
*/
public interface IRelationshipMapper extends Serializable {
-
-// public List getRelationshipsForElement(String source, IRelationship relationship);
-//
-// public void putRelationshipForElement(String source, IRelationship relationship, List targets);
-//
-// public void putRelationshipForElement(String source, IRelationship kind, String target);
+ // TODO: return a list
public IRelationship get(IProgramElement source);
-
-// public void putRelationshipForElement(IProgramElement source, IRelationship relationship, List targets);
-
+
+ // TODO: return a list
+ public IRelationship get(String handle);
+
public void put(IProgramElement source, IRelationship relationship);
+
+
}
import java.util.*;
import org.aspectj.asm.internal.ProgramElement;
-import org.aspectj.bridge.SourceLocation;
+import org.aspectj.bridge.*;
/**
* @author Mik Kersten
public static final IProgramElement NO_STRUCTURE = new ProgramElement("<build to view structure>", IProgramElement.Kind.ERROR, null);
+ public IProgramElement getElement(String handle) {
+ throw new RuntimeException("unimplemented");
+ }
+
public IProgramElement getRoot() {
return root;
}
this.root = root;
}
- private Map getFileMap() {
- return fileMap;
- }
-
public void addToFileMap( Object key, Object value ){
fileMap.put( key, value );
}
-
+
+ public void setFileMap(HashMap fileMap) {
+ this.fileMap = fileMap;
+ }
+
public Object findInFileMap( Object key ) {
return fileMap.get(key);
}
- public void setFileMap(HashMap fileMap) {
- this.fileMap = fileMap;
- }
public Set getFileMapEntrySet() {
return fileMap.entrySet();
return root != null && fileMap != null;
}
+
/**
* Returns the first match
*
return null;
}
+ /**
+ *
+ * @param signatureKey PackageName.TypeName.Signature.SourceLine.SourceColumn
+ */
public IProgramElement findNodeForSignatureKey(String signatureKey) {
- return null;
+ throw new RuntimeException("unimplemented");
}
/**
}
}
+ /**
+ * TODO: discriminate columns
+ */
+ public IProgramElement findNodeForSourceLine(ISourceLocation location) {
+ return findNodeForSourceLine(location.getSourceFile().getAbsolutePath(), location.getLine());
+ }
+
/**
* Never returns null
*
* @return a new structure node for the file if it was not found in the model
*/
public IProgramElement findNodeForSourceLine(String sourceFilePath, int lineNumber) {
- String correctedPath = sourceFilePath;//.replace('\\', '/');
- IProgramElement node = findNodeForSourceLineHelper(root, correctedPath, lineNumber);
+ IProgramElement node = findNodeForSourceLineHelper(root, sourceFilePath, lineNumber);
if (node != null) {
return node;
} else {
&& node.getSourceLocation().getSourceFile().getCanonicalPath().equals(sourceFilePath)
&& ((node.getSourceLocation().getLine() <= lineNumber
&& node.getSourceLocation().getEndLine() >= lineNumber)
- ||
+ ||
(lineNumber <= 1
&& node instanceof IProgramElement
&& ((IProgramElement)node).getKind().isSourceFileKind())
public void setConfigFile(String configFile) {
this.configFile = configFile;
}
-
}
+++ /dev/null
-/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Common Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.asm;
-
-import java.io.*;
-import java.util.*;
-
-import org.aspectj.asm.internal.*;
-
-/**
- * @author Mik Kersten
- */
-public class StructureModelManager {
-
- /**
- * @deprecated use getDefault() method instead
- */
- public static StructureModelManager INSTANCE = new StructureModelManager();
- private boolean shouldSaveModel = true;
- protected StructureModel model = new StructureModel();
- private List structureListeners = new ArrayList();
-
- private IRelationshipMapper mapper;
-// 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();
- }
-
- public StructureModel getModel() {
- return model;
- }
-
- public void fireModelUpdated() {
- notifyListeners();
- if (model.getConfigFile() != null) {
- writeStructureModel(model.getConfigFile());
- }
- }
-
- /**
- * Constructs map each time it's called.
- */
- public HashMap getInlineAnnotations(
- String sourceFile,
- boolean showSubMember,
- boolean showMemberAndType) {
-
- throw new RuntimeException("unimplemented");
-
-// if (!model.isValid()) return null;
-//
-// HashMap annotations = new HashMap();
-// IProgramElement node = model.findRootNodeForSourceFile(sourceFile);
-// if (node == StructureModel.NO_STRUCTURE) {
-// return null;
-// } else {
-// IProgramElement fileNode = (IProgramElement)node;
-// ArrayList peNodes = new ArrayList();
-// getAllStructureChildren(fileNode, peNodes, showSubMember, showMemberAndType);
-// for (Iterator it = peNodes.iterator(); it.hasNext(); ) {
-// IProgramElement peNode = (IProgramElement)it.next();
-// List entries = new ArrayList();
-// entries.add(peNode);
-// ISourceLocation sourceLoc = peNode.getSourceLocation();
-// if (null != sourceLoc) {
-// Integer hash = new Integer(sourceLoc.getLine());
-// List existingEntry = (List)annotations.get(hash);
-// if (existingEntry != null) {
-// entries.addAll(existingEntry);
-// }
-// annotations.put(hash, entries);
-// }
-// }
-// return annotations;
-// }
- }
-
-// private void getAllStructureChildren(IProgramElement node, List result, boolean showSubMember, boolean showMemberAndType) {
-// List children = node.getChildren();
-// for (Iterator it = children.iterator(); it.hasNext(); ) {
-// IProgramElement next = (IProgramElement)it.next();
-// if (next instanceof IProgramElement) {
-// IProgramElement pNode = (IProgramElement)next;
-// if (pNode != null
-// && ((pNode.isCode() && showSubMember) || (!pNode.isCode() && showMemberAndType))
-// && pNode.getRelations() != null
-// && pNode.getRelations().size() > 0) {
-// result.add(next);
-// }
-// getAllStructureChildren((IProgramElement)next, result, showSubMember, showMemberAndType);
-// }
-// }
-// }
-
- public void addListener(IStructureModelListener listener) {
- structureListeners.add(listener);
- }
-
- public void removeStructureListener(IStructureModelListener listener) {
- structureListeners.remove(listener);
- }
-
- private void notifyListeners() {
- for (Iterator it = structureListeners.iterator(); it.hasNext(); ) {
- ((IStructureModelListener)it.next()).containmentHierarchyUpdated(model);
- }
- }
-
- /**
- * Fails silently.
- */
- public void writeStructureModel(String configFilePath) {
- try {
- String filePath = genExternFilePath(configFilePath);
- ObjectOutputStream s = new ObjectOutputStream(new FileOutputStream(filePath));
- s.writeObject(model);
- s.flush();
- } catch (Exception e) {
- // ignore
- }
- }
-
- /**
- * @todo add proper handling of bad paths/suffixes/etc
- * @param configFilePath path to an ".lst" file
- */
- public void readStructureModel(String configFilePath) {
- try {
- if (configFilePath == null) {
- model.setRoot(StructureModel.NO_STRUCTURE);
- } else {
- String filePath = genExternFilePath(configFilePath);
- FileInputStream in = new FileInputStream(filePath);
- ObjectInputStream s = new ObjectInputStream(in);
- model = (StructureModel)s.readObject();
- }
- } catch (Exception e) {
- //System.err.println("AJDE Message: could not read structure model: " + e);
- model.setRoot(StructureModel.NO_STRUCTURE);
- } finally {
- notifyListeners();
- }
- }
-
- private String genExternFilePath(String configFilePath) {
- return configFilePath.substring(0, configFilePath.lastIndexOf(".lst")) + ".ajsym";
- }
-
- public void setShouldSaveModel(boolean shouldSaveModel) {
- this.shouldSaveModel = shouldSaveModel;
- }
-
- public static StructureModelManager getDefault() {
- return INSTANCE;
- }
- public IRelationshipMapper getMapper() {
- return mapper;
- }
-
-}
-
}
public String getPackageName() {
- if (kind == Kind.PACKAGE) return getSignature();
+ if (kind == Kind.PACKAGE) return getName();
if (getParent() == null || !(getParent() instanceof IProgramElement)) {
return "";
}
return kind;
}
- public String getSignature() {
- return name;
- }
-
public boolean isCode() {
return kind.equals(Kind.CODE);
}
return (IRelationship)super.get(source);
}
- /**
- * Creates the relationship if not present.
- */
+ public IRelationship get(String handle) {
+ throw new RuntimeException("unimplemented");
+ }
+
public void put(IProgramElement source, IRelationship relationship) {
super.put(source, relationship);
}
+
+ // TODO: add a remove, and a clear all
private static class RelationshipTable {
private IRelationship relationship;
return relationship;
}
}
+
}