|
From: <caw...@us...> - 2007-07-26 17:05:00
|
Revision: 2889
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=2889&view=rev
Author: cawilliams
Date: 2007-07-26 10:04:46 -0700 (Thu, 26 Jul 2007)
Log Message:
-----------
fix #5331 - Subtype Hierarchy doesn't actually show subtypes
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LogicalType.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/hierarchy/HierarchyResolver.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LogicalType.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LogicalType.java 2007-07-26 16:48:59 UTC (rev 2888)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LogicalType.java 2007-07-26 17:04:46 UTC (rev 2889)
@@ -22,7 +22,7 @@
for (int i = 0; i < types.length; i++) {
IRubyElement[] subchildren = types[i].getChildren();
for (int j = 0; j < subchildren.length; j++) {
- children.add(subchildren[j]);
+ if (subchildren[j] != null) children.add(subchildren[j]);
}
}
return (IRubyElement[]) children.toArray(new IRubyElement[children.size()]);
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/hierarchy/HierarchyResolver.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/hierarchy/HierarchyResolver.java 2007-07-26 16:48:59 UTC (rev 2888)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/hierarchy/HierarchyResolver.java 2007-07-26 17:04:46 UTC (rev 2889)
@@ -13,6 +13,8 @@
import org.rubypeople.rdt.internal.core.LogicalType;
import org.rubypeople.rdt.internal.core.Openable;
+import com.sun.org.apache.bcel.internal.generic.GETSTATIC;
+
public class HierarchyResolver {
private boolean superTypesOnly;
@@ -25,40 +27,25 @@
public void resolve(Openable[] openables, HashSet localTypes, IProgressMonitor monitor) {
try {
int openablesLength = openables.length;
- boolean[] hasLocalType = new boolean[openablesLength];
- org.rubypeople.rdt.core.IRubyScript[] cus = new org.rubypeople.rdt.core.IRubyScript[openablesLength];
- int unitsIndex = 0;
IType focus = this.builder.getType();
- Openable focusOpenable = null;
- if (focus != null) {
- focusOpenable = (Openable)focus.getRubyScript();
- }
for (int i = 0; i < openablesLength; i++) {
Openable openable = openables[i];
if (openable instanceof org.rubypeople.rdt.core.IRubyScript) {
org.rubypeople.rdt.core.IRubyScript cu = (org.rubypeople.rdt.core.IRubyScript)openable;
-
- // contains a potential subtype as a local or anonymous type?
- boolean containsLocalType = false;
- if (localTypes == null) { // case of hierarchy on region
- containsLocalType = true;
- } else {
- IPath path = cu.getPath();
- containsLocalType = localTypes.contains(path.toString());
- }
// Grab the types from the script and then connect them up!
IType[] types = cu.getAllTypes();
for (int j = 0; j < types.length; j++) {
IType type = types[j];
- if (!type.getFullyQualifiedName().equals(builder.focusQualifiedName)) continue;
- try {
- reportHierarchy(types[j]);
- } catch (RubyModelException e) {
- // ignore
- }
+ if (focusIsInHierarchy(focus, type)) { // if it's our focus type, or a subclass
+ try {
+ reportHierarchy(type);
+ } catch (RubyModelException e) {
+ // ignore
+ }
+ }
}
}
}
@@ -69,6 +56,12 @@
}
}
+ private boolean focusIsInHierarchy(IType focus, IType type) throws RubyModelException {
+ if (focus == null || type == null) return false;
+ if (type.getFullyQualifiedName().equals(focus.getFullyQualifiedName())) return true; // type is focus
+ return focusIsInHierarchy(focus, findSuperClass(type));
+ }
+
private void reportHierarchy(IType type) throws RubyModelException {
IType superclass;
if (type.isModule()){ // do not connect modules to Object
@@ -88,7 +81,14 @@
String[] names = type.getIncludedModuleNames();
List<IType> types = new ArrayList<IType>();
for (int i = 0; i < names.length; i++) {
- types.add(getLogicalType(type, names[i]));
+ IType logical = getLogicalType(type, names[i]);
+ if (logical == null) {
+ // try to see if full name is in same namespace.
+ String namespace = type.getFullyQualifiedName().substring(0, type.getFullyQualifiedName().length() - type.getElementName().length());
+ logical = getLogicalType(type, namespace + names[i]);
+ if (logical == null) continue;
+ }
+ types.add(logical);
}
return (IType[]) types.toArray(new IType[types.size()]);
}
@@ -100,11 +100,28 @@
}
private IType getLogicalType(IType type, String name) {
+// if (type instanceof LogicalType) {
+// try {
+// return getLogicalType((LogicalType)type, name);
+// } catch (RubyModelException e) {
+// // ignore
+// }
+// }
RubyElementRequestor requestor = new RubyElementRequestor(type.getRubyScript());
IType[] types = requestor.findType(name);
if (types == null || types.length == 0) return null;
return new LogicalType(types);
}
+
+ private IType getLogicalType(LogicalType type, String name) throws RubyModelException {
+ IType[] types = type.getTypes();
+ for (int i = 0; i < types.length; i++) {
+ RubyElementRequestor requestor = new RubyElementRequestor(types[i].getRubyScript());
+ IType[] result = requestor.findType(name);
+ if (types != null && types.length > 0) return new LogicalType(result); // FIXME Concatenate results?
+ }
+ return null;
+ }
private void reset() {
// this.focusType = null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|