|
From: <caw...@us...> - 2007-05-17 14:37:57
|
Revision: 2496
http://svn.sourceforge.net/rubyeclipse/?rev=2496&view=rev
Author: cawilliams
Date: 2007-05-17 07:37:56 -0700 (Thu, 17 May 2007)
Log Message:
-----------
when we try to resolve a call node and we can't infer the type, fall back to grabbing all types with a defined method matching the call node's 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-05-17 14:37:23 UTC (rev 2495)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java 2007-05-17 14:37:56 UTC (rev 2496)
@@ -173,6 +173,28 @@
} else {
ITypeInferrer inferrer = new DefaultTypeInferrer();
List<ITypeGuess> guesses = inferrer.infer(source, start);
+ // TODO If guesses are empty, just do a global search for this method?
+ if (guesses.isEmpty()) {
+ String methodName = ASTUtil.getNameReflectively(selected);
+ IRubySearchScope scope = SearchEngine.createRubySearchScope(new IRubyElement[] { script.getRubyProject() });
+ CollectingSearchRequestor requestor = new CollectingSearchRequestor();
+ SearchPattern pattern = SearchPattern.createPattern(
+ IRubyElement.METHOD, methodName,
+ IRubySearchConstants.DECLARATIONS,
+ SearchPattern.R_EXACT_MATCH);
+ SearchParticipant[] participants = { BasicSearchEngine.getDefaultSearchParticipant() };
+ try {
+ new BasicSearchEngine().search(pattern, participants, scope, requestor, null);
+ } catch (CoreException e) {
+ RubyCore.log(e);
+ }
+ List<SearchMatch> matches = requestor.getResults();
+ if (matches == null || matches.isEmpty()) return new IType[0];
+ for (SearchMatch match : matches) {
+ IMethod method = (IMethod) match.getElement();
+ types.add(method.getDeclaringType());
+ }
+ } else {
RubyElementRequestor requestor = new RubyElementRequestor(
script);
for (ITypeGuess guess : guesses) {
@@ -182,6 +204,7 @@
types.add(tmpTypes[i]);
}
}
+ }
}
return types.toArray(new IType[types.size()]);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|