From 1e0113299d9eea6272c7b83b40d95b808076a028 Mon Sep 17 00:00:00 2001 From: mkersten Date: Tue, 12 Aug 2003 10:23:30 +0000 Subject: [PATCH] Minor improvements to structure model generation, clean up of test suite output, and port of AJDT to new ASM APIs. --- .../tools/ajbrowser/BrowserManager.java | 2 +- ...ctureModelManager.java => AsmManager.java} | 13 ++-- asm/src/org/aspectj/asm/IProgramElement.java | 65 +++++++++++------- .../org/aspectj/asm/IRelationshipMapper.java | 16 ++--- asm/src/org/aspectj/asm/StructureModel.java | 39 +++++++---- .../aspectj/asm/internal/ProgramElement.java | 6 +- .../asm/internal/RelationshipMapper.java | 10 ++- docs/developer/asm.doc | Bin 138240 -> 138240 bytes 8 files changed, 88 insertions(+), 63 deletions(-) rename asm/src/org/aspectj/asm/{StructureModelManager.java => AsmManager.java} (94%) diff --git a/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserManager.java b/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserManager.java index 6ed175fed..c11db4399 100644 --- a/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserManager.java +++ b/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserManager.java @@ -102,7 +102,7 @@ public class BrowserManager { 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); diff --git a/asm/src/org/aspectj/asm/StructureModelManager.java b/asm/src/org/aspectj/asm/AsmManager.java similarity index 94% rename from asm/src/org/aspectj/asm/StructureModelManager.java rename to asm/src/org/aspectj/asm/AsmManager.java index 1e966bb01..dda0ab096 100644 --- a/asm/src/org/aspectj/asm/StructureModelManager.java +++ b/asm/src/org/aspectj/asm/AsmManager.java @@ -22,20 +22,18 @@ import org.aspectj.asm.internal.*; /** * @author Mik Kersten */ -public class StructureModelManager { +public class AsmManager { /** * @deprecated use getDefault() method instead - */ - public static StructureModelManager INSTANCE = new StructureModelManager(); + */ + private static AsmManager INSTANCE = new AsmManager(); 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() { + protected AsmManager() { List relationships = new ArrayList(); // relationships.add(ADVICE); mapper = new RelationshipMapper(); @@ -165,9 +163,10 @@ public class StructureModelManager { this.shouldSaveModel = shouldSaveModel; } - public static StructureModelManager getDefault() { + public static AsmManager getDefault() { return INSTANCE; } + public IRelationshipMapper getMapper() { return mapper; } diff --git a/asm/src/org/aspectj/asm/IProgramElement.java b/asm/src/org/aspectj/asm/IProgramElement.java index 8cde25862..ced44fa7e 100644 --- a/asm/src/org/aspectj/asm/IProgramElement.java +++ b/asm/src/org/aspectj/asm/IProgramElement.java @@ -23,46 +23,63 @@ import org.aspectj.bridge.*; 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. diff --git a/asm/src/org/aspectj/asm/IRelationshipMapper.java b/asm/src/org/aspectj/asm/IRelationshipMapper.java index d27aec8d3..ab8fffd34 100644 --- a/asm/src/org/aspectj/asm/IRelationshipMapper.java +++ b/asm/src/org/aspectj/asm/IRelationshipMapper.java @@ -21,17 +21,15 @@ import org.aspectj.asm.IRelationship.Kind; * @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); + + } diff --git a/asm/src/org/aspectj/asm/StructureModel.java b/asm/src/org/aspectj/asm/StructureModel.java index 60f48edcb..36318a2e5 100644 --- a/asm/src/org/aspectj/asm/StructureModel.java +++ b/asm/src/org/aspectj/asm/StructureModel.java @@ -18,7 +18,7 @@ import java.io.*; import java.util.*; import org.aspectj.asm.internal.ProgramElement; -import org.aspectj.bridge.SourceLocation; +import org.aspectj.bridge.*; /** * @author Mik Kersten @@ -32,6 +32,10 @@ public class StructureModel implements Serializable { public static final IProgramElement NO_STRUCTURE = new ProgramElement("", IProgramElement.Kind.ERROR, null); + public IProgramElement getElement(String handle) { + throw new RuntimeException("unimplemented"); + } + public IProgramElement getRoot() { return root; } @@ -40,21 +44,18 @@ public class StructureModel implements Serializable { 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(); @@ -64,6 +65,7 @@ public class StructureModel implements Serializable { return root != null && fileMap != null; } + /** * Returns the first match * @@ -86,8 +88,12 @@ public class StructureModel implements Serializable { return null; } + /** + * + * @param signatureKey PackageName.TypeName.Signature.SourceLine.SourceColumn + */ public IProgramElement findNodeForSignatureKey(String signatureKey) { - return null; + throw new RuntimeException("unimplemented"); } /** @@ -166,6 +172,13 @@ public class StructureModel implements Serializable { } } + /** + * TODO: discriminate columns + */ + public IProgramElement findNodeForSourceLine(ISourceLocation location) { + return findNodeForSourceLine(location.getSourceFile().getAbsolutePath(), location.getLine()); + } + /** * Never returns null * @@ -174,8 +187,7 @@ public class StructureModel implements Serializable { * @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 { @@ -224,7 +236,7 @@ public class StructureModel implements Serializable { && node.getSourceLocation().getSourceFile().getCanonicalPath().equals(sourceFilePath) && ((node.getSourceLocation().getLine() <= lineNumber && node.getSourceLocation().getEndLine() >= lineNumber) - || + || (lineNumber <= 1 && node instanceof IProgramElement && ((IProgramElement)node).getKind().isSourceFileKind()) @@ -249,6 +261,5 @@ public class StructureModel implements Serializable { public void setConfigFile(String configFile) { this.configFile = configFile; } - } diff --git a/asm/src/org/aspectj/asm/internal/ProgramElement.java b/asm/src/org/aspectj/asm/internal/ProgramElement.java index 9562169cd..9b2e3fdb0 100644 --- a/asm/src/org/aspectj/asm/internal/ProgramElement.java +++ b/asm/src/org/aspectj/asm/internal/ProgramElement.java @@ -121,7 +121,7 @@ public class ProgramElement implements IProgramElement { } public String getPackageName() { - if (kind == Kind.PACKAGE) return getSignature(); + if (kind == Kind.PACKAGE) return getName(); if (getParent() == null || !(getParent() instanceof IProgramElement)) { return ""; } @@ -132,10 +132,6 @@ public class ProgramElement implements IProgramElement { return kind; } - public String getSignature() { - return name; - } - public boolean isCode() { return kind.equals(Kind.CODE); } diff --git a/asm/src/org/aspectj/asm/internal/RelationshipMapper.java b/asm/src/org/aspectj/asm/internal/RelationshipMapper.java index 706a5603b..e794b76e0 100644 --- a/asm/src/org/aspectj/asm/internal/RelationshipMapper.java +++ b/asm/src/org/aspectj/asm/internal/RelationshipMapper.java @@ -25,12 +25,15 @@ public class RelationshipMapper extends HashMap implements IRelationshipMapper { 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; @@ -49,4 +52,5 @@ public class RelationshipMapper extends HashMap implements IRelationshipMapper { return relationship; } } + } diff --git a/docs/developer/asm.doc b/docs/developer/asm.doc index 608f8dca5229ee847f8fe76309b1f3df6e08c3b8..693bf5f06ad748db1cb48cabe9a27fbcc8d00dbc 100644 GIT binary patch delta 8075 zcmeI1dvH@#9>>o~Zkj+Jq^~qBg$5|J#XeGCc`du3Le(q^DmZGZC2dMu#wMM%PzplA zpt7?#BY1Y9GRhX#8AsOPl^qHw(DIUpKr09cicnq_k?Pjh?C#)xe>XWvNP*p*{bOfG zP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