|
From: <caw...@us...> - 2007-01-25 16:54:48
|
Revision: 1883
http://svn.sourceforge.net/rubyeclipse/?rev=1883&view=rev
Author: cawilliams
Date: 2007-01-25 08:54:46 -0800 (Thu, 25 Jan 2007)
Log Message:
-----------
add constants to things to be index in the new experimental index. Also make note of cocncurrency problem that we're gonna run into
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/ExperimentalIndex.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-01-25 16:39:47 UTC (rev 1882)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-01-25 16:54:46 UTC (rev 1883)
@@ -96,15 +96,8 @@
if (this.prefix != null) replaceStart -= this.prefix.length();
if (isConstant()) { // type or constant
- List<String> types = ExperimentalIndex.getTypes();
- // TODO Remove duplicates? Sort?
- for (String name : types) {
- if (this.prefix != null && !name.startsWith(this.prefix)) continue;
- CompletionProposal proposal = new CompletionProposal(
- CompletionProposal.TYPE_REF, name, 100);
- proposal.setReplaceRange(replaceStart, replaceStart + name.length());
- requestor.accept(proposal);
- }
+ suggestTypeNames(replaceStart);
+ suggestConstantNames(replaceStart);
} else { // method or variable
ITypeInferrer inferrer = new DefaultTypeInferrer();
List<ITypeGuess> guesses = inferrer
@@ -120,6 +113,30 @@
this.requestor.endReporting();
}
+ private void suggestTypeNames(int replaceStart) {
+ List<String> types = ExperimentalIndex.getTypes();
+ // TODO Remove duplicates? Sort?
+ for (String name : types) {
+ if (this.prefix != null && !name.startsWith(this.prefix)) continue;
+ CompletionProposal proposal = new CompletionProposal(
+ CompletionProposal.TYPE_REF, name, 100);
+ proposal.setReplaceRange(replaceStart, replaceStart + name.length());
+ requestor.accept(proposal);
+ }
+ }
+
+ private void suggestConstantNames(int replaceStart) {
+ List<String> types = ExperimentalIndex.getConstants();
+ // TODO Remove duplicates? Sort?
+ for (String name : types) {
+ if (this.prefix != null && !name.startsWith(this.prefix)) continue;
+ CompletionProposal proposal = new CompletionProposal(
+ CompletionProposal.FIELD_REF, name, 100);
+ proposal.setReplaceRange(replaceStart, replaceStart + name.length());
+ requestor.accept(proposal);
+ }
+ }
+
private boolean isConstant() {
return this.prefix != null && this.prefix.length() > 0 && Character.isUpperCase(this.prefix
.charAt(0));
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/ExperimentalIndex.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/ExperimentalIndex.java 2007-01-25 16:39:47 UTC (rev 1882)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/ExperimentalIndex.java 2007-01-25 16:54:46 UTC (rev 1883)
@@ -18,12 +18,14 @@
import org.rubypeople.rdt.internal.core.RubyModelManager;
public class ExperimentalIndex implements IElementChangedListener {
-
- private static List<String> fgTypes = new ArrayList<String>();
+
private static ExperimentalIndex fgInstance;
-
+ private static List<String> fgConstants;
+ private static List<String> fgTypes;
+
private ExperimentalIndex() {
-
+ fgTypes = new ArrayList<String>();
+ fgConstants = new ArrayList<String>();
}
public void elementChanged(ElementChangedEvent event) {
@@ -31,8 +33,14 @@
}
public static List<String> getTypes() {
+ // XXX We need to handle case where this gets invoked while index is updating (and we get a concurrent modification exception)!
return Collections.unmodifiableList(fgTypes);
}
+
+ public static List<String> getConstants() {
+// XXX We need to handle case where this gets invoked while index is updating (and we get a concurrent modification exception)!
+ return Collections.unmodifiableList(fgConstants);
+ }
private void processDelta(IRubyElementDelta delta) {
IRubyElement element = delta.getElement();
@@ -45,11 +53,7 @@
}
break;
case IRubyElementDelta.REMOVED:
- switch (element.getElementType()) {
- case IRubyElement.TYPE:
- fgTypes.remove(element.getElementName());
- break;
- }
+ removeElement(element);
break;
case IRubyElementDelta.ADDED:
addElement(element);
@@ -57,11 +61,25 @@
}
}
+ void removeElement(IRubyElement element) {
+ switch (element.getElementType()) {
+ case IRubyElement.TYPE:
+ fgTypes.remove(element.getElementName());
+ break;
+ case IRubyElement.CONSTANT:
+ fgConstants.remove(element.getElementName());
+ break;
+ }
+ }
+
void addElement(IRubyElement element) {
switch (element.getElementType()) {
case IRubyElement.TYPE:
fgTypes.add(element.getElementName());
break;
+ case IRubyElement.CONSTANT:
+ fgConstants.add(element.getElementName());
+ break;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|