|
From: <caw...@us...> - 2007-03-09 20:25:06
|
Revision: 2123
http://svn.sourceforge.net/rubyeclipse/?rev=2123&view=rev
Author: cawilliams
Date: 2007-03-09 12:24:09 -0800 (Fri, 09 Mar 2007)
Log Message:
-----------
do some more code completion tweaking
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-03-09 20:17:06 UTC (rev 2122)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-03-09 20:24:09 UTC (rev 2123)
@@ -67,9 +67,7 @@
this.fRequestor.beginReporting();
fContext = new CompletionContext(script, offset);
if (fContext.emptyPrefix()) { // no prefix, so we could suggest anything
- suggestTypeNames();
- suggestConstantNames();
- suggestGlobals();
+ suggestMethodsForEnclosingType(script);
getDocumentsRubyElementsInScope();
} else {
if (fContext.isConstant()) { // type or constant
@@ -94,15 +92,9 @@
// FIXME If we're invoked on the class declaration (it's super class) don't do this!
// FIXME Traverse the IRubyElement model, not nodes (and don't reparse)?
if (fContext.isMethodInvokationOrLocal()) {
- // Grab all the methods in this type and it's super/module.
- IMember element = (IMember) script.getElementAt(fContext.getOffset());
- IType type = element.getDeclaringType();
- List<CompletionProposal> list = sort(suggestMethods(100, type));
- for (CompletionProposal proposal : list) {
- fRequestor.accept(proposal);
- }
+ suggestMethodsForEnclosingType(script);
}
- // FIXME WHat about instance and class variables?
+ // FIXME What about instance and class variables?
// getDocumentsRubyElementsInScope();
}
if (fContext.isGlobal()) { // looks like a global
@@ -113,6 +105,15 @@
fContext = null;
}
+ private void suggestMethodsForEnclosingType(IRubyScript script) throws RubyModelException {
+ IMember element = (IMember) script.getElementAt(fContext.getOffset());
+ IType type = element.getDeclaringType();
+ List<CompletionProposal> list = sort(suggestMethods(100, type));
+ for (CompletionProposal proposal : list) {
+ fRequestor.accept(proposal);
+ }
+ }
+
private List<CompletionProposal> sort(Map<String, CompletionProposal> proposals) {
List<CompletionProposal> list = new ArrayList<CompletionProposal>(proposals.values());
Collections.sort(list, new CompletionProposalComparator());
@@ -171,13 +172,12 @@
}
}
proposals.putAll(addModuleMethods(confidence, type));
- proposals.putAll(addSuperClassMethods(confidence, type));
+ if (!type.isModule()) proposals.putAll(addSuperClassMethods(confidence, type));
return proposals;
}
private Map<String, CompletionProposal> addModuleMethods(int confidence, IType type) {
Map<String, CompletionProposal> proposals = new HashMap<String, CompletionProposal>();
- if (type.isModule()) return proposals;
String[] modules = null;
try {
modules = type.getIncludedModuleNames();
@@ -204,7 +204,6 @@
Map<String, CompletionProposal> proposals = new HashMap<String, CompletionProposal>();
String superClass = type.getSuperclassName();
if (superClass == null) return proposals;
- if (type.isModule() && superClass.equals("Module")) return proposals;
RubyElementRequestor requestor = new RubyElementRequestor(type.getRubyScript());
IType[] supers = requestor.findType(superClass);
for (int i = 0; i < supers.length; i++) {
@@ -495,6 +494,7 @@
// Find source and parse
RubyType rubyType = (RubyType) type;
String source = rubyType.getSource();
+ if (source == null) return new ArrayList<Node>(0);
// FIXME Why does the parser balk on \r chars?
source = source.replace('\r', ' ');
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|