summaryrefslogtreecommitdiffstats
path: root/ajde
diff options
context:
space:
mode:
authoraclement <aclement>2008-08-22 19:07:49 +0000
committeraclement <aclement>2008-08-22 19:07:49 +0000
commitba7d08a7631a6e7ee4685f4a893bb69ac6151aab (patch)
treebd15b16ca9d659d581d40e4ef54ee956ed881050 /ajde
parentc16372339bd3e5c6ec5b5fae538a0e9b504ef8e1 (diff)
downloadaspectj-ba7d08a7631a6e7ee4685f4a893bb69ac6151aab.tar.gz
aspectj-ba7d08a7631a6e7ee4685f4a893bb69ac6151aab.zip
incorrectly removed this code - although it needs changing, it needs null checks, not instanceof checks
Diffstat (limited to 'ajde')
-rw-r--r--ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java45
1 files changed, 30 insertions, 15 deletions
diff --git a/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java b/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java
index c187fe3c2..5b312fd25 100644
--- a/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java
+++ b/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java
@@ -386,26 +386,41 @@ public class TreeStructureViewBuilder {
public int compare(Object o1, Object o2) {
IProgramElement sv1 = ((IStructureViewNode)o1).getStructureNode();
IProgramElement sv2 = ((IStructureViewNode)o2).getStructureNode();
- if (sv1.getKind() == IProgramElement.Kind.IMPORT_REFERENCE) return 1;
- if (sv2.getKind() == IProgramElement.Kind.IMPORT_REFERENCE) return -1;
- return sv1.getName().compareTo(sv2.getName());
+
+ if (sv1 instanceof IProgramElement && sv2 instanceof IProgramElement) {
+
+ IProgramElement p1 = (IProgramElement)sv1;
+ IProgramElement p2 = (IProgramElement)sv2;
+
+ if (p2.getKind() == IProgramElement.Kind.IMPORT_REFERENCE) return 1;
+ if (p1.getKind() == IProgramElement.Kind.IMPORT_REFERENCE) return -1;
+
+ return p1.getName().compareTo(p2.getName());
+ } else {
+ return 0;
+ }
}
};
private static final Comparator DECLARATIONAL_COMPARATOR = new Comparator() {
public int compare(Object o1, Object o2) {
- IProgramElement p1 = ((IStructureViewNode)o1).getStructureNode();
- IProgramElement p2 = ((IStructureViewNode)o2).getStructureNode();
-
- if (p2.getKind() == IProgramElement.Kind.IMPORT_REFERENCE) return 1;
- if (p1.getKind() == IProgramElement.Kind.IMPORT_REFERENCE) return -1;
- if (p1.getSourceLocation() == null || p2.getSourceLocation() == null) {
- return 0;
- } else if (p1.getSourceLocation().getLine() < p2.getSourceLocation().getLine()) {
- return -1;
- } else {
- return 1;
- }
+ IProgramElement sv1 = ((IStructureViewNode)o1).getStructureNode();
+ IProgramElement sv2 = ((IStructureViewNode)o2).getStructureNode();
+ if (sv1 instanceof IProgramElement && sv2 instanceof IProgramElement) {
+ IProgramElement p1 = (IProgramElement)sv1;
+ IProgramElement p2 = (IProgramElement)sv2;
+ if (p2.getKind() == IProgramElement.Kind.IMPORT_REFERENCE) return 1;
+ if (p1.getKind() == IProgramElement.Kind.IMPORT_REFERENCE) return -1;
+ if (p1.getSourceLocation() == null || p2.getSourceLocation() == null) {
+ return 0;
+ } else if (p1.getSourceLocation().getLine() < p2.getSourceLocation().getLine()) {
+ return -1;
+ } else {
+ return 1;
+ }
+ } else {
+ return 0;
+ }
}
};
}