|
From: <caw...@us...> - 2007-07-30 18:49:02
|
Revision: 2901
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=2901&view=rev
Author: cawilliams
Date: 2007-07-30 11:48:50 -0700 (Mon, 30 Jul 2007)
Log Message:
-----------
when resolving a method, if we can't find the method up the type hierarchy, then do a global search for exact matches of the name.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java 2007-07-30 13:18:48 UTC (rev 2900)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java 2007-07-30 18:48:50 UTC (rev 2901)
@@ -59,8 +59,6 @@
import org.rubypeople.rdt.internal.ti.util.INodeAcceptor;
import org.rubypeople.rdt.internal.ti.util.OffsetNodeLocator;
-import com.sun.corba.se.impl.io.FVDCodeBaseImpl;
-
public class SelectionEngine {
private HashSet<IType> fVisitedTypes;
@@ -156,11 +154,33 @@
if (method.getElementName().equals(methodName))
possible.add(method);
}
- }
+ }
+ if (possible.isEmpty()) {
+ // do a global search for method declarations matching this name
+ try {
+ List<SearchMatch> results = search(IRubyElement.METHOD, methodName, IRubySearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH);
+ for (SearchMatch match : results) {
+ IRubyElement element = (IRubyElement) match.getElement();
+ possible.add(element);
+ }
+ } catch (CoreException e) {
+ RubyCore.log(e);
+ }
+ }
return possible.toArray(new IRubyElement[possible.size()]);
}
return new IRubyElement[0];
}
+
+ private List<SearchMatch> search(int type, String patternString, int limitTo, int matchRule) throws CoreException {
+ SearchEngine engine = new SearchEngine();
+ SearchPattern pattern = SearchPattern.createPattern(type, patternString, limitTo, matchRule);
+ SearchParticipant[] participants = new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()};
+ CollectingSearchRequestor requestor = new CollectingSearchRequestor();
+ IRubySearchScope scope = SearchEngine.createWorkspaceScope();
+ engine.search(pattern, participants, scope, requestor, null);
+ return requestor.getResults();
+ }
private IType[] getReceiver(IRubyScript script, String source, Node selected, Node root, int start) {
List<IType> types = new ArrayList<IType>();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|