summaryrefslogtreecommitdiffstats
path: root/ajde/src
diff options
context:
space:
mode:
authormkersten <mkersten>2003-08-12 10:29:59 +0000
committermkersten <mkersten>2003-08-12 10:29:59 +0000
commit11d7649fc3219af5a71d3bf0b9fe004c075c2b4f (patch)
tree11280a5298e3169aba7086e69b0512dc4c99f7ff /ajde/src
parent1e0113299d9eea6272c7b83b40d95b808076a028 (diff)
downloadaspectj-11d7649fc3219af5a71d3bf0b9fe004c075c2b4f.tar.gz
aspectj-11d7649fc3219af5a71d3bf0b9fe004c075c2b4f.zip
Minor improvements to structure model generation, clean up of test suite output, and port of AJDT to new ASM APIs.
Diffstat (limited to 'ajde/src')
-rw-r--r--ajde/src/org/aspectj/ajde/Ajde.java8
-rw-r--r--ajde/src/org/aspectj/ajde/ui/BuildConfigModel.java57
-rw-r--r--ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java28
-rw-r--r--ajde/src/org/aspectj/ajde/ui/StructureViewManager.java6
-rw-r--r--ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java6
-rw-r--r--ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java26
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/IconRegistry.java2
7 files changed, 89 insertions, 44 deletions
diff --git a/ajde/src/org/aspectj/ajde/Ajde.java b/ajde/src/org/aspectj/ajde/Ajde.java
index f75e3de82..032ad6e59 100644
--- a/ajde/src/org/aspectj/ajde/Ajde.java
+++ b/ajde/src/org/aspectj/ajde/Ajde.java
@@ -20,7 +20,7 @@ import org.aspectj.ajde.ui.IdeUIAdapter;
import org.aspectj.ajde.ui.StructureSearchManager;
import org.aspectj.ajde.ui.StructureViewManager;
import org.aspectj.ajde.ui.StructureViewNodeFactory;
-import org.aspectj.asm.StructureModelManager;
+import org.aspectj.asm.AsmManager;
import org.aspectj.bridge.Version;
import org.aspectj.util.LangUtil;
import org.aspectj.util.Reflection;
@@ -175,8 +175,8 @@ public class Ajde {
* use should be avoided. Used <CODE>getStructureViewManager()</CODE>
* instead.
*/
- public StructureModelManager getStructureModelManager() {
- return StructureModelManager.getDefault();
+ public AsmManager getStructureModelManager() {
+ return AsmManager.getDefault();
}
public void logEvent(String message) {
@@ -307,7 +307,7 @@ public class Ajde {
public void compileFinished(String buildConfig, int buildTime, boolean succeeded, boolean warnings) {
String configFilePath = projectProperties.getDefaultBuildConfigFile();
if (!succeeded) {
- StructureModelManager.getDefault().fireModelUpdated();
+ AsmManager.getDefault().fireModelUpdated();
}
}
diff --git a/ajde/src/org/aspectj/ajde/ui/BuildConfigModel.java b/ajde/src/org/aspectj/ajde/ui/BuildConfigModel.java
index fdd00fb76..c5fe1d5b9 100644
--- a/ajde/src/org/aspectj/ajde/ui/BuildConfigModel.java
+++ b/ajde/src/org/aspectj/ajde/ui/BuildConfigModel.java
@@ -14,14 +14,12 @@
package org.aspectj.ajde.ui;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.aspectj.asm.StructureModel;
+import java.io.IOException;
+import java.util.*;
/**
+ * TODO: we have schitzophrenia between BuildConfigNode(s) and IProgramElement(s), fix.
+ *
* @author Mik Kersten
*/
public class BuildConfigModel {
@@ -104,6 +102,53 @@ public class BuildConfigModel {
public void setRoot(BuildConfigNode node) {
root = node;
}
+
+ public BuildConfigNode findNodeForSourceLine(String sourceFilePath, int lineNumber) {
+ BuildConfigNode node = findNodeForSourceLineHelper(root, sourceFilePath, lineNumber);
+ return node;
+ }
+
+ private BuildConfigNode findNodeForSourceLineHelper(BuildConfigNode node, String sourceFilePath, int lineNumber) {
+ if (matches(node, sourceFilePath, lineNumber)
+ && !hasMoreSpecificChild(node, sourceFilePath, lineNumber)) {
+ return node;
+ }
+
+ if (node != null && node.getChildren() != null) {
+ for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
+ BuildConfigNode foundNode = findNodeForSourceLineHelper(
+ (BuildConfigNode)it.next(),
+ sourceFilePath,
+ lineNumber);
+ if (foundNode != null) return foundNode;
+ }
+ }
+ return null;
+ }
+
+ private boolean matches(BuildConfigNode node, String sourceFilePath, int lineNumber) {
+ try {
+ return node != null
+ && node.getSourceLocation() != null
+ && node.getSourceLocation().getSourceFile().getCanonicalPath().equals(sourceFilePath)
+ && ((node.getSourceLocation().getLine() <= lineNumber
+ && node.getSourceLocation().getEndLine() >= lineNumber)
+ ||
+ (lineNumber <= 1
+ && node instanceof BuildConfigNode)
+ );
+ } catch (IOException ioe) {
+ return false;
+ }
+ }
+
+ private boolean hasMoreSpecificChild(BuildConfigNode node, String sourceFilePath, int lineNumber) {
+ for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
+ BuildConfigNode child = (BuildConfigNode)it.next();
+ if (matches(child, sourceFilePath, lineNumber)) return true;
+ }
+ return false;
+ }
}
diff --git a/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java b/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java
index 0e12d5f7c..ec0b44a9e 100644
--- a/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java
+++ b/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java
@@ -37,23 +37,23 @@ public class StructureModelUtil {
public static Map getLinesToAspectMap(String sourceFilePath) {
Map annotationsMap =
- StructureModelManager.getDefault().getInlineAnnotations(
+ AsmManager.getDefault().getInlineAnnotations(
sourceFilePath,
true,
true);
Map aspectMap = new HashMap();
Set keys = annotationsMap.keySet();
- for (Iterator it = keys.iterator(); it.hasNext();) {
- Object key = it.next();
- List annotations = (List) annotationsMap.get(key);
- for (Iterator it2 = annotations.iterator(); it2.hasNext();) {
- IProgramElement node = (IProgramElement) it2.next();
+// for (Iterator it = keys.iterator(); it.hasNext();) {
+// Object key = it.next();
+// List annotations = (List) annotationsMap.get(key);
+// for (Iterator it2 = annotations.iterator(); it2.hasNext();) {
+// IProgramElement node = (IProgramElement) it2.next();
- List relations = node.getRelations();
-
- for (Iterator it3 = relations.iterator(); it3.hasNext();) {
- IRelationship relationNode = (IRelationship) it3.next();
+// List relations = node.getRelations();
+//
+// for (Iterator it3 = relations.iterator(); it3.hasNext();) {
+// IRelationship relationNode = (IRelationship) it3.next();
// if (relationNode.getKind().equals("Advice")) {
// List children = relationNode.getTargets();
@@ -83,10 +83,10 @@ public class StructureModelUtil {
// aspectMap.put(key, aspects);
// }
// }
-
- }
- }
- }
+//
+// }
+// }
+// }
return aspectMap;
}
diff --git a/ajde/src/org/aspectj/ajde/ui/StructureViewManager.java b/ajde/src/org/aspectj/ajde/ui/StructureViewManager.java
index 8acbbacba..7170001ba 100644
--- a/ajde/src/org/aspectj/ajde/ui/StructureViewManager.java
+++ b/ajde/src/org/aspectj/ajde/ui/StructureViewManager.java
@@ -55,7 +55,7 @@ public class StructureViewManager {
public StructureViewManager(StructureViewNodeFactory nodeFactory) {
treeViewBuilder = new TreeStructureViewBuilder(nodeFactory);
- StructureModelManager.getDefault().addListener(VIEW_LISTENER);
+ AsmManager.getDefault().addListener(VIEW_LISTENER);
}
public void fireNavigateBackAction(StructureView view) {
@@ -127,7 +127,7 @@ public class StructureViewManager {
if (defaultFileView.getSourceFile() != null
&& !defaultFileView.getSourceFile().equals(newFilePath)) {
defaultFileView.setSourceFile(newFilePath);
- treeViewBuilder.buildView(defaultFileView, StructureModelManager.getDefault().getModel());
+ treeViewBuilder.buildView(defaultFileView, AsmManager.getDefault().getModel());
}
}
@@ -195,7 +195,7 @@ public class StructureViewManager {
if (properties == null) properties = DEFAULT_VIEW_PROPERTIES;
FileStructureView view = new FileStructureView(properties);
view.setSourceFile(sourceFilePath);
- treeViewBuilder.buildView(view, StructureModelManager.getDefault().getModel());
+ treeViewBuilder.buildView(view, AsmManager.getDefault().getModel());
structureViews.add(view);
return view;
}
diff --git a/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java b/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java
index 1e41d6759..2cb822827 100644
--- a/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java
+++ b/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java
@@ -37,7 +37,7 @@ public abstract class StructureViewNodeFactory {
AbstractIcon icon = iconRegistry.getStructureIcon(node.getKind(), node.getAccessibility());
IStructureViewNode svNode = createDeclaration(node, icon, children);
- IRelationship rel = StructureModelManager.getDefault().getMapper().get(node);
+ IRelationship rel = AsmManager.getDefault().getMapper().get(node);
if (rel != null && rel.getTargets().size() > 0) {
IStructureViewNode relNode = createRelationship(
rel,
@@ -48,8 +48,8 @@ public abstract class StructureViewNodeFactory {
for (Iterator it = rel.getTargets().iterator(); it.hasNext(); ) {
IProgramElement link = (IProgramElement)it.next();
IStructureViewNode linkNode = createLink(
- link,
- iconRegistry.getIcon(link.getKind())
+ link,
+ iconRegistry.getStructureIcon(link.getKind(), link.getAccessibility())
);
relNode.add(linkNode);
diff --git a/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java b/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java
index 06534507f..cdbd5a11d 100644
--- a/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java
+++ b/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java
@@ -97,14 +97,14 @@ public class TreeStructureViewBuilder {
if (node == null) return null;
List children = new ArrayList();
// IProgramElement pNode = node;
- if (node.getRelations() != null) {
- for (Iterator it = node.getRelations().iterator(); it.hasNext(); ) {
- IProgramElement IProgramElement = (IProgramElement)it.next();
- if (acceptNode(IProgramElement, properties)) {
- children.add(createViewNode(IProgramElement, properties));
- }
- }
- }
+// if (node.getRelations() != null) {
+// for (Iterator it = node.getRelations().iterator(); it.hasNext(); ) {
+// IProgramElement IProgramElement = (IProgramElement)it.next();
+// if (acceptNode(IProgramElement, properties)) {
+// children.add(createViewNode(IProgramElement, properties));
+// }
+// }
+// }
if (node.isRunnable() && node.getParent() != null) {
IProgramElement parent = node.getParent();
if (parent.getKind().equals(IProgramElement.Kind.CLASS)
@@ -166,7 +166,7 @@ public class TreeStructureViewBuilder {
IProgramElement pNode = (IProgramElement)node;
if (!acceptGranularity(pNode.getKind(), properties.getGranularity())) {
return false;
- } else if (pNode.isMemberKind()) {
+ } else if (pNode.getKind().isMemberKind()) {
if (properties.getFilteredMemberAccessibility().contains(pNode.getAccessibility())) {
return false;
}
@@ -259,7 +259,7 @@ public class TreeStructureViewBuilder {
private IStructureViewNode getInheritanceChildren(IProgramElement node, List associations) {
IStructureViewNode treeNode = nodeFactory.createNode(node);
//StructureViewNode treeNode = new StructureViewNodeAdapter(node);
- List relations = ((IProgramElement)node).getRelations();
+// List relations = ((IProgramElement)node).getRelations();
throw new RuntimeException("unimplemented");
// if (relations != null) {
// for (Iterator it = relations.iterator(); it.hasNext(); ) {
@@ -282,8 +282,8 @@ public class TreeStructureViewBuilder {
private IStructureViewNode getCrosscuttingChildren(IProgramElement node) {
//StructureViewNodeAdapter treeNode = new StructureViewNodeAdapter(node);
- IStructureViewNode treeNode = nodeFactory.createNode(node);
- List relations = ((IProgramElement)node).getRelations();
+// IStructureViewNode treeNode = nodeFactory.createNode(node);
+// List relations = ((IProgramElement)node).getRelations();
throw new RuntimeException("unimplemented");
// if (relations != null) {
// for (Iterator it = relations.iterator(); it.hasNext(); ) {
@@ -336,7 +336,7 @@ public class TreeStructureViewBuilder {
IProgramElement child = (IProgramElement)itt.next();
if (child instanceof IProgramElement) {
IProgramElement progNode = (IProgramElement)child;
- if (!progNode.isCode()) {
+ if (progNode.getKind() != IProgramElement.Kind.CODE) {
childList.add(buildTree(child, associations));
}
} else {
diff --git a/ajde/src/org/aspectj/ajde/ui/swing/IconRegistry.java b/ajde/src/org/aspectj/ajde/ui/swing/IconRegistry.java
index f119a452c..e5ed1b908 100644
--- a/ajde/src/org/aspectj/ajde/ui/swing/IconRegistry.java
+++ b/ajde/src/org/aspectj/ajde/ui/swing/IconRegistry.java
@@ -112,7 +112,7 @@ public class IconRegistry extends AbstractIconRegistry {
return convertToSwingIcon(getIcon(relation));
}
- protected AbstractIcon getStructureIcon(IProgramElement.Kind kind, IProgramElement.Accessibility accessibility) {
+ public AbstractIcon getStructureIcon(IProgramElement.Kind kind, IProgramElement.Accessibility accessibility) {
return getIcon(kind);
}