diff options
author | mkersten <mkersten> | 2003-08-12 10:23:30 +0000 |
---|---|---|
committer | mkersten <mkersten> | 2003-08-12 10:23:30 +0000 |
commit | 1e0113299d9eea6272c7b83b40d95b808076a028 (patch) | |
tree | 9fd2fd3ea309852fb30d1ebebcdfadb33175b0a7 | |
parent | ca4acbfcb0622ad9a83b2f37e8257b4589e0920d (diff) | |
download | aspectj-1e0113299d9eea6272c7b83b40d95b808076a028.tar.gz aspectj-1e0113299d9eea6272c7b83b40d95b808076a028.zip |
Minor improvements to structure model generation, clean up of test suite output, and port of AJDT to new ASM APIs.
-rw-r--r-- | ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserManager.java | 2 | ||||
-rw-r--r-- | asm/src/org/aspectj/asm/AsmManager.java (renamed from asm/src/org/aspectj/asm/StructureModelManager.java) | 13 | ||||
-rw-r--r-- | asm/src/org/aspectj/asm/IProgramElement.java | 65 | ||||
-rw-r--r-- | asm/src/org/aspectj/asm/IRelationshipMapper.java | 16 | ||||
-rw-r--r-- | asm/src/org/aspectj/asm/StructureModel.java | 39 | ||||
-rw-r--r-- | asm/src/org/aspectj/asm/internal/ProgramElement.java | 6 | ||||
-rw-r--r-- | asm/src/org/aspectj/asm/internal/RelationshipMapper.java | 10 | ||||
-rw-r--r-- | docs/developer/asm.doc | bin | 138240 -> 138240 bytes |
8 files changed, 88 insertions, 63 deletions
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 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("<build to view structure>", 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"); } /** @@ -167,6 +173,13 @@ public class StructureModel implements Serializable { } /** + * TODO: discriminate columns + */ + public IProgramElement findNodeForSourceLine(ISourceLocation location) { + return findNodeForSourceLine(location.getSourceFile().getAbsolutePath(), location.getLine()); + } + + /** * Never returns null * * @param sourceFilePath canonicalized path for consistency @@ -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 Binary files differindex 608f8dca5..693bf5f06 100644 --- a/docs/developer/asm.doc +++ b/docs/developer/asm.doc |