You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
(41) |
Apr
(9) |
May
|
Jun
|
Jul
(39) |
Aug
(38) |
Sep
(135) |
Oct
(220) |
Nov
(75) |
Dec
(74) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(44) |
Feb
(160) |
Mar
(49) |
Apr
(69) |
May
(40) |
Jun
(52) |
Jul
(47) |
Aug
(51) |
Sep
(19) |
Oct
(22) |
Nov
(36) |
Dec
(76) |
| 2007 |
Jan
(154) |
Feb
(165) |
Mar
(186) |
Apr
(143) |
May
(175) |
Jun
(133) |
Jul
(203) |
Aug
(177) |
Sep
(136) |
Oct
|
Nov
|
Dec
|
|
From: <caw...@us...> - 2007-04-11 16:09:46
|
Revision: 2297
http://svn.sourceforge.net/rubyeclipse/?rev=2297&view=rev
Author: cawilliams
Date: 2007-04-11 09:09:44 -0700 (Wed, 11 Apr 2007)
Log Message:
-----------
remove feature branch which has already been merged to trunk
Removed Paths:
-------------
branches/syntax/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mir...@us...> - 2007-04-11 12:06:38
|
Revision: 2296
http://svn.sourceforge.net/rubyeclipse/?rev=2296&view=rev
Author: mirkostocker
Date: 2007-04-11 05:05:17 -0700 (Wed, 11 Apr 2007)
Log Message:
-----------
inline local GUI had a problem with the back button and the error message, this fixes it
Modified Paths:
--------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/InlineLocalPage.java
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/InlineLocalPage.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/InlineLocalPage.java 2007-04-06 15:54:53 UTC (rev 2295)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/InlineLocalPage.java 2007-04-11 12:05:17 UTC (rev 2296)
@@ -55,13 +55,22 @@
private String selectedItemName;
+ private LabeledTextField newMethodName;
+
+ private Button checkQuery;
+
public InlineLocalPage(InlineLocalConfig config, int occurencesCount, String selectedItemName) {
super(InlineLocalRefactoring.NAME + "..."); //$NON-NLS-1$
this.config = config;
this.occurencesCount = occurencesCount;
this.selectedItemName = selectedItemName;
+ }
+ @Override
+ public void pageIsEnabled() {
+ super.pageIsEnabled();
+ newMethodName.setEnabled(checkQuery.getSelection());
}
public void createControl(Composite parent) {
@@ -84,12 +93,11 @@
private void initExtractArea(Composite control) {
Group queryGroup = initGroup(control);
- final Button checkQuery = new Button(queryGroup, SWT.CHECK);
+ checkQuery = new Button(queryGroup, SWT.CHECK);
checkQuery.setText(Messages.InlineTempPage_ReplaceTempWithQuery);
checkQuery.setEnabled(true);
- final LabeledTextField newMethodName = new LabeledTextField(queryGroup, Messages.InlineTempPage_NewMethodName);
- newMethodName.setEnabled(checkQuery.getSelection());
+ newMethodName = new LabeledTextField(queryGroup, Messages.InlineTempPage_NewMethodName);
GridData textData = new GridData(GridData.FILL_HORIZONTAL);
newMethodName.setLayoutData(textData);
@@ -98,6 +106,7 @@
}
private void createModifyListener(final Text newMethodName) {
+
newMethodName.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
@@ -129,8 +138,13 @@
}
public void widgetSelected(SelectionEvent e) {
- newMethodName.setEnabled(checkQuery.getSelection());
- config.setReplaceTempWithQuery(checkQuery.getSelection());
+ boolean doReplaceTempWithQuery = checkQuery.getSelection();
+ newMethodName.setEnabled(doReplaceTempWithQuery);
+ config.setReplaceTempWithQuery(doReplaceTempWithQuery);
+ if (!doReplaceTempWithQuery) {
+ setMessage(null);
+ }
+ setPageComplete(!doReplaceTempWithQuery);
}
});
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-06 15:54:55
|
Revision: 2295
http://svn.sourceforge.net/rubyeclipse/?rev=2295&view=rev
Author: cawilliams
Date: 2007-04-06 08:54:53 -0700 (Fri, 06 Apr 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.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/internal/core/search/indexing/InternalSearchDocument.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java 2007-04-06 15:42:21 UTC (rev 2294)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java 2007-04-06 15:54:53 UTC (rev 2295)
@@ -5,7 +5,6 @@
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;
@@ -13,18 +12,35 @@
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.internal.core.Openable;
import org.rubypeople.rdt.internal.core.search.HandleFactory;
+import org.rubypeople.rdt.internal.core.search.indexing.InternalSearchDocument;
-public class SearchDocument {
+public class SearchDocument extends InternalSearchDocument {
private static HandleFactory factory = new HandleFactory();
+ private IRubyScript script;
+
private static final String SEPARATOR = "/";
+
private List<String> indices = new ArrayList<String>();
- private IPath path;
- private IRubyScript script;
+
+ private String documentPath;
- public SearchDocument(IPath path) {
- this.path = path;
+ public SearchDocument(String documentPath) {
+ this.documentPath = documentPath;
}
+
+ public void addIndexEntry(char[] category, char[] key) {
+ super.addIndexEntry(category, key);
+ }
+
+ /**
+ * Removes all index entries from the index for the given document.
+ * This method must be called from
+ * {@link SearchParticipant#indexDocument(SearchDocument document, org.eclipse.core.runtime.IPath indexPath)}.
+ */
+ public void removeAllIndexEntries() {
+ super.removeAllIndexEntries();
+ }
public Set<String> getElementNamesOfType(int type) {
Set<String> names = new HashSet<String>();
@@ -42,7 +58,7 @@
private IRubyScript getScript() {
if (this.script == null) {
- Openable openable = factory.createOpenable(path.toString());
+ Openable openable = factory.createOpenable(documentPath);
this.script = (IRubyScript) openable;
}
return this.script;
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:42:21 UTC (rev 2294)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java 2007-04-06 15:54:53 UTC (rev 2295)
@@ -65,7 +65,7 @@
(element.isType(IRubyElement.SOURCE_FOLDER))) return;
SearchDocument doc = documents.get(element.getPath());
if (doc == null) {
- doc = new SearchDocument(element.getPath());
+ doc = new SearchDocument(element.getPath().toString());
documents.put(element.getPath(), doc);
}
doc.addElement(element);
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/InternalSearchDocument.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/InternalSearchDocument.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/InternalSearchDocument.java 2007-04-06 15:54:53 UTC (rev 2295)
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.core.search.indexing;
+
+import org.rubypeople.rdt.internal.core.index.Index;
+
+/**
+ * Internal search document implementation
+ */
+public class InternalSearchDocument {
+ Index index;
+ private String containerRelativePath;
+// SourceElementParser parser;
+ /*
+ * Hidden by API SearchDocument subclass
+ */
+ public void addIndexEntry(char[] category, char[] key) {
+ if (this.index != null) {
+ index.addIndexEntry(category, key, getContainerRelativePath());
+// if (category == IIndexConstants.TYPE_DECL && key != null) {
+// int length = key.length;
+// if (length > 1 && key[length-2] == IIndexConstants.SEPARATOR && key[length-1] == IIndexConstants.SECONDARY_SUFFIX ) {
+// // This is a key of a secondary type => reset ruby model manager secondary types cache for document path project
+// RubyModelManager manager = RubyModelManager.getRubyModelManager();
+// manager.secondaryTypeAdding(getPath(), key);
+// }
+// }
+ }
+ }
+ private String getContainerRelativePath() {
+ if (this.containerRelativePath == null)
+ this.containerRelativePath = this.index.containerRelativePath(getPath());
+ return this.containerRelativePath;
+ }
+ /*
+ * Hidden by API SearchDocument subclass
+ */
+ public void removeAllIndexEntries() {
+ if (this.index != null)
+ index.remove(getContainerRelativePath());
+ }
+ /*
+ * Hidden by API SearchDocument subclass
+ */
+ public String getPath() {
+ return null; // implemented by subclass
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|
|
From: <caw...@us...> - 2007-04-06 15:31:17
|
Revision: 2293
http://svn.sourceforge.net/rubyeclipse/?rev=2293&view=rev
Author: cawilliams
Date: 2007-04-06 08:31:13 -0700 (Fri, 06 Apr 2007)
Log Message:
-----------
move searches into BasicSearchEngine - we're moving IndexManager to get more hollowed out and have it instead focus on just managing the storage/retrieval of Index objects and scheduling of Index related jobs
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/codeassist/RubyElementRequestor.java
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
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 15:21:16 UTC (rev 2292)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-04-06 15:31:13 UTC (rev 2293)
@@ -45,6 +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.BasicSearchEngine;
import org.rubypeople.rdt.internal.core.search.indexing.IndexManager;
import org.rubypeople.rdt.internal.core.util.ASTUtil;
import org.rubypeople.rdt.internal.ti.DefaultTypeInferrer;
@@ -135,7 +136,7 @@
}
private void suggestGlobals() {
- Set<String> globals = IndexManager.getGlobalNames(fContext.getScript());
+ Set<String> globals = BasicSearchEngine.getGlobalNames(fContext.getScript());
for (String name : globals) {
if (!fContext.prefixStartsWith(name))
continue;
@@ -145,7 +146,7 @@
}
private void suggestTypeNames() {
- Set<String> types = IndexManager.getTypeNames(fContext.getScript());
+ Set<String> types = BasicSearchEngine.getTypeNames(fContext.getScript());
for (String name : types) {
if (!fContext.prefixStartsWith(name))
continue;
@@ -162,7 +163,7 @@
}
private void suggestConstantNames() {
- Set<String> types = IndexManager.getConstantNames(fContext.getScript());
+ Set<String> types = BasicSearchEngine.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 15:21:16 UTC (rev 2292)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java 2007-04-06 15:31:13 UTC (rev 2293)
@@ -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.indexing.IndexManager;
+import org.rubypeople.rdt.internal.core.search.BasicSearchEngine;
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(IndexManager.findType(typeName));
+ types.addAll(BasicSearchEngine.findType(typeName));
}
} catch (RubyModelException e) {
RubyCore.log(e);
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:21:16 UTC (rev 2292)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java 2007-04-06 15:31:13 UTC (rev 2293)
@@ -1,5 +1,75 @@
package org.rubypeople.rdt.internal.core.search;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IPath;
+import org.rubypeople.rdt.core.IRubyElement;
+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.IndexManager;
+
public class BasicSearchEngine {
+
+ // 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;
+ }
+
+ private static Map<IPath, SearchDocument> documents() {
+ return IndexManager.instance().documents;
+ }
+
+ public static Set<String> getGlobalNames(IRubyScript script) {
+ return getElementNames(IRubyElement.GLOBAL, script);
+ }
}
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:21:16 UTC (rev 2292)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java 2007-04-06 15:31:13 UTC (rev 2293)
@@ -1,10 +1,7 @@
package org.rubypeople.rdt.internal.core.search.indexing;
-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;
@@ -12,17 +9,12 @@
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.SearchDocument;
public class IndexManager implements IElementChangedListener {
private static IndexManager fgInstance;
- private static Map<IPath, SearchDocument> documents;
+ public static Map<IPath, SearchDocument> documents;
private IndexManager() {
documents = new HashMap<IPath, SearchDocument>();
@@ -31,60 +23,7 @@
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()) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-06 15:21:19
|
Revision: 2292
http://svn.sourceforge.net/rubyeclipse/?rev=2292&view=rev
Author: cawilliams
Date: 2007-04-06 08:21:16 -0700 (Fri, 06 Apr 2007)
Log Message:
-----------
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IIndexConstants.java
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IIndexConstants.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IIndexConstants.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IIndexConstants.java 2007-04-06 15:21:16 UTC (rev 2292)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.core.search.indexing;
+
+public interface IIndexConstants {
+
+ /* index encoding */
+ char[] REF= "ref".toCharArray(); //$NON-NLS-1$
+ char[] METHOD_REF= "methodRef".toCharArray(); //$NON-NLS-1$
+ char[] CONSTRUCTOR_REF= "constructorRef".toCharArray(); //$NON-NLS-1$
+ char[] SUPER_REF = "superRef".toCharArray(); //$NON-NLS-1$
+ char[] TYPE_DECL = "typeDecl".toCharArray(); //$NON-NLS-1$
+ char[] METHOD_DECL= "methodDecl".toCharArray(); //$NON-NLS-1$
+ char[] CONSTRUCTOR_DECL= "constructorDecl".toCharArray(); //$NON-NLS-1$
+ char[] FIELD_DECL= "fieldDecl".toCharArray(); //$NON-NLS-1$
+ char[] OBJECT = "Object".toCharArray(); //$NON-NLS-1$
+ char[][] COUNTS=
+ new char[][] { new char[] {'/', '0'}, new char[] {'/', '1'}, new char[] {'/', '2'}, new char[] {'/', '3'}, new char[] {'/', '4'},
+ new char[] {'/', '5'}, new char[] {'/', '6'}, new char[] {'/', '7'}, new char[] {'/', '8'}, new char[] {'/', '9'}
+ };
+ char CLASS_SUFFIX = 'C';
+ char MODULE_SUFFIX = 'M';
+ char TYPE_SUFFIX = 0;
+ char CLASS_AND_MODULE_SUFFIX = 10;
+ char SEPARATOR= '/';
+ char SECONDARY_SUFFIX = 'S';
+
+ char[] ONE_STAR = new char[] {'*'};
+ char[][] ONE_STAR_CHAR = new char[][] {ONE_STAR};
+
+ // used as special marker for enclosing type name of local and anonymous classes
+ char ZERO_CHAR = '0';
+ char[] ONE_ZERO = new char[] { ZERO_CHAR };
+ char[][] ONE_ZERO_CHAR = new char[][] {ONE_ZERO};
+
+ int SCRIPT_REF_PATTERN = 0x0001;
+ int TYPE_REF_PATTERN = 0x0002;
+ int TYPE_DECL_PATTERN = 0x0004;
+ int SUPER_REF_PATTERN = 0x0008;
+ int CONSTRUCTOR_PATTERN = 0x0010;
+ int FIELD_PATTERN = 0x0020;
+ int METHOD_PATTERN = 0x0040;
+ int OR_PATTERN = 0x0080;
+ int LOCAL_VAR_PATTERN = 0x0100;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-06 14:22:23
|
Revision: 2291
http://svn.sourceforge.net/rubyeclipse/?rev=2291&view=rev
Author: cawilliams
Date: 2007-04-06 07:22:22 -0700 (Fri, 06 Apr 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Messages.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Util.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/messages.properties
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/parser/
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/parser/ScannerHelper.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/DiskIndex.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/EntryResult.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/Index.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/MemoryIndex.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-04-06 14:22:22 UTC (rev 2291)
@@ -0,0 +1,132 @@
+package org.rubypeople.rdt.core.search;
+
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+
+public class SearchPattern {
+// Rules for pattern matching: (exact, prefix, pattern) [ | case sensitive]
+ /**
+ * Match rule: The search pattern matches exactly the search result,
+ * that is, the source of the search result equals the search pattern.
+ */
+ public static final int R_EXACT_MATCH = 0;
+
+ /**
+ * Match rule: The search pattern is a prefix of the search result.
+ */
+ public static final int R_PREFIX_MATCH = 0x0001;
+
+ /**
+ * Match rule: The search pattern contains one or more wild cards ('*' or '?').
+ * A '*' wild-card can replace 0 or more characters in the search result.
+ * A '?' wild-card replaces exactly 1 character in the search result.
+ */
+ public static final int R_PATTERN_MATCH = 0x0002;
+
+ /**
+ * Match rule: The search pattern contains a regular expression.
+ */
+ public static final int R_REGEXP_MATCH = 0x0004;
+
+ /**
+ * Match rule: The search pattern matches the search result only if cases are the same.
+ * Can be combined to previous rules, e.g. {@link #R_EXACT_MATCH} | {@link #R_CASE_SENSITIVE}
+ */
+ public static final int R_CASE_SENSITIVE = 0x0008;
+
+ /**
+ * Match rule: The search pattern matches search results as raw/parameterized types/methods with same erasure.
+ * This mode has no effect on other java elements search.<br>
+ * Type search example:
+ * <ul>
+ * <li>pattern: <code>List<Exception></code></li>
+ * <li>match: <code>List<Object></code></li>
+ * </ul>
+ * Method search example:
+ * <ul>
+ * <li>declaration: <code><T>foo(T t)</code></li>
+ * <li>pattern: <code><Exception>foo(new Exception())</code></li>
+ * <li>match: <code><Object>foo(new Object())</code></li>
+ * </ul>
+ * Can be combined to all other match rules, e.g. {@link #R_CASE_SENSITIVE} | {@link #R_ERASURE_MATCH}
+ * This rule is not activated by default, so raw types or parameterized types with same erasure will not be found
+ * for pattern List<String>,
+ * Note that with this pattern, the match selection will be only on the erasure even for parameterized types.
+ * @since 3.1
+ */
+ public static final int R_ERASURE_MATCH = 0x0010;
+
+ /**
+ * Match rule: The search pattern matches search results as raw/parameterized types/methods with equivalent type parameters.
+ * This mode has no effect on other java elements search.<br>
+ * Type search example:
+ * <ul>
+ * <li>pattern: <code>List<Exception></code></li>
+ * <li>match:
+ * <ul>
+ * <li><code>List<? extends Throwable></code></li>
+ * <li><code>List<? super RuntimeException></code></li>
+ * <li><code>List<?></code></li>
+ * </ul>
+ * </li>
+ * </ul>
+ * Method search example:
+ * <ul>
+ * <li>declaration: <code><T>foo(T t)</code></li>
+ * <li>pattern: <code><Exception>foo(new Exception())</code></li>
+ * <li>match:
+ * <ul>
+ * <li><code><? extends Throwable>foo(new Exception())</code></li>
+ * <li><code><? super RuntimeException>foo(new Exception())</code></li>
+ * <li><code>foo(new Exception())</code></li>
+ * </ul>
+ * </ul>
+ * Can be combined to all other match rules, e.g. {@link #R_CASE_SENSITIVE} | {@link #R_EQUIVALENT_MATCH}
+ * This rule is not activated by default, so raw types or equivalent parameterized types will not be found
+ * for pattern List<String>,
+ * This mode is overridden by {@link #R_ERASURE_MATCH} as erasure matches obviously include equivalent ones.
+ * That means that pattern with rule set to {@link #R_EQUIVALENT_MATCH} | {@link #R_ERASURE_MATCH}
+ * will return same results than rule only set with {@link #R_ERASURE_MATCH}.
+ * @since 3.1
+ */
+ public static final int R_EQUIVALENT_MATCH = 0x0020;
+
+ /**
+ * Match rule: The search pattern matches exactly the search result,
+ * that is, the source of the search result equals the search pattern.
+ * @since 3.1
+ */
+ public static final int R_FULL_MATCH = 0x0040;
+
+ /**
+ * Match rule: The search pattern contains a Camel Case expression.
+ * <br>
+ * Examples:
+ * <ul>
+ * <li><code>NPE</code> type string pattern will match
+ * <code>NullPointerException</code> and <code>NpPermissionException</code> types,</li>
+ * <li><code>NuPoEx</code> type string pattern will only match
+ * <code>NullPointerException</code> type.</li>
+ * </ul>
+ * @see CharOperation#camelCaseMatch(char[], char[]) for a detailed explanation
+ * of Camel Case matching.
+ *<br>
+ * Can be combined to {@link #R_PREFIX_MATCH} match rule. For example,
+ * when prefix match rule is combined with Camel Case match rule,
+ * <code>"nPE"</code> pattern will match <code>nPException</code>.
+ *<br>
+ * Match rule {@link #R_PATTERN_MATCH} may also be combined but both rules
+ * will not be used simultaneously as they are mutually exclusive.
+ * Used match rule depends on whether string pattern contains specific pattern
+ * characters (e.g. '*' or '?') or not. If it does, then only Pattern match rule
+ * will be used, otherwise only Camel Case match will be used.
+ * For example, with <code>"NPE"</code> string pattern, search will only use
+ * Camel Case match rule, but with <code>N*P*E*</code> string pattern, it will
+ * use only Pattern match rule.
+ *
+ * @since 3.2
+ */
+ public static final int R_CAMELCASE_MATCH = 0x0080;
+
+ private static final int MODE_MASK = R_EXACT_MATCH | R_PREFIX_MATCH | R_PATTERN_MATCH | R_REGEXP_MATCH;
+
+}
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/parser/ScannerHelper.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/parser/ScannerHelper.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/parser/ScannerHelper.java 2007-04-06 14:22:22 UTC (rev 2291)
@@ -0,0 +1,105 @@
+package org.rubypeople.rdt.internal.compiler.parser;
+
+
+
+public class ScannerHelper {
+ public final static int MAX_OBVIOUS = 128;
+ public final static int[] OBVIOUS_IDENT_CHAR_NATURES = new int[MAX_OBVIOUS];
+
+ public final static int C_JLS_SPACE = 0x100;
+ public final static int C_SPECIAL = 0x80;
+ public final static int C_IDENT_START = 0x40;
+ public final static int C_UPPER_LETTER = 0x20;
+ public final static int C_LOWER_LETTER = 0x10;
+ public final static int C_IDENT_PART = 0x8;
+ public final static int C_DIGIT = 0x4;
+ public final static int C_SEPARATOR = 0x2;
+ public final static int C_SPACE = 0x1;
+
+ static {
+ OBVIOUS_IDENT_CHAR_NATURES[0] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[1] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[2] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[3] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[4] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[5] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[6] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[7] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[8] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[14] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[15] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[16] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[17] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[18] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[19] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[20] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[21] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[22] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[23] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[24] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[25] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[26] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[27] = C_IDENT_PART;
+ OBVIOUS_IDENT_CHAR_NATURES[127] = C_IDENT_PART;
+
+ for (int i = '0'; i <= '9'; i++)
+ OBVIOUS_IDENT_CHAR_NATURES[i] = C_DIGIT | C_IDENT_PART;
+
+ for (int i = 'a'; i <= 'z'; i++)
+ OBVIOUS_IDENT_CHAR_NATURES[i] = C_LOWER_LETTER | C_IDENT_PART | C_IDENT_START;
+ for (int i = 'A'; i <= 'Z'; i++)
+ OBVIOUS_IDENT_CHAR_NATURES[i] = C_UPPER_LETTER | C_IDENT_PART | C_IDENT_START;
+
+ OBVIOUS_IDENT_CHAR_NATURES['_'] = C_SPECIAL | C_IDENT_PART | C_IDENT_START;
+ OBVIOUS_IDENT_CHAR_NATURES['$'] = C_SPECIAL | C_IDENT_PART | C_IDENT_START;
+
+ OBVIOUS_IDENT_CHAR_NATURES[9] = C_SPACE | C_JLS_SPACE; // \ u0009: HORIZONTAL TABULATION
+ OBVIOUS_IDENT_CHAR_NATURES[10] = C_SPACE | C_JLS_SPACE; // \ u000a: LINE FEED
+ OBVIOUS_IDENT_CHAR_NATURES[11] = C_SPACE;
+ OBVIOUS_IDENT_CHAR_NATURES[12] = C_SPACE | C_JLS_SPACE; // \ u000c: FORM FEED
+ OBVIOUS_IDENT_CHAR_NATURES[13] = C_SPACE | C_JLS_SPACE; // \ u000d: CARRIAGE RETURN
+ OBVIOUS_IDENT_CHAR_NATURES[28] = C_SPACE;
+ OBVIOUS_IDENT_CHAR_NATURES[29] = C_SPACE;
+ OBVIOUS_IDENT_CHAR_NATURES[30] = C_SPACE;
+ OBVIOUS_IDENT_CHAR_NATURES[31] = C_SPACE;
+ OBVIOUS_IDENT_CHAR_NATURES[32] = C_SPACE | C_JLS_SPACE; // \ u0020: SPACE
+
+ OBVIOUS_IDENT_CHAR_NATURES['.'] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES[':'] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES[';'] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES[','] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES['['] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES[']'] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES['('] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES[')'] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES['{'] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES['}'] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES['+'] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES['-'] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES['*'] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES['/'] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES['='] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES['&'] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES['|'] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES['?'] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES['<'] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES['>'] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES['!'] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES['%'] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES['^'] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES['~'] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES['"'] = C_SEPARATOR;
+ OBVIOUS_IDENT_CHAR_NATURES['\''] = C_SEPARATOR;
+ }
+
+ public static char toLowerCase(char c) {
+ if (c < MAX_OBVIOUS) {
+ if ((ScannerHelper.OBVIOUS_IDENT_CHAR_NATURES[c] & ScannerHelper.C_LOWER_LETTER) != 0) {
+ return c;
+ } else if ((ScannerHelper.OBVIOUS_IDENT_CHAR_NATURES[c] & ScannerHelper.C_UPPER_LETTER) != 0) {
+ return (char) (32 + c);
+ }
+ }
+ return Character.toLowerCase(c);
+}
+}
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/DiskIndex.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/DiskIndex.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/DiskIndex.java 2007-04-06 14:22:22 UTC (rev 2291)
@@ -0,0 +1,933 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.core.index;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
+import org.rubypeople.rdt.core.search.SearchPattern;
+import org.rubypeople.rdt.internal.compiler.util.HashtableOfIntValues;
+import org.rubypeople.rdt.internal.compiler.util.HashtableOfObject;
+import org.rubypeople.rdt.internal.compiler.util.SimpleLookupTable;
+import org.rubypeople.rdt.internal.compiler.util.SimpleSet;
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+import org.rubypeople.rdt.internal.core.util.Messages;
+import org.rubypeople.rdt.internal.core.util.SimpleWordSet;
+import org.rubypeople.rdt.internal.core.util.Util;
+
+public class DiskIndex {
+
+String fileName;
+
+private int headerInfoOffset;
+private int numberOfChunks;
+private int sizeOfLastChunk;
+private int[] chunkOffsets;
+private int documentReferenceSize; // 1, 2 or more bytes... depends on # of document names
+private int startOfCategoryTables;
+private HashtableOfIntValues categoryOffsets;
+
+private int cacheUserCount;
+private String[][] cachedChunks; // decompressed chunks of document names
+private HashtableOfObject categoryTables; // category name -> HashtableOfObject(words -> int[] of document #'s) or offset if not read yet
+private char[] cachedCategoryName;
+
+public static final String SIGNATURE= "INDEX VERSION 1.115"; //$NON-NLS-1$
+public static boolean DEBUG = false;
+
+private static final int RE_INDEXED = -1;
+private static final int DELETED = -2;
+
+private static final int CHUNK_SIZE = 100;
+
+class IntList {
+
+int size;
+int[] elements;
+
+IntList(int[] elements) {
+ this.elements = elements;
+ this.size = elements.length;
+}
+void add(int newElement) {
+ if (this.size == this.elements.length) {
+ int newSize = this.size * 3;
+ if (newSize < 7) newSize = 7;
+ System.arraycopy(this.elements, 0, this.elements = new int[newSize], 0, this.size);
+ }
+ this.elements[this.size++] = newElement;
+}
+int[] asArray() {
+ int[] result = new int[this.size];
+ System.arraycopy(this.elements, 0, result, 0, this.size);
+ return result;
+}
+}
+
+
+DiskIndex(String fileName) {
+ this.fileName = fileName;
+
+ // clear cached items
+ this.headerInfoOffset = -1;
+ this.numberOfChunks = -1;
+ this.sizeOfLastChunk = -1;
+ this.chunkOffsets = null;
+ this.documentReferenceSize = -1;
+ this.cacheUserCount = -1;
+ this.cachedChunks = null;
+ this.categoryTables = null;
+ this.cachedCategoryName = null;
+ this.categoryOffsets = null;
+}
+SimpleSet addDocumentNames(String substring, MemoryIndex memoryIndex) throws IOException {
+ // must skip over documents which have been added/changed/deleted in the memory index
+ String[] docNames = readAllDocumentNames();
+ SimpleSet results = new SimpleSet(docNames.length);
+ if (substring == null) {
+ if (memoryIndex == null) {
+ for (int i = 0, l = docNames.length; i < l; i++)
+ results.add(docNames[i]);
+ } else {
+ SimpleLookupTable docsToRefs = memoryIndex.docsToReferences;
+ for (int i = 0, l = docNames.length; i < l; i++) {
+ String docName = docNames[i];
+ if (!docsToRefs.containsKey(docName))
+ results.add(docName);
+ }
+ }
+ } else {
+ if (memoryIndex == null) {
+ for (int i = 0, l = docNames.length; i < l; i++)
+ if (docNames[i].startsWith(substring, 0))
+ results.add(docNames[i]);
+ } else {
+ SimpleLookupTable docsToRefs = memoryIndex.docsToReferences;
+ for (int i = 0, l = docNames.length; i < l; i++) {
+ String docName = docNames[i];
+ if (docName.startsWith(substring, 0) && !docsToRefs.containsKey(docName))
+ results.add(docName);
+ }
+ }
+ }
+ return results;
+}
+private HashtableOfObject addQueryResult(HashtableOfObject results, char[] word, HashtableOfObject wordsToDocNumbers, MemoryIndex memoryIndex) throws IOException {
+ // must skip over documents which have been added/changed/deleted in the memory index
+ if (results == null)
+ results = new HashtableOfObject(13);
+ EntryResult result = (EntryResult) results.get(word);
+ if (memoryIndex == null) {
+ if (result == null)
+ results.put(word, new EntryResult(word, wordsToDocNumbers));
+ else
+ result.addDocumentTable(wordsToDocNumbers);
+ } else {
+ SimpleLookupTable docsToRefs = memoryIndex.docsToReferences;
+ if (result == null)
+ result = new EntryResult(word, null);
+ int[] docNumbers = readDocumentNumbers(wordsToDocNumbers.get(word));
+ for (int i = 0, l = docNumbers.length; i < l; i++) {
+ String docName = readDocumentName(docNumbers[i]);
+ if (!docsToRefs.containsKey(docName))
+ result.addDocumentName(docName);
+ }
+ if (!result.isEmpty())
+ results.put(word, result);
+ }
+ return results;
+}
+HashtableOfObject addQueryResults(char[][] categories, char[] key, int matchRule, MemoryIndex memoryIndex) throws IOException {
+ // assumes sender has called startQuery() & will call stopQuery() when finished
+ if (this.categoryOffsets == null) return null; // file is empty
+
+ HashtableOfObject results = null; // initialized if needed
+ if (key == null) {
+ for (int i = 0, l = categories.length; i < l; i++) {
+ HashtableOfObject wordsToDocNumbers = readCategoryTable(categories[i], true); // cache if key is null since its a definite match
+ if (wordsToDocNumbers != null) {
+ char[][] words = wordsToDocNumbers.keyTable;
+ if (results == null)
+ results = new HashtableOfObject(wordsToDocNumbers.elementSize);
+ for (int j = 0, m = words.length; j < m; j++)
+ if (words[j] != null)
+ results = addQueryResult(results, words[j], wordsToDocNumbers, memoryIndex);
+ }
+ }
+ if (results != null && this.cachedChunks == null)
+ cacheDocumentNames();
+ } else {
+ switch (matchRule) {
+ case SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE:
+ for (int i = 0, l = categories.length; i < l; i++) {
+ HashtableOfObject wordsToDocNumbers = readCategoryTable(categories[i], false);
+ if (wordsToDocNumbers != null && wordsToDocNumbers.containsKey(key))
+ results = addQueryResult(results, key, wordsToDocNumbers, memoryIndex);
+ }
+ break;
+ case SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CASE_SENSITIVE:
+ for (int i = 0, l = categories.length; i < l; i++) {
+ HashtableOfObject wordsToDocNumbers = readCategoryTable(categories[i], false);
+ if (wordsToDocNumbers != null) {
+ char[][] words = wordsToDocNumbers.keyTable;
+ for (int j = 0, m = words.length; j < m; j++) {
+ char[] word = words[j];
+ if (word != null && key[0] == word[0] && CharOperation.prefixEquals(key, word))
+ results = addQueryResult(results, word, wordsToDocNumbers, memoryIndex);
+ }
+ }
+ }
+ break;
+ default:
+ for (int i = 0, l = categories.length; i < l; i++) {
+ HashtableOfObject wordsToDocNumbers = readCategoryTable(categories[i], false);
+ if (wordsToDocNumbers != null) {
+ char[][] words = wordsToDocNumbers.keyTable;
+ for (int j = 0, m = words.length; j < m; j++) {
+ char[] word = words[j];
+ if (word != null && Index.isMatch(key, word, matchRule))
+ results = addQueryResult(results, word, wordsToDocNumbers, memoryIndex);
+ }
+ }
+ }
+ }
+ }
+
+ if (results == null) return null;
+ return results;
+}
+private void cacheDocumentNames() throws IOException {
+ // will need all document names so get them now
+ this.cachedChunks = new String[this.numberOfChunks][];
+ DataInputStream stream = new DataInputStream(new BufferedInputStream(new FileInputStream(getIndexFile()), this.numberOfChunks > 5 ? 4096 : 2048));
+ try {
+ stream.skip(this.chunkOffsets[0]);
+ for (int i = 0; i < this.numberOfChunks; i++) {
+ int size = i == this.numberOfChunks - 1 ? this.sizeOfLastChunk : CHUNK_SIZE;
+ readChunk(this.cachedChunks[i] = new String[size], stream, 0, size);
+ }
+ } finally {
+ stream.close();
+ }
+}
+private String[] computeDocumentNames(String[] onDiskNames, int[] positions, SimpleLookupTable indexedDocuments, MemoryIndex memoryIndex) {
+ int onDiskLength = onDiskNames.length;
+ Object[] docNames = memoryIndex.docsToReferences.keyTable;
+ Object[] referenceTables = memoryIndex.docsToReferences.valueTable;
+ if (onDiskLength == 0) {
+ // disk index was empty, so add every indexed document
+ for (int i = 0, l = referenceTables.length; i < l; i++)
+ if (referenceTables[i] != null)
+ indexedDocuments.put(docNames[i], null); // remember each new document
+
+ String[] newDocNames = new String[indexedDocuments.elementSize];
+ int count = 0;
+ Object[] added = indexedDocuments.keyTable;
+ for (int i = 0, l = added.length; i < l; i++)
+ if (added[i] != null)
+ newDocNames[count++] = (String) added[i];
+ Util.sort(newDocNames);
+ for (int i = 0, l = newDocNames.length; i < l; i++)
+ indexedDocuments.put(newDocNames[i], new Integer(i));
+ return newDocNames;
+ }
+
+ // initialize positions as if each document will remain in the same position
+ for (int i = 0; i < onDiskLength; i++)
+ positions[i] = i;
+
+ // find out if the memory index has any new or deleted documents, if not then the names & positions are the same
+ int numDeletedDocNames = 0;
+ int numReindexedDocNames = 0;
+ nextPath : for (int i = 0, l = docNames.length; i < l; i++) {
+ String docName = (String) docNames[i];
+ if (docName != null) {
+ for (int j = 0; j < onDiskLength; j++) {
+ if (docName.equals(onDiskNames[j])) {
+ if (referenceTables[i] == null) {
+ positions[j] = DELETED;
+ numDeletedDocNames++;
+ } else {
+ positions[j] = RE_INDEXED;
+ numReindexedDocNames++;
+ }
+ continue nextPath;
+ }
+ }
+ if (referenceTables[i] != null)
+ indexedDocuments.put(docName, null); // remember each new document, skip deleted documents which were never saved
+ }
+ }
+
+ String[] newDocNames = onDiskNames;
+ if (numDeletedDocNames > 0 || indexedDocuments.elementSize > 0) {
+ // some new documents have been added or some old ones deleted
+ newDocNames = new String[onDiskLength + indexedDocuments.elementSize - numDeletedDocNames];
+ int count = 0;
+ for (int i = 0; i < onDiskLength; i++)
+ if (positions[i] >= RE_INDEXED)
+ newDocNames[count++] = onDiskNames[i]; // keep each unchanged document
+ Object[] added = indexedDocuments.keyTable;
+ for (int i = 0, l = added.length; i < l; i++)
+ if (added[i] != null)
+ newDocNames[count++] = (String) added[i]; // add each new document
+ Util.sort(newDocNames);
+ for (int i = 0, l = newDocNames.length; i < l; i++)
+ if (indexedDocuments.containsKey(newDocNames[i]))
+ indexedDocuments.put(newDocNames[i], new Integer(i)); // remember the position for each new document
+ }
+
+ // need to be able to look up an old position (ref# from a ref[]) and map it to its new position
+ // if its old position == DELETED then its forgotton
+ // if its old position == ReINDEXED then its also forgotten but its new position is needed to map references
+ int count = -1;
+ for (int i = 0; i < onDiskLength;) {
+ switch(positions[i]) {
+ case DELETED :
+ i++; // skip over deleted... references are forgotten
+ break;
+ case RE_INDEXED :
+ String newName = newDocNames[++count];
+ if (newName.equals(onDiskNames[i])) {
+ indexedDocuments.put(newName, new Integer(count)); // the reindexed docName that was at position i is now at position count
+ i++;
+ }
+ break;
+ default :
+ if (newDocNames[++count].equals(onDiskNames[i]))
+ positions[i++] = count; // the unchanged docName that was at position i is now at position count
+ }
+ }
+ return newDocNames;
+}
+private void copyQueryResults(HashtableOfObject categoryToWords, int newPosition) {
+ char[][] categoryNames = categoryToWords.keyTable;
+ Object[] wordSets = categoryToWords.valueTable;
+ for (int i = 0, l = categoryNames.length; i < l; i++) {
+ char[] categoryName = categoryNames[i];
+ if (categoryName != null) {
+ SimpleWordSet wordSet = (SimpleWordSet) wordSets[i];
+ HashtableOfObject wordsToDocs = (HashtableOfObject) this.categoryTables.get(categoryName);
+ if (wordsToDocs == null)
+ this.categoryTables.put(categoryName, wordsToDocs = new HashtableOfObject(wordSet.elementSize));
+
+ char[][] words = wordSet.words;
+ for (int j = 0, m = words.length; j < m; j++) {
+ char[] word = words[j];
+ if (word != null) {
+ Object o = wordsToDocs.get(word);
+ if (o == null) {
+ wordsToDocs.put(word, new int[] {newPosition});
+ } else if (o instanceof IntList) {
+ ((IntList) o).add(newPosition);
+ } else {
+ IntList list = new IntList((int[]) o);
+ list.add(newPosition);
+ wordsToDocs.put(word, list);
+ }
+ }
+ }
+ }
+ }
+}
+File getIndexFile() {
+ if (this.fileName == null) return null;
+
+ return new File(this.fileName);
+}
+void initialize(boolean reuseExistingFile) throws IOException {
+ File indexFile = getIndexFile();
+ if (indexFile.exists()) {
+ if (reuseExistingFile) {
+ RandomAccessFile file = new RandomAccessFile(this.fileName, "r"); //$NON-NLS-1$
+ try {
+ String signature = file.readUTF();
+ if (!signature.equals(SIGNATURE))
+ throw new IOException(Messages.exception_wrongFormat);
+
+ this.headerInfoOffset = file.readInt();
+ if (this.headerInfoOffset > 0) // file is empty if its not set
+ readHeaderInfo(file);
+ } finally {
+ file.close();
+ }
+ return;
+ }
+ if (!indexFile.delete()) {
+ if (DEBUG)
+ System.out.println("initialize - Failed to delete index " + this.fileName); //$NON-NLS-1$
+ throw new IOException("Failed to delete index " + this.fileName); //$NON-NLS-1$
+ }
+ }
+ if (indexFile.createNewFile()) {
+ RandomAccessFile file = new RandomAccessFile(this.fileName, "rw"); //$NON-NLS-1$
+ try {
+ file.writeUTF(SIGNATURE);
+ file.writeInt(-1); // file is empty
+ } finally {
+ file.close();
+ }
+ } else {
+ if (DEBUG)
+ System.out.println("initialize - Failed to create new index " + this.fileName); //$NON-NLS-1$
+ throw new IOException("Failed to create new index " + this.fileName); //$NON-NLS-1$
+ }
+}
+private void initializeFrom(DiskIndex diskIndex, File newIndexFile) throws IOException {
+ if (newIndexFile.exists() && !newIndexFile.delete()) { // delete the temporary index file
+ if (DEBUG)
+ System.out.println("initializeFrom - Failed to delete temp index " + this.fileName); //$NON-NLS-1$
+ } else if (!newIndexFile.createNewFile()) {
+ if (DEBUG)
+ System.out.println("initializeFrom - Failed to create temp index " + this.fileName); //$NON-NLS-1$
+ throw new IOException("Failed to create temp index " + this.fileName); //$NON-NLS-1$
+ }
+
+ int size = diskIndex.categoryOffsets == null ? 8 : diskIndex.categoryOffsets.elementSize;
+ this.categoryOffsets = new HashtableOfIntValues(size);
+ this.categoryTables = new HashtableOfObject(size);
+}
+private void mergeCategories(DiskIndex onDisk, int[] positions, DataOutputStream stream) throws IOException {
+ // at this point, this.categoryTables contains the names -> wordsToDocs added in copyQueryResults()
+ char[][] oldNames = onDisk.categoryOffsets.keyTable;
+ for (int i = 0, l = oldNames.length; i < l; i++) {
+ char[] oldName = oldNames[i];
+ if (oldName != null && !this.categoryTables.containsKey(oldName))
+ this.categoryTables.put(oldName, null);
+ }
+
+ char[][] categoryNames = this.categoryTables.keyTable;
+ for (int i = 0, l = categoryNames.length; i < l; i++)
+ if (categoryNames[i] != null)
+ mergeCategory(categoryNames[i], onDisk, positions, stream);
+ this.categoryTables = null;
+}
+private void mergeCategory(char[] categoryName, DiskIndex onDisk, int[] positions, DataOutputStream stream) throws IOException {
+ HashtableOfObject wordsToDocs = (HashtableOfObject) this.categoryTables.get(categoryName);
+ if (wordsToDocs == null)
+ wordsToDocs = new HashtableOfObject(3);
+
+ HashtableOfObject oldWordsToDocs = onDisk.readCategoryTable(categoryName, true);
+ if (oldWordsToDocs != null) {
+ char[][] oldWords = oldWordsToDocs.keyTable;
+ Object[] oldArrayOffsets = oldWordsToDocs.valueTable;
+ nextWord: for (int i = 0, l = oldWords.length; i < l; i++) {
+ char[] oldWord = oldWords[i];
+ if (oldWord != null) {
+ int[] oldDocNumbers = (int[]) oldArrayOffsets[i];
+ int length = oldDocNumbers.length;
+ int[] mappedNumbers = new int[length];
+ int count = 0;
+ for (int j = 0; j < length; j++) {
+ int pos = positions[oldDocNumbers[j]];
+ if (pos > RE_INDEXED) // forget any reference to a document which was deleted or re_indexed
+ mappedNumbers[count++] = pos;
+ }
+ if (count < length) {
+ if (count == 0) continue nextWord; // skip words which no longer have any references
+ System.arraycopy(mappedNumbers, 0, mappedNumbers = new int[count], 0, count);
+ }
+
+ Object o = wordsToDocs.get(oldWord);
+ if (o == null) {
+ wordsToDocs.put(oldWord, mappedNumbers);
+ } else {
+ IntList list = null;
+ if (o instanceof IntList) {
+ list = (IntList) o;
+ } else {
+ list = new IntList((int[]) o);
+ wordsToDocs.put(oldWord, list);
+ }
+ for (int j = 0; j < count; j++)
+ list.add(mappedNumbers[j]);
+ }
+ }
+ }
+ onDisk.categoryTables.put(categoryName, null); // flush cached table
+ }
+ writeCategoryTable(categoryName, wordsToDocs, stream);
+}
+DiskIndex mergeWith(MemoryIndex memoryIndex) throws IOException {
+ // assume write lock is held
+ // compute & write out new docNames
+ String[] docNames = readAllDocumentNames();
+ int previousLength = docNames.length;
+ int[] positions = new int[previousLength]; // keeps track of the position of each document in the new sorted docNames
+ SimpleLookupTable indexedDocuments = new SimpleLookupTable(3); // for each new/changed document in the memoryIndex
+ docNames = computeDocumentNames(docNames, positions, indexedDocuments, memoryIndex);
+ if (docNames.length == 0) {
+ if (previousLength == 0) return this; // nothing to do... memory index contained deleted documents that had never been saved
+
+ // index is now empty since all the saved documents were removed
+ DiskIndex newDiskIndex = new DiskIndex(this.fileName);
+ newDiskIndex.initialize(false);
+ return newDiskIndex;
+ }
+
+ DiskIndex newDiskIndex = new DiskIndex(this.fileName + ".tmp"); //$NON-NLS-1$
+ File newIndexFile = newDiskIndex.getIndexFile();
+ try {
+ newDiskIndex.initializeFrom(this, newIndexFile);
+ DataOutputStream stream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(newIndexFile, false), 2048));
+ int offsetToHeader = -1;
+ try {
+ newDiskIndex.writeAllDocumentNames(docNames, stream);
+ docNames = null; // free up the space
+
+ // add each new/changed doc to empty category tables using its new position #
+ if (indexedDocuments.elementSize > 0) {
+ Object[] names = indexedDocuments.keyTable;
+ Object[] integerPositions = indexedDocuments.valueTable;
+ for (int i = 0, l = names.length; i < l; i++)
+ if (names[i] != null)
+ newDiskIndex.copyQueryResults(
+ (HashtableOfObject) memoryIndex.docsToReferences.get(names[i]),
+ ((Integer) integerPositions[i]).intValue());
+ }
+ indexedDocuments = null; // free up the space
+
+ // merge each category table with the new ones & write them out
+ if (previousLength == 0)
+ newDiskIndex.writeCategories(stream);
+ else
+ newDiskIndex.mergeCategories(this, positions, stream);
+ offsetToHeader = stream.size();
+ newDiskIndex.writeHeaderInfo(stream);
+ positions = null; // free up the space
+ } finally {
+ stream.close();
+ }
+ newDiskIndex.writeOffsetToHeader(offsetToHeader);
+
+ // rename file by deleting previous index file & renaming temp one
+ File old = getIndexFile();
+ if (old.exists() && !old.delete()) {
+ if (DEBUG)
+ System.out.println("mergeWith - Failed to delete " + this.fileName); //$NON-NLS-1$
+ throw new IOException("Failed to delete index file " + this.fileName); //$NON-NLS-1$
+ }
+ if (!newIndexFile.renameTo(old)) {
+ if (DEBUG)
+ System.out.println("mergeWith - Failed to rename " + this.fileName); //$NON-NLS-1$
+ throw new IOException("Failed to rename index file " + this.fileName); //$NON-NLS-1$
+ }
+ } catch (IOException e) {
+ if (newIndexFile.exists() && !newIndexFile.delete())
+ if (DEBUG)
+ System.out.println("mergeWith - Failed to delete temp index " + newDiskIndex.fileName); //$NON-NLS-1$
+ throw e;
+ }
+
+ newDiskIndex.fileName = this.fileName;
+ return newDiskIndex;
+}
+private synchronized String[] readAllDocumentNames() throws IOException {
+ if (this.numberOfChunks <= 0)
+ return new String[0];
+
+ DataInputStream stream = new DataInputStream(new BufferedInputStream(new FileInputStream(getIndexFile()), this.numberOfChunks > 5 ? 4096 : 2048));
+ try {
+ stream.skip(this.chunkOffsets[0]);
+ int lastIndex = this.numberOfChunks - 1;
+ String[] docNames = new String[lastIndex * CHUNK_SIZE + sizeOfLastChunk];
+ for (int i = 0; i < this.numberOfChunks; i++)
+ readChunk(docNames, stream, i * CHUNK_SIZE, i < lastIndex ? CHUNK_SIZE : sizeOfLastChunk);
+ return docNames;
+ } finally {
+ stream.close();
+ }
+}
+private synchronized HashtableOfObject readCategoryTable(char[] categoryName, boolean readDocNumbers) throws IOException {
+ // result will be null if categoryName is unknown
+ int offset = this.categoryOffsets.get(categoryName);
+ if (offset == HashtableOfIntValues.NO_VALUE)
+ return null;
+
+ if (this.categoryTables == null) {
+ this.categoryTables = new HashtableOfObject(3);
+ } else {
+ HashtableOfObject cachedTable = (HashtableOfObject) this.categoryTables.get(categoryName);
+ if (cachedTable != null) {
+ if (readDocNumbers) { // must cache remaining document number arrays
+ Object[] arrayOffsets = cachedTable.valueTable;
+ for (int i = 0, l = arrayOffsets.length; i < l; i++)
+ if (arrayOffsets[i] instanceof Integer)
+ arrayOffsets[i] = readDocumentNumbers(arrayOffsets[i]);
+ }
+ return cachedTable;
+ }
+ }
+
+ DataInputStream stream = new DataInputStream(new BufferedInputStream(new FileInputStream(getIndexFile()), 2048));
+ HashtableOfObject categoryTable = null;
+ char[][] matchingWords = null;
+ int count = 0;
+ int firstOffset = -1;
+ try {
+ stream.skip(offset);
+ int size = stream.readInt();
+ try {
+ if (size < 0) { // DEBUG
+ System.err.println("-------------------- DEBUG --------------------"); //$NON-NLS-1$
+ System.err.println("file = "+getIndexFile()); //$NON-NLS-1$
+ System.err.println("offset = "+offset); //$NON-NLS-1$
+ System.err.println("size = "+size); //$NON-NLS-1$
+ System.err.println("-------------------- END --------------------"); //$NON-NLS-1$
+ }
+ categoryTable = new HashtableOfObject(size);
+ } catch (OutOfMemoryError oom) {
+ // DEBUG
+ oom.printStackTrace();
+ System.err.println("-------------------- DEBUG --------------------"); //$NON-NLS-1$
+ System.err.println("file = "+getIndexFile()); //$NON-NLS-1$
+ System.err.println("offset = "+offset); //$NON-NLS-1$
+ System.err.println("size = "+size); //$NON-NLS-1$
+ System.err.println("-------------------- END --------------------"); //$NON-NLS-1$
+ throw oom;
+ }
+ int largeArraySize = 256;
+ for (int i = 0; i < size; i++) {
+ char[] word = Util.readUTF(stream);
+ int arrayOffset = stream.readInt();
+ // if arrayOffset is:
+ // <= 0 then the array size == 1 with the value -> -arrayOffset
+ // > 1 & < 256 then the size of the array is > 1 & < 256, the document array follows immediately
+ // 256 if the array size >= 256 followed by another int which is the offset to the array (written prior to the table)
+ if (arrayOffset <= 0) {
+ categoryTable.put(word, new int[] {-arrayOffset}); // store 1 element array by negating documentNumber
+ } else if (arrayOffset < largeArraySize) {
+ categoryTable.put(word, readDocumentArray(stream, arrayOffset)); // read in-lined array providing size
+ } else {
+ arrayOffset = stream.readInt(); // read actual offset
+ if (readDocNumbers) {
+ if (matchingWords == null)
+ matchingWords = new char[size][];
+ if (count == 0)
+ firstOffset = arrayOffset;
+ matchingWords[count++] = word;
+ }
+ categoryTable.put(word, new Integer(arrayOffset)); // offset to array in the file
+ }
+ }
+ this.categoryTables.put(categoryName, categoryTable);
+ // cache the table as long as its not too big
+ // in practise, some tables can be greater than 500K when the contain more than 10K elements
+ this.cachedCategoryName = categoryTable.elementSize < 10000 ? categoryName : null;
+ } finally {
+ stream.close();
+ }
+
+ if (matchingWords != null && count > 0) {
+ stream = new DataInputStream(new BufferedInputStream(new FileInputStream(getIndexFile()), 2048));
+ try {
+ stream.skip(firstOffset);
+ for (int i = 0; i < count; i++) // each array follows the previous one
+ categoryTable.put(matchingWords[i], readDocumentArray(stream, stream.readInt()));
+ } finally {
+ stream.close();
+ }
+ }
+ return categoryTable;
+}
+private void readChunk(String[] docNames, DataInputStream stream, int index, int size) throws IOException {
+ String current = stream.readUTF();
+ docNames[index++] = current;
+ for (int i = 1; i < size; i++) {
+ int start = stream.readUnsignedByte(); // number of identical characters at the beginning
+ int end = stream.readUnsignedByte(); // number of identical characters at the end
+ String next = stream.readUTF();
+ if (start > 0) {
+ if (end > 0) {
+ int length = current.length();
+ next = current.substring(0, start) + next + current.substring(length - end, length);
+ } else {
+ next = current.substring(0, start) + next;
+ }
+ } else if (end > 0) {
+ int length = current.length();
+ next = next + current.substring(length - end, length);
+ }
+ docNames[index++] = next;
+ current = next;
+ }
+}
+private int[] readDocumentArray(DataInputStream stream, int arraySize) throws IOException {
+ int[] result = new int[arraySize];
+ switch (this.documentReferenceSize) {
+ case 1 :
+ for (int i = 0; i < arraySize; i++)
+ result[i] = stream.readUnsignedByte();
+ break;
+ case 2 :
+ for (int i = 0; i < arraySize; i++)
+ result[i] = stream.readUnsignedShort();
+ break;
+ default :
+ for (int i = 0; i < arraySize; i++)
+ result[i] = stream.readInt();
+ break;
+ }
+ return result;
+}
+synchronized String readDocumentName(int docNumber) throws IOException {
+ if (this.cachedChunks == null)
+ this.cachedChunks = new String[this.numberOfChunks][];
+
+ int chunkNumber = docNumber / CHUNK_SIZE;
+ String[] chunk = this.cachedChunks[chunkNumber];
+ if (chunk == null) {
+ boolean isLastChunk = chunkNumber == this.numberOfChunks - 1;
+ int start = this.chunkOffsets[chunkNumber];
+ int numberOfBytes = (isLastChunk ? this.startOfCategoryTables : this.chunkOffsets[chunkNumber + 1]) - start;
+ if (numberOfBytes < 0)
+ throw new IllegalArgumentException();
+ byte[] bytes = new byte[numberOfBytes];
+ FileInputStream file = new FileInputStream(getIndexFile());
+ try {
+ file.skip(start);
+ if (file.read(bytes, 0, numberOfBytes) != numberOfBytes)
+ throw new IOException();
+ } finally {
+ file.close();
+ }
+ DataInputStream stream = new DataInputStream(new ByteArrayInputStream(bytes));
+ int numberOfNames = isLastChunk ? this.sizeOfLastChunk : CHUNK_SIZE;
+ chunk = this.cachedChunks[chunkNumber] = new String[numberOfNames];
+ readChunk(chunk, stream, 0, numberOfNames);
+ }
+ return chunk[docNumber - (chunkNumber * CHUNK_SIZE)];
+}
+synchronized int[] readDocumentNumbers(Object arrayOffset) throws IOException {
+ // arrayOffset is either a cached array of docNumbers or an Integer offset in the file
+ if (arrayOffset instanceof int[])
+ return (int[]) arrayOffset;
+
+ DataInputStream stream = new DataInputStream(new BufferedInputStream(new FileInputStream(getIndexFile()), 2048));
+ try {
+ stream.skip(((Integer) arrayOffset).intValue());
+ return readDocumentArray(stream, stream.readInt());
+ } finally {
+ stream.close();
+ }
+}
+private void readHeaderInfo(RandomAccessFile file) throws IOException {
+ file.seek(this.headerInfoOffset);
+
+ // must be same order as writeHeaderInfo()
+ this.numberOfChunks = file.readInt();
+ this.sizeOfLastChunk = file.readUnsignedByte();
+ this.documentReferenceSize = file.readUnsignedByte();
+
+ this.chunkOffsets = new int[this.numberOfChunks];
+ for (int i = 0; i < this.numberOfChunks; i++)
+ this.chunkOffsets[i] = file.readInt();
+
+ this.startOfCategoryTables = file.readInt();
+
+ int size = file.readInt();
+ this.categoryOffsets = new HashtableOfIntValues(size);
+ for (int i = 0; i < size; i++)
+ this.categoryOffsets.put(Util.readUTF(file), file.readInt()); // cache offset to category table
+ this.categoryTables = new HashtableOfObject(3);
+}
+synchronized void startQuery() {
+ this.cacheUserCount++;
+}
+synchronized void stopQuery() {
+ if (--this.cacheUserCount < 0) {
+ // clear cached items
+ this.cacheUserCount = -1;
+ this.cachedChunks = null;
+ if (this.categoryTables != null) {
+ if (this.cachedCategoryName == null) {
+ this.categoryTables = null;
+ } else if (this.categoryTables.elementSize > 1) {
+ HashtableOfObject newTables = new HashtableOfObject(3);
+ newTables.put(this.cachedCategoryName, this.categoryTables.get(this.cachedCategoryName));
+ this.categoryTables = newTables;
+ }
+ }
+ }
+}
+private void writeAllDocumentNames(String[] sortedDocNames, DataOutputStream stream) throws IOException {
+ if (sortedDocNames.length == 0)
+ throw new IllegalArgumentException();
+
+ // assume the file was just created by initializeFrom()
+ // in order, write: SIGNATURE & headerInfoOffset place holder, then each compressed chunk of document names
+ stream.writeUTF(SIGNATURE);
+ this.headerInfoOffset = stream.size();
+ stream.writeInt(-1); // will overwrite with correct value later
+
+ int size = sortedDocNames.length;
+ this.numberOfChunks = (size / CHUNK_SIZE) + 1;
+ this.sizeOfLastChunk = size % CHUNK_SIZE;
+ if (this.sizeOfLastChunk == 0) {
+ this.numberOfChunks--;
+ this.sizeOfLastChunk = CHUNK_SIZE;
+ }
+ this.documentReferenceSize = size <= 0x7F ? 1 : (size <= 0x7FFF ? 2 : 4); // number of bytes used to encode a reference
+
+ this.chunkOffsets = new int[this.numberOfChunks];
+ int lastIndex = this.numberOfChunks - 1;
+ for (int i = 0; i < this.numberOfChunks; i++) {
+ this.chunkOffsets[i] = stream.size();
+
+ int chunkSize = i == lastIndex ? this.sizeOfLastChunk : CHUNK_SIZE;
+ int chunkIndex = i * CHUNK_SIZE;
+ String current = sortedDocNames[chunkIndex];
+ stream.writeUTF(current);
+ for (int j = 1; j < chunkSize; j++) {
+ String next = sortedDocNames[chunkIndex + j];
+ int len1 = current.length();
+ int len2 = next.length();
+ int max = len1 < len2 ? len1 : len2;
+ int start = 0; // number of identical characters at the beginning (also the index of first character that is different)
+ while (current.charAt(start) == next.charAt(start)) {
+ start++;
+ if (max == start) break; // current is 'abba', next is 'abbab'
+ }
+ if (start > 255) start = 255;
+
+ int end = 0; // number of identical characters at the end
+ while (current.charAt(--len1) == next.charAt(--len2)) {
+ end++;
+ if (len2 == start) break; // current is 'abbba', next is 'abba'
+ if (len1 == 0) break; // current is 'xabc', next is 'xyabc'
+ }
+ if (end > 255) end = 255;
+ stream.writeByte(start);
+ stream.writeByte(end);
+
+ int last = next.length() - end;
+ stream.writeUTF(start < last ? next.substring(start, last) : ""); //$NON-NLS-1$
+ current = next;
+ }
+ }
+ this.startOfCategoryTables = stream.size() + 1;
+}
+private void writeCategories(DataOutputStream stream) throws IOException {
+ char[][] categoryNames = this.categoryTables.keyTable;
+ Object[] tables = this.categoryTables.valueTable;
+ for (int i = 0, l = categoryNames.length; i < l; i++)
+ if (categoryNames[i] != null)
+ writeCategoryTable(categoryNames[i], (HashtableOfObject) tables[i], stream);
+ this.categoryTables = null;
+}
+private void writeCategoryTable(char[] categoryName, HashtableOfObject wordsToDocs, DataOutputStream stream) throws IOException {
+ // the format of a category table is as follows:
+ // any document number arrays with >= 256 elements are written before the table (the offset to each array is remembered)
+ // then the number of word->int[] pairs in the table is written
+ // for each word -> int[] pair, the word is written followed by:
+ // an int <= 0 if the array size == 1
+ // an int > 1 & < 256 for the size of the array if its > 1 & < 256, the document array follows immediately
+ // 256 if the array size >= 256 followed by another int which is the offset to the array (written prior to the table)
+
+ int largeArraySize = 256;
+ Object[] values = wordsToDocs.valueTable;
+ for (int i = 0, l = values.length; i < l; i++) {
+ Object o = values[i];
+ if (o != null) {
+ if (o instanceof IntList)
+ o = values[i] = ((IntList) values[i]).asArray();
+ int[] documentNumbers = (int[]) o;
+ if (documentNumbers.length >= largeArraySize) {
+ values[i] = new Integer(stream.size());
+ writeDocumentNumbers(documentNumbers, stream);
+ }
+ }
+ }
+
+ this.categoryOffsets.put(categoryName, stream.size()); // remember the offset to the start of the table
+ this.categoryTables.put(categoryName, null); // flush cached table
+ stream.writeInt(wordsToDocs.elementSize);
+ char[][] words = wordsToDocs.keyTable;
+ for (int i = 0, l = words.length; i < l; i++) {
+ Object o = values[i];
+ if (o != null) {
+ Util.writeUTF(stream, words[i]);
+ if (o instanceof int[]) {
+ int[] documentNumbers = (int[]) o;
+ if (documentNumbers.length == 1)
+ stream.writeInt(-documentNumbers[0]); // store an array of 1 element by negating the documentNumber (can be zero)
+ else
+ writeDocumentNumbers(documentNumbers, stream);
+ } else {
+ stream.writeInt(largeArraySize); // mark to identify that an offset follows
+ stream.writeInt(((Integer) o).intValue()); // offset in the file of the array of document numbers
+ }
+ }
+ }
+}
+private void writeDocumentNumbers(int[] documentNumbers, DataOutputStream stream) throws IOException {
+ // must store length as a positive int to detect in-lined array of 1 element
+ int length = documentNumbers.length;
+ stream.writeInt(length);
+ Util.sort(documentNumbers);
+ switch (this.documentReferenceSize) {
+ case 1 :
+ for (int i = 0; i < length; i++)
+ stream.writeByte(documentNumbers[i]);
+ break;
+ case 2 :
+ for (int i = 0; i < length; i++)
+ stream.writeShort(documentNumbers[i]);
+ break;
+ default :
+ for (int i = 0; i < length; i++)
+ stream.writeInt(documentNumbers[i]);
+ break;
+ }
+}
+private void writeHeaderInfo(DataOutputStream stream) throws IOException {
+ stream.writeInt(this.numberOfChunks);
+ stream.writeByte(this.sizeOfLastChunk);
+ stream.writeByte(this.documentReferenceSize);
+
+ // apend the file with chunk offsets
+ for (int i = 0; i < this.numberOfChunks; i++)
+ stream.writeInt(this.chunkOffsets[i]);
+
+ stream.writeInt(this.startOfCategoryTables);
+
+ // append the file with the category offsets... # of name -> offset pairs, followed by each name & an offset to its word->doc# table
+ stream.writeInt(this.categoryOffsets.elementSize);
+ char[][] categoryNames = this.categoryOffsets.keyTable;
+ int[] offsets = this.categoryOffsets.valueTable;
+ for (int i = 0, l = categoryNames.length; i < l; i++) {
+ if (categoryNames[i] != null) {
+ Util.writeUTF(stream, categoryNames[i]);
+ stream.writeInt(offsets[i]);
+ }
+ }
+}
+private void writeOffsetToHeader(int offsetToHeader) throws IOException {
+ if (offsetToHeader > 0) {
+ RandomAccessFile file = new RandomAccessFile(this.fileName, "rw"); //$NON-NLS-1$
+ try {
+ file.seek(this.headerInfoOffset); // offset to position in header
+ file.writeInt(offsetToHeader);
+ this.headerInfoOffset = offsetToHeader; // update to reflect the correct offset
+ } finally {
+ file.close();
+ }
+ }
+}
+}
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/EntryResult.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/EntryResult.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/EntryResult.java 2007-04-06 14:22:22 UTC (rev 2291)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.core.index;
+
+import org.rubypeople.rdt.internal.compiler.util.HashtableOfObject;
+import org.rubypeople.rdt.internal.compiler.util.SimpleSet;
+
+public class EntryResult {
+
+private char[] word;
+private HashtableOfObject[] documentTables;
+private SimpleSet documentNames;
+
+public EntryResult(char[] word, HashtableOfObject table) {
+ this.word = word;
+ if (table != null)
+ this.documentTables = new HashtableOfObject[] {table};
+}
+public void addDocumentName(String documentName) {
+ if (this.documentNames == null)
+ this.documentNames = new SimpleSet(3);
+ this.documentNames.add(documentName);
+}
+public void addDocumentTable(HashtableOfObject table) {
+ if (this.documentTables != null) {
+ int length = this.documentTables.length;
+ System.arraycopy(this.documentTables, 0, this.documentTables = new HashtableOfObject[length + 1], 0, length);
+ this.documentTables[length] = table;
+ } else {
+ this.documentTables = new HashtableOfObject[] {table};
+ }
+}
+public char[] getWord() {
+ return this.word;
+}
+public String[] getDocumentNames(Index index) throws java.io.IOException {
+ if (this.documentTables != null) {
+ int length = this.documentTables.length;
+ if (length == 1 && this.documentNames == null) { // have a single table
+ Object offset = this.documentTables[0].get(word);
+ int[] numbers = index.diskIndex.readDocumentNumbers(offset);
+ String[] names = new String[numbers.length];
+ for (int i = 0, l = numbers.length; i < l; i++)
+ names[i] = index.diskIndex.readDocumentName(numbers[i]);
+ return names;
+ }
+
+ for (int i = 0; i < length; i++) {
+ Object offset = this.documentTables[i].get(word);
+ int[] numbers = index.diskIndex.readDocumentNumbers(offset);
+ for (int j = 0, k = numbers.length; j < k; j++)
+ addDocumentName(index.diskIndex.readDocumentName(numbers[j]));
+ }
+ }
+
+ if (this.documentNames == null)
+ return new String[0];
+
+ String[] names = new String[this.documentNames.elementSize];
+ int count = 0;
+ Object[] values = this.documentNames.values;
+ for (int i = 0, l = values.length; i < l; i++)
+ if (values[i] != null)
+ names[count++] = (String) values[i];
+ return names;
+}
+public boolean isEmpty() {
+ return this.documentTables == null && this.documentNames == null;
+}
+}
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/Index.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/Index.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/Index.java 2007-04-06 14:22:22 UTC (rev 2291)
@@ -0,0 +1,196 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.core.index;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.rubypeople.rdt.core.search.SearchPattern;
+import org.rubypeople.rdt.internal.compiler.util.HashtableOfObject;
+import org.rubypeople.rdt.internal.compiler.util.SimpleSet;
+import org.rubypeople.rdt.internal.core.search.indexing.ReadWriteMonitor;
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+
+/**
+ * An <code>Index</code> maps document names to their referenced words in various categories.
+ *
+ * Queries can search a single category or several at the same time.
+ *
+ * Indexes are not synchronized structures and should only be queried/updated one at a time.
+ */
+
+public class Index {
+
+public String containerPath;
+public ReadWriteMonitor monitor;
+
+protected DiskIndex diskIndex;
+protected MemoryIndex memoryIndex;
+
+/**
+ * Mask used on match rule for indexing.
+ */
+static final int MATCH_RULE_INDEX_MASK =
+ SearchPattern.R_EXACT_MATCH |
+ SearchPattern.R_PREFIX_MATCH |
+ SearchPattern.R_PATTERN_MATCH |
+ SearchPattern.R_REGEXP_MATCH |
+ SearchPattern.R_CASE_SENSITIVE |
+ SearchPattern.R_CAMELCASE_MATCH;
+
+public static boolean isMatch(char[] pattern, char[] word, int matchRule) {
+ if (pattern == null) return true;
+ int patternLength = pattern.length;
+ int wordLength = word.length;
+ if (patternLength == 0) return matchRule != SearchPattern.R_EXACT_MATCH;
+ if (wordLength == 0) return (matchRule & SearchPattern.R_PATTERN_MATCH) != 0 && patternLength == 1 && pattern[0] == '*';
+
+ // First test camel case if necessary
+ boolean isCamelCase = (matchRule & SearchPattern.R_CAMELCASE_MATCH) != 0;
+ if (isCamelCase && pattern[0] == word[0] && CharOperation.camelCaseMatch(pattern, word)) {
+ return true;
+ }
+
+ // need to mask some bits of pattern rule (bug 79790)
+ matchRule &= ~SearchPattern.R_CAMELCASE_MATCH;
+ switch(matchRule & MATCH_RULE_INDEX_MASK) {
+ case SearchPattern.R_EXACT_MATCH :
+ if (!isCamelCase) {
+ return patternLength == wordLength && CharOperation.equals(pattern, word, false);
+ }
+ // fall through prefix match if camel case failed
+ case SearchPattern.R_PREFIX_MATCH :
+ return patternLength <= wordLength && CharOperation.prefixEquals(pattern, word, false);
+ case SearchPattern.R_PATTERN_MATCH :
+ return CharOperation.match(pattern, word, false);
+ case SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE :
+ if (!isCamelCase) {
+ return pattern[0] == word[0] && patternLength == wordLength && CharOperation.equals(pattern, word);
+ }
+ // fall through prefix match if camel case failed
+ case SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CASE_SENSITIVE :
+ return pattern[0] == word[0] && patternLength <= wordLength && CharOperation.prefixEquals(pattern, word);
+ case SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE :
+ return CharOperation.match(pattern, word, true);
+ }
+ return false;
+}
+
+
+public Index(String fileName, String containerPath, boolean reuseExistingFile) throws IOException {
+ this.containerPath = containerPath;
+ this.monitor = new ReadWriteMonitor();
+
+ this.memoryIndex = new MemoryIndex();
+ this.diskIndex = new DiskIndex(fileName);
+ this.diskIndex.initialize(reuseExistingFile);
+}
+public void addIndexEntry(char[] category, char[] key, String containerRelativePath) {
+ this.memoryIndex.addIndexEntry(category, key, containerRelativePath);
+}
+public String containerRelativePath(String documentPath) {
+// int index = documentPath.indexOf(IRubySearchScope.JAR_FILE_ENTRY_SEPARATOR); FIXME What do we do here since we don't have jars?
+ int index = -1;
+ if (index == -1) {
+ index = this.containerPath.length();
+ if (documentPath.length() <= index)
+ throw new IllegalArgumentException("Document path " + documentPath + " must be relative to " + this.containerPath); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return documentPath.substring(index + 1);
+}
+public File getIndexFile() {
+ if (this.diskIndex == null) return null;
+
+ return this.diskIndex.getIndexFile();
+}
+public boolean hasChanged() {
+ return this.memoryIndex.hasChanged();
+}
+/**
+ * Returns the entries containing the given key in a group of categories, or null if no matches are found.
+ * The matchRule dictates whether its an exact, prefix or pattern match, as well as case sensitive or insensitive.
+ * If the key is null then all entries in specified categories are returned.
+ */
+public EntryResult[] query(char[][] categories, char[] key, int matchRule) throws IOException {
+ if (this.memoryIndex.shouldMerge() && monitor.exitReadEnterWrite()) {
+ try {
+ save();
+ } finally {
+ monitor.exitWriteEnterRead();
+ }
+ }
+
+ HashtableOfObject results;
+ int rule = matchRule & MATCH_RULE_INDEX_MASK;
+ if (this.memoryIndex.hasChanged()) {
+ results = this.diskIndex.addQueryResults(categories, key, rule, this.memoryIndex);
+ results = this.memoryIndex.addQueryResults(categories, key, rule, results);
+ } else {
+ results = this.diskIndex.addQueryResults(categories, key, rule, null);
+ }
+ if (results == null) return null;
+
+ EntryResult[] entryResults = new EntryResult[results.elementSize];
+ int count = 0;
+ Object[] values = results.valueTable;
+ for (int i = 0, l = values.length; i < l; i++) {
+ EntryResult result = (EntryResult) values[i];
+ if (result != null)
+ entryResults[count++] = result;
+ }
+ return entryResults;
+}
+/**
+ * Returns the document names that contain the given substring, if null then returns all of them.
+ */
+public String[] queryDocumentNames(String substring) throws IOException {
+ SimpleSet results;
+ if (this.memoryIndex.hasChanged()) {
+ results = this.diskIndex.addDocumentNames(substring, this.memoryIndex);
+ this.memoryIndex.addDocumentNames(substring, results);
+ } else {
+ results = this.diskIndex.addDocumentNames(substring, null);
+ }
+ if (results.elementSize == 0) return null;
+
+ String[] documentNames = new String[results.elementSize];
+ int count = 0;
+ Object[] paths = results.values;
+ for (int i = 0, l = paths.length; i < l; i++)
+ if (paths[i] != null)
+ documentNames[count++] = (String) paths[i];
+ return documentNames;
+}
+public void remove(String containerRelativePath) {
+ this.memoryIndex.remove(containerRelativePath);
+}
+public void save() throws IOException {
+ // must own the write lock of the monitor
+ if (!hasChanged()) return;
+
+ int numberOfChanges = this.memoryIndex.docsToReferences.elementSize;
+ this.diskIndex = this.diskIndex.mergeWith(this.memoryIndex);
+ this.memoryIndex = new ...
[truncated message content] |
|
From: <caw...@us...> - 2007-04-06 14:06:14
|
Revision: 2290
http://svn.sourceforge.net/rubyeclipse/?rev=2290&view=rev
Author: cawilliams
Date: 2007-04-06 07:06:13 -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/SearchDocument.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/indexing/IndexManager.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexManager.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:02:49 UTC (rev 2289)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-04-06 14:06:13 UTC (rev 2290)
@@ -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.IndexManager;
+import org.rubypeople.rdt.internal.core.search.indexing.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;
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:02:49 UTC (rev 2289)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-04-06 14:06:13 UTC (rev 2290)
@@ -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.IndexManager;
+import org.rubypeople.rdt.internal.core.search.indexing.IndexManager;
import org.rubypeople.rdt.internal.core.util.ASTUtil;
import org.rubypeople.rdt.internal.ti.DefaultTypeInferrer;
import org.rubypeople.rdt.internal.ti.ITypeGuess;
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:02:49 UTC (rev 2289)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java 2007-04-06 14:06:13 UTC (rev 2290)
@@ -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.IndexManager;
+import org.rubypeople.rdt.internal.core.search.indexing.IndexManager;
import org.rubypeople.rdt.internal.core.util.Util;
public class RubyElementRequestor {
Deleted: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexManager.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexManager.java 2007-04-06 14:02:49 UTC (rev 2289)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexManager.java 2007-04-06 14:06:13 UTC (rev 2290)
@@ -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 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/SearchDocument.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/SearchDocument.java 2007-04-06 14:02:49 UTC (rev 2289)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/SearchDocument.java 2007-04-06 14:06:13 UTC (rev 2290)
@@ -21,7 +21,7 @@
private IPath path;
private IRubyScript script;
- SearchDocument(IPath path) {
+ public SearchDocument(IPath path) {
this.path = path;
}
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:02:49 UTC (rev 2289)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexAllJob.java 2007-04-06 14:06:13 UTC (rev 2290)
@@ -10,7 +10,6 @@
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.IndexManager;
public class IndexAllJob extends Job {
private IndexManager index;
Copied: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java (from rev 2289, trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexManager.java)
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java 2007-04-06 14:06:13 UTC (rev 2290)
@@ -0,0 +1,146 @@
+package org.rubypeople.rdt.internal.core.search.indexing;
+
+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.SearchDocument;
+
+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());
+ }
+
+ 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();
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|
|
From: <caw...@us...> - 2007-04-06 14:00:42
|
Revision: 2288
http://svn.sourceforge.net/rubyeclipse/?rev=2288&view=rev
Author: cawilliams
Date: 2007-04-06 07:00:40 -0700 (Fri, 06 Apr 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/ExperimentalIndex.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexAllJob.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexAllJob.java
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-04-06 13:59:15 UTC (rev 2287)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/ExperimentalIndex.java 2007-04-06 14:00:40 UTC (rev 2288)
@@ -17,6 +17,7 @@
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 {
@@ -117,7 +118,7 @@
documents.remove(element.getPath());
}
- void addElement(IRubyElement element) {
+ public void addElement(IRubyElement element) {
if ((element.isType(IRubyElement.RUBY_MODEL)) ||
(element.isType(IRubyElement.RUBY_PROJECT)) ||
(element.isType(IRubyElement.SCRIPT)) ||
Deleted: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexAllJob.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexAllJob.java 2007-04-06 13:59:15 UTC (rev 2287)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexAllJob.java 2007-04-06 14:00:40 UTC (rev 2288)
@@ -1,49 +0,0 @@
-package org.rubypeople.rdt.internal.core.search;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.rubypeople.rdt.core.IParent;
-import org.rubypeople.rdt.core.IRubyElement;
-import org.rubypeople.rdt.core.IRubyModel;
-import org.rubypeople.rdt.core.RubyCore;
-import org.rubypeople.rdt.core.RubyModelException;
-import org.rubypeople.rdt.internal.core.RubyModelManager;
-
-class IndexAllJob extends Job {
- private ExperimentalIndex index;
-
- public IndexAllJob(ExperimentalIndex index) {
- super("Search Index Job");
- this.index = index;
- }
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- // TODO Load up saved data if there is any, rather than starting
- // over
- // TODO Clear saved state if user cleans a project
- // TODO Save state after a run
- IRubyModel model = RubyModelManager.getRubyModelManager().getRubyModel();
- addChildren(model);
- return Status.OK_STATUS;
- }
-
- private void addChildren(IParent parent) {
- try {
- IRubyElement[] children = parent.getChildren();
- for (int i = 0; i < children.length; i++) {
- index.addElement(children[i]);
- if (children[i] instanceof IParent) {
- IParent newParent = (IParent) children[i];
- addChildren(newParent);
- }
- }
- } catch (RubyModelException e) {
- RubyCore.log(e);
- }
- }
-
- }
-
Copied: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexAllJob.java (from rev 2287, trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexAllJob.java)
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexAllJob.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexAllJob.java 2007-04-06 14:00:40 UTC (rev 2288)
@@ -0,0 +1,50 @@
+package org.rubypeople.rdt.internal.core.search.indexing;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.rubypeople.rdt.core.IParent;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyModel;
+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;
+
+public class IndexAllJob extends Job {
+ private ExperimentalIndex index;
+
+ public IndexAllJob(ExperimentalIndex index) {
+ super("Search Index Job");
+ this.index = index;
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ // TODO Load up saved data if there is any, rather than starting
+ // over
+ // TODO Clear saved state if user cleans a project
+ // TODO Save state after a run
+ IRubyModel model = RubyModelManager.getRubyModelManager().getRubyModel();
+ addChildren(model);
+ return Status.OK_STATUS;
+ }
+
+ private void addChildren(IParent parent) {
+ try {
+ IRubyElement[] children = parent.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ index.addElement(children[i]);
+ if (children[i] instanceof IParent) {
+ IParent newParent = (IParent) children[i];
+ addChildren(newParent);
+ }
+ }
+ } catch (RubyModelException e) {
+ RubyCore.log(e);
+ }
+ }
+
+ }
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-06 13:59:26
|
Revision: 2287
http://svn.sourceforge.net/rubyeclipse/?rev=2287&view=rev
Author: cawilliams
Date: 2007-04-06 06:59:15 -0700 (Fri, 06 Apr 2007)
Log Message:
-----------
start refactoring code for existing search / index functionality until we can get closer to architecture used by JDT...
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/ExperimentalIndex.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexAllJob.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/SearchDocument.java
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-04-06 13:51:46 UTC (rev 2286)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/ExperimentalIndex.java 2007-04-06 13:59:15 UTC (rev 2287)
@@ -1,38 +1,27 @@
package org.rubypeople.rdt.internal.core.search;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.rubypeople.rdt.core.ElementChangedEvent;
import org.rubypeople.rdt.core.IElementChangedListener;
-import org.rubypeople.rdt.core.IParent;
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyElementDelta;
-import org.rubypeople.rdt.core.IRubyModel;
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.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
-import org.rubypeople.rdt.internal.core.Openable;
-import org.rubypeople.rdt.internal.core.RubyModelManager;
public class ExperimentalIndex implements IElementChangedListener {
private static ExperimentalIndex fgInstance;
private static Map<IPath, SearchDocument> documents;
- private static HandleFactory factory = new HandleFactory();
private ExperimentalIndex() {
documents = new HashMap<IPath, SearchDocument>();
@@ -150,145 +139,7 @@
}
public static void start() {
- Job job = new ExperimentalIndexJob(instance());
+ Job job = new IndexAllJob(instance());
job.schedule();
}
-
- private static class ExperimentalIndexJob extends Job {
- private ExperimentalIndex index;
-
- public ExperimentalIndexJob(ExperimentalIndex index) {
- super("Search Index Job");
- this.index = index;
- }
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- // TODO Load up saved data if there is any, rather than starting
- // over
- // TODO Clear saved state if user cleans a project
- // TODO Save state after a run
- IRubyModel model = RubyModelManager.getRubyModelManager().getRubyModel();
- addChildren(model);
- return Status.OK_STATUS;
- }
-
- private void addChildren(IParent parent) {
- try {
- IRubyElement[] children = parent.getChildren();
- for (int i = 0; i < children.length; i++) {
- index.addElement(children[i]);
- if (children[i] instanceof IParent) {
- IParent newParent = (IParent) children[i];
- addChildren(newParent);
- }
- }
- } catch (RubyModelException e) {
- RubyCore.log(e);
- }
- }
-
- }
-
- private class SearchDocument {
- private static final String SEPARATOR = "/";
- private List<String> indices = new ArrayList<String>();
- private IPath path;
- private IRubyScript script;
-
- 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]);
- }
- }
}
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexAllJob.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexAllJob.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexAllJob.java 2007-04-06 13:59:15 UTC (rev 2287)
@@ -0,0 +1,49 @@
+package org.rubypeople.rdt.internal.core.search;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.rubypeople.rdt.core.IParent;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyModel;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.internal.core.RubyModelManager;
+
+class IndexAllJob extends Job {
+ private ExperimentalIndex index;
+
+ public IndexAllJob(ExperimentalIndex index) {
+ super("Search Index Job");
+ this.index = index;
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ // TODO Load up saved data if there is any, rather than starting
+ // over
+ // TODO Clear saved state if user cleans a project
+ // TODO Save state after a run
+ IRubyModel model = RubyModelManager.getRubyModelManager().getRubyModel();
+ addChildren(model);
+ return Status.OK_STATUS;
+ }
+
+ private void addChildren(IParent parent) {
+ try {
+ IRubyElement[] children = parent.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ index.addElement(children[i]);
+ if (children[i] instanceof IParent) {
+ IParent newParent = (IParent) children[i];
+ addChildren(newParent);
+ }
+ }
+ } catch (RubyModelException e) {
+ RubyCore.log(e);
+ }
+ }
+
+ }
+
Added: 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 (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/SearchDocument.java 2007-04-06 13:59:15 UTC (rev 2287)
@@ -0,0 +1,118 @@
+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;
+
+ 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]);
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-06 13:51:49
|
Revision: 2286
http://svn.sourceforge.net/rubyeclipse/?rev=2286&view=rev
Author: cawilliams
Date: 2007-04-06 06:51:46 -0700 (Fri, 06 Apr 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/Util.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Messages.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/messages.properties
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/ReadWriteMonitor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/processing/JobManager.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/Util.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/Util.java 2007-04-05 18:03:13 UTC (rev 2285)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/Util.java 2007-04-06 13:51:46 UTC (rev 2286)
@@ -4,7 +4,11 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+
public class Util {
public interface Displayable {
@@ -115,4 +119,91 @@
});
}
+ /**
+ * Returns the contents of the given file as a char array.
+ * When encoding is null, then the platform default one is used
+ * @throws IOException if a problem occured reading the file.
+ */
+ public static char[] getFileCharContent(File file, String encoding) throws IOException {
+ InputStream stream = null;
+ try {
+ stream = new FileInputStream(file);
+ return getInputStreamAsCharArray(stream, (int) file.length(), encoding);
+ } finally {
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the given input stream's contents as a character array.
+ * If a length is specified (ie. if length != -1), this represents the number of bytes in the stream.
+ * Note this doesn't close the stream.
+ * @throws IOException if a problem occured reading the stream.
+ */
+ public static char[] getInputStreamAsCharArray(InputStream stream, int length, String encoding)
+ throws IOException {
+ InputStreamReader reader = null;
+ try {
+ reader = encoding == null
+ ? new InputStreamReader(stream)
+ : new InputStreamReader(stream, encoding);
+ } catch (UnsupportedEncodingException e) {
+ // encoding is not supported
+ reader = new InputStreamReader(stream);
+ }
+ char[] contents;
+ int totalRead = 0;
+ if (length == -1) {
+ contents = CharOperation.NO_CHAR;
+ } else {
+ // length is a good guess when the encoding produces less or the same amount of characters than the file length
+ contents = new char[length]; // best guess
+ }
+
+ while (true) {
+ int amountRequested;
+ if (totalRead < length) {
+ // until known length is met, reuse same array sized eagerly
+ amountRequested = length - totalRead;
+ } else {
+ // reading beyond known length
+ int current = reader.read();
+ if (current < 0) break;
+
+ amountRequested = Math.max(stream.available(), DEFAULT_READING_SIZE); // read at least 8K
+
+ // resize contents if needed
+ if (totalRead + 1 + amountRequested > contents.length)
+ System.arraycopy(contents, 0, contents = new char[totalRead + 1 + amountRequested], 0, totalRead);
+
+ // add current character
+ contents[totalRead++] = (char) current; // coming from totalRead==length
+ }
+ // read as many chars as possible
+ int amountRead = reader.read(contents, totalRead, amountRequested);
+ if (amountRead < 0) break;
+ totalRead += amountRead;
+ }
+
+ // Do not keep first character for UTF-8 BOM encoding
+ int start = 0;
+ if (totalRead > 0 && UTF_8.equals(encoding)) {
+ if (contents[0] == 0xFEFF) { // if BOM char then skip
+ totalRead--;
+ start = 1;
+ }
+ }
+
+ // resize contents if necessary
+ if (totalRead < contents.length)
+ System.arraycopy(contents, start, contents = new char[totalRead], 0, totalRead);
+
+ return contents;
+ }
}
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/ReadWriteMonitor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/ReadWriteMonitor.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/ReadWriteMonitor.java 2007-04-06 13:51:46 UTC (rev 2286)
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.core.search.indexing;
+
+/**
+ * Monitor ensuring no more than one writer working concurrently.
+ * Multiple readers are allowed to perform simultaneously.
+ */
+public class ReadWriteMonitor {
+
+/**
+ * <0 : writing (cannot go beyond -1, i.e one concurrent writer)
+ * =0 : idle
+ * >0 : reading (number of concurrent readers)
+ */
+private int status = 0;
+/**
+ * Concurrent reading is allowed
+ * Blocking only when already writing.
+ */
+public synchronized void enterRead() {
+ while (status < 0) {
+ try {
+ wait();
+ } catch(InterruptedException e) {
+ // ignore
+ }
+ }
+ status++;
+}
+/**
+ * Only one writer at a time is allowed to perform
+ * Blocking only when already writing or reading.
+ */
+public synchronized void enterWrite() {
+ while (status != 0) {
+ try {
+ wait();
+ } catch(InterruptedException e) {
+ // ignore
+ }
+ }
+ status--;
+}
+/**
+ * Only notify waiting writer(s) if last reader
+ */
+public synchronized void exitRead() {
+
+ if (--status == 0) notifyAll();
+}
+/**
+ * When writing is over, all readers and possible
+ * writers are granted permission to restart concurrently
+ */
+public synchronized void exitWrite() {
+
+ if (++status == 0) notifyAll();
+}
+/**
+ * Atomic exitRead/enterWrite: Allows to keep monitor in between
+ * exit read and next enter write.
+ * Use when writing changes is optional, otherwise call the individual methods.
+ * Returns false if multiple readers are accessing the index.
+ */
+public synchronized boolean exitReadEnterWrite() {
+ if (status != 1) return false; // only continue if this is the only reader
+
+ status = -1;
+ return true;
+}
+/**
+ * Atomic exitWrite/enterRead: Allows to keep monitor in between
+ * exit write and next enter read.
+ * When writing is over, all readers are granted permissing to restart
+ * concurrently.
+ * This is the same as:
+ * <pre>
+ * synchronized(monitor) {
+ * monitor.exitWrite();
+ * monitor.enterRead();
+ * }
+ * </pre>
+ */
+public synchronized void exitWriteEnterRead() {
+ this.exitWrite();
+ this.enterRead();
+}
+public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ if (status == 0) {
+ buffer.append("Monitor idle "); //$NON-NLS-1$
+ } else if (status < 0) {
+ buffer.append("Monitor writing "); //$NON-NLS-1$
+ } else if (status > 0) {
+ buffer.append("Monitor reading "); //$NON-NLS-1$
+ }
+ buffer.append("(status = "); //$NON-NLS-1$
+ buffer.append(this.status);
+ buffer.append(")"); //$NON-NLS-1$
+ return buffer.toString();
+}
+}
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/processing/JobManager.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/processing/JobManager.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/processing/JobManager.java 2007-04-06 13:51:46 UTC (rev 2286)
@@ -0,0 +1,449 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.core.search.processing;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.jobs.Job;
+import org.rubypeople.rdt.internal.core.util.Messages;
+import org.rubypeople.rdt.internal.core.util.Util;
+
+public abstract class JobManager implements Runnable {
+
+ /* queue of jobs to execute */
+ protected IJob[] awaitingJobs = new IJob[10];
+ protected int jobStart = 0;
+ protected int jobEnd = -1;
+ protected boolean executing = false;
+
+ /* background processing */
+ protected Thread processingThread;
+ protected Job progressJob;
+
+ /* counter indicating whether job execution is enabled or not, disabled if <= 0
+ it cannot go beyond 1 */
+ private int enableCount = 1;
+
+ public static boolean VERBOSE = false;
+ /* flag indicating that the activation has completed */
+ public boolean activated = false;
+
+ private int awaitingClients = 0;
+
+ /**
+ * Invoked exactly once, in background, before starting processing any job
+ */
+ public void activateProcessing() {
+ this.activated = true;
+ }
+ /**
+ * Answer the amount of awaiting jobs.
+ */
+ public synchronized int awaitingJobsCount() {
+ // pretend busy in case concurrent job attempts performing before activated
+ return this.activated ? this.jobEnd - this.jobStart + 1 : 1;
+ }
+ /**
+ * Answers the first job in the queue, or null if there is no job available
+ * Until the job has completed, the job manager will keep answering the same job.
+ */
+ public synchronized IJob currentJob() {
+ if (this.enableCount > 0 && this.jobStart <= this.jobEnd)
+ return this.awaitingJobs[this.jobStart];
+ return null;
+ }
+ public void disable() {
+ this.enableCount--;
+ if (VERBOSE)
+ Util.verbose("DISABLING background indexing"); //$NON-NLS-1$
+ }
+ /**
+ * Remove the index from cache for a given project.
+ * Passing null as a job family discards them all.
+ */
+ public void discardJobs(String jobFamily) {
+
+ if (VERBOSE)
+ Util.verbose("DISCARD background job family - " + jobFamily); //$NON-NLS-1$
+
+ try {
+ IJob currentJob;
+ // cancel current job if it belongs to the given family
+ synchronized(this){
+ currentJob = this.currentJob();
+ disable();
+ }
+ if (currentJob != null && (jobFamily == null || currentJob.belongsTo(jobFamily))) {
+ currentJob.cancel();
+
+ // wait until current active job has finished
+ while (this.processingThread != null && this.executing){
+ try {
+ if (VERBOSE)
+ Util.verbose("-> waiting end of current background job - " + currentJob); //$NON-NLS-1$
+ Thread.sleep(50);
+ } catch(InterruptedException e){
+ // ignore
+ }
+ }
+ }
+
+ // flush and compact awaiting jobs
+ int loc = -1;
+ synchronized(this) {
+ for (int i = this.jobStart; i <= this.jobEnd; i++) {
+ currentJob = this.awaitingJobs[i];
+ if (currentJob != null) { // sanity check
+ this.awaitingJobs[i] = null;
+ if (!(jobFamily == null || currentJob.belongsTo(jobFamily))) { // copy down, compacting
+ this.awaitingJobs[++loc] = currentJob;
+ } else {
+ if (VERBOSE)
+ Util.verbose("-> discarding background job - " + currentJob); //$NON-NLS-1$
+ currentJob.cancel();
+ }
+ }
+ }
+ this.jobStart = 0;
+ this.jobEnd = loc;
+ }
+ } finally {
+ enable();
+ }
+ if (VERBOSE)
+ Util.verbose("DISCARD DONE with background job family - " + jobFamily); //$NON-NLS-1$
+ }
+ public synchronized void enable() {
+ this.enableCount++;
+ if (VERBOSE)
+ Util.verbose("ENABLING background indexing"); //$NON-NLS-1$
+ this.notifyAll(); // wake up the background thread if it is waiting (context must be synchronized)
+ }
+ protected synchronized boolean isJobWaiting(IJob request) {
+ for (int i = this.jobEnd; i > this.jobStart; i--) // don't check job at jobStart, as it may have already started
+ if (request.equals(this.awaitingJobs[i])) return true;
+ return false;
+ }
+ /**
+ * Advance to the next available job, once the current one has been completed.
+ * Note: clients awaiting until the job count is zero are still waiting at this point.
+ */
+ protected synchronized void moveToNextJob() {
+ //if (!enabled) return;
+
+ if (this.jobStart <= this.jobEnd) {
+ this.awaitingJobs[this.jobStart++] = null;
+ if (this.jobStart > this.jobEnd) {
+ this.jobStart = 0;
+ this.jobEnd = -1;
+ }
+ }
+ }
+ /**
+ * When idle, give chance to do something
+ */
+ protected void notifyIdle(long idlingTime) {
+ // do nothing
+ }
+ /**
+ * This API is allowing to run one job in concurrence with background processing.
+ * Indeed since other jobs are performed in background, resource sharing might be
+ * an issue.Therefore, this functionality allows a given job to be run without
+ * colliding with background ones.
+ * Note: multiple thread might attempt to perform concurrent jobs at the same time,
+ * and should synchronize (it is deliberately left to clients to decide whether
+ * concurrent jobs might interfere or not. In general, multiple read jobs are ok).
+ *
+ * Waiting policy can be:
+ * IJobConstants.ForceImmediateSearch
+ * IJobConstants.CancelIfNotReadyToSearch
+ * IJobConstants.WaitUntilReadyToSearch
+ *
+ */
+ public boolean performConcurrentJob(IJob searchJob, int waitingPolicy, IProgressMonitor progress) {
+ if (VERBOSE)
+ Util.verbose("STARTING concurrent job - " + searchJob); //$NON-NLS-1$
+
+ searchJob.ensureReadyToRun();
+
+ int concurrentJobWork = 100;
+ if (progress != null)
+ progress.beginTask("", concurrentJobWork); //$NON-NLS-1$
+ boolean status = IJob.FAILED;
+ if (awaitingJobsCount() > 0) {
+ switch (waitingPolicy) {
+
+ case IJob.ForceImmediate :
+ if (VERBOSE)
+ Util.verbose("-> NOT READY - forcing immediate - " + searchJob);//$NON-NLS-1$
+ try {
+ disable(); // pause indexing
+ status = searchJob.execute(progress == null ? null : new SubProgressMonitor(progress, concurrentJobWork));
+ } finally {
+ enable();
+ }
+ if (VERBOSE)
+ Util.verbose("FINISHED concurrent job - " + searchJob); //$NON-NLS-1$
+ return status;
+
+ case IJob.CancelIfNotReady :
+ if (VERBOSE)
+ Util.verbose("-> NOT READY - cancelling - " + searchJob); //$NON-NLS-1$
+ if (VERBOSE)
+ Util.verbose("CANCELED concurrent job - " + searchJob); //$NON-NLS-1$
+ throw new OperationCanceledException();
+
+ case IJob.WaitUntilReady :
+ int awaitingWork;
+ IJob previousJob = null;
+ IJob currentJob;
+ IProgressMonitor subProgress = null;
+ int totalWork = this.awaitingJobsCount();
+ if (progress != null && totalWork > 0) {
+ subProgress = new SubProgressMonitor(progress, concurrentJobWork / 2);
+ subProgress.beginTask("", totalWork); //$NON-NLS-1$
+ concurrentJobWork = concurrentJobWork / 2;
+ }
+ // use local variable to avoid potential NPE (see bug 20435 NPE when searching java method
+ // and bug 42760 NullPointerException in JobManager when searching)
+ Thread t = this.processingThread;
+ int originalPriority = t == null ? -1 : t.getPriority();
+ try {
+ if (t != null)
+ t.setPriority(Thread.currentThread().getPriority());
+ synchronized(this) {
+ this.awaitingClients++;
+ }
+ while ((awaitingWork = awaitingJobsCount()) > 0) {
+ if (subProgress != null && subProgress.isCanceled())
+ throw new OperationCanceledException();
+ currentJob = currentJob();
+ // currentJob can be null when jobs have been added to the queue but job manager is not enabled
+ if (currentJob != null && currentJob != previousJob) {
+ if (VERBOSE)
+ Util.verbose("-> NOT READY - waiting until ready - " + searchJob);//$NON-NLS-1$
+ if (subProgress != null) {
+ subProgress.subTask(
+ Messages.bind(Messages.manager_filesToIndex, Integer.toString(awaitingWork)));
+ subProgress.worked(1);
+ }
+ previousJob = currentJob;
+ }
+ try {
+ if (VERBOSE)
+ Util.verbose("-> GOING TO SLEEP - " + searchJob);//$NON-NLS-1$
+ Thread.sleep(50);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ }
+ } finally {
+ synchronized(this) {
+ this.awaitingClients--;
+ }
+ if (t != null && originalPriority > -1 && t.isAlive())
+ t.setPriority(originalPriority);
+ }
+ if (subProgress != null)
+ subProgress.done();
+ }
+ }
+ status = searchJob.execute(progress == null ? null : new SubProgressMonitor(progress, concurrentJobWork));
+ if (progress != null)
+ progress.done();
+ if (VERBOSE)
+ Util.verbose("FINISHED concurrent job - " + searchJob); //$NON-NLS-1$
+ return status;
+ }
+ public abstract String processName();
+
+ public synchronized void request(IJob job) {
+
+ job.ensureReadyToRun();
+
+ // append the job to the list of ones to process later on
+ int size = this.awaitingJobs.length;
+ if (++this.jobEnd == size) { // when growing, relocate jobs starting at position 0
+ this.jobEnd -= this.jobStart;
+ System.arraycopy(this.awaitingJobs, this.jobStart, this.awaitingJobs = new IJob[size * 2], 0, this.jobEnd);
+ this.jobStart = 0;
+ }
+ this.awaitingJobs[this.jobEnd] = job;
+ if (VERBOSE) {
+ Util.verbose("REQUEST background job - " + job); //$NON-NLS-1$
+ Util.verbose("AWAITING JOBS count: " + awaitingJobsCount()); //$NON-NLS-1$
+ }
+ notifyAll(); // wake up the background thread if it is waiting
+ }
+ /**
+ * Flush current state
+ */
+ public synchronized void reset() {
+ if (VERBOSE)
+ Util.verbose("Reset"); //$NON-NLS-1$
+
+ if (this.processingThread != null) {
+ discardJobs(null); // discard all jobs
+ } else {
+ /* initiate background processing */
+ this.processingThread = new Thread(this, this.processName());
+ this.processingThread.setDaemon(true);
+ // less prioritary by default, priority is raised if clients are actively waiting on it
+ this.processingThread.setPriority(Thread.NORM_PRIORITY-1);
+ this.processingThread.start();
+ }
+ }
+ /**
+ * Infinite loop performing resource indexing
+ */
+ public void run() {
+
+ long idlingStart = -1;
+ activateProcessing();
+ try {
+ class ProgressJob extends Job {
+ ProgressJob(String name) {
+ super(name);
+ }
+ protected IStatus run(IProgressMonitor monitor) {
+ int awaitingJobsCount;
+ while (!monitor.isCanceled() && (awaitingJobsCount = awaitingJobsCount()) > 0) {
+ monitor.subTask(Messages.bind(Messages.manager_filesToIndex, Integer.toString(awaitingJobsCount)));
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ }
+ return Status.OK_STATUS;
+ }
+ }
+ this.progressJob = null;
+ while (this.processingThread != null) {
+ try {
+ IJob job;
+ synchronized (this) {
+ // handle shutdown case when notifyAll came before the wait but after the while loop was entered
+ if (this.processingThread == null) continue;
+
+ // must check for new job inside this sync block to avoid timing hole
+ if ((job = currentJob()) == null) {
+ if (this.progressJob != null) {
+ this.progressJob.cancel();
+ this.progressJob = null;
+ }
+ if (idlingStart < 0)
+ idlingStart = System.currentTimeMillis();
+ else
+ notifyIdle(System.currentTimeMillis() - idlingStart);
+ this.wait(); // wait until a new job is posted (or reenabled:38901)
+ } else {
+ idlingStart = -1;
+ }
+ }
+ if (job == null) {
+ notifyIdle(System.currentTimeMillis() - idlingStart);
+ // just woke up, delay before processing any new jobs, allow some time for the active thread to finish
+ Thread.sleep(500);
+ continue;
+ }
+ if (VERBOSE) {
+ Util.verbose(awaitingJobsCount() + " awaiting jobs"); //$NON-NLS-1$
+ Util.verbose("STARTING background job - " + job); //$NON-NLS-1$
+ }
+ try {
+ this.executing = true;
+ if (this.progressJob == null) {
+ this.progressJob = new ProgressJob(Messages.manager_indexingInProgress);
+ this.progressJob.setPriority(Job.LONG);
+ this.progressJob.setSystem(true);
+ this.progressJob.schedule();
+ }
+ /*boolean status = */job.execute(null);
+ //if (status == FAILED) request(job);
+ } finally {
+ this.executing = false;
+ if (VERBOSE)
+ Util.verbose("FINISHED background job - " + job); //$NON-NLS-1$
+ moveToNextJob();
+ if (this.awaitingClients == 0)
+ Thread.sleep(50);
+ }
+ } catch (InterruptedException e) { // background indexing was interrupted
+ }
+ }
+ } catch (RuntimeException e) {
+ if (this.processingThread != null) { // if not shutting down
+ // log exception
+ Util.log(e, "Background Indexer Crash Recovery"); //$NON-NLS-1$
+
+ // keep job manager alive
+ this.discardJobs(null);
+ this.processingThread = null;
+ this.reset(); // this will fork a new thread with no waiting jobs, some indexes will be inconsistent
+ }
+ throw e;
+ } catch (Error e) {
+ if (this.processingThread != null && !(e instanceof ThreadDeath)) {
+ // log exception
+ Util.log(e, "Background Indexer Crash Recovery"); //$NON-NLS-1$
+
+ // keep job manager alive
+ this.discardJobs(null);
+ this.processingThread = null;
+ this.reset(); // this will fork a new thread with no waiting jobs, some indexes will be inconsistent
+ }
+ throw e;
+ }
+ }
+ /**
+ * Stop background processing, and wait until the current job is completed before returning
+ */
+ public void shutdown() {
+
+ if (VERBOSE)
+ Util.verbose("Shutdown"); //$NON-NLS-1$
+
+ disable();
+ discardJobs(null); // will wait until current executing job has completed
+ Thread thread = this.processingThread;
+ try {
+ if (thread != null) { // see http://bugs.eclipse.org/bugs/show_bug.cgi?id=31858
+ synchronized (this) {
+ this.processingThread = null; // mark the job manager as shutting down so that the thread will stop by itself
+ this.notifyAll(); // ensure its awake so it can be shutdown
+ }
+ // in case processing thread is handling a job
+ thread.join();
+ }
+ Job job = this.progressJob;
+ if (job != null) {
+ job.cancel();
+ job.join();
+ }
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ }
+ public String toString() {
+ StringBuffer buffer = new StringBuffer(10);
+ buffer.append("Enable count:").append(this.enableCount).append('\n'); //$NON-NLS-1$
+ int numJobs = this.jobEnd - this.jobStart + 1;
+ buffer.append("Jobs in queue:").append(numJobs).append('\n'); //$NON-NLS-1$
+ for (int i = 0; i < numJobs && i < 15; i++) {
+ buffer.append(i).append(" - job["+i+"]: ").append(this.awaitingJobs[this.jobStart+i]).append('\n'); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return buffer.toString();
+ }
+}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Messages.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Messages.java 2007-04-05 18:03:13 UTC (rev 2285)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Messages.java 2007-04-06 13:51:46 UTC (rev 2286)
@@ -154,6 +154,9 @@
public static String build_saveStateProgress;
public static String build_saveStateComplete;
public static String project_has_no_ruby_nature;
+ public static String manager_filesToIndex;
+ public static String manager_indexingInProgress;
+ public static String process_name;
static {
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/messages.properties
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/messages.properties 2007-04-05 18:03:13 UTC (rev 2285)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/messages.properties 2007-04-06 13:51:46 UTC (rev 2286)
@@ -11,7 +11,7 @@
### JavaModel messages_
-### java element
+### ruby element
element_doesNotExist = {0} does not exist
element_notOnClasspath = {0} is not on its project's build path
element_invalidClassFileName = Class file name must end with .class
@@ -22,7 +22,7 @@
element_nullType = Type cannot be null
element_illegalParent = Illegal parent argument
-### java model operations
+### ruby model operations
operation_needElements = Operation requires one or more elements
operation_needName = Operation requires a name
operation_needPath = Operation requires a path
@@ -163,3 +163,7 @@
convention_package_uppercaseName = By convention, package names usually start with a lowercase letter
project_has_no_ruby_nature = The project {0} is supposed to have a ruby nature.
+
+process_name = Ruby indexing
+manager_filesToIndex = {0} files to index
+manager_indexingInProgress = Ruby indexing in progress
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-05 18:03:27
|
Revision: 2285
http://svn.sourceforge.net/rubyeclipse/?rev=2285&view=rev
Author: cawilliams
Date: 2007-04-05 11:03:13 -0700 (Thu, 05 Apr 2007)
Log Message:
-----------
revert setting stdout and stderr to sync/auto-flush, it messes up __FILE__ global and breaks the if __FILE__ == $0 idiom
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMRunner.java
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMRunner.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMRunner.java 2007-04-05 18:02:49 UTC (rev 2284)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMRunner.java 2007-04-05 18:03:13 UTC (rev 2285)
@@ -195,13 +195,13 @@
// options like '-client' & '-server' which are required to be the first option
String[] allVMArgs = combineVmArgs(config, fVMInstance);
addArguments(allVMArgs, arguments);
- // FIXME Find a better place for this to go?
- arguments.add("-e");
- arguments.add("STDOUT.sync=true");
- arguments.add("-e");
- arguments.add("STDERR.sync=true");
- arguments.add("-e");
- arguments.add("load($0=ARGV.shift)");
+ // FIXME Find a way to set stderr and stdout to sync/auto-flush without messing up value of __FILE__ (becomes absolute which messes up the 'if __FILE__ == $0' idiom)
+// arguments.add("-e");
+// arguments.add("STDOUT.sync=true");
+// arguments.add("-e");
+// arguments.add("STDERR.sync=true");
+// arguments.add("-e");
+// arguments.add("load($0=ARGV.shift)");
String[] lp= config.getLoadPath();
if (lp.length > 0) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-05 18:03:27
|
Revision: 2284
http://svn.sourceforge.net/rubyeclipse/?rev=2284&view=rev
Author: cawilliams
Date: 2007-04-05 11:02:49 -0700 (Thu, 05 Apr 2007)
Log Message:
-----------
migrate references to deprecated constant
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_DebuggerLaunch.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyApplicationShortcut.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyEntryPointTab.java
trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyApplicationShortcut.java
trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyEntryPointTab.java
trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RunnerLaunching.java
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyTokenScanner.java
Modified: trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_DebuggerLaunch.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_DebuggerLaunch.java 2007-04-05 13:12:55 UTC (rev 2283)
+++ trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_DebuggerLaunch.java 2007-04-05 18:02:49 UTC (rev 2284)
@@ -17,6 +17,7 @@
import org.rubypeople.eclipse.testutils.ResourceTools;
import org.rubypeople.rdt.internal.debug.core.RubyLineBreakpoint;
import org.rubypeople.rdt.internal.launching.RubyLaunchConfigurationAttribute;
+import org.rubypeople.rdt.launching.IRubyLaunchConfigurationConstants;
import org.rubypeople.rdt.launching.IVMInstallType;
import org.rubypeople.rdt.launching.RubyRuntime;
import org.rubypeople.rdt.launching.VMStandin;
@@ -81,7 +82,7 @@
rubyFile.create(new ByteArrayInputStream("puts 'a'\nputs 'b'".getBytes()), true, new NullProgressMonitor()) ;
wc.setAttribute(RubyLaunchConfigurationAttribute.PROJECT_NAME, rubyFile.getProject().getName());
- wc.setAttribute(RubyLaunchConfigurationAttribute.FILE_NAME, rubyFile.getProjectRelativePath().toString());
+ wc.setAttribute(IRubyLaunchConfigurationConstants.ATTR_FILE_NAME, rubyFile.getProjectRelativePath().toString());
//wc.setAttribute(RubyLaunchConfigurationAttribute.WORKING_DIRECTORY, RubyApplicationShortcut.getDefaultWorkingDirectory(rubyFile.getProject()));
wc.setAttribute(RubyLaunchConfigurationAttribute.SELECTED_INTERPRETER, RUBY_INTERPRETER_ID);
ILaunchConfiguration lc = wc.doSave() ;
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyApplicationShortcut.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyApplicationShortcut.java 2007-04-05 13:12:55 UTC (rev 2283)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyApplicationShortcut.java 2007-04-05 18:02:49 UTC (rev 2284)
@@ -101,7 +101,7 @@
ILaunchConfiguration config = configs[i];
boolean projectsEqual = config.getAttribute(RubyLaunchConfigurationAttribute.PROJECT_NAME, "").equals(rubyFile.getProject().getName());
if (projectsEqual) {
- boolean projectRelativeFileNamesEqual = config.getAttribute(RubyLaunchConfigurationAttribute.FILE_NAME, "").equals(rubyFile.getProjectRelativePath().toString());
+ boolean projectRelativeFileNamesEqual = config.getAttribute(IRubyLaunchConfigurationConstants.ATTR_FILE_NAME, "").equals(rubyFile.getProjectRelativePath().toString());
if (projectRelativeFileNamesEqual) {
candidateConfigs.add(config);
}
@@ -129,7 +129,7 @@
ILaunchConfigurationType configType = getRubyLaunchConfigType();
ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(rubyFile.getName()));
wc.setAttribute(RubyLaunchConfigurationAttribute.PROJECT_NAME, rubyFile.getProject().getName());
- wc.setAttribute(RubyLaunchConfigurationAttribute.FILE_NAME, rubyFile.getProjectRelativePath().toString());
+ wc.setAttribute(IRubyLaunchConfigurationConstants.ATTR_FILE_NAME, rubyFile.getProjectRelativePath().toString());
wc.setAttribute(RubyLaunchConfigurationAttribute.WORKING_DIRECTORY, RubyApplicationShortcut.getDefaultWorkingDirectory(rubyFile.getProject()));
wc.setAttribute(IRubyLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, RubyRuntime.getDefaultVMInstall().getName());
wc.setAttribute(IRubyLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, RubyRuntime.getDefaultVMInstall().getVMInstallType().getId());
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyEntryPointTab.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyEntryPointTab.java 2007-04-05 13:12:55 UTC (rev 2283)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyEntryPointTab.java 2007-04-05 18:02:49 UTC (rev 2284)
@@ -24,6 +24,7 @@
import org.rubypeople.rdt.internal.ui.RubyPlugin;
import org.rubypeople.rdt.internal.ui.util.RubyFileSelector;
import org.rubypeople.rdt.internal.ui.util.RubyProjectSelector;
+import org.rubypeople.rdt.launching.IRubyLaunchConfigurationConstants;
public class RubyEntryPointTab extends AbstractLaunchConfigurationTab {
protected String originalFileName, originalProjectName;
@@ -70,13 +71,13 @@
return ;
}
configuration.setAttribute(RubyLaunchConfigurationAttribute.PROJECT_NAME, project.getName());
- configuration.setAttribute(RubyLaunchConfigurationAttribute.FILE_NAME, selectedResource.getProjectRelativePath().toString()) ;
+ configuration.setAttribute(IRubyLaunchConfigurationConstants.ATTR_FILE_NAME, selectedResource.getProjectRelativePath().toString()) ;
}
public void initializeFrom(ILaunchConfiguration configuration) {
try {
originalProjectName = configuration.getAttribute(RubyLaunchConfigurationAttribute.PROJECT_NAME, "");
- originalFileName = configuration.getAttribute(RubyLaunchConfigurationAttribute.FILE_NAME, "");
+ originalFileName = configuration.getAttribute(IRubyLaunchConfigurationConstants.ATTR_FILE_NAME, "");
} catch (CoreException e) {
log(e);
}
@@ -90,7 +91,7 @@
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute(RubyLaunchConfigurationAttribute.PROJECT_NAME, projectSelector.getSelectionText());
IFile file = fileSelector.getSelection();
- configuration.setAttribute(RubyLaunchConfigurationAttribute.FILE_NAME, file == null ? "" : file.getProjectRelativePath().toString());
+ configuration.setAttribute(IRubyLaunchConfigurationConstants.ATTR_FILE_NAME, file == null ? "" : file.getProjectRelativePath().toString());
}
protected Composite createPageRoot(Composite parent) {
@@ -116,7 +117,7 @@
return false;
}
- String fileName = launchConfig.getAttribute(RubyLaunchConfigurationAttribute.FILE_NAME, "");
+ String fileName = launchConfig.getAttribute(IRubyLaunchConfigurationConstants.ATTR_FILE_NAME, "");
if (fileName.length() == 0) {
setErrorMessage(RdtDebugUiMessages.LaunchConfigurationTab_RubyEntryPoint_invalidFileSelectionMessage);
return false;
Modified: trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyApplicationShortcut.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyApplicationShortcut.java 2007-04-05 13:12:55 UTC (rev 2283)
+++ trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyApplicationShortcut.java 2007-04-05 18:02:49 UTC (rev 2284)
@@ -25,6 +25,7 @@
import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiPlugin;
import org.rubypeople.rdt.internal.debug.ui.RubySourceLocator;
import org.rubypeople.rdt.internal.launching.RubyLaunchConfigurationAttribute;
+import org.rubypeople.rdt.launching.IRubyLaunchConfigurationConstants;
import org.rubypeople.rdt.launching.IVMInstall;
import org.rubypeople.rdt.launching.IVMInstallType;
import org.rubypeople.rdt.launching.RubyRuntime;
@@ -50,7 +51,7 @@
ILaunchConfigurationType configType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(SHAM_LAUNCH_CONFIG_TYPE);
ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, pFile.getName());
wc.setAttribute(RubyLaunchConfigurationAttribute.PROJECT_NAME, pFile.getProject().getName());
- wc.setAttribute(RubyLaunchConfigurationAttribute.FILE_NAME, pFile.getProjectRelativePath().toString());
+ wc.setAttribute(IRubyLaunchConfigurationConstants.ATTR_FILE_NAME, pFile.getProjectRelativePath().toString());
wc.setAttribute(RubyLaunchConfigurationAttribute.WORKING_DIRECTORY, "");
wc.setAttribute(RubyLaunchConfigurationAttribute.SELECTED_INTERPRETER, RubyRuntime.getCompositeIdFromVM(RubyRuntime.getDefaultVMInstall()));
wc.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "org.rubypeople.rdt.debug.ui.rubySourceLocator");
@@ -156,7 +157,7 @@
assertEquals("A launch took place.", 1, shortcut.launchCount());
assertTrue("The shortcut should not log a message when asked to launch the correct file type.", !shortcut.didLog());
- String launchedFileName = configurations[0].getAttribute(RubyLaunchConfigurationAttribute.FILE_NAME, "");
+ String launchedFileName = configurations[0].getAttribute(IRubyLaunchConfigurationConstants.ATTR_FILE_NAME, "");
assertEquals("folderOne/myFile.rb", launchedFileName);
}
@@ -180,7 +181,7 @@
assertEquals("A launch took place.", 1, shortcut.launchCount());
assertTrue("The shortcut should not log a message when asked to launch the correct file type.", !shortcut.didLog());
- String launchedFileName = configurations[0].getAttribute(RubyLaunchConfigurationAttribute.FILE_NAME, "");
+ String launchedFileName = configurations[0].getAttribute(IRubyLaunchConfigurationConstants.ATTR_FILE_NAME, "");
assertEquals("folderOne/myFile.rb", launchedFileName);
}
Modified: trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyEntryPointTab.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyEntryPointTab.java 2007-04-05 13:12:55 UTC (rev 2283)
+++ trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyEntryPointTab.java 2007-04-05 18:02:49 UTC (rev 2284)
@@ -7,6 +7,7 @@
import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiMessages;
import org.rubypeople.rdt.internal.debug.ui.launcher.RubyEntryPointTab;
import org.rubypeople.rdt.internal.launching.RubyLaunchConfigurationAttribute;
+import org.rubypeople.rdt.launching.IRubyLaunchConfigurationConstants;
public class TC_RubyEntryPointTab extends TestCase {
@@ -29,7 +30,7 @@
errorMessage = RdtDebugUiMessages.LaunchConfigurationTab_RubyEntryPoint_invalidFileSelectionMessage;
assertEquals("The tab should set the error message for no file.", errorMessage, tab.getErrorMessage());
- configuration.setAttribute(RubyLaunchConfigurationAttribute.FILE_NAME, "myFileName");
+ configuration.setAttribute(IRubyLaunchConfigurationConstants.ATTR_FILE_NAME, "myFileName");
assertTrue("The tab is valid when the configuration has a filename and projectName.", tab.isValid(configuration));
assertNull("The tab should set the error message to null when there is a filename and projectname.", tab.getErrorMessage());
}
Modified: trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RunnerLaunching.java
===================================================================
--- trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RunnerLaunching.java 2007-04-05 13:12:55 UTC (rev 2283)
+++ trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RunnerLaunching.java 2007-04-05 18:02:49 UTC (rev 2284)
@@ -174,7 +174,7 @@
public String getAttribute(String attributeName, String defaultValue) throws CoreException {
if (attributeName.equals(RubyLaunchConfigurationAttribute.PROJECT_NAME)) {
return PROJECT_NAME;
- } else if (attributeName.equals(RubyLaunchConfigurationAttribute.FILE_NAME)) {
+ } else if (attributeName.equals(IRubyLaunchConfigurationConstants.ATTR_FILE_NAME)) {
return RUBY_LIB_DIR + File.separator + RUBY_FILE_NAME;
} else if (attributeName.equals(RubyLaunchConfigurationAttribute.WORKING_DIRECTORY)) {
return '/' + PROJECT_NAME;
Modified: trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyTokenScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyTokenScanner.java 2007-04-05 13:12:55 UTC (rev 2283)
+++ trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyTokenScanner.java 2007-04-05 18:02:49 UTC (rev 2284)
@@ -228,4 +228,16 @@
assertToken(IRubyColorConstants.RUBY_SYMBOL, 6, 2); // '$$'
assertToken(IRubyColorConstants.RUBY_DEFAULT, 8, 1); // ')'
}
+
+ public void testTertiaryConditionalWithNoSpaces() {
+ String code = "puts(a?b:c)";
+ setUpScanner(code);
+ assertToken(IRubyColorConstants.RUBY_DEFAULT, 0, 4); // 'puts'
+ assertToken(IRubyColorConstants.RUBY_DEFAULT, 4, 1); // '('
+ assertToken(IRubyColorConstants.RUBY_DEFAULT, 5, 2); // 'a?'
+ assertToken(IRubyColorConstants.RUBY_DEFAULT, 7, 1); // 'b'
+ assertToken(IRubyColorConstants.RUBY_DEFAULT, 8, 1); // ':'
+ assertToken(IRubyColorConstants.RUBY_DEFAULT, 9, 1); // 'c'
+ assertToken(IRubyColorConstants.RUBY_DEFAULT, 10, 1); // ')'
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-05 13:13:16
|
Revision: 2283
http://svn.sourceforge.net/rubyeclipse/?rev=2283&view=rev
Author: cawilliams
Date: 2007-04-05 06:12:55 -0700 (Thu, 05 Apr 2007)
Log Message:
-----------
the millionth patch to try and fix Ticket #249
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyTokenScanner.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-04-04 18:49:43 UTC (rev 2282)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-04-05 13:12:55 UTC (rev 2283)
@@ -177,9 +177,9 @@
if (isSymbolTerminator(i)) {
isInSymbol = false; // we're at the end of the symbol
if (shouldReturnDefault(i))
- return doGetToken(IRubyColorConstants.RUBY_DEFAULT);
- return doGetToken(IRubyColorConstants.RUBY_SYMBOL);
+ return doGetToken(IRubyColorConstants.RUBY_DEFAULT);
}
+ return doGetToken(IRubyColorConstants.RUBY_SYMBOL);
}
// The next two conditionals work around a JRuby parsing bug
// JRuby returns the number for ':' on second symbol's beginning in alias calls
@@ -232,6 +232,7 @@
case NEWLINE:
case COMMA:
case Tokens.tASSOC:
+ case Tokens.tRPAREN:
return true;
default:
return false;
@@ -260,7 +261,10 @@
case Tokens.tASET:
case Tokens.tIDENTIFIER:
case Tokens.tIVAR:
+ case Tokens.tGVAR:
case Tokens.tASSOC:
+ case Tokens.tLSHFT:
+ case Tokens.tRPAREN:
case COMMA:
case NEWLINE:
return true;
Modified: trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyTokenScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyTokenScanner.java 2007-04-04 18:49:43 UTC (rev 2282)
+++ trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyTokenScanner.java 2007-04-05 13:12:55 UTC (rev 2283)
@@ -209,4 +209,23 @@
assertToken(IRubyColorConstants.RUBY_FIXNUM, 27, 2); // ' 0'
}
+ public void testAppendSymbol() {
+ String code = "puts(:<<)";
+ setUpScanner(code);
+ assertToken(IRubyColorConstants.RUBY_DEFAULT, 0, 4); // 'puts'
+ assertToken(IRubyColorConstants.RUBY_DEFAULT, 4, 1); // '('
+ assertToken(IRubyColorConstants.RUBY_SYMBOL, 5, 1); // ':'
+ assertToken(IRubyColorConstants.RUBY_SYMBOL, 6, 2); // '<<'
+ assertToken(IRubyColorConstants.RUBY_DEFAULT, 8, 1); // ')'
+ }
+
+ public void testDollarDollarSymbol() {
+ String code = "puts(:$$)";
+ setUpScanner(code);
+ assertToken(IRubyColorConstants.RUBY_DEFAULT, 0, 4); // 'puts'
+ assertToken(IRubyColorConstants.RUBY_DEFAULT, 4, 1); // '('
+ assertToken(IRubyColorConstants.RUBY_SYMBOL, 5, 1); // ':'
+ assertToken(IRubyColorConstants.RUBY_SYMBOL, 6, 2); // '$$'
+ assertToken(IRubyColorConstants.RUBY_DEFAULT, 8, 1); // ')'
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-04 18:49:49
|
Revision: 2282
http://svn.sourceforge.net/rubyeclipse/?rev=2282&view=rev
Author: cawilliams
Date: 2007-04-04 11:49:43 -0700 (Wed, 04 Apr 2007)
Log Message:
-----------
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-04-04 16:27:57 UTC (rev 2281)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-04-04 18:49:43 UTC (rev 2282)
@@ -232,8 +232,11 @@
flags |= Flags.AccStatic;
if (method.isConstructor())
name = CONSTRUCTOR_INVOKE_NAME;
- else
- name = name.substring(typeName.length() + 1);
+ else {
+ if (name.startsWith(typeName)) {
+ name = name.substring(typeName.length() + 1);
+ }
+ }
} else {
// Don't show instance methods if the thing we're working on is a class' name!
// FIXME We do want to show if it is a constant, but not a class name
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-04 16:27:59
|
Revision: 2281
http://svn.sourceforge.net/rubyeclipse/?rev=2281&view=rev
Author: cawilliams
Date: 2007-04-04 09:27:57 -0700 (Wed, 04 Apr 2007)
Log Message:
-----------
cleanup code (particularly calls to System.out.println())
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultOccurrencesFinder.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultReferenceFinder.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/TypeInferenceVisitor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/AttributeLocator.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/FirstPrecursorNodeLocator.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/OffsetNodeLocator.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultOccurrencesFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultOccurrencesFinder.java 2007-04-04 16:22:14 UTC (rev 2280)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultOccurrencesFinder.java 2007-04-04 16:27:57 UTC (rev 2281)
@@ -252,9 +252,6 @@
* @param occurrences
*/
private void pushLocalVarRefs(Node root, Node orig, List<ISourcePosition> occurrences) {
- // System.out.println("Finding occurrences for a local variable " +
- // orig.toString());
-
// Find the search space
Node searchSpace = FirstPrecursorNodeLocator.Instance().findFirstPrecursor(root, orig.getPosition().getStartOffset(), new INodeAcceptor() {
public boolean doesAccept(Node node) {
@@ -297,9 +294,6 @@
* @param occurrences
*/
private void pushDVarRefs(Node root, Node orig, List<ISourcePosition> occurrences) {
- // System.out.println("Finding occurrences for a local variable " +
- // orig.toString());
-
// Find the search space
Node searchSpace = FirstPrecursorNodeLocator.Instance().findFirstPrecursor(root, orig.getPosition().getStartOffset(), new INodeAcceptor() {
public boolean doesAccept(Node node) {
@@ -340,9 +334,6 @@
* @param occurrences
*/
private void pushInstVarRefs(Node root, Node orig, List<ISourcePosition> occurrences) {
- // System.out.println("Finding occurrences for an instance variable " +
- // orig.toString() );
-
Node searchSpace = determineSearchSpace(root, orig);
// Finalize searchSpace because Java's scoping rules are the awesome
@@ -411,9 +402,6 @@
* @param occurrences
*/
private void pushClassVarRefs(Node root, Node orig, List<ISourcePosition> occurrences) {
- // System.out.println("Finding occurrences for an instance variable " +
- // orig.toString() );
-
Node searchSpace = determineSearchSpace(root, orig);
// Finalize searchSpace because Java's scoping rules are the awesome
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultReferenceFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultReferenceFinder.java 2007-04-04 16:22:14 UTC (rev 2280)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultReferenceFinder.java 2007-04-04 16:27:57 UTC (rev 2281)
@@ -183,7 +183,6 @@
List<Node> searchResults = ScopedNodeLocator.Instance().findNodesInScope(searchSpace, new INodeAcceptor() {
public boolean doesAccept(Node node) {
String name = getLocalVarRefName(node, finalSearchSpace);
-// System.out.println("Matching name" + name);
return ( name != null && name.equals(origName));
}
});
@@ -192,8 +191,6 @@
for ( Node searchResult : searchResults ) {
references.add(getPositionOfName(searchResult, searchSpace));
}
-
-// System.out.println("Searching search space " + searchSpace.toString() + searchSpace.getPosition().toString() );
}
private void log(String string) {
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/TypeInferenceVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/TypeInferenceVisitor.java 2007-04-04 16:22:14 UTC (rev 2280)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/TypeInferenceVisitor.java 2007-04-04 16:27:57 UTC (rev 2281)
@@ -23,26 +23,10 @@
// TODO: init globalScope to null, push in first non-null node as
// globalScope
public TypeInferenceVisitor( Node rootNode ) {
- System.out.println("Instantiating new TypeInferenceVisitor with root node " + stringifyNode(rootNode) );
globalScope = new Scope( rootNode, null );
currentScope = globalScope;
}
-
- public Instruction handleNode(Node iVisited) {
-
-// if ( iVisited != null )
-// {
-// String pos = "";
-// String cls = "";
-// if ( iVisited.getPosition() != null ) pos = Integer.toString(iVisited.getPosition().getStartLine());
-// if ( iVisited.getClass() != null ) cls = iVisited.getClass().getName();
-// System.out.println("Visiting " + iVisited.getClass().getSimpleName() + "\tat line " + pos + " of class " + cls );
-// System.out.println(" - Spanning " + iVisited.getPosition().getStartOffset() + "-" + iVisited.getPosition().getEndOffset());
-// }
- return super.handleNode(iVisited);
- }
-
/**
* Visit a ModuleNode, and extract its local variables from the embedded
* body ScopeNode
@@ -106,7 +90,6 @@
* @return newly pushed Scope
*/
private Scope pushScope( Node node ) {
- System.out.println("Pushing Scope for Node: " + stringifyNode(node) );
Scope newScope = new Scope( node, currentScope );
currentScope = newScope;
return newScope;
@@ -114,8 +97,7 @@
// TODO: how to tell when to do this?
// TODO: perhaps model IndexUpdater rather than InOrderVisitor
- private void popScope()
- {
+ private void popScope() {
currentScope = currentScope.getParentScope();
}
@@ -125,9 +107,7 @@
*/
public Instruction visitCallNode(CallNode iVisited) {
Variable var = getVariableByVarNode( iVisited.getReceiverNode() );
- if ( var != null )
- {
-// System.out.println("Call: " + var.getName() + "." + iVisited.getName() );
+ if ( var != null ) {
// TODO: add call to list
}
return super.visitCallNode(iVisited);
@@ -159,7 +139,6 @@
* Local assignment may provide a concrete type from the rvalue
*/
public Instruction visitLocalAsgnNode(LocalAsgnNode iVisited) {
-// System.out.println("Visiting LocalAsgnNode: " + stringifyNode(iVisited));
Variable var = currentScope.getLocalVariableByCount( iVisited.getIndex() );
if ( var == null )
{
@@ -214,32 +193,16 @@
}
}
}
-
- // Print list of types now assoc'd with the var
- System.out.print("[");
- for ( ITypeGuess guess : var.getTypeGuesses() )
- {
- System.out.print(guess.getType() + ",");
- }
- System.out.print("]");
-
-
- System.out.println("");
return super.visitLocalAsgnNode(iVisited);
}
-
-
-
-
/**
* Similar to Node.toString(),. but with the beginning line number.
*
* @param node
* @return
*/
- private String stringifyNode(Node node)
- {
+ private String stringifyNode(Node node) {
return node.getClass().getName() + "@ :" + node.getPosition().getStartLine();
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/AttributeLocator.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/AttributeLocator.java 2007-04-04 16:22:14 UTC (rev 2280)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/AttributeLocator.java 2007-04-04 16:27:57 UTC (rev 2281)
@@ -78,9 +78,7 @@
}
if ( argNode instanceof StrNode ) {
attributes.add(attrPrefix + ((StrNode)argNode).getValue() );
- }
- System.out.println(argNode.getClass().getName());
-
+ }
}
}
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/FirstPrecursorNodeLocator.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/FirstPrecursorNodeLocator.java 2007-04-04 16:22:14 UTC (rev 2280)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/FirstPrecursorNodeLocator.java 2007-04-04 16:27:57 UTC (rev 2281)
@@ -48,21 +48,15 @@
/**
* Searches via InOrderVisitor for the closest precursor.
*/
- public Instruction handleNode(Node iVisited)
- {
-//todo: This will include nodes that envelop nodeStart, not only those starting strictly before it.
+ public Instruction handleNode(Node iVisited) {
+// TODO This will include nodes that envelop nodeStart, not only those starting strictly before it.
// If this behavior is unwanted, remove the || (iVisited.getPosition().getStartOffset() <= offset)
-// in the conditional
-
- if (( iVisited.getPosition().getEndOffset() <= offset) || (iVisited.getPosition().getStartOffset() <= offset ))
- {
- if ( acceptor.doesAccept( iVisited ) )
- {
-// System.out.println("Recording accepted node: " + iVisited.getClass().getSimpleName() + "@" + iVisited.getPosition().getStartOffset() + ".." + iVisited.getPosition().getEndOffset() );
+// in the conditional
+ if (( iVisited.getPosition().getEndOffset() <= offset) || (iVisited.getPosition().getStartOffset() <= offset )) {
+ if ( acceptor.doesAccept( iVisited ) ) {
locatedNode = iVisited;
}
- }
-
+ }
return super.handleNode(iVisited);
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/OffsetNodeLocator.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/OffsetNodeLocator.java 2007-04-04 16:22:14 UTC (rev 2280)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/OffsetNodeLocator.java 2007-04-04 16:27:57 UTC (rev 2281)
@@ -58,14 +58,12 @@
private Node refine(Node node) {
// If the search returned an ArgsNode, try to find the specific ArgumentNode matched
- if ( node instanceof ArgsNode )
- {
+ if ( node instanceof ArgsNode ) {
ArgsNode argsNode = (ArgsNode)node;
if ( argsNode.getArgsCount() > 0 ) {
for (Iterator iter = argsNode.getArgs().childNodes().iterator(); iter.hasNext();) {
ArgumentNode argNode = (ArgumentNode) iter.next();
if ( nodeDoesSpanOffset(argNode, offset) ) {
-// System.out.println("Refining " + node.getClass().getSimpleName() + "["+node.getPosition().getStartOffset() + ".." + node.getPosition().getEndOffset() + "] to " + argNode.getClass().getSimpleName() + "["+argNode.getPosition().getStartOffset() + ".." + argNode.getPosition().getEndOffset() + "]");
return argNode;
}
}
@@ -79,9 +77,7 @@
* If so, see if it spans it more closely than any previously identified spanning node.
* If so, record it as the most closely spanning yet.
*/
- public Instruction handleNode(Node iVisited)
- {
-// System.out.println("Looking for node at offset, checking: " + iVisited.getClass().getName() + "[" + iVisited.getPosition().getStartOffset() + ".." + iVisited.getPosition().getEndOffset() + "]" );
+ public Instruction handleNode(Node iVisited) {
// Skip the NewlineNode since its position is very unaccurate
if (!(iVisited instanceof NewlineNode) && nodeDoesSpanOffset(iVisited, offset)) {
//note: careful... should this be <=? I think so; since it traverses in-order, this should find the "most specific" closest node. i.e.
@@ -93,7 +89,7 @@
}
}
- //todo: Since we are moving in order, if a spanning node has been located, and the current node does
+ // TODO Since we are moving in order, if a spanning node has been located, and the current node does
// not span, we can effectively return early since no subsequent nodes should span. Not doing this
// now, just in case InOrderVisitor proves to not quite be in-order (i.e. offsets reported are off.)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-04 16:22:15
|
Revision: 2280
http://svn.sourceforge.net/rubyeclipse/?rev=2280&view=rev
Author: cawilliams
Date: 2007-04-04 09:22:14 -0700 (Wed, 04 Apr 2007)
Log Message:
-----------
add missing message
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/NewWizardMessages.properties
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/NewWizardMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/NewWizardMessages.properties 2007-04-04 16:22:09 UTC (rev 2279)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/NewWizardMessages.properties 2007-04-04 16:22:14 UTC (rev 2280)
@@ -68,4 +68,6 @@
NewClassWizardPage_methods_main=public static void main(Strin&g[] args)
NewClassWizardPage_methods_constructors=&Constructors from superclass
+
+BuildPathsBlock_operationdesc_java=Setting build paths...
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-04 16:22:10
|
Revision: 2279
http://svn.sourceforge.net/rubyeclipse/?rev=2279&view=rev
Author: cawilliams
Date: 2007-04-04 09:22:09 -0700 (Wed, 04 Apr 2007)
Log Message:
-----------
ignore syntax errors thrown by parser
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/hyperlinks/RubyHyperLinkDetector.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/hyperlinks/RubyHyperLinkDetector.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/hyperlinks/RubyHyperLinkDetector.java 2007-04-04 16:12:48 UTC (rev 2278)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/hyperlinks/RubyHyperLinkDetector.java 2007-04-04 16:22:09 UTC (rev 2279)
@@ -100,12 +100,10 @@
}
}
} catch (RubyModelException e) {
- RubyPlugin.log(e);
+ //ignore
}
}
-
return null;
-
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-04 16:12:50
|
Revision: 2278
http://svn.sourceforge.net/rubyeclipse/?rev=2278&view=rev
Author: cawilliams
Date: 2007-04-04 09:12:48 -0700 (Wed, 04 Apr 2007)
Log Message:
-----------
handle completion inside class context (inside a class, but not inside a method)
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-04-04 16:12:13 UTC (rev 2277)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-04-04 16:12:48 UTC (rev 2278)
@@ -116,6 +116,8 @@
RubyElementRequestor requestor = new RubyElementRequestor(script);
IType[] types = requestor.findType(OBJECT);
if (types != null && types.length > 0) type = types[0];
+ } else if (element instanceof IType) {
+ type = (IType) element;
} else {
type = element.getDeclaringType();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-04 16:12:14
|
Revision: 2277
http://svn.sourceforge.net/rubyeclipse/?rev=2277&view=rev
Author: cawilliams
Date: 2007-04-04 09:12:13 -0700 (Wed, 04 Apr 2007)
Log Message:
-----------
fix naming of singleton methods
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceParser.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceParser.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceParser.java 2007-04-04 16:12:05 UTC (rev 2276)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceParser.java 2007-04-04 16:12:13 UTC (rev 2277)
@@ -179,23 +179,9 @@
@Override
public Instruction visitDefsNode(DefsNode iVisited) {
- /*
- * Get the name of the current static method and add the name of the
- * class or module to the beginning of it. This aInstructions instance
- * method naming conflicts. e.g.: class A def self.method; end def
- * method; end end will give us: A.method method in the Outline View.
- */
- String fullName;
- String receiver = ASTUtil.stringRepresentation(iVisited.getReceiverNode());
- if (receiver != null && receiver.trim().length() > 0) {
- fullName = receiver + "." + iVisited.getName();
- } else {
- fullName = iVisited.getName();
- }
-
MethodInfo methodInfo = new MethodInfo();
methodInfo.declarationStart = iVisited.getPosition().getStartOffset();
- methodInfo.name = fullName;
+ methodInfo.name = iVisited.getName();
methodInfo.nameSourceStart = iVisited.getNameNode().getPosition().getStartOffset();
methodInfo.nameSourceEnd = iVisited.getNameNode().getPosition().getEndOffset() - 1;
methodInfo.isConstructor = false;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-04 16:12:07
|
Revision: 2276
http://svn.sourceforge.net/rubyeclipse/?rev=2276&view=rev
Author: cawilliams
Date: 2007-04-04 09:12:05 -0700 (Wed, 04 Apr 2007)
Log Message:
-----------
avoid null pointers
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyElementDeltaBuilder.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyElementDeltaBuilder.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyElementDeltaBuilder.java 2007-04-04 15:30:23 UTC (rev 2275)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyElementDeltaBuilder.java 2007-04-04 16:12:05 UTC (rev 2276)
@@ -224,9 +224,11 @@
}
} else if (oldInfo instanceof RubyFieldElementInfo
&& newInfo instanceof RubyFieldElementInfo) {
- if (!((RubyFieldElementInfo) oldInfo).getTypeName().equals(
+ if ( ((RubyFieldElementInfo) oldInfo).getTypeName() != null && ((RubyFieldElementInfo) newInfo).getTypeName() != null) {
+ if (!((RubyFieldElementInfo) oldInfo).getTypeName().equals(
((RubyFieldElementInfo) newInfo).getTypeName())) {
- this.delta.changed(newElement, IRubyElementDelta.F_CONTENT);
+ this.delta.changed(newElement, IRubyElementDelta.F_CONTENT);
+ }
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-04 15:30:25
|
Revision: 2275
http://svn.sourceforge.net/rubyeclipse/?rev=2275&view=rev
Author: cawilliams
Date: 2007-04-04 08:30:23 -0700 (Wed, 04 Apr 2007)
Log Message:
-----------
when creating a new type convert the CamelCase constant for the type name to an under_score_file_name.rb
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewTypeWizardPage.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewTypeWizardPage.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewTypeWizardPage.java 2007-04-04 15:01:25 UTC (rev 2274)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewTypeWizardPage.java 2007-04-04 15:30:23 UTC (rev 2275)
@@ -518,17 +518,34 @@
/**
* Hook method that is called when evaluating the name of the compilation unit to create. By default, a file extension
- * <code>java</code> is added to the given type name, but implementors can override this behavior.
+ * <code>rb</code> is added to the given type name, but implementors can override this behavior.
*
* @param typeName the name of the type to create the compilation unit for.
* @return the name of the compilation unit to be created for the given name
*
- * @since 3.2
+ * @since 0.9.0
*/
protected String getRubyScriptName(String typeName) {
- return typeName + RubyModelUtil.DEFAULT_SCRIPT_SUFFIX;
+ return convertCamelCaseToUnderscore(typeName) + RubyModelUtil.DEFAULT_SCRIPT_SUFFIX;
}
+ private String convertCamelCaseToUnderscore(String name) {
+ StringBuffer newName = new StringBuffer();
+ boolean lastWasUpper = false;
+ for (int i = 0; i < name.length(); i++) {
+ char c = name.charAt(i);
+ newName.append(Character.toLowerCase(c));
+ if (lastWasUpper && Character.isLowerCase(c)) {
+ if (newName.length() > 2) newName.insert(newName.length() - 2, "_");
+ lastWasUpper = false;
+ }
+ if (Character.isUpperCase(c)) {
+ lastWasUpper = true;
+ }
+ }
+ return newName.toString();
+ }
+
/**
* Returns the package fragment corresponding to the current input.
*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-04 15:01:35
|
Revision: 2274
http://svn.sourceforge.net/rubyeclipse/?rev=2274&view=rev
Author: cawilliams
Date: 2007-04-04 08:01:25 -0700 (Wed, 04 Apr 2007)
Log Message:
-----------
fix bug that threw errors on creating a new Ruby class via wizard (positions are off by one in SourceParser for type and module). Also fix so when a new class is created, it is opened in editor
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceParser.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewTypeWizardPage.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceParser.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceParser.java 2007-04-04 14:35:34 UTC (rev 2273)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceParser.java 2007-04-04 15:01:25 UTC (rev 2274)
@@ -120,7 +120,7 @@
Instruction ins = super.visitClassNode(iVisited);
- requestor.exitType(iVisited.getPosition().getEndOffset());
+ requestor.exitType(iVisited.getPosition().getEndOffset() - 1);
return ins;
}
@@ -139,7 +139,7 @@
Instruction ins = super.visitModuleNode(iVisited);
- requestor.exitType(iVisited.getPosition().getEndOffset());
+ requestor.exitType(iVisited.getPosition().getEndOffset() - 1);
return ins;
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewTypeWizardPage.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewTypeWizardPage.java 2007-04-04 14:35:34 UTC (rev 2273)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewTypeWizardPage.java 2007-04-04 15:01:25 UTC (rev 2274)
@@ -31,6 +31,7 @@
import org.rubypeople.rdt.core.RubyConventions;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.formatter.CodeFormatter;
+import org.rubypeople.rdt.internal.core.RubyProject;
import org.rubypeople.rdt.internal.corext.codemanipulation.StubUtility;
import org.rubypeople.rdt.internal.corext.util.CodeFormatterUtil;
import org.rubypeople.rdt.internal.corext.util.Messages;
@@ -118,9 +119,9 @@
protected IStatus fSuperInterfacesStatus;
private int fTypeKind;
- private ISourceFolder fCurrPackage;
+ private ISourceFolder fCurrSourceFolder;
- private boolean fCanModifyPackage;
+ private boolean fCanModifySourceFolder;
/**
* Constant to signal that the created type is a class.
@@ -230,7 +231,7 @@
ISourceFolderRoot root= getSourceFolderRoot();
if (root != null) {
- fCurrPackage= root.getSourceFolder(packName);
+ fCurrSourceFolder= root.getSourceFolder(packName);
} else {
status.setError(""); //$NON-NLS-1$
}
@@ -535,7 +536,7 @@
* could not be resolved.
*/
public ISourceFolder getSourceFolder() {
- return fCurrPackage;
+ return fCurrSourceFolder;
}
/**
@@ -547,8 +548,8 @@
* editable; otherwise it is read-only.
*/
public void setSourceFolder(ISourceFolder pack, boolean canBeModified) {
- fCurrPackage= pack;
- fCanModifyPackage= canBeModified;
+ fCurrSourceFolder= pack;
+ fCanModifySourceFolder= canBeModified;
String str= (pack == null) ? "" : pack.getElementName(); //$NON-NLS-1$
fPackageDialogField.setText(str);
updateEnableState();
@@ -559,7 +560,7 @@
*/
private void updateEnableState() {
boolean enclosing= isEnclosingTypeSelected();
- fPackageDialogField.setEnabled(fCanModifyPackage && !enclosing);
+ fPackageDialogField.setEnabled(fCanModifySourceFolder && !enclosing);
}
private boolean isEnclosingTypeSelected() {
@@ -830,13 +831,17 @@
ArrayList initSuperinterfaces= new ArrayList(5);
IRubyProject project= null;
- ISourceFolder pack= null;
+ ISourceFolder folder= null;
IType enclosingType= null;
if (elem != null) {
// evaluate the enclosing type
project= elem.getRubyProject();
- pack= (ISourceFolder) elem.getAncestor(IRubyElement.SOURCE_FOLDER);
+ if (elem instanceof RubyProject) {
+ folder = getSourceFolderRoot().getSourceFolder(new String[0]);
+ } else {
+ folder= (ISourceFolder) elem.getAncestor(IRubyElement.SOURCE_FOLDER);
+ }
IType typeInCU= (IType) elem.getAncestor(IRubyElement.TYPE);
if (typeInCU != null) {
if (typeInCU.getRubyScript() != null) {
@@ -878,7 +883,7 @@
}
}
-// setPackageFragment(pack, true);
+ setSourceFolder(folder, true);
setTypeName(typeName, true);
setSuperClass(initSuperclass, true);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mir...@us...> - 2007-04-04 14:36:02
|
Revision: 2273
http://svn.sourceforge.net/rubyeclipse/?rev=2273&view=rev
Author: mirkostocker
Date: 2007-04-04 07:35:34 -0700 (Wed, 04 Apr 2007)
Log Message:
-----------
Fix a bug with multiple, nested modules in the rename class refactoring.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/SelectionNodeProvider.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renameclass/rename_class_test_9.activeFile.rb.result
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renameclass/rename_class_test_9.activeFile.rb.source
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renameclass/rename_class_test_9.test_properties
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/SelectionNodeProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/SelectionNodeProvider.java 2007-04-04 14:25:31 UTC (rev 2272)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/SelectionNodeProvider.java 2007-04-04 14:35:34 UTC (rev 2273)
@@ -54,7 +54,6 @@
import org.jruby.ast.NewlineNode;
import org.jruby.ast.Node;
import org.jruby.ast.RootNode;
-import org.jruby.ast.SClassNode;
import org.jruby.ast.types.INameNode;
import org.jruby.lexer.yacc.ISourcePosition;
import org.rubypeople.rdt.refactoring.exception.NoClassNodeException;
@@ -250,21 +249,20 @@
public static final int CURSOR_TOLERANCE = 1;
public static ClassNodeWrapper getSelectedClassNode(Node rootNode, int position) throws NoClassNodeException {
- return getSelectedClassNode(rootNode, position, SClassNode.class, ClassNode.class);
- }
-
- private static ClassNodeWrapper getSelectedClassNode(Node rootNode, int position, Class... classes) throws NoClassNodeException {
-
- Node enclosingClassNode = getSelectedNodeOfType(rootNode, position, classes);
+ Node enclosingClassNode = getSelectedNodeOfType(rootNode, position, ClassNode.class);
PartialClassNodeWrapper partialClassNode = PartialClassNodeWrapper.getPartialClassNodeWrapper(enclosingClassNode, rootNode);
ArrayList<ModuleNode> moduleNodes = new ArrayList<ModuleNode>();
- ModuleNode moduleNode = (ModuleNode) SelectionNodeProvider.getSelectedNodeOfType(rootNode, position, ModuleNode.class);
- if (moduleNode != null) {
- moduleNodes.add(moduleNode);
- partialClassNode.setEnclosingModules(moduleNodes);
+ Collection<Node> subNodes = NodeProvider.getSubNodes(rootNode, ModuleNode.class);
+ for (Node node : subNodes) {
+ if(nodeContainsPosition(node, position)) {
+ moduleNodes.add((ModuleNode) node);
+ }
}
+
+ partialClassNode.setEnclosingModules(moduleNodes);
+
return new ClassNodeWrapper(partialClassNode);
}
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renameclass/rename_class_test_9.activeFile.rb.result
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renameclass/rename_class_test_9.activeFile.rb.result (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renameclass/rename_class_test_9.activeFile.rb.result 2007-04-04 14:35:34 UTC (rev 2273)
@@ -0,0 +1,8 @@
+module Spec
+ module Runner
+ module Formatter
+ class NewName
+ end
+ end
+ end
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renameclass/rename_class_test_9.activeFile.rb.source
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renameclass/rename_class_test_9.activeFile.rb.source (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renameclass/rename_class_test_9.activeFile.rb.source 2007-04-04 14:35:34 UTC (rev 2273)
@@ -0,0 +1,8 @@
+module Spec
+ module Runner
+ module Formatter
+ class ProgressBarFormatter
+ end
+ end
+ end
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renameclass/rename_class_test_9.test_properties
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renameclass/rename_class_test_9.test_properties (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renameclass/rename_class_test_9.test_properties 2007-04-04 14:35:34 UTC (rev 2273)
@@ -0,0 +1,3 @@
+name=NewName
+pos=74
+activeFile=activeFile.rb
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|