|
From: <caw...@us...> - 2007-04-06 15:42:24
|
Revision: 2294
http://svn.sourceforge.net/rubyeclipse/?rev=2294&view=rev
Author: cawilliams
Date: 2007-04-06 08:42:21 -0700 (Fri, 06 Apr 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/SearchDocument.java
Copied: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java (from rev 2290, trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/SearchDocument.java)
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java 2007-04-06 15:42:21 UTC (rev 2294)
@@ -0,0 +1,119 @@
+package org.rubypeople.rdt.core.search;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IPath;
+import org.rubypeople.rdt.core.IParent;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.internal.core.Openable;
+import org.rubypeople.rdt.internal.core.search.HandleFactory;
+
+public class SearchDocument {
+
+ private static HandleFactory factory = new HandleFactory();
+ private static final String SEPARATOR = "/";
+ private List<String> indices = new ArrayList<String>();
+ private IPath path;
+ private IRubyScript script;
+
+ public SearchDocument(IPath path) {
+ this.path = path;
+ }
+
+ public Set<String> getElementNamesOfType(int type) {
+ Set<String> names = new HashSet<String>();
+ for (String indexKey : indices) {
+ if (getTypeFromKey(indexKey) != type) continue;
+ names.add(getNameFromKey(indexKey));
+ }
+ return names;
+ }
+
+ public List<IRubyElement> getElementsOfType(int type) {
+ IRubyScript script = getScript();
+ return getChildrenOfType(script, type);
+ }
+
+ private IRubyScript getScript() {
+ if (this.script == null) {
+ Openable openable = factory.createOpenable(path.toString());
+ this.script = (IRubyScript) openable;
+ }
+ return this.script;
+ }
+
+ private List<IRubyElement> getChildrenOfType(IParent parent, int type) {
+ List<IRubyElement> elements = new ArrayList<IRubyElement>();
+ if (parent == null) return elements;
+ try {
+ IRubyElement[] children = parent.getChildren();
+ if (children == null)
+ return elements;
+ for (int i = 0; i < children.length; i++) {
+ if (children[i].isType(type))
+ elements.add(children[i]);
+ if (children[i] instanceof IParent) {
+ IParent childParent = (IParent) children[i];
+ elements.addAll(getChildrenOfType(childParent, type));
+ }
+ }
+ } catch (RubyModelException e) {
+ // ignore
+ }
+ return elements;
+ }
+
+ public boolean isEmpty() {
+ return indices.isEmpty();
+ }
+
+ public void removeElement(IRubyElement element) {
+ indices.remove(createKey(element));
+ }
+
+ private String createKey(IRubyElement element) {
+ return createKey(element.getElementType(), element.getElementName());
+ }
+
+ private String createKey(int type, String name) {
+ return type + SEPARATOR + name;
+ }
+
+ public void addElement(IRubyElement element) {
+ indices.add(createKey(element));
+ }
+
+ public IType findType(String name) {
+ return (IType) findElement(createKey(IRubyElement.TYPE, name));
+ }
+
+ private IRubyElement findElement(String key) {
+ for (String indexKey : indices) {
+ if (!indexKey.equals(key))
+ continue;
+ IRubyScript script = getScript();
+ List<IRubyElement> children = getChildrenOfType(script, getTypeFromKey(key));
+ for (IRubyElement element : children) {
+ if (element.getElementName().equals(getNameFromKey(key)))
+ return element;
+ }
+ }
+ return null;
+ }
+
+ private String getNameFromKey(String key) {
+ String[] parts = key.split(SEPARATOR);
+ return parts[1];
+ }
+
+ private int getTypeFromKey(String key) {
+ String[] parts = key.split(SEPARATOR);
+ return Integer.parseInt(parts[0]);
+ }
+}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java 2007-04-06 15:31:13 UTC (rev 2293)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java 2007-04-06 15:42:21 UTC (rev 2294)
@@ -12,6 +12,7 @@
import org.rubypeople.rdt.core.ISourceFolderRoot;
import org.rubypeople.rdt.core.IType;
import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.search.SearchDocument;
import org.rubypeople.rdt.internal.core.search.indexing.IndexManager;
public class BasicSearchEngine {
Deleted: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/SearchDocument.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/SearchDocument.java 2007-04-06 15:31:13 UTC (rev 2293)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/SearchDocument.java 2007-04-06 15:42:21 UTC (rev 2294)
@@ -1,118 +0,0 @@
-package org.rubypeople.rdt.internal.core.search;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IPath;
-import org.rubypeople.rdt.core.IParent;
-import org.rubypeople.rdt.core.IRubyElement;
-import org.rubypeople.rdt.core.IRubyScript;
-import org.rubypeople.rdt.core.IType;
-import org.rubypeople.rdt.core.RubyModelException;
-import org.rubypeople.rdt.internal.core.Openable;
-
-public class SearchDocument {
-
- private static HandleFactory factory = new HandleFactory();
- private static final String SEPARATOR = "/";
- private List<String> indices = new ArrayList<String>();
- private IPath path;
- private IRubyScript script;
-
- public SearchDocument(IPath path) {
- this.path = path;
- }
-
- public Set<String> getElementNamesOfType(int type) {
- Set<String> names = new HashSet<String>();
- for (String indexKey : indices) {
- if (getTypeFromKey(indexKey) != type) continue;
- names.add(getNameFromKey(indexKey));
- }
- return names;
- }
-
- public List<IRubyElement> getElementsOfType(int type) {
- IRubyScript script = getScript();
- return getChildrenOfType(script, type);
- }
-
- private IRubyScript getScript() {
- if (this.script == null) {
- Openable openable = factory.createOpenable(path.toString());
- this.script = (IRubyScript) openable;
- }
- return this.script;
- }
-
- private List<IRubyElement> getChildrenOfType(IParent parent, int type) {
- List<IRubyElement> elements = new ArrayList<IRubyElement>();
- if (parent == null) return elements;
- try {
- IRubyElement[] children = parent.getChildren();
- if (children == null)
- return elements;
- for (int i = 0; i < children.length; i++) {
- if (children[i].isType(type))
- elements.add(children[i]);
- if (children[i] instanceof IParent) {
- IParent childParent = (IParent) children[i];
- elements.addAll(getChildrenOfType(childParent, type));
- }
- }
- } catch (RubyModelException e) {
- // ignore
- }
- return elements;
- }
-
- public boolean isEmpty() {
- return indices.isEmpty();
- }
-
- public void removeElement(IRubyElement element) {
- indices.remove(createKey(element));
- }
-
- private String createKey(IRubyElement element) {
- return createKey(element.getElementType(), element.getElementName());
- }
-
- private String createKey(int type, String name) {
- return type + SEPARATOR + name;
- }
-
- public void addElement(IRubyElement element) {
- indices.add(createKey(element));
- }
-
- public IType findType(String name) {
- return (IType) findElement(createKey(IRubyElement.TYPE, name));
- }
-
- private IRubyElement findElement(String key) {
- for (String indexKey : indices) {
- if (!indexKey.equals(key))
- continue;
- IRubyScript script = getScript();
- List<IRubyElement> children = getChildrenOfType(script, getTypeFromKey(key));
- for (IRubyElement element : children) {
- if (element.getElementName().equals(getNameFromKey(key)))
- return element;
- }
- }
- return null;
- }
-
- private String getNameFromKey(String key) {
- String[] parts = key.split(SEPARATOR);
- return parts[1];
- }
-
- private int getTypeFromKey(String key) {
- String[] parts = key.split(SEPARATOR);
- return Integer.parseInt(parts[0]);
- }
-}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java 2007-04-06 15:31:13 UTC (rev 2293)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java 2007-04-06 15:42:21 UTC (rev 2294)
@@ -9,7 +9,7 @@
import org.rubypeople.rdt.core.IElementChangedListener;
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyElementDelta;
-import org.rubypeople.rdt.internal.core.search.SearchDocument;
+import org.rubypeople.rdt.core.search.SearchDocument;
public class IndexManager implements IElementChangedListener {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|