|
From: <caw...@us...> - 2007-04-06 14:02:58
|
Revision: 2289
http://svn.sourceforge.net/rubyeclipse/?rev=2289&view=rev
Author: cawilliams
Date: 2007-04-06 07:02:49 -0700 (Fri, 06 Apr 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexAllJob.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexManager.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/ExperimentalIndex.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-04-06 14:00:40 UTC (rev 2288)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-04-06 14:02:49 UTC (rev 2289)
@@ -56,7 +56,7 @@
import org.rubypeople.rdt.internal.core.builder.MassIndexUpdaterJob;
import org.rubypeople.rdt.internal.core.builder.RubyBuilder;
import org.rubypeople.rdt.internal.core.parser.RubyParser;
-import org.rubypeople.rdt.internal.core.search.ExperimentalIndex;
+import org.rubypeople.rdt.internal.core.search.IndexManager;
import org.rubypeople.rdt.internal.core.symbols.ISymbolFinder;
import org.rubypeople.rdt.internal.core.symbols.SymbolIndex;
import org.rubypeople.rdt.internal.core.util.MementoTokenizer;
@@ -321,8 +321,8 @@
List rubyProjects = Arrays.asList(getRubyProjects());
MassIndexUpdaterJob massUpdater = new MassIndexUpdaterJob(indexUpdater, rubyProjects);
massUpdater.schedule();
- addElementChangedListener(ExperimentalIndex.instance());
- ExperimentalIndex.start();
+ addElementChangedListener(IndexManager.instance());
+ IndexManager.start();
}
/*
@@ -334,7 +334,7 @@
public void stop(BundleContext context) throws Exception {
try {
RubyModelManager.getRubyModelManager().shutdown();
- removeElementChangedListener(ExperimentalIndex.instance());
+ removeElementChangedListener(IndexManager.instance());
} finally {
// ensure we call super.stop as the last thing
super.stop(context);
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-04-06 14:00:40 UTC (rev 2288)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-04-06 14:02:49 UTC (rev 2289)
@@ -45,7 +45,7 @@
import org.rubypeople.rdt.internal.core.RubyScript;
import org.rubypeople.rdt.internal.core.RubyType;
import org.rubypeople.rdt.internal.core.parser.RubyParser;
-import org.rubypeople.rdt.internal.core.search.ExperimentalIndex;
+import org.rubypeople.rdt.internal.core.search.IndexManager;
import org.rubypeople.rdt.internal.core.util.ASTUtil;
import org.rubypeople.rdt.internal.ti.DefaultTypeInferrer;
import org.rubypeople.rdt.internal.ti.ITypeGuess;
@@ -135,7 +135,7 @@
}
private void suggestGlobals() {
- Set<String> globals = ExperimentalIndex.getGlobalNames(fContext.getScript());
+ Set<String> globals = IndexManager.getGlobalNames(fContext.getScript());
for (String name : globals) {
if (!fContext.prefixStartsWith(name))
continue;
@@ -145,7 +145,7 @@
}
private void suggestTypeNames() {
- Set<String> types = ExperimentalIndex.getTypeNames(fContext.getScript());
+ Set<String> types = IndexManager.getTypeNames(fContext.getScript());
for (String name : types) {
if (!fContext.prefixStartsWith(name))
continue;
@@ -162,7 +162,7 @@
}
private void suggestConstantNames() {
- Set<String> types = ExperimentalIndex.getConstantNames(fContext.getScript());
+ Set<String> types = IndexManager.getConstantNames(fContext.getScript());
for (String name : types) {
if (!fContext.prefixStartsWith(name))
continue;
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java 2007-04-06 14:00:40 UTC (rev 2288)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java 2007-04-06 14:02:49 UTC (rev 2289)
@@ -15,7 +15,7 @@
import org.rubypeople.rdt.core.IType;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
-import org.rubypeople.rdt.internal.core.search.ExperimentalIndex;
+import org.rubypeople.rdt.internal.core.search.IndexManager;
import org.rubypeople.rdt.internal.core.util.Util;
public class RubyElementRequestor {
@@ -48,7 +48,7 @@
}
if (types.size() == 0) { // Couldn't find any!
// Do a full search
- types.addAll(ExperimentalIndex.findType(typeName));
+ types.addAll(IndexManager.findType(typeName));
}
} catch (RubyModelException e) {
RubyCore.log(e);
Deleted: 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-04-06 14:00:40 UTC (rev 2288)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/ExperimentalIndex.java 2007-04-06 14:02:49 UTC (rev 2289)
@@ -1,146 +0,0 @@
-package org.rubypeople.rdt.internal.core.search;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.jobs.Job;
-import org.rubypeople.rdt.core.ElementChangedEvent;
-import org.rubypeople.rdt.core.IElementChangedListener;
-import org.rubypeople.rdt.core.IRubyElement;
-import org.rubypeople.rdt.core.IRubyElementDelta;
-import org.rubypeople.rdt.core.IRubyProject;
-import org.rubypeople.rdt.core.IRubyScript;
-import org.rubypeople.rdt.core.ISourceFolderRoot;
-import org.rubypeople.rdt.core.IType;
-import org.rubypeople.rdt.core.RubyModelException;
-import org.rubypeople.rdt.internal.core.search.indexing.IndexAllJob;
-
-public class ExperimentalIndex implements IElementChangedListener {
-
- private static ExperimentalIndex fgInstance;
- private static Map<IPath, SearchDocument> documents;
-
- private ExperimentalIndex() {
- documents = new HashMap<IPath, SearchDocument>();
- }
-
- public void elementChanged(ElementChangedEvent event) {
- processDelta(event.getDelta());
- }
-
- // FIXME We're doing poor man's scoping by passing in the script. We should actually create scope classes which could tell if a document fell in our out of it...
- public static Set<String> getTypeNames(IRubyScript script) {
- return getElementNames(IRubyElement.TYPE, script);
- }
-
- public static Set<String> getConstantNames(IRubyScript script) {
- return getElementNames(IRubyElement.CONSTANT, script);
- }
-
- private static Set<String> getElementNames(int type, IRubyScript script) {
- Set<String> names = new HashSet<String>();
- Collection<SearchDocument> documents = getDocumentsInScope(script);
- for (SearchDocument doc : documents) {
- Set<String> elements = doc.getElementNamesOfType(type);
- for (String element : elements) {
- names.add(element);
- }
- }
- return names;
- }
-
- private static Collection<SearchDocument> getDocumentsInScope(IRubyScript script) {
- try {
- Set<SearchDocument> matches = new HashSet<SearchDocument>();
- IRubyProject project = script.getRubyProject();
- ISourceFolderRoot[] roots = project.getSourceFolderRoots();
- for (IPath path : documents.keySet()) {
- // If path is in loadpath of script's project, add it
- for (int i = 0; i < roots.length; i++) {
- if (roots[i].getPath().isPrefixOf(path)) matches.add(documents.get(path));
- }
- }
- return matches;
- } catch (RubyModelException e) {
- // ignore?
- return documents.values();
- }
- }
-
- public static Set<IType> findType(String name) {
- Set<IType> types = new HashSet<IType>();
- for (SearchDocument doc : documents.values()) {
- IType type = doc.findType(name);
- if (type != null)
- types.add(type);
- }
- return types;
- }
-
- public static Set<String> getGlobalNames(IRubyScript script) {
- return getElementNames(IRubyElement.GLOBAL, script);
- }
-
- private void processDelta(IRubyElementDelta delta) {
- IRubyElement element = delta.getElement();
- switch (delta.getKind()) {
- case IRubyElementDelta.CHANGED:
- IRubyElementDelta[] children = delta.getAffectedChildren();
- for (int i = 0, length = children.length; i < length; i++) {
- IRubyElementDelta child = children[i];
- this.processDelta(child);
- }
- break;
- case IRubyElementDelta.REMOVED:
- removeElement(element);
- break;
- case IRubyElementDelta.ADDED:
- addElement(element);
- break;
- }
- }
-
- void removeElement(IRubyElement element) {
- if ((element.isType(IRubyElement.RUBY_MODEL)) ||
- (element.isType(IRubyElement.RUBY_PROJECT)) ||
- (element.isType(IRubyElement.SCRIPT)) ||
- (element.isType(IRubyElement.SOURCE_FOLDER_ROOT)) ||
- (element.isType(IRubyElement.SOURCE_FOLDER))) return;
- SearchDocument doc = documents.get(element.getPath());
- if (doc == null)
- return;
- doc.removeElement(element);
- if (doc.isEmpty())
- documents.remove(element.getPath());
- }
-
- public void addElement(IRubyElement element) {
- if ((element.isType(IRubyElement.RUBY_MODEL)) ||
- (element.isType(IRubyElement.RUBY_PROJECT)) ||
- (element.isType(IRubyElement.SCRIPT)) ||
- (element.isType(IRubyElement.SOURCE_FOLDER_ROOT)) ||
- (element.isType(IRubyElement.SOURCE_FOLDER))) return;
- SearchDocument doc = documents.get(element.getPath());
- if (doc == null) {
- doc = new SearchDocument(element.getPath());
- documents.put(element.getPath(), doc);
- }
- doc.addElement(element);
- }
-
- public static ExperimentalIndex instance() {
- if (fgInstance == null) {
- fgInstance = new ExperimentalIndex();
- }
- return fgInstance;
- }
-
- public static void start() {
- Job job = new IndexAllJob(instance());
- job.schedule();
- }
-}
Copied: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexManager.java (from rev 2288, 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/IndexManager.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexManager.java 2007-04-06 14:02:49 UTC (rev 2289)
@@ -0,0 +1,146 @@
+package org.rubypeople.rdt.internal.core.search;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.jobs.Job;
+import org.rubypeople.rdt.core.ElementChangedEvent;
+import org.rubypeople.rdt.core.IElementChangedListener;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyElementDelta;
+import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.ISourceFolderRoot;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.internal.core.search.indexing.IndexAllJob;
+
+public class IndexManager implements IElementChangedListener {
+
+ private static IndexManager fgInstance;
+ private static Map<IPath, SearchDocument> documents;
+
+ private IndexManager() {
+ documents = new HashMap<IPath, SearchDocument>();
+ }
+
+ public void elementChanged(ElementChangedEvent event) {
+ processDelta(event.getDelta());
+ }
+
+ // FIXME We're doing poor man's scoping by passing in the script. We should actually create scope classes which could tell if a document fell in our out of it...
+ public static Set<String> getTypeNames(IRubyScript script) {
+ return getElementNames(IRubyElement.TYPE, script);
+ }
+
+ public static Set<String> getConstantNames(IRubyScript script) {
+ return getElementNames(IRubyElement.CONSTANT, script);
+ }
+
+ private static Set<String> getElementNames(int type, IRubyScript script) {
+ Set<String> names = new HashSet<String>();
+ Collection<SearchDocument> documents = getDocumentsInScope(script);
+ for (SearchDocument doc : documents) {
+ Set<String> elements = doc.getElementNamesOfType(type);
+ for (String element : elements) {
+ names.add(element);
+ }
+ }
+ return names;
+ }
+
+ private static Collection<SearchDocument> getDocumentsInScope(IRubyScript script) {
+ try {
+ Set<SearchDocument> matches = new HashSet<SearchDocument>();
+ IRubyProject project = script.getRubyProject();
+ ISourceFolderRoot[] roots = project.getSourceFolderRoots();
+ for (IPath path : documents.keySet()) {
+ // If path is in loadpath of script's project, add it
+ for (int i = 0; i < roots.length; i++) {
+ if (roots[i].getPath().isPrefixOf(path)) matches.add(documents.get(path));
+ }
+ }
+ return matches;
+ } catch (RubyModelException e) {
+ // ignore?
+ return documents.values();
+ }
+ }
+
+ public static Set<IType> findType(String name) {
+ Set<IType> types = new HashSet<IType>();
+ for (SearchDocument doc : documents.values()) {
+ IType type = doc.findType(name);
+ if (type != null)
+ types.add(type);
+ }
+ return types;
+ }
+
+ public static Set<String> getGlobalNames(IRubyScript script) {
+ return getElementNames(IRubyElement.GLOBAL, script);
+ }
+
+ private void processDelta(IRubyElementDelta delta) {
+ IRubyElement element = delta.getElement();
+ switch (delta.getKind()) {
+ case IRubyElementDelta.CHANGED:
+ IRubyElementDelta[] children = delta.getAffectedChildren();
+ for (int i = 0, length = children.length; i < length; i++) {
+ IRubyElementDelta child = children[i];
+ this.processDelta(child);
+ }
+ break;
+ case IRubyElementDelta.REMOVED:
+ removeElement(element);
+ break;
+ case IRubyElementDelta.ADDED:
+ addElement(element);
+ break;
+ }
+ }
+
+ void removeElement(IRubyElement element) {
+ if ((element.isType(IRubyElement.RUBY_MODEL)) ||
+ (element.isType(IRubyElement.RUBY_PROJECT)) ||
+ (element.isType(IRubyElement.SCRIPT)) ||
+ (element.isType(IRubyElement.SOURCE_FOLDER_ROOT)) ||
+ (element.isType(IRubyElement.SOURCE_FOLDER))) return;
+ SearchDocument doc = documents.get(element.getPath());
+ if (doc == null)
+ return;
+ doc.removeElement(element);
+ if (doc.isEmpty())
+ documents.remove(element.getPath());
+ }
+
+ public void addElement(IRubyElement element) {
+ if ((element.isType(IRubyElement.RUBY_MODEL)) ||
+ (element.isType(IRubyElement.RUBY_PROJECT)) ||
+ (element.isType(IRubyElement.SCRIPT)) ||
+ (element.isType(IRubyElement.SOURCE_FOLDER_ROOT)) ||
+ (element.isType(IRubyElement.SOURCE_FOLDER))) return;
+ SearchDocument doc = documents.get(element.getPath());
+ if (doc == null) {
+ doc = new SearchDocument(element.getPath());
+ documents.put(element.getPath(), doc);
+ }
+ doc.addElement(element);
+ }
+
+ public static IndexManager instance() {
+ if (fgInstance == null) {
+ fgInstance = new IndexManager();
+ }
+ return fgInstance;
+ }
+
+ public static void start() {
+ Job job = new IndexAllJob(instance());
+ job.schedule();
+ }
+}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexAllJob.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexAllJob.java 2007-04-06 14:00:40 UTC (rev 2288)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexAllJob.java 2007-04-06 14:02:49 UTC (rev 2289)
@@ -10,12 +10,12 @@
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.internal.core.RubyModelManager;
-import org.rubypeople.rdt.internal.core.search.ExperimentalIndex;
+import org.rubypeople.rdt.internal.core.search.IndexManager;
public class IndexAllJob extends Job {
- private ExperimentalIndex index;
+ private IndexManager index;
- public IndexAllJob(ExperimentalIndex index) {
+ public IndexAllJob(IndexManager index) {
super("Search Index Job");
this.index = index;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|