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: <mir...@us...> - 2007-04-16 09:07:30
|
Revision: 2322
http://svn.sourceforge.net/rubyeclipse/?rev=2322&view=rev
Author: mirkostocker
Date: 2007-04-16 02:07:25 -0700 (Mon, 16 Apr 2007)
Log Message:
-----------
rename module: correctly rename module-method definitions, todo: usages and includes
Modified Paths:
--------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/ModuleNodeProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/ChildClassesRenameEditProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/ConstructorRenameEditProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConfig.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleEditProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/documentprovider/DocumentWithIncluding.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/editprovider/ScopingNodeRenameEditProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/nodewrapper/ModuleNodeWrapper.java
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_2.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_3.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_4.activeFile.rb.result
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_4.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/TC_ModuleNodeProvider.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/ModuleMethodDefRenameEditProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/editprovider/SimpleNodeEditProvider.java
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_FindMultipleMethods.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_FindSingleMethod.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_TwoSimpleModules.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_5.activeFile.rb.result
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_5.activeFile.rb.source
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_5.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_6.activeFile.rb.result
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_6.activeFile.rb.source
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_6.includedFile.rb.result
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_6.includedFile.rb.source
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_6.test_properties
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/ModuleNodeProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/ModuleNodeProvider.java 2007-04-16 00:20:37 UTC (rev 2321)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/ModuleNodeProvider.java 2007-04-16 09:07:25 UTC (rev 2322)
@@ -26,16 +26,18 @@
* the terms of any one of the CPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/
-
package org.rubypeople.rdt.refactoring.core;
import java.util.ArrayList;
+import java.util.Collection;
+import org.jruby.ast.ConstNode;
import org.jruby.ast.ModuleNode;
import org.jruby.ast.Node;
+import org.rubypeople.rdt.refactoring.documentprovider.IDocumentProvider;
import org.rubypeople.rdt.refactoring.nodewrapper.ModuleNodeWrapper;
-public class ModuleNodeProvider {
+public abstract class ModuleNodeProvider {
public static ModuleNodeWrapper getSelectedModuleNode(Node root, int pos) {
@@ -43,7 +45,36 @@
if(module == null) {
return null;
}
+ return createModuleNodeWrapper(root, module);
+ }
+
+ public static Collection<ModuleNodeWrapper> findOtherParts(IDocumentProvider doc, ModuleNodeWrapper module) {
+ ArrayList<ModuleNodeWrapper> modules = new ArrayList<ModuleNodeWrapper>();
+ for (String file : doc.getFileNames()) {
+ for (Node node : NodeProvider.getSubNodes(doc.getRootNode(file), ModuleNode.class)) {
+ ModuleNode moduleNode = (ModuleNode) node;
+ ModuleNodeWrapper wrapper = createModuleNodeWrapper(doc.getRootNode(file), moduleNode);
+ if(wrapper.getFullName().equals(module.getFullName())) {
+ modules.add(wrapper);
+ }
+ }
+ }
+
+ return modules;
+ }
+
+ public static Collection<ConstNode> getAllModuleMethodDefinitions(Collection<ModuleNodeWrapper> modules) {
+ ArrayList<ConstNode> methods = new ArrayList<ConstNode>();
+
+ for (ModuleNodeWrapper wrapper : modules) {
+ methods.addAll(wrapper.getModuleMethodConstNodes());
+ }
+
+ return methods;
+ }
+
+ private static ModuleNodeWrapper createModuleNodeWrapper(Node root, ModuleNode module) {
ArrayList<ModuleNode> modules = new ArrayList<ModuleNode>();
modules.add(module);
ModuleNode parent = null;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/ChildClassesRenameEditProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/ChildClassesRenameEditProvider.java 2007-04-16 00:20:37 UTC (rev 2321)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/ChildClassesRenameEditProvider.java 2007-04-16 09:07:25 UTC (rev 2322)
@@ -33,37 +33,11 @@
import org.jruby.ast.ClassNode;
import org.jruby.ast.ConstNode;
-import org.jruby.ast.Node;
import org.rubypeople.rdt.refactoring.editprovider.FileEditProvider;
-import org.rubypeople.rdt.refactoring.editprovider.ReplaceEditProvider;
+import org.rubypeople.rdt.refactoring.editprovider.SimpleNodeEditProvider;
public class ChildClassesRenameEditProvider {
- private static class ChildClassEditProvider extends ReplaceEditProvider {
-
- private final Node node;
-
- public ChildClassEditProvider(Node node) {
- this.node = node;
- }
-
- @Override
- protected int getOffsetLength() {
- return node.getPosition().getEndOffset() - node.getPosition().getStartOffset();
- }
-
- @Override
- protected Node getEditNode(int offset, String document) {
- return node;
- }
-
- @Override
- protected int getOffset(String document) {
- return node.getPosition().getStartOffset();
- }
-
- }
-
private final Collection<ClassNode> classes;
private final String newName;
@@ -77,7 +51,7 @@
for(ClassNode klass : classes) {
((ConstNode) klass.getSuperNode()).setName(newName);
- edits.add(new FileEditProvider(klass.getPosition().getFile(), new ChildClassEditProvider(klass.getSuperNode())));
+ edits.add(new FileEditProvider(klass.getPosition().getFile(), new SimpleNodeEditProvider(klass.getSuperNode())));
}
return edits;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/ConstructorRenameEditProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/ConstructorRenameEditProvider.java 2007-04-16 00:20:37 UTC (rev 2321)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/ConstructorRenameEditProvider.java 2007-04-16 09:07:25 UTC (rev 2322)
@@ -59,7 +59,6 @@
protected int getOffset(String document) {
return call.getReceiverOffset();
}
-
}
private final Collection<ConstructorCall> calls;
Added: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/ModuleMethodDefRenameEditProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/ModuleMethodDefRenameEditProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/ModuleMethodDefRenameEditProvider.java 2007-04-16 09:07:25 UTC (rev 2322)
@@ -0,0 +1,58 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.core.renamemodule;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.jruby.ast.ConstNode;
+import org.rubypeople.rdt.refactoring.editprovider.FileEditProvider;
+import org.rubypeople.rdt.refactoring.editprovider.SimpleNodeEditProvider;
+
+public class ModuleMethodDefRenameEditProvider {
+
+ private final Collection<ConstNode> nodes;
+ private final String newName;
+
+ public ModuleMethodDefRenameEditProvider(Collection<ConstNode> nodes, String newName) {
+ this.nodes = nodes;
+ this.newName = newName;
+ }
+
+ public Collection<FileEditProvider> getEditProviders() {
+ Collection<FileEditProvider> edits = new ArrayList<FileEditProvider>();
+
+ for(ConstNode node : nodes) {
+ node.setName(newName);
+ edits.add(new FileEditProvider(node.getPosition().getFile(), new SimpleNodeEditProvider(node)));
+ }
+
+ return edits;
+ }
+}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConditionChecker.java 2007-04-16 00:20:37 UTC (rev 2321)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConditionChecker.java 2007-04-16 09:07:25 UTC (rev 2322)
@@ -1,3 +1,31 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
package org.rubypeople.rdt.refactoring.core.renamemodule;
import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
@@ -33,10 +61,10 @@
return;
}
config.setNewName(selectedModule.getName());
+ config.setModuleParts(ModuleNodeProvider.findOtherParts(config.getDocumentProvider(), config.getSelectedModule()));
}
private boolean caretIsNotOnModuleName(ModuleNodeWrapper selectedModule) {
return !NodeUtil.positionIsInNode(config.getCarretPosition(), selectedModule.getWrappedNode().getCPath());
}
-
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConfig.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConfig.java 2007-04-16 00:20:37 UTC (rev 2321)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConfig.java 2007-04-16 09:07:25 UTC (rev 2322)
@@ -1,6 +1,37 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
package org.rubypeople.rdt.refactoring.core.renamemodule;
+import java.util.Collection;
+
import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
+import org.rubypeople.rdt.refactoring.documentprovider.DocumentWithIncluding;
import org.rubypeople.rdt.refactoring.documentprovider.IDocumentProvider;
import org.rubypeople.rdt.refactoring.nodewrapper.ModuleNodeWrapper;
import org.rubypeople.rdt.refactoring.ui.INewNameReceiver;
@@ -11,6 +42,7 @@
private final int carretPosition;
private ModuleNodeWrapper selectedModule;
private String newName;
+ private Collection<ModuleNodeWrapper> moduleParts;
public RenameModuleConfig(IDocumentProvider doc, int carretPosition) {
this.doc = doc;
@@ -22,7 +54,7 @@
}
public void setDocumentProvider(IDocumentProvider doc) {
- this.doc = doc;
+ this.doc = new DocumentWithIncluding(doc);
}
public void setNewName(String newName) {
@@ -48,4 +80,12 @@
public String getNewName() {
return newName;
}
+
+ public void setModuleParts(Collection<ModuleNodeWrapper> moduleParts) {
+ this.moduleParts = moduleParts;
+ }
+
+ public Collection<ModuleNodeWrapper> getModuleParts() {
+ return moduleParts;
+ }
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleEditProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleEditProvider.java 2007-04-16 00:20:37 UTC (rev 2321)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleEditProvider.java 2007-04-16 09:07:25 UTC (rev 2322)
@@ -1,3 +1,32 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+
package org.rubypeople.rdt.refactoring.core.renamemodule;
import java.util.ArrayList;
@@ -4,10 +33,12 @@
import java.util.Collection;
import org.jruby.ast.IScopingNode;
+import org.rubypeople.rdt.refactoring.core.ModuleNodeProvider;
import org.rubypeople.rdt.refactoring.editprovider.FileMultiEditProvider;
import org.rubypeople.rdt.refactoring.editprovider.IMultiFileEditProvider;
import org.rubypeople.rdt.refactoring.editprovider.MultiFileEditProvider;
import org.rubypeople.rdt.refactoring.editprovider.ScopingNodeRenameEditProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.ModuleNodeWrapper;
public class RenameModuleEditProvider implements IMultiFileEditProvider {
@@ -16,17 +47,26 @@
public RenameModuleEditProvider(RenameModuleConfig config) {
this.config = config;
}
-
+
private ScopingNodeRenameEditProvider getModuleEditProvider() {
ArrayList<IScopingNode> modules = new ArrayList<IScopingNode>();
- modules.add(config.getSelectedModule().getWrappedNode());
+
+ for (ModuleNodeWrapper node : config.getModuleParts()) {
+ modules.add(node.getWrappedNode());
+ }
+
return new ScopingNodeRenameEditProvider(modules, config.getNewName());
}
+
+ private ModuleMethodDefRenameEditProvider getModuleModuleMethodDefEditProvider() {
+ return new ModuleMethodDefRenameEditProvider(ModuleNodeProvider.getAllModuleMethodDefinitions(config.getModuleParts()), config.getNewName());
+ }
public Collection<FileMultiEditProvider> getFileEditProviders() {
MultiFileEditProvider fileEdits = new MultiFileEditProvider();
fileEdits.addEditProviders(getModuleEditProvider().getEditProviders());
+ fileEdits.addEditProviders(getModuleModuleMethodDefEditProvider().getEditProviders());
return fileEdits.getFileEditProviders();
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/documentprovider/DocumentWithIncluding.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/documentprovider/DocumentWithIncluding.java 2007-04-16 00:20:37 UTC (rev 2321)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/documentprovider/DocumentWithIncluding.java 2007-04-16 09:07:25 UTC (rev 2322)
@@ -66,7 +66,7 @@
continue;
}
for (FCallNode node : getRequires(actFileName)) {
- if(nodeRequiresMe(node)) {
+ if(nodeRequiresMe(node) && !getFileNames().contains(actFileName)) {
addAndRemove(markedForRemoval, actFileName, fileName);
}
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/editprovider/ScopingNodeRenameEditProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/editprovider/ScopingNodeRenameEditProvider.java 2007-04-16 00:20:37 UTC (rev 2321)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/editprovider/ScopingNodeRenameEditProvider.java 2007-04-16 09:07:25 UTC (rev 2322)
@@ -33,35 +33,9 @@
import org.jruby.ast.IScopingNode;
import org.jruby.ast.Node;
-import org.rubypeople.rdt.refactoring.editprovider.FileEditProvider;
-import org.rubypeople.rdt.refactoring.editprovider.ReplaceEditProvider;
public class ScopingNodeRenameEditProvider {
- private static class ScopingNodeRenameEdit extends ReplaceEditProvider {
-
- private final IScopingNode node;
-
- public ScopingNodeRenameEdit(IScopingNode klass) {
- this.node = klass;
- }
-
- @Override
- protected int getOffsetLength() {
- return node.getCPath().getPosition().getEndOffset() - node.getCPath().getPosition().getStartOffset();
- }
-
- @Override
- protected Node getEditNode(int offset, String document) {
- return node.getCPath();
- }
-
- @Override
- protected int getOffset(String document) {
- return node.getCPath().getPosition().getStartOffset();
- }
- }
-
private final Collection<? extends IScopingNode> nodes;
private final String newName;
@@ -75,7 +49,7 @@
for(IScopingNode klass : nodes) {
klass.getCPath().setName(newName);
- edits.add(new FileEditProvider(((Node) klass).getPosition().getFile(), new ScopingNodeRenameEdit(klass)));
+ edits.add(new FileEditProvider(((Node) klass).getPosition().getFile(), new SimpleNodeEditProvider(klass.getCPath())));
}
return edits;
Added: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/editprovider/SimpleNodeEditProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/editprovider/SimpleNodeEditProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/editprovider/SimpleNodeEditProvider.java 2007-04-16 09:07:25 UTC (rev 2322)
@@ -0,0 +1,55 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.editprovider;
+
+import org.jruby.ast.Node;
+
+public class SimpleNodeEditProvider extends ReplaceEditProvider {
+
+ private final Node node;
+
+ public SimpleNodeEditProvider(Node node) {
+ this.node = node;
+ }
+
+ @Override
+ protected int getOffsetLength() {
+ return node.getPosition().getEndOffset() - node.getPosition().getStartOffset();
+ }
+
+ @Override
+ protected Node getEditNode(int offset, String document) {
+ return node;
+ }
+
+ @Override
+ protected int getOffset(String document) {
+ return node.getPosition().getStartOffset();
+ }
+}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/nodewrapper/ModuleNodeWrapper.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/nodewrapper/ModuleNodeWrapper.java 2007-04-16 00:20:37 UTC (rev 2321)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/nodewrapper/ModuleNodeWrapper.java 2007-04-16 09:07:25 UTC (rev 2322)
@@ -1,14 +1,23 @@
package org.rubypeople.rdt.refactoring.nodewrapper;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.jruby.ast.ConstNode;
+import org.jruby.ast.DefsNode;
import org.jruby.ast.ModuleNode;
+import org.jruby.ast.Node;
+import org.rubypeople.rdt.refactoring.core.NodeProvider;
public class ModuleNodeWrapper implements INodeWrapper {
private final ModuleNode moduleNode;
private ModuleNodeWrapper parentModule;
+ private ArrayList<ConstNode> moduleMethodNodes = new ArrayList<ConstNode>();;
public ModuleNodeWrapper(ModuleNode moduleNode, ModuleNodeWrapper parentModule) {
this.moduleNode = moduleNode;
- this.parentModule = parentModule;
+ this.parentModule = parentModule;
+ initModuleMethodConstNodes();
}
public ModuleNode getWrappedNode() {
@@ -30,4 +39,18 @@
public String getFullName() {
return (parentModule != null ? parentModule.getFullName() + "::" : "") + getName();
}
+
+ public Collection<ConstNode> getModuleMethodConstNodes() {
+
+ return moduleMethodNodes;
+ }
+
+ private void initModuleMethodConstNodes() {
+ for (Node node : NodeProvider.getSubNodes(getWrappedNode(), DefsNode.class)) {
+ ConstNode constNode = (ConstNode) ((DefsNode) node).getReceiverNode();
+ if(constNode.getName().equals(getName())) {
+ moduleMethodNodes.add(constNode);
+ }
+ }
+ }
}
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_FindMultipleMethods.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_FindMultipleMethods.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_FindMultipleMethods.rb 2007-04-16 09:07:25 UTC (rev 2322)
@@ -0,0 +1,20 @@
+module Modul
+ def Modul.test_method
+ end
+end
+
+module OuterModul
+ module Modul
+ def Modul.test_method
+ end
+ end
+end
+
+module Modul
+ def Modul.test_method
+ end
+ def Modul.second_method
+ end
+ def Modul.third_method
+ end
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_FindSingleMethod.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_FindSingleMethod.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_FindSingleMethod.rb 2007-04-16 09:07:25 UTC (rev 2322)
@@ -0,0 +1,16 @@
+module Modul
+ def Modul.test_method
+ end
+end
+
+module OuterModul
+ module Modul
+ def Modul.test_method
+ end
+ end
+end
+
+module Modul
+ def Modul.test_method
+ end
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_TwoSimpleModules.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_TwoSimpleModules.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_TwoSimpleModules.rb 2007-04-16 09:07:25 UTC (rev 2322)
@@ -0,0 +1,12 @@
+module Modul
+end
+
+module Modul
+ module Modul
+ end
+end
+
+module Crap
+ module Modul
+ end
+end
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_2.test_properties
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_2.test_properties 2007-04-16 00:20:37 UTC (rev 2321)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_2.test_properties 2007-04-16 09:07:25 UTC (rev 2322)
@@ -1,3 +1,3 @@
-name=Debug
+name=Moral
pos=8
activeFile=activeFile.rb
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_3.test_properties
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_3.test_properties 2007-04-16 00:20:37 UTC (rev 2321)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_3.test_properties 2007-04-16 09:07:25 UTC (rev 2322)
@@ -1,3 +1,3 @@
-name=NewModule
+name=Debug
pos=8
activeFile=activeFile.rb
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_4.activeFile.rb.result
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_4.activeFile.rb.result 2007-04-16 00:20:37 UTC (rev 2321)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_4.activeFile.rb.result 2007-04-16 09:07:25 UTC (rev 2322)
@@ -6,15 +6,15 @@
end
module Module
- module CentralModule
+ module InnerModule
end
end
-module CentralModule
+module InnerModule
end
class ModulTest
include OuterModule::Module::CentralModule
- include Module::CentralModule
- include CentralModule
+ include Module::InnerModule
+ include InnerModule
end
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_4.test_properties
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_4.test_properties 2007-04-16 00:20:37 UTC (rev 2321)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_4.test_properties 2007-04-16 09:07:25 UTC (rev 2322)
@@ -1,3 +1,3 @@
-name=NewModule
-pos=8
+name=CentralModule
+pos=47
activeFile=activeFile.rb
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_5.activeFile.rb.result
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_5.activeFile.rb.result (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_5.activeFile.rb.result 2007-04-16 09:07:25 UTC (rev 2322)
@@ -0,0 +1,5 @@
+module NewModule
+end
+
+module NewModule
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_5.activeFile.rb.source
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_5.activeFile.rb.source (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_5.activeFile.rb.source 2007-04-16 09:07:25 UTC (rev 2322)
@@ -0,0 +1,5 @@
+module Modul
+end
+
+module Modul
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_5.test_properties
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_5.test_properties (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_5.test_properties 2007-04-16 09:07:25 UTC (rev 2322)
@@ -0,0 +1,3 @@
+name=NewModule
+pos=8
+activeFile=activeFile.rb
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_6.activeFile.rb.result
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_6.activeFile.rb.result (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_6.activeFile.rb.result 2007-04-16 09:07:25 UTC (rev 2322)
@@ -0,0 +1,7 @@
+require 'includedFile'
+
+module NewModule
+end
+
+module NewModule
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_6.activeFile.rb.source
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_6.activeFile.rb.source (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_6.activeFile.rb.source 2007-04-16 09:07:25 UTC (rev 2322)
@@ -0,0 +1,7 @@
+require 'includedFile'
+
+module Modul
+end
+
+module Modul
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_6.includedFile.rb.result
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_6.includedFile.rb.result (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_6.includedFile.rb.result 2007-04-16 09:07:25 UTC (rev 2322)
@@ -0,0 +1,5 @@
+module NewModule
+end
+
+module NewModule
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_6.includedFile.rb.source
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_6.includedFile.rb.source (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_6.includedFile.rb.source 2007-04-16 09:07:25 UTC (rev 2322)
@@ -0,0 +1,5 @@
+module Modul
+end
+
+module Modul
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_6.test_properties
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_6.test_properties (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_6.test_properties 2007-04-16 09:07:25 UTC (rev 2322)
@@ -0,0 +1,4 @@
+name=NewModule
+pos=52
+activeFile=activeFile.rb
+destinationFiles=includedFile.rb
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/TC_ModuleNodeProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/TC_ModuleNodeProvider.java 2007-04-16 00:20:37 UTC (rev 2321)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/TC_ModuleNodeProvider.java 2007-04-16 09:07:25 UTC (rev 2322)
@@ -28,7 +28,12 @@
package org.rubypeople.rdt.refactoring.tests.core;
+import java.util.Collection;
+
+import org.jruby.ast.ConstNode;
+import org.jruby.lexer.yacc.SourcePosition;
import org.rubypeople.rdt.refactoring.core.ModuleNodeProvider;
+import org.rubypeople.rdt.refactoring.documentprovider.StringDocumentProvider;
import org.rubypeople.rdt.refactoring.nodewrapper.ModuleNodeWrapper;
import org.rubypeople.rdt.refactoring.tests.FileTestCase;
@@ -42,6 +47,10 @@
return ModuleNodeProvider.getSelectedModuleNode(getRootNode(file),position);
}
+ private Collection<ModuleNodeWrapper> findModules(String file, ModuleNodeWrapper moduleNode) {
+ return ModuleNodeProvider.findOtherParts(new StringDocumentProvider("TC_ModuleNodeProvider", getSource(file)), moduleNode);
+ }
+
public void testSimpleModule() {
ModuleNodeWrapper moduleNode = findModule("TC_ModuleNodeProvider_SimpleModule.rb", 8);
@@ -68,4 +77,47 @@
assertEquals("M5", moduleNode.getName());
assertEquals("M1::M2::M3::M4::M5", moduleNode.getFullName());
}
+
+ public void testTwoSimpleModules() {
+ ModuleNodeWrapper[] nodeWrappers = getModules("TC_ModuleNodeProvider_TwoSimpleModules.rb", 8).toArray(new ModuleNodeWrapper[]{});
+
+ assertEquals(2, nodeWrappers.length);
+ assertEquals("Modul", nodeWrappers[0].getFullName());
+ assertEquals("Modul", nodeWrappers[1].getFullName());
+ }
+
+ private Collection<ModuleNodeWrapper> getModules(String fileName, int pos) {
+ ModuleNodeWrapper moduleNode = findModule(fileName, pos);
+ return findModules(fileName, moduleNode);
+ }
+
+ public void testFindSingleMethod() {
+ Collection<ModuleNodeWrapper> modules = getModules("TC_ModuleNodeProvider_FindSingleMethod.rb", 8);
+ ConstNode[] nodes = ModuleNodeProvider.getAllModuleMethodDefinitions(modules).toArray(new ConstNode[]{});
+
+ assertEquals(2, nodes.length);
+ assertEquals("Modul", nodes[0].getName());
+ assertEquals(new SourcePosition("TC_ModuleNodeProvider", 1, 1, 19, 24), nodes[0].getPosition());
+
+ assertEquals("Modul", nodes[1].getName());
+ assertEquals(new SourcePosition("TC_ModuleNodeProvider", 13, 13, 145, 150), nodes[1].getPosition());
+ }
+
+ public void testFindMultipleMethods() {
+ Collection<ModuleNodeWrapper> modules = getModules("TC_ModuleNodeProvider_FindMultipleMethods.rb", 8);
+ ConstNode[] nodes = ModuleNodeProvider.getAllModuleMethodDefinitions(modules).toArray(new ConstNode[]{});
+
+ assertEquals(4, nodes.length);
+ assertEquals("Modul", nodes[0].getName());
+ assertEquals(new SourcePosition("TC_ModuleNodeProvider", 1, 1, 19, 24), nodes[0].getPosition());
+
+ assertEquals("Modul", nodes[1].getName());
+ assertEquals(new SourcePosition("TC_ModuleNodeProvider", 13, 13, 145, 150), nodes[1].getPosition());
+
+ assertEquals("Modul", nodes[2].getName());
+ assertEquals(new SourcePosition("TC_ModuleNodeProvider", 15, 15, 175, 180), nodes[2].getPosition());
+
+ assertEquals("Modul", nodes[3].getName());
+ assertEquals(new SourcePosition("TC_ModuleNodeProvider", 17, 17, 207, 212), nodes[3].getPosition());
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-16 00:20:38
|
Revision: 2321
http://svn.sourceforge.net/rubyeclipse/?rev=2321&view=rev
Author: cawilliams
Date: 2007-04-15 17:20:37 -0700 (Sun, 15 Apr 2007)
Log Message:
-----------
expose search packages to external plugins
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/META-INF/MANIFEST.MF
Modified: branches/search_engine/org.rubypeople.rdt.core/META-INF/MANIFEST.MF
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/META-INF/MANIFEST.MF 2007-04-15 14:34:45 UTC (rev 2320)
+++ branches/search_engine/org.rubypeople.rdt.core/META-INF/MANIFEST.MF 2007-04-16 00:20:37 UTC (rev 2321)
@@ -11,12 +11,14 @@
org.rubypeople.rdt.core,
org.rubypeople.rdt.core.compiler,
org.rubypeople.rdt.core.formatter,
+ org.rubypeople.rdt.core.search,
org.rubypeople.rdt.internal.compiler,
org.rubypeople.rdt.internal.core,
org.rubypeople.rdt.internal.core.buffer,
org.rubypeople.rdt.internal.core.builder,
org.rubypeople.rdt.internal.core.parser,
org.rubypeople.rdt.internal.core.parser.warnings,
+ org.rubypeople.rdt.internal.core.search,
org.rubypeople.rdt.internal.core.symbols,
org.rubypeople.rdt.internal.core.util,
org.rubypeople.rdt.internal.formatter,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
Revision: 2318
http://svn.sourceforge.net/rubyeclipse/?rev=2318&view=rev
Author: cawilliams
Date: 2007-04-15 07:33:23 -0700 (Sun, 15 Apr 2007)
Log Message:
-----------
check for null to avoid null pointers
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFolderToIndex.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFolderToIndex.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFolderToIndex.java 2007-04-14 14:34:33 UTC (rev 2317)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFolderToIndex.java 2007-04-15 14:33:23 UTC (rev 2318)
@@ -164,6 +164,7 @@
private void addDirectorysChildren(File file, String EXISTS, SimpleLookupTable indexedFileNames) {
File[] children = file.listFiles();
+ if (children == null) return;
for (int i = 0; i < children.length; i++) {
String name = children[i].getName();
if (Util.isRubyLikeFileName(name)) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-15 14:34:46
|
Revision: 2320
http://svn.sourceforge.net/rubyeclipse/?rev=2320&view=rev
Author: cawilliams
Date: 2007-04-15 07:34:45 -0700 (Sun, 15 Apr 2007)
Log Message:
-----------
roll back change sthat moved prefix into search pattern. for whatever reason our search pattern is being matched up against the index key (not just the type name for types, for example) - so we're not getting any matches...
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-04-15 14:33:33 UTC (rev 2319)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-04-15 14:34:45 UTC (rev 2320)
@@ -142,7 +142,7 @@
}
private void suggestGlobals() {
- SearchPattern pattern = SearchPattern.createPattern(IRubyElement.GLOBAL, "$*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
+ SearchPattern pattern = SearchPattern.createPattern(IRubyElement.GLOBAL, "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
IRubySearchScope scope = BasicSearchEngine.createRubySearchScope(new IRubyElement[] {fContext.getScript().getRubyProject()});
List<SearchMatch> results = search(pattern, scope);
for (SearchMatch match: results) {
@@ -157,12 +157,14 @@
}
private void suggestTypeNames() {
- SearchPattern pattern = SearchPattern.createPattern(IRubyElement.TYPE, fContext.getPartialPrefix() + "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
+ SearchPattern pattern = SearchPattern.createPattern(IRubyElement.TYPE, "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
IRubySearchScope scope = BasicSearchEngine.createRubySearchScope(new IRubyElement[] {fContext.getScript().getRubyProject()});
List<SearchMatch> results = search(pattern, scope);
for (SearchMatch match: results) {
IRubyElement element = (IRubyElement) match.getElement();
String name = element.getElementName();
+ if (!fContext.prefixStartsWith(name))
+ continue;
CompletionProposal proposal = createProposal(fContext.getReplaceStart(), CompletionProposal.TYPE_REF, name);
proposal.setType(name);
fRequestor.accept(proposal);
@@ -189,12 +191,14 @@
}
private void suggestConstantNames() {
- SearchPattern pattern = SearchPattern.createPattern(IRubyElement.CONSTANT, fContext.getPartialPrefix() + "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
+ SearchPattern pattern = SearchPattern.createPattern(IRubyElement.CONSTANT, "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
IRubySearchScope scope = BasicSearchEngine.createRubySearchScope(new IRubyElement[] {fContext.getScript()});
List<SearchMatch> results = search(pattern, scope);
for (SearchMatch match: results) {
IRubyElement element = (IRubyElement) match.getElement();
String name = element.getElementName();
+ if (!fContext.prefixStartsWith(name))
+ continue;
CompletionProposal proposal = createProposal(fContext.getReplaceStart(), CompletionProposal.FIELD_REF, name);
proposal.setType(name);
fRequestor.accept(proposal);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-15 14:33:36
|
Revision: 2319
http://svn.sourceforge.net/rubyeclipse/?rev=2319&view=rev
Author: cawilliams
Date: 2007-04-15 07:33:33 -0700 (Sun, 15 Apr 2007)
Log Message:
-----------
turn off verbose flags
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/processing/JobManager.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java 2007-04-15 14:33:23 UTC (rev 2318)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java 2007-04-15 14:33:33 UTC (rev 2319)
@@ -33,7 +33,7 @@
public class BasicSearchEngine {
- public static final boolean VERBOSE = true;
+ public static final boolean VERBOSE = false;
/*
* A list of working copies that take precedence over their original
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/processing/JobManager.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/processing/JobManager.java 2007-04-15 14:33:23 UTC (rev 2318)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/processing/JobManager.java 2007-04-15 14:33:33 UTC (rev 2319)
@@ -35,7 +35,7 @@
it cannot go beyond 1 */
private int enableCount = 1;
- public static boolean VERBOSE = true;
+ public static boolean VERBOSE = false;
/* flag indicating that the activation has completed */
public boolean activated = false;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mba...@us...> - 2007-04-14 14:34:35
|
Revision: 2317
http://svn.sourceforge.net/rubyeclipse/?rev=2317&view=rev
Author: mbarchfe
Date: 2007-04-14 07:34:33 -0700 (Sat, 14 Apr 2007)
Log Message:
-----------
updated fetchTag and version.qualifier
Modified Paths:
--------------
trunk/org.rubypeople.rdt.pluginbuilder/releases/0.9.0RC1.properties
Modified: trunk/org.rubypeople.rdt.pluginbuilder/releases/0.9.0RC1.properties
===================================================================
--- trunk/org.rubypeople.rdt.pluginbuilder/releases/0.9.0RC1.properties 2007-04-14 14:29:50 UTC (rev 2316)
+++ trunk/org.rubypeople.rdt.pluginbuilder/releases/0.9.0RC1.properties 2007-04-14 14:34:33 UTC (rev 2317)
@@ -2,6 +2,6 @@
#Fri Mar 30 11:05:22 EDT 2007
buildType=S
version=0.9.0
-fetchTag=2248
-version.qualifier=200703301105
+fetchTag=2316
+version.qualifier=200704141430
buildTypePresentation=RC1
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mba...@us...> - 2007-04-14 14:29:52
|
Revision: 2316
http://svn.sourceforge.net/rubyeclipse/?rev=2316&view=rev
Author: mbarchfe
Date: 2007-04-14 07:29:50 -0700 (Sat, 14 Apr 2007)
Log Message:
-----------
ruby-debug gems are not bundled anymore since they can now be installed via gem install
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/build.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties
Removed Paths:
-------------
trunk/org.rubypeople.rdt.launching/ruby-debug-base-0.9.gem
trunk/org.rubypeople.rdt.launching/ruby-debug-ide-0.1.0.gem
Modified: trunk/org.rubypeople.rdt.launching/build.properties
===================================================================
--- trunk/org.rubypeople.rdt.launching/build.properties 2007-04-13 20:15:32 UTC (rev 2315)
+++ trunk/org.rubypeople.rdt.launching/build.properties 2007-04-14 14:29:50 UTC (rev 2316)
@@ -2,8 +2,7 @@
plugin.properties,\
ruby/*,\
launching.jar,\
- .options,\
- *.gem
+ .options
plugin = org.rubypeople.rdt.launching
plugin.name = launching
plugin.classpath = ../org.eclipse.core.runtime/runtime.jar;../org.eclipse.core.resources/resources.jar;../org.eclipse.core.boot/boot.jar;../org.eclipse.debug.core/dtcore.jar;../org.eclipse.ui/workbench.jar;../org.apache.xerces/xmlParserAPIs.jar;../org.rubypeople.rdt.core/bin;../org.rubypeople.rdt.debug.core/bin;
Deleted: trunk/org.rubypeople.rdt.launching/ruby-debug-base-0.9.gem
===================================================================
(Binary files differ)
Deleted: trunk/org.rubypeople.rdt.launching/ruby-debug-ide-0.1.0.gem
===================================================================
(Binary files differ)
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties 2007-04-13 20:15:32 UTC (rev 2315)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties 2007-04-14 14:29:50 UTC (rev 2316)
@@ -172,7 +172,7 @@
DebuggerPreferencePage_description_label=Debugger preferences
DebuggerPreferencePage_useRubyDebug_label=Use ruby-debug library
DebuggerPreferencePage_verboseDebugger_label=Debugger verbose mode
-DebuggerPreferencePage_useRubyDebug_comment=ruby-debug requires a ruby version >= 1.8.4.\nThere must be two gems installed: ruby-debug-base (version 0.9) and ruby-debug-ide (version 0.1.0). They are packaged with RDT and can be found at:\n {0}.\nInstall with the command 'gem install' but please be aware that ruby-debug-base contains native code and therefore requires a C compiler.
+DebuggerPreferencePage_useRubyDebug_comment=In order to use ruby-debug you have to install the gem ruby-debug-ide, version 0.1 is compatible with this release of RDT. You should always take the latest service release (currently being 0.1.2)\nFor the installation you usually have to enter 'gem install ruby-debug-ide'
PropertyAndPreferencePage_useprojectsettings_label=Enable pr&oject specific settings
PropertyAndPreferencePage_useworkspacesettings_change=Configure Workspace Settings...
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-13 20:15:36
|
Revision: 2315
http://svn.sourceforge.net/rubyeclipse/?rev=2315&view=rev
Author: cawilliams
Date: 2007-04-13 13:15:32 -0700 (Fri, 13 Apr 2007)
Log Message:
-----------
don't ask for every constant/global/type and the check prefix afterwards. bake the prefix right into the search pattern!
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-04-13 20:10:32 UTC (rev 2314)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-04-13 20:15:32 UTC (rev 2315)
@@ -157,14 +157,12 @@
}
private void suggestTypeNames() {
- SearchPattern pattern = SearchPattern.createPattern(IRubyElement.TYPE, "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
+ SearchPattern pattern = SearchPattern.createPattern(IRubyElement.TYPE, fContext.getPartialPrefix() + "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
IRubySearchScope scope = BasicSearchEngine.createRubySearchScope(new IRubyElement[] {fContext.getScript().getRubyProject()});
List<SearchMatch> results = search(pattern, scope);
for (SearchMatch match: results) {
IRubyElement element = (IRubyElement) match.getElement();
String name = element.getElementName();
- if (!fContext.prefixStartsWith(name))
- continue;
CompletionProposal proposal = createProposal(fContext.getReplaceStart(), CompletionProposal.TYPE_REF, name);
proposal.setType(name);
fRequestor.accept(proposal);
@@ -191,15 +189,12 @@
}
private void suggestConstantNames() {
- // TODO Do a regexp search for anything starting with an uppercase?
- SearchPattern pattern = SearchPattern.createPattern(IRubyElement.CONSTANT, "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
+ SearchPattern pattern = SearchPattern.createPattern(IRubyElement.CONSTANT, fContext.getPartialPrefix() + "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
IRubySearchScope scope = BasicSearchEngine.createRubySearchScope(new IRubyElement[] {fContext.getScript()});
List<SearchMatch> results = search(pattern, scope);
for (SearchMatch match: results) {
IRubyElement element = (IRubyElement) match.getElement();
String name = element.getElementName();
- if (!fContext.prefixStartsWith(name))
- continue;
CompletionProposal proposal = createProposal(fContext.getReplaceStart(), CompletionProposal.FIELD_REF, name);
proposal.setType(name);
fRequestor.accept(proposal);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-13 20:11:32
|
Revision: 2314
http://svn.sourceforge.net/rubyeclipse/?rev=2314&view=rev
Author: cawilliams
Date: 2007-04-13 13:10:32 -0700 (Fri, 13 Apr 2007)
Log Message:
-----------
hey, external libraries are working now too!
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchDocument.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFolderToIndex.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SourceIndexerRequestor.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchDocument.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchDocument.java 2007-04-13 19:36:06 UTC (rev 2313)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchDocument.java 2007-04-13 20:10:32 UTC (rev 2314)
@@ -17,6 +17,11 @@
public RubySearchDocument(String documentPath, SearchParticipant participant) {
super(documentPath, participant);
}
+
+ public RubySearchDocument(String documentPath, char[] contents, SearchParticipant participant) {
+ this(documentPath, participant);
+ this.charContents = contents;
+ }
@Override
public char[] getCharContents() {
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFolderToIndex.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFolderToIndex.java 2007-04-13 19:36:06 UTC (rev 2313)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFolderToIndex.java 2007-04-13 20:10:32 UTC (rev 2314)
@@ -1,7 +1,9 @@
package org.rubypeople.rdt.internal.core.search.indexing;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -135,7 +137,9 @@
}
String name = children[i].getName();
if (Util.isRubyLikeFileName(name)) {
- RubySearchDocument entryDocument = new RubySearchDocument(children[i].getAbsolutePath(), participant);
+ InputStream stream = new FileInputStream(children[i]);
+ char[] contents = Util.getInputStreamAsCharArray(stream, -1, null);
+ RubySearchDocument entryDocument = new RubySearchDocument(children[i].getAbsolutePath(), contents, participant);
this.manager.indexDocument(entryDocument, participant, index, this.containerPath);
}
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SourceIndexerRequestor.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SourceIndexerRequestor.java 2007-04-13 19:36:06 UTC (rev 2313)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SourceIndexerRequestor.java 2007-04-13 20:10:32 UTC (rev 2314)
@@ -74,7 +74,11 @@
mod[i] = modules[i].toCharArray();
}
char[] packName = new char[0];
- indexer.addClassDeclaration(type.isModule ? Flags.AccModule : 0, type.name.toCharArray(), packName, null, type.superclass.toCharArray(), mod, type.secondary);
+ char[] superclass = new char[0];
+ if (type.superclass != null) {
+ superclass = type.superclass.toCharArray();
+ }
+ indexer.addClassDeclaration(type.isModule ? Flags.AccModule : 0, type.name.toCharArray(), packName, null, superclass, mod, type.secondary);
}
public void exitConstructor(int endOffset) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-13 19:36:10
|
Revision: 2313
http://svn.sourceforge.net/rubyeclipse/?rev=2313&view=rev
Author: cawilliams
Date: 2007-04-13 12:36:06 -0700 (Fri, 13 Apr 2007)
Log Message:
-----------
try to work towards the external loadpaths (like ruby std library) to get indexed properly.
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java
Added Paths:
-----------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFolderToIndex.java
Removed Paths:
-------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFileToIndex.java
Deleted: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFileToIndex.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFileToIndex.java 2007-04-13 18:53:42 UTC (rev 2312)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFileToIndex.java 2007-04-13 19:36:06 UTC (rev 2313)
@@ -1,17 +0,0 @@
-package org.rubypeople.rdt.internal.core.search.indexing;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-public class AddExternalFileToIndex extends IndexRequest {
-
- public AddExternalFileToIndex(IPath containerPath, IndexManager manager) {
- super(containerPath, manager);
- }
-
- public boolean execute(IProgressMonitor progress) {
- // TODO Auto-generated method stub
- return false;
- }
-
-}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFolderToIndex.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFolderToIndex.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFolderToIndex.java 2007-04-13 19:36:06 UTC (rev 2313)
@@ -0,0 +1,192 @@
+package org.rubypeople.rdt.internal.core.search.indexing;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.rubypeople.rdt.core.search.SearchParticipant;
+import org.rubypeople.rdt.internal.compiler.util.SimpleLookupTable;
+import org.rubypeople.rdt.internal.core.RubyModelManager;
+import org.rubypeople.rdt.internal.core.index.Index;
+import org.rubypeople.rdt.internal.core.search.BasicSearchEngine;
+import org.rubypeople.rdt.internal.core.search.RubySearchDocument;
+import org.rubypeople.rdt.internal.core.search.processing.JobManager;
+import org.rubypeople.rdt.internal.core.util.Util;
+
+public class AddExternalFolderToIndex extends IndexRequest {
+
+ public AddExternalFolderToIndex(IPath containerPath, IndexManager manager) {
+ super(containerPath, manager);
+ }
+
+ public boolean execute(IProgressMonitor progressMonitor) {
+
+ if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled())
+ return true;
+
+ try {
+ // if index is already cached, then do not perform any check
+ // MUST reset the IndexManager if a jar file is changed
+ Index index = this.manager.getIndexForUpdate(this.containerPath, false, /* do not reuse index file */false /* do not create if none */);
+ if (index != null) {
+ if (JobManager.VERBOSE)
+ org.rubypeople.rdt.internal.core.util.Util.verbose("-> no indexing required (index already exists) for " + this.containerPath); //$NON-NLS-1$
+ return true;
+ }
+
+ index = this.manager.getIndexForUpdate(this.containerPath, true, /* reuse index file */true /* create if none */);
+ if (index == null) {
+ if (JobManager.VERBOSE)
+ org.rubypeople.rdt.internal.core.util.Util.verbose("-> index could not be created for " + this.containerPath); //$NON-NLS-1$
+ return true;
+ }
+ ReadWriteMonitor monitor = index.monitor;
+ if (monitor == null) {
+ if (JobManager.VERBOSE)
+ org.rubypeople.rdt.internal.core.util.Util.verbose("-> index for " + this.containerPath + " just got deleted"); //$NON-NLS-1$//$NON-NLS-2$
+ return true; // index got deleted since acquired
+ }
+ File file = null;
+ try {
+ monitor.enterWrite(); // ask permission to write
+
+ if (RubyModelManager.ZIP_ACCESS_VERBOSE)
+ System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Creating ZipFile on " + this.containerPath); //$NON-NLS-1$ //$NON-NLS-2$
+ // external file -> it is ok to use toFile()
+ file = this.containerPath.toFile();
+ // path is already canonical since coming from a library
+ // classpath entry
+
+ if (this.isCancelled) {
+ if (JobManager.VERBOSE)
+ org.rubypeople.rdt.internal.core.util.Util.verbose("-> indexing of " + file.getName() + " has been cancelled"); //$NON-NLS-1$ //$NON-NLS-2$
+ return false;
+ }
+
+ if (JobManager.VERBOSE)
+ org.rubypeople.rdt.internal.core.util.Util.verbose("-> indexing " + file.getName()); //$NON-NLS-1$
+ long initialTime = System.currentTimeMillis();
+
+ String[] paths = index.queryDocumentNames(""); // all file
+ // names
+ // //$NON-NLS-1$
+ if (paths != null) {
+ int max = paths.length;
+ /*
+ * check integrity of the existing index file if the length
+ * is equal to 0, we want to index the whole jar again If
+ * not, then we want to check that there is no missing
+ * entry, if one entry is missing then we recreate the index
+ */
+ String EXISTS = "OK"; //$NON-NLS-1$
+ String DELETED = "DELETED"; //$NON-NLS-1$
+ SimpleLookupTable indexedFileNames = new SimpleLookupTable(max == 0 ? 33 : max + 11);
+ for (int i = 0; i < max; i++)
+ indexedFileNames.put(paths[i], DELETED);
+
+ addDirectorysChildren(file, EXISTS, indexedFileNames);
+ boolean needToReindex = indexedFileNames.elementSize != max; // a
+ // new
+ // file
+ // was
+ // added
+ if (!needToReindex) {
+ Object[] valueTable = indexedFileNames.valueTable;
+ for (int i = 0, l = valueTable.length; i < l; i++) {
+ if (valueTable[i] == DELETED) {
+ needToReindex = true; // a file was deleted so
+ // re-index
+ break;
+ }
+ }
+ if (!needToReindex) {
+ if (JobManager.VERBOSE)
+ org.rubypeople.rdt.internal.core.util.Util.verbose("-> no indexing required (index is consistent with library) for " //$NON-NLS-1$
+ + file.getName() + " (" //$NON-NLS-1$
+ + (System.currentTimeMillis() - initialTime) + "ms)"); //$NON-NLS-1$
+ this.manager.saveIndex(index); // to ensure its
+ // placed into the
+ // saved state
+ return true;
+ }
+ }
+ }
+
+ // Index the jar for the first time or reindex the jar in case
+ // the previous index file has been corrupted
+ // index already existed: recreate it so that we forget about
+ // previous entries
+ SearchParticipant participant = BasicSearchEngine.getDefaultSearchParticipant();
+ index = manager.recreateIndex(this.containerPath);
+ if (index == null) {
+ // failed to recreate index, see 73330
+ manager.removeIndex(this.containerPath);
+ return false;
+ }
+
+ File[] children = file.listFiles();
+ for (int i = 0; i < children.length; i++) {
+ if (this.isCancelled) {
+ if (JobManager.VERBOSE)
+ org.rubypeople.rdt.internal.core.util.Util.verbose("-> indexing of " + file.getName() + " has been cancelled"); //$NON-NLS-1$ //$NON-NLS-2$
+ return false;
+ }
+ String name = children[i].getName();
+ if (Util.isRubyLikeFileName(name)) {
+ RubySearchDocument entryDocument = new RubySearchDocument(children[i].getAbsolutePath(), participant);
+ this.manager.indexDocument(entryDocument, participant, index, this.containerPath);
+ }
+ }
+ this.manager.saveIndex(index);
+ if (JobManager.VERBOSE)
+ org.rubypeople.rdt.internal.core.util.Util.verbose("-> done indexing of " //$NON-NLS-1$
+ + file.getName() + " (" //$NON-NLS-1$
+ + (System.currentTimeMillis() - initialTime) + "ms)"); //$NON-NLS-1$
+ } finally {
+ monitor.exitWrite(); // free write lock
+ }
+ } catch (IOException e) {
+ if (JobManager.VERBOSE) {
+ org.rubypeople.rdt.internal.core.util.Util.verbose("-> failed to index " + this.containerPath + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
+ e.printStackTrace();
+ }
+ manager.removeIndex(this.containerPath);
+ return false;
+ }
+ return true;
+ }
+
+ private void addDirectorysChildren(File file, String EXISTS, SimpleLookupTable indexedFileNames) {
+ File[] children = file.listFiles();
+ for (int i = 0; i < children.length; i++) {
+ String name = children[i].getName();
+ if (Util.isRubyLikeFileName(name)) {
+ indexedFileNames.put(name, EXISTS);
+ }
+ addDirectorysChildren(children[i], EXISTS, indexedFileNames);
+ }
+ }
+
+ protected Integer updatedIndexState() {
+ return IndexManager.REBUILDING_STATE;
+ }
+ public String toString() {
+ return "indexing " + this.containerPath.toString(); //$NON-NLS-1$
+ }
+
+ public boolean equals(Object o) {
+ if (o instanceof AddExternalFolderToIndex) {
+ if (this.containerPath != null)
+ return this.containerPath.equals(((AddExternalFolderToIndex) o).containerPath);
+ }
+ return false;
+ }
+ public int hashCode() {
+ if (this.containerPath != null)
+ return this.containerPath.hashCode();
+ return -1;
+ }
+
+}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java 2007-04-13 18:53:42 UTC (rev 2312)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java 2007-04-13 19:36:06 UTC (rev 2313)
@@ -254,12 +254,8 @@
IProject p = (IProject) target;
if (RubyProject.hasRubyNature(p))
request = new IndexAllProject(p, this);
-// } else if (target instanceof IFolder) {
-// request = new IndexBinaryFolder((IFolder) target, this);
-// } else if (target instanceof IFile) {
-// request = new AddJarFileToIndex((IFile) target, this);
} else if (target instanceof File) {
- request = new AddExternalFileToIndex(containerPath, this);
+ request = new AddExternalFolderToIndex(containerPath, this);
}
if (request != null)
request(request);
@@ -500,8 +496,25 @@
// TODO take into account the project?
return new SourceParser(requestor);
}
- public void indexLibrary(IPath projectPath, IProject project) {
- // XXX Actually implement this?!
+ public void indexLibrary(IPath path, IProject project) {
+// requestingProject is no longer used to cancel jobs but leave it here just in case
+ if (RubyCore.getPlugin() == null) return;
+
+ Object target = RubyModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), path, true);
+ IndexRequest request = null;
+ if (target instanceof java.io.File) {
+ if (((java.io.File) target).isDirectory()) {
+ request = new AddExternalFolderToIndex(path, this);
+ } else {
+ return;
+ }
+ } else {
+ return;
+ }
+
+ // check if the same request is not already in the queue
+ if (!isJobWaiting(request))
+ this.request(request);
}
/**
* Trigger addition of the entire content of a project
@@ -553,4 +566,35 @@
for (int i = 0, length = toRemove.size(); i < length; i++)
this.removeIndex((IPath) toRemove.get(i));
}
+
+ /**
+ * Recreates the index for a given path, keeping the same read-write monitor.
+ * Returns the new empty index or null if it didn't exist before.
+ * Warning: Does not check whether index is consistent (not being used)
+ */
+ public synchronized Index recreateIndex(IPath containerPath) {
+ // only called to over write an existing cached index...
+ String containerPathString = containerPath.getDevice() == null ? containerPath.toString() : containerPath.toOSString();
+ try {
+ // Path is already canonical
+ IPath indexLocation = computeIndexLocation(containerPath);
+
+ Index index = (Index) this.indexes.get(indexLocation);
+ ReadWriteMonitor monitor = index == null ? null : index.monitor;
+
+ if (VERBOSE)
+ Util.verbose("-> recreating index: "+indexLocation+" for path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$
+ index = new Index(indexLocation.toString(), containerPathString, false /*reuse index file*/);
+ this.indexes.put(indexLocation, index);
+ index.monitor = monitor;
+ return index;
+ } catch (IOException e) {
+ // The file could not be created. Possible reason: the project has been deleted.
+ if (VERBOSE) {
+ Util.verbose("-> failed to recreate index for path: "+containerPathString); //$NON-NLS-1$
+ e.printStackTrace();
+ }
+ return null;
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-13 18:53:48
|
Revision: 2312
http://svn.sourceforge.net/rubyeclipse/?rev=2312&view=rev
Author: cawilliams
Date: 2007-04-13 11:53:42 -0700 (Fri, 13 Apr 2007)
Log Message:
-----------
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-04-13 18:50:01 UTC (rev 2311)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-04-13 18:53:42 UTC (rev 2312)
@@ -142,18 +142,10 @@
}
private void suggestGlobals() {
- BasicSearchEngine engine = new BasicSearchEngine();
- SearchParticipant[] participants = new SearchParticipant[] { BasicSearchEngine.getDefaultSearchParticipant() };
- SearchPattern pattern = SearchPattern.createPattern(IRubyElement.GLOBAL, "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
+ SearchPattern pattern = SearchPattern.createPattern(IRubyElement.GLOBAL, "$*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
IRubySearchScope scope = BasicSearchEngine.createRubySearchScope(new IRubyElement[] {fContext.getScript().getRubyProject()});
- CollectingSearchRequestor requestor = new CollectingSearchRequestor();
- try {
- engine.search(pattern, participants, scope, requestor, null);
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- for (SearchMatch match: requestor.getResults()) {
+ List<SearchMatch> results = search(pattern, scope);
+ for (SearchMatch match: results) {
IRubyElement element = (IRubyElement) match.getElement();
String name = element.getElementName();
if (!fContext.prefixStartsWith(name))
@@ -164,19 +156,11 @@
}
}
- private void suggestTypeNames() {
- BasicSearchEngine engine = new BasicSearchEngine();
- SearchParticipant[] participants = new SearchParticipant[] { BasicSearchEngine.getDefaultSearchParticipant() };
+ private void suggestTypeNames() {
SearchPattern pattern = SearchPattern.createPattern(IRubyElement.TYPE, "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
IRubySearchScope scope = BasicSearchEngine.createRubySearchScope(new IRubyElement[] {fContext.getScript().getRubyProject()});
- CollectingSearchRequestor requestor = new CollectingSearchRequestor();
- try {
- engine.search(pattern, participants, scope, requestor, null);
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- for (SearchMatch match: requestor.getResults()) {
+ List<SearchMatch> results = search(pattern, scope);
+ for (SearchMatch match: results) {
IRubyElement element = (IRubyElement) match.getElement();
String name = element.getElementName();
if (!fContext.prefixStartsWith(name))
@@ -186,6 +170,19 @@
fRequestor.accept(proposal);
}
}
+
+ private List<SearchMatch> search(SearchPattern pattern, IRubySearchScope scope) {
+ BasicSearchEngine engine = new BasicSearchEngine();
+ SearchParticipant[] participants = new SearchParticipant[] { BasicSearchEngine.getDefaultSearchParticipant() };
+ CollectingSearchRequestor requestor = new CollectingSearchRequestor();
+ try {
+ engine.search(pattern, participants, scope, requestor, null);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return requestor.getResults();
+ }
private CompletionProposal createProposal(int replaceStart, int type, String name) {
CompletionProposal proposal = new CompletionProposal(type, name, 100);
@@ -194,21 +191,13 @@
}
private void suggestConstantNames() {
- BasicSearchEngine engine = new BasicSearchEngine();
- SearchParticipant[] participants = new SearchParticipant[] { BasicSearchEngine.getDefaultSearchParticipant() };
+ // TODO Do a regexp search for anything starting with an uppercase?
SearchPattern pattern = SearchPattern.createPattern(IRubyElement.CONSTANT, "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
IRubySearchScope scope = BasicSearchEngine.createRubySearchScope(new IRubyElement[] {fContext.getScript()});
- CollectingSearchRequestor requestor = new CollectingSearchRequestor();
- try {
- engine.search(pattern, participants, scope, requestor, null);
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- for (SearchMatch match: requestor.getResults()) {
+ List<SearchMatch> results = search(pattern, scope);
+ for (SearchMatch match: results) {
IRubyElement element = (IRubyElement) match.getElement();
String name = element.getElementName();
- // TODO Skip if not starting with an uppercase?
if (!fContext.prefixStartsWith(name))
continue;
CompletionProposal proposal = createProposal(fContext.getReplaceStart(), CompletionProposal.FIELD_REF, name);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-13 18:50:02
|
Revision: 2311
http://svn.sourceforge.net/rubyeclipse/?rev=2311&view=rev
Author: cawilliams
Date: 2007-04-13 11:50:01 -0700 (Fri, 13 Apr 2007)
Log Message:
-----------
Ha ha! I finally got this stuff working! I can actually look up constant and type names very quickly. Rock on!
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/Flags.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchConstants.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessor.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolderRoot.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SourceIndexer.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SourceIndexerRequestor.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/FieldLocator.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/FieldPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PatternLocator.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeDeclarationLocator.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeDeclarationPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/processing/JobManager.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
Added Paths:
-----------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/CollectingSearchRequestor.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/Flags.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/Flags.java 2007-04-13 16:00:49 UTC (rev 2310)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/Flags.java 2007-04-13 18:50:01 UTC (rev 2311)
@@ -16,6 +16,8 @@
* @since 3.0
*/
public static final int AccDefault = 0;
+
+ public static final int AccModule = 0x0001;
/**
* Returns whether the given integer includes the <code>private</code> modifier.
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchConstants.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchConstants.java 2007-04-13 16:00:49 UTC (rev 2310)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchConstants.java 2007-04-13 18:50:01 UTC (rev 2311)
@@ -32,4 +32,22 @@
* so as to better narrow down the search.
*/
int ALL_OCCURRENCES= 3;
+
+ /**
+ * When searching for field matches, it will exclusively find read accesses, as
+ * opposed to write accesses. Note that some expressions are considered both
+ * as field read/write accesses: for example, x++; x+= 1;
+ *
+ * @since 2.0
+ */
+ int READ_ACCESSES = 4;
+
+ /**
+ * When searching for field matches, it will exclusively find write accesses, as
+ * opposed to read accesses. Note that some expressions are considered both
+ * as field read/write accesses: for example, x++; x+= 1;
+ *
+ * @since 2.0
+ */
+ int WRITE_ACCESSES = 5;
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java 2007-04-13 16:00:49 UTC (rev 2310)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java 2007-04-13 18:50:01 UTC (rev 2311)
@@ -70,6 +70,18 @@
}
return this.script;
}
+
+ /**
+ * Returns the path to the original document to publicly mention in index
+ * or search results. This path is a string that uniquely identifies the document.
+ * Most of the time it is a workspace-relative path, but it can also be a file system path,
+ * or a path inside a zip file.
+ *
+ * @return the path to the document
+ */
+ public final String getPath() {
+ return this.documentPath;
+ }
private List<IRubyElement> getChildrenOfType(IParent parent, int type) {
List<IRubyElement> elements = new ArrayList<IRubyElement>();
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-04-13 16:00:49 UTC (rev 2310)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-04-13 18:50:01 UTC (rev 2311)
@@ -3,6 +3,7 @@
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.internal.core.search.indexing.IIndexConstants;
import org.rubypeople.rdt.internal.core.search.matching.ConstructorPattern;
+import org.rubypeople.rdt.internal.core.search.matching.FieldPattern;
import org.rubypeople.rdt.internal.core.search.matching.InternalSearchPattern;
import org.rubypeople.rdt.internal.core.search.matching.MethodPattern;
import org.rubypeople.rdt.internal.core.search.matching.OrPattern;
@@ -251,6 +252,12 @@
return createTypePattern(stringPattern, limitTo, matchRule, IIndexConstants.TYPE_SUFFIX);
case IRubyElement.METHOD:
return createMethodOrConstructorPattern(stringPattern, limitTo, matchRule, false/*not a constructor*/);
+ case IRubyElement.FIELD:
+ case IRubyElement.CONSTANT:
+ case IRubyElement.GLOBAL:
+ case IRubyElement.CLASS_VAR:
+ case IRubyElement.INSTANCE_VAR:
+ return createFieldPattern(stringPattern, limitTo, matchRule);
default:
break;
}
@@ -258,6 +265,55 @@
}
/**
+ * Field pattern are formed by [declaringType.]name[ type]
+ * e.g. java.lang.String.serialVersionUID long
+ * field*
+ */
+ private static SearchPattern createFieldPattern(String patternString, int limitTo, int matchRule) {
+ String fieldName = patternString;
+ if (fieldName == null) return null;
+
+ char[] fieldNameChars = fieldName.toCharArray();
+ if (fieldNameChars.length == 1 && fieldNameChars[0] == '*') fieldNameChars = null;
+
+ char[] declaringTypeQualification = null, declaringTypeSimpleName = null;
+ char[] typeQualification = null, typeSimpleName = null;
+
+ // Create field pattern
+ boolean findDeclarations = false;
+ boolean readAccess = false;
+ boolean writeAccess = false;
+ switch (limitTo) {
+ case IRubySearchConstants.DECLARATIONS :
+ findDeclarations = true;
+ break;
+ case IRubySearchConstants.REFERENCES :
+ readAccess = true;
+ writeAccess = true;
+ break;
+ case IRubySearchConstants.READ_ACCESSES :
+ readAccess = true;
+ break;
+ case IRubySearchConstants.WRITE_ACCESSES :
+ writeAccess = true;
+ break;
+ case IRubySearchConstants.ALL_OCCURRENCES :
+ findDeclarations = true;
+ readAccess = true;
+ writeAccess = true;
+ break;
+ }
+ return new FieldPattern(
+ findDeclarations,
+ readAccess,
+ writeAccess,
+ fieldNameChars,
+ declaringTypeQualification,
+ declaringTypeSimpleName,
+ matchRule);
+ }
+
+ /**
* Returns whether the given name matches the given pattern.
* <p>
* This method should be re-implemented in subclasses that need to define how
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-04-13 16:00:49 UTC (rev 2310)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-04-13 18:50:01 UTC (rev 2311)
@@ -11,6 +11,7 @@
import java.util.Set;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.jruby.ast.ClassNode;
import org.jruby.ast.ClassVarAsgnNode;
@@ -43,6 +44,7 @@
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.search.IRubySearchConstants;
import org.rubypeople.rdt.core.search.IRubySearchScope;
+import org.rubypeople.rdt.core.search.SearchMatch;
import org.rubypeople.rdt.core.search.SearchParticipant;
import org.rubypeople.rdt.core.search.SearchPattern;
import org.rubypeople.rdt.internal.core.RubyElement;
@@ -50,6 +52,7 @@
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.CollectingSearchRequestor;
import org.rubypeople.rdt.internal.core.util.ASTUtil;
import org.rubypeople.rdt.internal.ti.DefaultTypeInferrer;
import org.rubypeople.rdt.internal.ti.ITypeGuess;
@@ -139,11 +142,24 @@
}
private void suggestGlobals() {
- Set<String> globals = BasicSearchEngine.getGlobalNames(fContext.getScript());
- for (String name : globals) {
+ BasicSearchEngine engine = new BasicSearchEngine();
+ SearchParticipant[] participants = new SearchParticipant[] { BasicSearchEngine.getDefaultSearchParticipant() };
+ SearchPattern pattern = SearchPattern.createPattern(IRubyElement.GLOBAL, "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
+ IRubySearchScope scope = BasicSearchEngine.createRubySearchScope(new IRubyElement[] {fContext.getScript().getRubyProject()});
+ CollectingSearchRequestor requestor = new CollectingSearchRequestor();
+ try {
+ engine.search(pattern, participants, scope, requestor, null);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ for (SearchMatch match: requestor.getResults()) {
+ IRubyElement element = (IRubyElement) match.getElement();
+ String name = element.getElementName();
if (!fContext.prefixStartsWith(name))
continue;
CompletionProposal proposal = createProposal(fContext.getReplaceStart(), CompletionProposal.FIELD_REF, name);
+ proposal.setType(name);
fRequestor.accept(proposal);
}
}
@@ -153,9 +169,16 @@
SearchParticipant[] participants = new SearchParticipant[] { BasicSearchEngine.getDefaultSearchParticipant() };
SearchPattern pattern = SearchPattern.createPattern(IRubyElement.TYPE, "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
IRubySearchScope scope = BasicSearchEngine.createRubySearchScope(new IRubyElement[] {fContext.getScript().getRubyProject()});
- engine.search(pattern, participants, scope, requestor, null);
- Set<String> types = BasicSearchEngine.getTypeNames(fContext.getScript());
- for (String name : types) {
+ CollectingSearchRequestor requestor = new CollectingSearchRequestor();
+ try {
+ engine.search(pattern, participants, scope, requestor, null);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ for (SearchMatch match: requestor.getResults()) {
+ IRubyElement element = (IRubyElement) match.getElement();
+ String name = element.getElementName();
if (!fContext.prefixStartsWith(name))
continue;
CompletionProposal proposal = createProposal(fContext.getReplaceStart(), CompletionProposal.TYPE_REF, name);
@@ -171,11 +194,25 @@
}
private void suggestConstantNames() {
- Set<String> types = BasicSearchEngine.getConstantNames(fContext.getScript());
- for (String name : types) {
+ BasicSearchEngine engine = new BasicSearchEngine();
+ SearchParticipant[] participants = new SearchParticipant[] { BasicSearchEngine.getDefaultSearchParticipant() };
+ SearchPattern pattern = SearchPattern.createPattern(IRubyElement.CONSTANT, "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
+ IRubySearchScope scope = BasicSearchEngine.createRubySearchScope(new IRubyElement[] {fContext.getScript()});
+ CollectingSearchRequestor requestor = new CollectingSearchRequestor();
+ try {
+ engine.search(pattern, participants, scope, requestor, null);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ for (SearchMatch match: requestor.getResults()) {
+ IRubyElement element = (IRubyElement) match.getElement();
+ String name = element.getElementName();
+ // TODO Skip if not starting with an uppercase?
if (!fContext.prefixStartsWith(name))
continue;
CompletionProposal proposal = createProposal(fContext.getReplaceStart(), CompletionProposal.FIELD_REF, name);
+ proposal.setType(name);
fRequestor.accept(proposal);
}
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessor.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessor.java 2007-04-13 16:00:49 UTC (rev 2310)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessor.java 2007-04-13 18:50:01 UTC (rev 2311)
@@ -9,6 +9,7 @@
import java.util.Map;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
@@ -30,10 +31,13 @@
import org.rubypeople.rdt.core.IRubyModel;
import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.ISourceFolder;
import org.rubypeople.rdt.core.ISourceFolderRoot;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.internal.core.builder.RubyBuilder;
+import org.rubypeople.rdt.internal.core.search.indexing.IndexManager;
+import org.rubypeople.rdt.internal.core.util.CharOperation;
import org.rubypeople.rdt.internal.core.util.Util;
public class DeltaProcessor {
@@ -177,6 +181,8 @@
* is.
*/
public int overridenEventType = -1;
+
+ private SourceParser sourceElementParserCache;
public DeltaProcessor(DeltaProcessingState state, RubyModelManager manager) {
this.state = state;
@@ -1298,117 +1304,6 @@
return (ArrayList)this.state.otherRoots.get(path);
}
- /*
- * Update the current delta (ie. add/remove/change the given element) and
- * update the correponding index. Returns whether the children of the given
- * delta must be processed. @throws a RubyModelException if the delta
- * doesn't correspond to a ruby element of the given type.
- */
- public boolean updateCurrentDeltaAndIndex(IResourceDelta delta, int elementType, RootInfo rootInfo) {
- Openable element;
- switch (delta.getKind()) {
- case IResourceDelta.ADDED:
- IResource deltaRes = delta.getResource();
- element = createElement(deltaRes, elementType, rootInfo);
- if (element == null) {
- // resource might be containing shared roots (see bug 19058)
- this.state.updateRoots(deltaRes.getFullPath(), delta, this);
- return rootInfo != null && rootInfo.inclusionPatterns != null;
- }
- elementAdded(element, delta, rootInfo);
- return elementType == IRubyElement.SOURCE_FOLDER;
- case IResourceDelta.REMOVED:
- deltaRes = delta.getResource();
- element = createElement(deltaRes, elementType, rootInfo);
- if (element == null) {
- // resource might be containing shared roots (see bug 19058)
- this.state.updateRoots(deltaRes.getFullPath(), delta, this);
- return rootInfo != null && rootInfo.inclusionPatterns != null;
- }
- elementRemoved(element, delta, rootInfo);
-
- if (deltaRes.getType() == IResource.PROJECT) {
- // reset the corresponding project built state, since cannot
- // reuse if added back
- if (RubyBuilder.DEBUG)
- System.out.println("Clearing last state for removed project : " + deltaRes); //$NON-NLS-1$
- this.manager.setLastBuiltState((IProject)deltaRes, null /*no state*/);
-
- // clean up previous session containers (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=89850)
- this.manager.previousSessionContainers.remove(element);
- }
- return elementType == IRubyElement.SOURCE_FOLDER;
- case IResourceDelta.CHANGED:
- int flags = delta.getFlags();
- if ((flags & IResourceDelta.CONTENT) != 0 || (flags & IResourceDelta.ENCODING) != 0) {
- // content or encoding has changed
- element = createElement(delta.getResource(), elementType, rootInfo);
- if (element == null) return false;
- contentChanged(element);
- } else if (elementType == IRubyElement.RUBY_PROJECT) {
- if ((flags & IResourceDelta.OPEN) != 0) {
- // project has been opened or closed
- IProject res = (IProject) delta.getResource();
- element = createElement(res, elementType, rootInfo);
- if (element == null) { return false; }
- if (res.isOpen()) {
- if (RubyProject.hasRubyNature(res)) {
- addToParentInfo(element);
- currentDelta().opened(element);
- this.state.updateRoots(element.getPath(), delta, this);
-
- // refresh src folder roots and caches of the project (and its dependents)
- this.rootsToRefresh.add((IRubyProject)element);
- this.projectCachesToReset.add((IRubyProject)element);
-
-// this.manager.indexManager.indexAll(res);
- }
- } else {
- RubyModel javaModel = this.manager.getRubyModel();
- boolean wasJavaProject = javaModel.findRubyProject(res) != null;
- if (wasJavaProject) {
- close(element);
- removeFromParentInfo(element);
- currentDelta().closed(element);
- }
- }
- return false; // when a project is open/closed don't
- // process children
- }
- if ((flags & IResourceDelta.DESCRIPTION) != 0) {
- IProject res = (IProject) delta.getResource();
- RubyModel javaModel = this.manager.getRubyModel();
- boolean wasJavaProject = javaModel.findRubyProject(res) != null;
- boolean isJavaProject = RubyProject.hasRubyNature(res);
- if (wasJavaProject != isJavaProject) {
- // project's nature has been added or removed
- element = this.createElement(res, elementType, rootInfo);
- if (element == null) return false; // note its
- // resources are
- // still visible as
- // roots to other
- // projects
- if (isJavaProject) {
- elementAdded(element, delta, rootInfo);
- } else {
- elementRemoved(element, delta, rootInfo);
- // reset the corresponding project built state,
- // since cannot reuse if added back
- if (RubyBuilder.DEBUG)
- System.out
- .println("Clearing last state for project losing Ruby nature: " + res); //$NON-NLS-1$
-
- }
- return false; // when a project's nature is
- // added/removed don't process children
- }
- }
- }
- return true;
- }
- return true;
- }
-
/*
* Closes the given element, which removes it from the cache of open
* elements.
@@ -1879,5 +1774,245 @@
}
}
}
+
+ private void updateIndex(Openable element, IResourceDelta delta) {
+
+ IndexManager indexManager = this.manager.getIndexManager();
+ if (indexManager == null)
+ return;
+
+ switch (element.getElementType()) {
+ case IRubyElement.RUBY_PROJECT :
+ switch (delta.getKind()) {
+ case IResourceDelta.ADDED :
+ indexManager.indexAll(element.getRubyProject().getProject());
+ break;
+ case IResourceDelta.REMOVED :
+ indexManager.removeIndexFamily(element.getRubyProject().getProject().getFullPath());
+ // NB: Discarding index jobs belonging to this project was done during PRE_DELETE
+ break;
+ // NB: Update of index if project is opened, closed, or its java nature is added or removed
+ // is done in updateCurrentDeltaAndIndex
+ }
+ break;
+ case IRubyElement.SOURCE_FOLDER_ROOT :
+ if (element instanceof ExternalSourceFolderRoot) {
+ ExternalSourceFolderRoot root = (ExternalSourceFolderRoot)element;
+ // index jar file only once (if the root is in its declaring project)
+ IPath jarPath = root.getPath();
+ switch (delta.getKind()) {
+ case IResourceDelta.ADDED:
+ // index the new jar
+ indexManager.indexLibrary(jarPath, root.getRubyProject().getProject());
+ break;
+ case IResourceDelta.CHANGED:
+ // first remove the index so that it is forced to be re-indexed
+ indexManager.removeIndex(jarPath);
+ // then index the jar
+ indexManager.indexLibrary(jarPath, root.getRubyProject().getProject());
+ break;
+ case IResourceDelta.REMOVED:
+ // the jar was physically removed: remove the index
+ indexManager.discardJobs(jarPath.toString());
+ indexManager.removeIndex(jarPath);
+ break;
+ }
+ break;
+ }
+ int kind = delta.getKind();
+ if (kind == IResourceDelta.ADDED || kind == IResourceDelta.REMOVED) {
+ SourceFolderRoot root = (SourceFolderRoot)element;
+ this.updateRootIndex(root, CharOperation.NO_STRINGS, delta);
+ break;
+ }
+ // don't break as packages of the package fragment root can be indexed below
+ case IRubyElement.SOURCE_FOLDER :
+ switch (delta.getKind()) {
+ case IResourceDelta.ADDED:
+ case IResourceDelta.REMOVED:
+ ISourceFolder pkg = null;
+ if (element instanceof ISourceFolderRoot) {
+ SourceFolderRoot root = (SourceFolderRoot)element;
+ pkg = root.getSourceFolder(CharOperation.NO_STRINGS);
+ } else {
+ pkg = (ISourceFolder)element;
+ }
+ RootInfo rootInfo = rootInfo(pkg.getParent().getPath(), delta.getKind());
+ boolean isSource =
+ rootInfo == null // if null, defaults to source
+ || rootInfo.entryKind == ILoadpathEntry.CPE_SOURCE;
+ IResourceDelta[] children = delta.getAffectedChildren();
+ for (int i = 0, length = children.length; i < length; i++) {
+ IResourceDelta child = children[i];
+ IResource resource = child.getResource();
+ // TODO (philippe) Why do this? Every child is added anyway as the delta is walked
+ if (resource instanceof IFile) {
+ String name = resource.getName();
+ if (isSource) {
+ if (org.rubypeople.rdt.internal.core.util.Util.isRubyLikeFileName(name)) {
+ Openable cu = (Openable)pkg.getRubyScript(name);
+ this.updateIndex(cu, child);
+ }
+ }
+ }
+ }
+ break;
+ }
+ break;
+ case IRubyElement.SCRIPT :
+ IFile file = (IFile) delta.getResource();
+ switch (delta.getKind()) {
+ case IResourceDelta.CHANGED :
+ // no need to index if the content has not changed
+ int flags = delta.getFlags();
+ if ((flags & IResourceDelta.CONTENT) == 0 && (flags & IResourceDelta.ENCODING) == 0)
+ break;
+ case IResourceDelta.ADDED :
+ indexManager.addSource(file, file.getProject().getFullPath(), getSourceElementParser(element));
+ // Clean file from secondary types cache but do not update indexing secondary type cache as it will be updated through indexing itself
+ this.manager.secondaryTypesRemoving(file, false);
+ break;
+ case IResourceDelta.REMOVED :
+ indexManager.remove(Util.relativePath(file.getFullPath(), 1/*remove project segment*/), file.getProject().getFullPath());
+ // Clean file from secondary types cache and update indexing secondary type cache as indexing cannot remove secondary types from cache
+ this.manager.secondaryTypesRemoving(file, true);
+ break;
+ }
+ }
+ }
+ private SourceParser getSourceElementParser(Openable element) {
+ if (this.sourceElementParserCache == null)
+ this.sourceElementParserCache = this.manager.getIndexManager().getSourceElementParser(element.getRubyProject(), null/*requestor will be set by indexer*/);
+ return this.sourceElementParserCache;
+ }
+
+ /*
+ * Updates the index of the given root (assuming it's an addition or a removal).
+ * This is done recusively, pkg being the current package.
+ */
+ private void updateRootIndex(SourceFolderRoot root, String[] pkgName, IResourceDelta delta) {
+ Openable pkg = root.getSourceFolder(pkgName);
+ this.updateIndex(pkg, delta);
+ IResourceDelta[] children = delta.getAffectedChildren();
+ for (int i = 0, length = children.length; i < length; i++) {
+ IResourceDelta child = children[i];
+ IResource resource = child.getResource();
+ if (resource instanceof IFolder) {
+ String[] subpkgName = Util.arrayConcat(pkgName, resource.getName());
+ this.updateRootIndex(root, subpkgName, child);
+ }
+ }
+ }
+
+ /*
+ * Update the current delta (ie. add/remove/change the given element) and update the correponding index.
+ * Returns whether the children of the given delta must be processed.
+ * @throws a JavaModelException if the delta doesn't correspond to a java element of the given type.
+ */
+ public boolean updateCurrentDeltaAndIndex(IResourceDelta delta, int elementType, RootInfo rootInfo) {
+ Openable element;
+ switch (delta.getKind()) {
+ case IResourceDelta.ADDED :
+ IResource deltaRes = delta.getResource();
+ element = createElement(deltaRes, elementType, rootInfo);
+ if (element == null) {
+ // resource might be containing shared roots (see bug 19058)
+ this.state.updateRoots(deltaRes.getFullPath(), delta, this);
+ return rootInfo != null && rootInfo.inclusionPatterns != null;
+ }
+ updateIndex(element, delta);
+ elementAdded(element, delta, rootInfo);
+ return elementType == IRubyElement.SOURCE_FOLDER;
+ case IResourceDelta.REMOVED :
+ deltaRes = delta.getResource();
+ element = createElement(deltaRes, elementType, rootInfo);
+ if (element == null) {
+ // resource might be containing shared roots (see bug 19058)
+ this.state.updateRoots(deltaRes.getFullPath(), delta, this);
+ return rootInfo != null && rootInfo.inclusionPatterns != null;
+ }
+ updateIndex(element, delta);
+ elementRemoved(element, delta, rootInfo);
+
+ if (deltaRes.getType() == IResource.PROJECT){
+ // reset the corresponding project built state, since cannot reuse if added back
+ if (RubyBuilder.DEBUG)
+ System.out.println("Clearing last state for removed project : " + deltaRes); //$NON-NLS-1$
+ this.manager.setLastBuiltState((IProject)deltaRes, null /*no state*/);
+
+ // clean up previous session containers (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=89850)
+ this.manager.previousSessionContainers.remove(element);
+ }
+ return elementType == IRubyElement.SOURCE_FOLDER;
+ case IResourceDelta.CHANGED :
+ int flags = delta.getFlags();
+ if ((flags & IResourceDelta.CONTENT) != 0 || (flags & IResourceDelta.ENCODING) != 0) {
+ // content or encoding has changed
+ element = createElement(delta.getResource(), elementType, rootInfo);
+ if (element == null) return false;
+ updateIndex(element, delta);
+ contentChanged(element);
+ } else if (elementType == IRubyElement.RUBY_PROJECT) {
+ if ((flags & IResourceDelta.OPEN) != 0) {
+ // project has been opened or closed
+ IProject res = (IProject)delta.getResource();
+ element = createElement(res, elementType, rootInfo);
+ if (element == null) {
+ // resource might be containing shared roots (see bug 19058)
+ this.state.updateRoots(res.getFullPath(), delta, this);
+ return false;
+ }
+ if (res.isOpen()) {
+ if (RubyProject.hasRubyNature(res)) {
+ addToParentInfo(element);
+ currentDelta().opened(element);
+ this.state.updateRoots(element.getPath(), delta, this);
+
+ // refresh pkg fragment roots and caches of the project (and its dependents)
+ this.rootsToRefresh.add((IRubyProject)element);
+ this.projectCachesToReset.add((IRubyProject)element);
+
+ this.manager.getIndexManager().indexAll(res);
+ }
+ } else {
+ boolean wasJavaProject = this.state.findRubyProject(res.getName()) != null;
+ if (wasJavaProject) {
+ close(element);
+ removeFromParentInfo(element);
+ currentDelta().closed(element);
+ this.manager.getIndexManager().discardJobs(element.getElementName());
+ this.manager.getIndexManager().removeIndexFamily(res.getFullPath());
+ }
+ }
+ return false; // when a project is open/closed don't process children
+ }
+ if ((flags & IResourceDelta.DESCRIPTION) != 0) {
+ IProject res = (IProject)delta.getResource();
+ boolean wasJavaProject = this.state.findRubyProject(res.getName()) != null;
+ boolean isJavaProject = RubyProject.hasRubyNature(res);
+ if (wasJavaProject != isJavaProject) {
+ // project's nature has been added or removed
+ element = this.createElement(res, elementType, rootInfo);
+ if (element == null) return false; // note its resources are still visible as roots to other projects
+ if (isJavaProject) {
+ elementAdded(element, delta, rootInfo);
+ this.manager.getIndexManager().indexAll(res);
+ } else {
+ elementRemoved(element, delta, rootInfo);
+ this.manager.getIndexManager().discardJobs(element.getElementName());
+ this.manager.getIndexManager().removeIndexFamily(res.getFullPath());
+ // reset the corresponding project built state, since cannot reuse if added back
+ if (RubyBuilder.DEBUG)
+ System.out.println("Clearing last state for project loosing Java nature: " + res); //$NON-NLS-1$
+ this.manager.setLastBuiltState(res, null /*no state*/);
+ }
+ return false; // when a project's nature is added/removed don't process children
+ }
+ }
+ }
+ return true;
+ }
+ return true;
+ }
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java 2007-04-13 16:00:49 UTC (rev 2310)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java 2007-04-13 18:50:01 UTC (rev 2311)
@@ -75,6 +75,7 @@
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.ISourceFolder;
import org.rubypeople.rdt.core.ISourceFolderRoot;
+import org.rubypeople.rdt.core.IType;
import org.rubypeople.rdt.core.LoadpathContainerInitializer;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
@@ -115,6 +116,7 @@
public static final String DELTA_LISTENER_PERF = RubyCore.PLUGIN_ID + "/perf/rubydeltalistener"; //$NON-NLS-1$
public static final String RECONCILE_PERF = RubyCore.PLUGIN_ID + "/perf/reconcile"; //$NON-NLS-1$
+ private final static String INDEXED_SECONDARY_TYPES = "#@*_indexing secondary cache_*@#"; //$NON-NLS-1$
/**
* Name of the extension point for contributing classpath variable initializers
@@ -746,6 +748,7 @@
public Map resolvedPathToRawEntries; // reverse map from resolved
// path to raw entries
public IPath outputLocation;
+ public Hashtable secondaryTypes;
public IEclipsePreferences preferences;
public Hashtable options;
@@ -943,7 +946,7 @@
| IResourceChangeEvent.PRE_DELETE
| IResourceChangeEvent.PRE_CLOSE);
-// startIndexing();
+ startIndexing();
// process deltas since last activated in indexer thread so that indexes are up-to-date.
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658
@@ -980,6 +983,14 @@
}
}
+ /**
+ * Initiate the background indexing process.
+ * This should be deferred after the plugin activation.
+ */
+ private void startIndexing() {
+ getIndexManager().reset();
+ }
+
public void loadVariablesAndContainers() throws CoreException {
// backward compatibility, consider persistent property
QualifiedName qName = new QualifiedName(RubyCore.PLUGIN_ID, "variables"); //$NON-NLS-1$
@@ -2783,4 +2794,120 @@
return indexManager;
}
+ /**
+ * Remove from secondary types cache all types belonging to a given file.
+ * Clean secondary types cache built while indexing if requested.
+ *
+ * Project's secondary types cache is found using file location.
+ *
+ * @param file File to remove
+ */
+ public void secondaryTypesRemoving(IFile file, boolean cleanIndexCache) {
+ if (VERBOSE) {
+ StringBuffer buffer = new StringBuffer("JavaModelManager.removeFromSecondaryTypesCache("); //$NON-NLS-1$
+ buffer.append(file.getName());
+ buffer.append(')');
+ Util.verbose(buffer.toString());
+ }
+ if (file != null) {
+ PerProjectInfo projectInfo = getPerProjectInfo(file.getProject(), false);
+ if (projectInfo != null && projectInfo.secondaryTypes != null) {
+ if (VERBOSE) {
+ Util.verbose("-> remove file from cache of project: "+file.getProject().getName()); //$NON-NLS-1$
+ }
+
+ // Clean current cache
+ secondaryTypesRemoving(projectInfo.secondaryTypes, file);
+
+ // Clean indexing cache if necessary
+ if (!cleanIndexCache) return;
+ HashMap indexingCache = (HashMap) projectInfo.secondaryTypes.get(INDEXED_SECONDARY_TYPES);
+ if (indexingCache != null) {
+ Set keys = indexingCache.keySet();
+ int filesSize = keys.size(), filesCount = 0;
+ IFile[] removed = null;
+ Iterator cachedFiles = keys.iterator();
+ while (cachedFiles.hasNext()) {
+ IFile cachedFile = (IFile) cachedFiles.next();
+ if (file.equals(cachedFile)) {
+ if (removed == null) removed = new IFile[filesSize];
+ filesSize--;
+ removed[filesCount++] = cachedFile;
+ }
+ }
+ if (removed != null) {
+ for (int i=0; i<filesCount; i++) {
+ indexingCache.remove(removed[i]);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * Remove from a given cache map all secondary types belonging to a given file.
+ * Note that there can have several secondary types per file...
+ */
+ private void secondaryTypesRemoving(Hashtable secondaryTypesMap, IFile file) {
+ if (VERBOSE) {
+ StringBuffer buffer = new StringBuffer("RubyModelManager.removeSecondaryTypesFromMap("); //$NON-NLS-1$
+ Iterator keys = secondaryTypesMap.keySet().iterator();
+ while (keys.hasNext()) {
+ String qualifiedName = (String) keys.next();
+ buffer.append(qualifiedName+':'+secondaryTypesMap.get(qualifiedName));
+ }
+ buffer.append(',');
+ buffer.append(file.getFullPath());
+ buffer.append(')');
+ Util.verbose(buffer.toString());
+ }
+ Set packageKeys = secondaryTypesMap.keySet();
+ int packagesSize = packageKeys.size(), removedPackagesCount = 0;
+ String[] removedPackages = null;
+ Iterator packages = packageKeys.iterator();
+ while (packages.hasNext()) {
+ String packName = (String) packages.next();
+ if (packName != INDEXED_SECONDARY_TYPES) { // skip indexing cache entry if present (!= is intentional)
+ HashMap types = (HashMap) secondaryTypesMap.get(packName);
+ Set nameKeys = types.keySet();
+ int namesSize = nameKeys.size(), removedNamesCount = 0;
+ String[] removedNames = null;
+ Iterator names = nameKeys.iterator();
+ while (names.hasNext()) {
+ String typeName = (String) names.next();
+ IType type = (IType) types.get(typeName);
+ if (file.equals(type.getResource())) {
+ if (removedNames == null) removedNames = new String[namesSize];
+ namesSize--;
+ removedNames[removedNamesCount++] = typeName;
+ }
+ }
+ if (removedNames != null) {
+ for (int i=0; i<removedNamesCount; i++) {
+ types.remove(removedNames[i]);
+ }
+ }
+ if (types.size() == 0) {
+ if (removedPackages == null) removedPackages = new String[packagesSize];
+ packagesSize--;
+ removedPackages[removedPackagesCount++] = packName;
+ }
+ }
+ }
+ if (removedPackages != null) {
+ for (int i=0; i<removedPackagesCount; i++) {
+ secondaryTypesMap.remove(removedPackages[i]);
+ }
+ }
+ if (VERBOSE) {
+ Util.verbose(" - new secondary types map:"); //$NON-NLS-1$
+ Iterator keys = secondaryTypesMap.keySet().iterator();
+ while (keys.hasNext()) {
+ String qualifiedName = (String) keys.next();
+ Util.verbose(" + "+qualifiedName+':'+secondaryTypesMap.get(qualifiedName) ); //$NON-NLS-1$
+ }
+ }
+ }
+
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolderRoot.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolderRoot.java 2007-04-13 16:00:49 UTC (rev 2310)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolderRoot.java 2007-04-13 18:50:01 UTC (rev 2311)
@@ -244,7 +244,7 @@
return super.exists() && validateOnLoadpath().isOK();
}
- public ISourceFolder getSourceFolder(String[] names) {
+ public SourceFolder getSourceFolder(String[] names) {
return new SourceFolder(this, names);
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java 2007-04-13 16:00:49 UTC (rev 2310)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java 2007-04-13 18:50:01 UTC (rev 2311)
@@ -1,7 +1,10 @@
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 org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -9,11 +12,13 @@
import org.eclipse.core.runtime.SubProgressMonitor;
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.core.WorkingCopyOwner;
import org.rubypeople.rdt.core.search.IRubySearchConstants;
import org.rubypeople.rdt.core.search.IRubySearchScope;
import org.rubypeople.rdt.core.search.SearchDocument;
+import org.rubypeople.rdt.core.search.SearchMatch;
import org.rubypeople.rdt.core.search.SearchParticipant;
import org.rubypeople.rdt.core.search.SearchPattern;
import org.rubypeople.rdt.core.search.SearchRequestor;
@@ -28,7 +33,7 @@
public class BasicSearchEngine {
- public static final boolean VERBOSE = false;
+ public static final boolean VERBOSE = true;
/*
* A list of working copies that take precedence over their original
@@ -233,4 +238,30 @@
public static IRubySearchScope createWorkspaceScope() {
return RubyModelManager.getRubyModelManager().getWorkspaceScope();
}
+
+ public static Collection<? extends IType> findType(String typeName) {
+ SearchPattern pattern = SearchPattern.createPattern(IRubyElement.TYPE, typeName, IRubySearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH);
+ SearchParticipant[] participants = new SearchParticipant[] {getDefaultSearchParticipant()};
+ IRubySearchScope scope = createWorkspaceScope();
+ TypeRequestor requestor = new TypeRequestor();
+ try {
+ new BasicSearchEngine().search(pattern, participants, scope, requestor, null);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return requestor.getTypes();
+ }
+
+ private static class TypeRequestor extends SearchRequestor {
+ private List<IType> types = new ArrayList<IType>();
+ @Override
+ public void acceptSearchMatch(SearchMatch match) throws CoreException {
+ Object element = match.getElement();
+ types.add((IType) element);
+ }
+ public List<IType> getTypes() {
+ return types;
+ }
+ }
}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/CollectingSearchRequestor.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/CollectingSearchRequestor.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/CollectingSearchRequestor.java 2007-04-13 18:50:01 UTC (rev 2311)
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.rubypeople.rdt.core.search.SearchMatch;
+import org.rubypeople.rdt.core.search.SearchRequestor;
+
+/**
+ * Collects the results returned by a <code>SearchEngine</code>.
+ */
+public class CollectingSearchRequestor extends SearchRequestor {
+ private ArrayList<SearchMatch> fFound;
+
+ public CollectingSearchRequestor() {
+ fFound = new ArrayList<SearchMatch>();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jdt.core.search.SearchRequestor#acceptSearchMatch(org.eclipse.jdt.core.search.SearchMatch)
+ */
+ public void acceptSearchMatch(SearchMatch match) throws CoreException {
+ fFound.add(match);
+ }
+
+ /**
+ * @return a List of {@link SearchMatch}es (not sorted)
+ */
+ public List<SearchMatch> getResults() {
+ return fFound;
+ }
+}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java 2007-04-13 16:00:49 UTC (rev 2310)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java 2007-04-13 18:50:01 UTC (rev 2311)
@@ -4,6 +4,7 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.zip.CRC32;
import org.eclipse.core.resources.IFile;
@@ -13,8 +14,10 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.rubypeople.rdt.core.ILoadpathEntry;
import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.search.IRubySearchScope;
import org.rubypeople.rdt.core.search.SearchDocument;
import org.rubypeople.rdt.core.search.SearchParticipant;
@@ -22,6 +25,7 @@
import org.rubypeople.rdt.internal.compiler.util.SimpleLookupTable;
import org.rubypeople.rdt.internal.compiler.util.SimpleSet;
import org.rubypeople.rdt.internal.core.RubyModel;
+import org.rubypeople.rdt.internal.core.RubyModelManager;
import org.rubypeople.rdt.internal.core.RubyProject;
import org.rubypeople.rdt.internal.core.SourceParser;
import org.rubypeople.rdt.internal.core.index.DiskIndex;
@@ -408,7 +412,7 @@
if (RubyCore.getPlugin() == null) return;
SearchParticipant participant = BasicSearchEngine.getDefaultSearchParticipant();
SearchDocument document = participant.getDocument(resource.getFullPath().toString());
-// ((InternalSearchDocument) document).parser = parser; FIXME Uncomment and fix this when we have participants
+ ((InternalSearchDocument) document).parser = parser;
IPath indexLocation = computeIndexLocation(containerPath);
scheduleDocumentIndexing(document, containerPath, indexLocation, participant);
}
@@ -499,4 +503,54 @@
public void indexLibrary(IPath projectPath, IProject project) {
// XXX Actually implement this?!
}
+ /**
+ * Trigger addition of the entire content of a project
+ * Note: the actual operation is performed in background
+ */
+ public void indexAll(IProject project) {
+ if (RubyCore.getPlugin() == null) return;
+
+ // Also request indexing of binaries on the classpath
+ // determine the new children
+ try {
+ RubyModel model = RubyModelManager.getRubyModelManager().getRubyModel();
+ RubyProject javaProject = (RubyProject) model.getRubyProject(project);
+ // only consider immediate libraries - each project will do the same
+ // NOTE: force to resolve CP variables before calling indexer - 19303, so that initializers
+ // will be run in the current thread.
+ ILoadpathEntry[] entries = javaProject.getResolvedLoadpath(true/*ignoreUnresolvedEntry*/, false/*don't generateMarkerOnError*/, false/*don't returnResolutionInProgress*/);
+ for (int i = 0; i < entries.length; i++) {
+ ILoadpathEntry entry= entries[i];
+ if (entry.getEntryKind() == ILoadpathEntry.CPE_LIBRARY)
+ this.indexLibrary(entry.getPath(), project);
+ }
+ } catch(RubyModelException e){ // cannot retrieve classpath info
+ }
+
+ // check if the same request is not already in the queue
+ IndexRequest request = new IndexAllProject(project, this);
+ if (!isJobWaiting(request))
+ this.request(request);
+ }
+
+ /**
+ * Removes all indexes whose paths start with (or are equal to) the given path.
+ */
+ public synchronized void removeIndexFamily(IPath path) {
+ // only finds cached index files... shutdown removes all non-cached index files
+ ArrayList toRemove = null;
+ Object[] containerPaths = this.indexLocations.keyTable;
+ for (int i = 0, length = containerPaths.length; i < length; i++) {
+ IPath containerPath = (IPath) containerPaths[i];
+ if (containerPath == null) continue;
+ if (path.isPrefixOf(containerPath)) {
+ if (toRemove == null)
+ toRemove = new ArrayList();
+ toRemove.add(containerPath);
+ }
+ }
+ if (toRemove != null)
+ for (int i = 0, length = toRemove.size(); i < length; i++)
+ this.removeIndex((IPath) toRemove.get(i));
+ }
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SourceIndexer.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SourceIndexer.java 2007-04-13 16:00:49 UTC (rev 2310)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SourceIndexer.java 2007-04-13 18:50:01 UTC (rev 2311)
@@ -4,15 +4,18 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.jruby.ast.Node;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.search.SearchDocument;
import org.rubypeople.rdt.internal.core.RubyModelManager;
import org.rubypeople.rdt.internal.core.SourceParser;
-import org.rubypeople.rdt.internal.core.parser.RubyParser;
+import org.rubypeople.rdt.internal.core.search.matching.ConstructorPattern;
+import org.rubypeople.rdt.internal.core.search.matching.FieldPattern;
+import org.rubypeople.rdt.internal.core.search.matching.MethodPattern;
+import org.rubypeople.rdt.internal.core.search.matching.TypeDeclarationPattern;
import org.rubypeople.rdt.internal.core.search.processing.JobManager;
+import org.rubypeople.rdt.internal.core.util.CharOperation;
-public class SourceIndexer {
+public class SourceIndexer implements IIndexConstants {
private SearchDocument document;
@@ -32,21 +35,20 @@
} else {
parser.requestor = requestor;
}
-
+
// Launch the parser
char[] source = null;
char[] name = null;
try {
source = document.getCharContents();
name = documentPath.toCharArray();
- } catch(Exception e){
+ } catch (Exception e) {
// ignore
}
- if (source == null || name == null) return; // could not retrieve document info (e.g. resource was discarded)
+ if (source == null || name == null)
+ return; // could not retrieve document info (e.g. resource was
+ // discarded)
try {
- RubyParser p = new RubyParser();
- Node ast = p.parse(new String(source));
- parser.acceptNode(ast);
parser.parse(source, name);
} catch (Exception e) {
if (JobManager.VERBOSE) {
@@ -55,4 +57,60 @@
}
}
+ public void addClassDeclaration(int modifiers, char[] packageName, char[] name, char[][] enclosingTypeNames, char[] superclass, char[][] superinterfaces, boolean secondary) {
+ char[] indexKey = TypeDeclarationPattern.createIndexKey(modifiers, name, packageName, enclosingTypeNames, secondary);
+ addIndexEntry(TYPE_DECL, indexKey);
+
+ if (superclass != null) {
+ addTypeReference(superclass);
+ }
+ // FIXME Add back in references to super type when we have SuperTypePattern!
+// addIndexEntry(SUPER_REF, SuperTypeReferencePattern.createIndexKey(modifiers, packageName, name, enclosingTypeNames, typeParameterSignatures, CLASS_SUFFIX, superclass, CLASS_SUFFIX));
+// if (superinterfaces != null) {
+// for (int i = 0, max = superinterfaces.length; i < max; i++) {
+// char[] superinterface = superinterfaces[i];
+// addTypeReference(superinterface);
+// addIndexEntry(SUPER_REF, SuperTypeReferencePattern.createIndexKey(modifiers, packageName, name, enclosingTypeNames, typeParameterSignatures, CLASS_SUFFIX, superinterface, MODULE_SUFFIX));
+// }
+// }
+ }
+
+ public void addFieldDeclaration(char[] typeName, char[] fieldName) {
+ addIndexEntry(FIELD_DECL, FieldPattern.createIndexKey(fieldName));
+ addTypeReference(typeName);
+ }
+ public void addFieldReference(char[] fieldName) {
+ addNameReference(fieldName);
+ }
+
+ public void addMethodDeclaration(char[] methodName, int arity) {
+ addIndexEntry(METHOD_DECL, MethodPattern.createIndexKey(methodName, arity));
+ }
+
+ public void addMethodReference(char[] methodName, int argCount) {
+ addIndexEntry(METHOD_REF, MethodPattern.createIndexKey(methodName, argCount));
+ }
+
+ public void addNameReference(char[] name) {
+ addIndexEntry(REF, name);
+ }
+
+ public void addTypeReference(char[] typeName) {
+ addNameReference(CharOperation.lastSegment(typeName, "::"));
+ }
+
+ protected void addIndexEntry(char[] category, char[] key) {
+ this.document.addIndexEntry(category, key);
+ }
+
+ public void addConstructorDeclaration(char[] typeName, int argCount) {
+ addIndexEntry(CONSTRUCTOR_DECL, ConstructorPattern.createIndexKey(CharOperation.lastSegment(typeName, "::"), argCount));
+ }
+
+ public void addConstructorReference(char[] typeName, int argCount) {
+ char[] simpleTypeName = CharOperation.lastSegment(typeName, "::");
+ addTypeReference(simpleTypeName);
+ addIndexEntry(CONSTRUCTOR_REF, ConstructorPattern.createIndexKey(simpleTypeName, argCount));
+ }
+
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SourceIndexerRequestor.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SourceIndexerRequestor.java 2007-04-13 16:00:49 UTC (rev 2310)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SourceIndexerRequestor.java 2007-04-13 18:50:01 UTC (rev 2311)
@@ -1,5 +1,6 @@
package org.rubypeople.rdt.internal.core.search.indexing;
+import org.rubypeople.rdt.core.Flags;
import org.rubypeople.rdt.core.compiler.CategorizedProblem;
import org.rubypeople.rdt.internal.compiler.ISourceElementRequestor;
@@ -12,8 +13,7 @@
}
public void acceptConstructorReference(String name, int argCount, int offset) {
- // TODO Auto-generated method stub
-
+ indexer.addConstructorReference(name.toCharArray(), argCount);
}
public void acceptFieldReference(String name, int offset) {
@@ -27,8 +27,7 @@
}
public void acceptMethodReference(String name, int argCount, int offset) {
- // TODO Auto-generated method stub
-
+ indexer.addMethodReference(name.toCharArray(), argCount);
}
public void acceptMixin(String string) {
@@ -42,8 +41,7 @@
}
public void acceptTypeReference(String name, int startOffset, int endOffset) {
- // TODO Auto-generated method stub
-
+ indexer.addTypeReference(name.toCharArray());
}
public void acceptUnknownReference(String name, int startOffset,
@@ -53,18 +51,15 @@
}
public void enterConstructor(MethodInfo constructor) {
- // TODO Auto-generated method stub
-
+ indexer.addConstructorDeclaration(constructor.name.toCharArray(), constructor.parameterNames.length);
}
public void enterField(FieldInfo field) {
- // TODO Auto-generated method stub
-
+ indexer.addFieldDeclaration(null, field.name.toCharArray());
}
public void enterMethod(MethodInfo method) {
- // TODO Auto-generated method stub
-
+ indexer.addMethodDeclaration(method.name.toCharArray(), method.parameterNames.length);
}
public void enterScript() {
@@ -72,9 +67,14 @@
}
- public void enterType(TypeInfo type) {
- // TODO Auto-generated method stub
-
+ public void enterType(TypeInfo type) {
+ String[] modules = type.modules;
+ char[][] mod = new char[modules.length][];
+ for (int i = 0; i < modules.length; i++) {
+ mod[i] = modules[i].toCharArray();
+ }
+ char[] packName = new char[0];
+ indexer.addClassDeclaration(type.isModule ? Flags.AccModule : 0, type.name.toCharArray(), packName, null, type.superclass.toCharArray(), mod, type.secondary);
}
public void exitConstructor(int endOffset) {
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/FieldLocator.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/FieldLocator.java 2007-04-13 16:00:49 UTC (rev 2310)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/FieldLocator.java 2007-04-13 18:50:01 UTC (rev 2311)
@@ -1,11 +1,74 @@
package org.rubypeople.rdt.internal.core.search.matching;
-import org.rubypeople.rdt.core.search.SearchPattern;
+import org.eclipse.core.runtime.CoreException;
+import org.rubypeople.rdt.core.IField;
+import org.rubypeople.rdt.core.IMember;
+import org.rubypeople.rdt.core.IParent;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.ISourceRange;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.internal.core.RubyScript;
public class FieldLocator extends PatternLocator {
- public FieldLocator(SearchPattern pattern) {
+ private FieldPattern pattern;
+
+ public FieldLocator(FieldPattern pattern) {
super(pattern);
+ this.pattern = pattern;
}
+
+ @Override
+ public void reportMatches(RubyScript script, MatchLocator locator) {
+ reportMatches((IParent) script, locator);
+ }
+ private void reportMatches(IParent parent, MatchLocator locator) {
+ try {
+ IRubyElement[] children = parent.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ IRubyElement child = children[i];
+ if (child.isType(IRubyElement.FIELD) ||
+ child.isType(IRubyElement.GLOBAL) ||
+ child.isType(IRubyElement.CONSTANT) ||
+ child.isType(IRubyElement.CLASS_VAR) ||
+ child.isType(IRubyElement.INSTANCE_VAR)) {
+ int accuracy = getAccuracy((IField) child);
+ if (accuracy != IMPOSSIBLE_MATCH) {
+ IMember member = (IMember) child;
+ ISourceRange range = member.getSourceRange();
+ try {
+ locator.report(locator.newDeclarationMatch(child, accuracy, range.getOffset(), range.getLength()));
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ if (child instanceof IParent) {
+ IParent parentTwo = (IParent) child;
+ reportMatches(parentTwo, locator);
+ }
+ }
+ } catch (RubyModelException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ private int getAccuracy(IField field) {
+ if (this.pattern.findReferences)
+ // must be a write only access with an initializer
+ if (this.pattern.writeAccess)
+ if (matchesName(this.pattern.name, field.getElementName().toCharArray()))
+ return ACCURATE_MATCH;
+
+ if (this.pattern.findDeclarations) {
+ if (matchesName(this.pattern.name, field.getElementName().toCharArray()))
+ return ACCURATE_MATCH;
+
+ }
+ return IMPOSSIBLE_MATCH;
+ }
+
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/FieldPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/FieldPattern.java 2007-04-13 16:00:49 UTC (rev 2310)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/FieldPattern.java 2007-04-13 18:50:01 UTC (rev 2311)
@@ -1,35 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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 ...
[truncated message content] |
|
From: <caw...@us...> - 2007-04-13 16:00:50
|
Revision: 2310
http://svn.sourceforge.net/rubyeclipse/?rev=2310&view=rev
Author: cawilliams
Date: 2007-04-13 09:00:49 -0700 (Fri, 13 Apr 2007)
Log Message:
-----------
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MethodPattern.java
Added Paths:
-----------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/ConstructorPattern.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-04-13 15:18:20 UTC (rev 2309)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-04-13 16:00:49 UTC (rev 2310)
@@ -2,6 +2,7 @@
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.internal.core.search.indexing.IIndexConstants;
+import org.rubypeople.rdt.internal.core.search.matching.ConstructorPattern;
import org.rubypeople.rdt.internal.core.search.matching.InternalSearchPattern;
import org.rubypeople.rdt.internal.core.search.matching.MethodPattern;
import org.rubypeople.rdt.internal.core.search.matching.OrPattern;
@@ -374,6 +375,9 @@
private static SearchPattern createMethodOrConstructorPattern(String patternString, int limitTo, int matchRule, boolean isConstructor) {
char[] selectorChars = patternString.toCharArray();
// TODO Break up the patternString into declaring type, method name, etc
+ char[][] parameterNames = new char[0][];
+ char[] declaringTypeSimpleName = null;
+ char[] declaringTypeQualification = null;
// Create method/constructor pattern
boolean findDeclarations = true;
boolean findReferences = true;
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/ConstructorPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/ConstructorPattern.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/ConstructorPattern.java 2007-04-13 16:00:49 UTC (rev 2310)
@@ -0,0 +1,204 @@
+/*******************************************************************************
+ * 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.matching;
+
+import java.io.IOException;
+
+import org.rubypeople.rdt.core.IMethod;
+import org.rubypeople.rdt.core.search.SearchPattern;
+import org.rubypeople.rdt.internal.core.index.EntryResult;
+import org.rubypeople.rdt.internal.core.index.Index;
+import org.rubypeople.rdt.internal.core.search.indexing.IIndexConstants;
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+
+public class ConstructorPattern extends RubySearchPattern implements IIndexConstants {
+
+protected boolean findDeclarations;
+protected boolean findReferences;
+
+public char[] declaringQualification;
+public char[] declaringSimpleName;
+
+public char[][] parameterNames;
+public int parameterCount;
+public boolean varargs = false;
+
+boolean constructorParameters = false;
+
+protected static char[][] REF_CATEGORIES = { CONSTRUCTOR_REF };
+protected static char[][] REF_AND_DECL_CATEGORIES = { CONSTRUCTOR_REF, CONSTRUCTOR_DECL };
+protected static char[][] DECL_CATEGORIES = { CONSTRUCTOR_DECL };
+
+/**
+ * Constructor entries are encoded as TypeName '/' Arity:
+ * e.g. 'X/0'
+ */
+public static char[] createIndexKey(char[] typeName, int argCount) {
+ char[] countChars = argCount < 10
+ ? COUNTS[argCount]
+ : ("/" + String.valueOf(argCount)).toCharArray(); //$NON-NLS-1$
+ return CharOperation.concat(typeName, countChars);
+}
+
+ConstructorPattern(int matchRule) {
+ super(CONSTRUCTOR_PATTERN, matchRule);
+}
+public ConstructorPattern(
+ boolean findDeclarations,
+ boolean findReferences,
+ char[] declaringSimpleName,
+ char[] declaringQualification,
+ char[][] parameterNames,
+ int matchRule) {
+
+ this(matchRule);
+
+ this.findDeclarations = findDeclarations;
+ this.findReferences = findReferences;
+
+ this.declaringQualification = isCaseSensitive() ? declaringQualification : CharOperation.toLowerCase(declaringQualification);
+ this.declaringSimpleName = (isCaseSensitive() || isCamelCase()) ? declaringSimpleName : CharOperation.toLowerCase(declaringSimpleName);
+ if (parameterNames != null) {
+ this.parameterCount = parameterNames.length;
+ int offset = 0;
+ this.parameterNames = new char[this.parameterCount][];
+ for (int i = 0; i < this.parameterCount; i++) {
+ this.parameterNames[i] = isCaseSensitive() ? parameterNames[i+offset] : CharOperation.toLowerCase(parameterNames[i+offset]);
+ }
+ } else {
+ this.parameterCount = -1;
+ }
+ ((InternalSearchPattern)this).mustResolve = mustResolve();
+}
+/*
+ * Instanciate a method pattern with signatures for generics search
+ */
+public ConstructorPattern(
+ boolean findDeclarations,
+ boolean findReferences,
+ char[] declaringSimpleName,
+ char[] declaringQualification,
+ char[][] parameterNames,
+ IMethod method,
+// boolean varargs,
+ int matchRule) {
+
+ this(findDeclarations,
+ findReferences,
+ declaringSimpleName,
+ declaringQualification,
+ parameterNames,
+ matchRule);
+
+ this.varargs = true; // XXX We need to know whetehr there are optional arguments!
+}
+
+public void decodeIndexKey(char[] key) {
+ int last = key.length - 1;
+ this.parameterCount = 0;
+ this.declaringSimpleName = null;
+ int power = 1;
+ for (int i=last; i>=0; i--) {
+ if (key[i] == SEPARATOR) {
+ System.arraycopy(key, 0, this.declaringSimpleName = new char[i], 0, i);
+ break;
+ }
+ if (i == last) {
+ this.parameterCount = key[i] - '0';
+ } else {
+ power *= 10;
+ this.parameterCount += power * (key[i] - '0');
+ }
+ }
+}
+public SearchPattern getBlankPattern() {
+ return new ConstructorPattern(R_EXACT_MATCH | R_CASE_SENSITIVE);
+}
+public char[][] getIndexCategories() {
+ if (this.findReferences)
+ return this.findDeclarations ? REF_AND_DECL_CATEGORIES : REF_CATEGORIES;
+ if (this.findDeclarations)
+ return DECL_CATEGORIES;
+ return CharOperation.NO_CHAR_CHAR;
+}
+boolean hasConstructorParameters() {
+ return constructorParameters;
+}
+public boolean matchesDecodedKey(SearchPattern decodedPattern) {
+ ConstructorPattern pattern = (ConstructorPattern) decodedPattern;
+
+ return (this.parameterCount == pattern.parameterCount || this.parameterCount == -1 || this.varargs)
+ && matchesName(this.declaringSimpleName, pattern.declaringSimpleName);
+}
+protected boolean mustResolve() {
+ if (this.declaringQualification != null) return true;
+
+ return this.findReferences; // need to check resolved default constructors and explicit constructor calls
+}
+EntryResult[] queryIn(Index index) throws IOException {
+ char[] key = this.declaringSimpleName; // can be null
+ int matchRule = getMatchRule();
+
+ switch(getMatchMode()) {
+ case R_EXACT_MATCH :
+ if (this.isCamelCase) break;
+ if (this.declaringSimpleName != null && this.parameterCount >= 0 && !this.varargs)
+ key = createIndexKey(this.declaringSimpleName, this.parameterCount);
+ else { // do a prefix query with the declaringSimpleName
+ matchRule &= ~R_EXACT_MATCH;
+ matchRule |= R_PREFIX_MATCH;
+ }
+ break;
+ case R_PREFIX_MATCH :
+ // do a prefix query with the declaringSimpleName
+ break;
+ case R_PATTERN_MATCH :
+ if (this.parameterCount >= 0 && !this.varargs)
+ key = createIndexKey(this.declaringSimpleName == null ? ONE_STAR : this.declaringSimpleName, this.parameterCount);
+ else if (this.declaringSimpleName != null && this.declaringSimpleName[this.declaringSimpleName.length - 1] != '*')
+ key = CharOperation.concat(this.declaringSimpleName, ONE_STAR, SEPARATOR);
+ // else do a pattern query with just the declaringSimpleName
+ break;
+ case R_REGEXP_MATCH :
+ // TODO (frederic) implement regular expression match
+ break;
+ }
+
+ return index.query(getIndexCategories(), key, matchRule); // match rule is irrelevant when the key is null
+}
+protected StringBuffer print(StringBuffer output) {
+ if (this.findDeclarations) {
+ output.append(this.findReferences
+ ? "ConstructorCombinedPattern: " //$NON-NLS-1$
+ : "ConstructorDeclarationPattern: "); //$NON-NLS-1$
+ } else {
+ output.append("ConstructorReferencePattern: "); //$NON-NLS-1$
+ }
+ if (declaringQualification != null)
+ output.append(declaringQualification).append('.');
+ if (declaringSimpleName != null)
+ output.append(declaringSimpleName);
+ else if (declaringQualification != null)
+ output.append("*"); //$NON-NLS-1$
+
+ output.append('(');
+ if (parameterNames == null) {
+ output.append("..."); //$NON-NLS-1$
+ } else {
+ for (int i = 0, max = parameterNames.length; i < max; i++) {
+ if (i > 0) output.append(", "); //$NON-NLS-1$
+ if (parameterNames[i] == null) output.append('*'); else output.append(parameterNames[i]);
+ }
+ }
+ output.append(')');
+ return super.print(output);
+}
+}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MethodPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MethodPattern.java 2007-04-13 15:18:20 UTC (rev 2309)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MethodPattern.java 2007-04-13 16:00:49 UTC (rev 2310)
@@ -12,16 +12,13 @@
import java.io.IOException;
-import org.rubypeople.rdt.core.Flags;
import org.rubypeople.rdt.core.IMethod;
import org.rubypeople.rdt.core.IType;
-import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.search.SearchPattern;
import org.rubypeople.rdt.internal.core.index.EntryResult;
import org.rubypeople.rdt.internal.core.index.Index;
import org.rubypeople.rdt.internal.core.search.indexing.IIndexConstants;
import org.rubypeople.rdt.internal.core.util.CharOperation;
-import org.rubypeople.rdt.internal.core.util.Util;
public class MethodPattern extends RubySearchPattern implements IIndexConstants {
@@ -114,6 +111,26 @@
this.varargs = true; // XXX We need to know whether this can take optional args (and what about blocks?)
}
+/*
+ * Instanciate a method pattern with signatures for generics search
+ */
+public MethodPattern(
+ boolean findDeclarations,
+ boolean findReferences,
+ char[] selector,
+ char[] declaringQualification,
+ char[] declaringSimpleName,
+ char[][] parameterSimpleNames,
+ int matchRule) {
+ this(findDeclarations,
+ findReferences,
+ selector,
+ declaringQualification,
+ declaringSimpleName,
+ parameterSimpleNames,
+ (IMethod)null,
+ matchRule);
+}
public void decodeIndexKey(char[] key) {
int last = key.length - 1;
this.parameterCount = 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-13 15:18:27
|
Revision: 2309
http://svn.sourceforge.net/rubyeclipse/?rev=2309&view=rev
Author: cawilliams
Date: 2007-04-13 08:18:20 -0700 (Fri, 13 Apr 2007)
Log Message:
-----------
someday I'll be able to actually do a search for a type or method and this will work. hopefully...
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MethodPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-04-13 14:44:33 UTC (rev 2308)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-04-13 15:18:20 UTC (rev 2309)
@@ -3,6 +3,7 @@
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.internal.core.search.indexing.IIndexConstants;
import org.rubypeople.rdt.internal.core.search.matching.InternalSearchPattern;
+import org.rubypeople.rdt.internal.core.search.matching.MethodPattern;
import org.rubypeople.rdt.internal.core.search.matching.OrPattern;
import org.rubypeople.rdt.internal.core.search.matching.QualifiedTypeDeclarationPattern;
import org.rubypeople.rdt.internal.core.search.matching.TypeReferencePattern;
@@ -321,16 +322,16 @@
* - '?' is treated as a wildcard when it is inside <> (ie. it must be put on first position of the type argument)
*/
private static SearchPattern createTypePattern(String patternString, int limitTo, int matchRule, char indexSuffix) {
- char[] typeChars = patternString.toCharArray();
char[] typePart = patternString.toCharArray();
- char[] qualificationChars;
+ char[] typeChars = null;
+ char[] qualificationChars = null;
// get qualification name
- int lastDotPosition = CharOperation.lastIndexOf('.', typePart);
+ int lastDotPosition = CharOperation.lastIndexOf("::", typePart);
if (lastDotPosition >= 0) {
qualificationChars = CharOperation.subarray(typePart, 0, lastDotPosition);
if (qualificationChars.length == 1 && qualificationChars[0] == '*')
qualificationChars = null;
- typeChars = CharOperation.subarray(typePart, lastDotPosition+1, typePart.length);
+ typeChars = CharOperation.subarray(typePart, lastDotPosition+2, typePart.length);
} else {
typeChars = typePart;
}
@@ -352,4 +353,58 @@
return null;
}
+ /**
+ * Method pattern are formed by:<br>
+ * [declaringType '.'] selector ['(' parameterTypes ')']
+ * <br>e.g.<ul>
+ * <li>java.lang.Runnable.run() void</li>
+ * <li>main(*)</li>
+ * <li><String>toArray(String[])</li>
+ * </ul>
+ * Constructor pattern are formed by:<br>
+ * [declaringQualification '.'] type ['(' parameterTypes ')']
+ * <br>e.g.<ul>
+ * <li>java.lang.Object()</li>
+ * <li>Main(*)</li>
+ * <li><Exception>Sample(Exception)</li>
+ * </ul>
+ * Type arguments have the same pattern that for type patterns
+ * @see #createTypePattern(String,int,int,char)
+ */
+ private static SearchPattern createMethodOrConstructorPattern(String patternString, int limitTo, int matchRule, boolean isConstructor) {
+ char[] selectorChars = patternString.toCharArray();
+ // TODO Break up the patternString into declaring type, method name, etc
+ // Create method/constructor pattern
+ boolean findDeclarations = true;
+ boolean findReferences = true;
+ switch (limitTo) {
+ case IRubySearchConstants.DECLARATIONS :
+ findReferences = false;
+ break;
+ case IRubySearchConstants.REFERENCES :
+ findDeclarations = false;
+ break;
+ case IRubySearchConstants.ALL_OCCURRENCES :
+ break;
+ }
+ if (isConstructor) {
+ return new ConstructorPattern(
+ findDeclarations,
+ findReferences,
+ declaringTypeSimpleName,
+ declaringTypeQualification,
+ parameterNames,
+ matchRule);
+ } else {
+ return new MethodPattern(
+ findDeclarations,
+ findReferences,
+ selectorChars,
+ declaringTypeQualification,
+ declaringTypeSimpleName,
+ parameterNames,
+ matchRule);
+ }
+ }
+
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MethodPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MethodPattern.java 2007-04-13 14:44:33 UTC (rev 2308)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MethodPattern.java 2007-04-13 15:18:20 UTC (rev 2309)
@@ -1,13 +1,229 @@
+/*******************************************************************************
+ * 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.matching;
+import java.io.IOException;
-public class MethodPattern extends RubySearchPattern {
+import org.rubypeople.rdt.core.Flags;
+import org.rubypeople.rdt.core.IMethod;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.search.SearchPattern;
+import org.rubypeople.rdt.internal.core.index.EntryResult;
+import org.rubypeople.rdt.internal.core.index.Index;
+import org.rubypeople.rdt.internal.core.search.indexing.IIndexConstants;
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+import org.rubypeople.rdt.internal.core.util.Util;
+
+public class MethodPattern extends RubySearchPattern implements IIndexConstants {
+
+protected boolean findDeclarations;
+protected boolean findReferences;
+
+public char[] selector;
+
+public char[] declaringQualification;
+public char[] declaringSimpleName;
+
+public char[][] parameterNames;
+public int parameterCount;
+public boolean varargs = false;
+
+// extra reference info
+protected IType declaringType;
+
+char[][] methodArguments;
+
+protected static char[][] REF_CATEGORIES = { METHOD_REF };
+protected static char[][] REF_AND_DECL_CATEGORIES = { METHOD_REF, METHOD_DECL };
+protected static char[][] DECL_CATEGORIES = { METHOD_DECL };
+
+/**
+ * Method entries are encoded as selector '/' Arity:
+ * e.g. 'foo/0'
+ */
+public static char[] createIndexKey(char[] selector, int argCount) {
+ char[] countChars = argCount < 10
+ ? COUNTS[argCount]
+ : ("/" + String.valueOf(argCount)).toCharArray(); //$NON-NLS-1$
+ return CharOperation.concat(selector, countChars);
+}
+
+MethodPattern(int matchRule) {
+ super(METHOD_PATTERN, matchRule);
+}
+public MethodPattern(
+ boolean findDeclarations,
+ boolean findReferences,
+ char[] selector,
+ char[] declaringQualification,
+ char[] declaringSimpleName,
+ char[][] parameterNames,
+ IType declaringType,
+ int matchRule) {
+
+ this(matchRule);
+
+ this.findDeclarations = findDeclarations;
+ this.findReferences = findReferences;
+
+ this.selector = (isCaseSensitive() || isCamelCase()) ? selector : CharOperation.toLowerCase(selector);
+ this.declaringQualification = isCaseSensitive() ? declaringQualification : CharOperation.toLowerCase(declaringQualification);
+ this.declaringSimpleName = isCaseSensitive() ? declaringSimpleName : CharOperation.toLowerCase(declaringSimpleName);
+ if (parameterNames != null) {
+ this.parameterCount = parameterNames.length;
+ this.parameterNames = new char[this.parameterCount][];
+ for (int i = 0; i < this.parameterCount; i++) {
+ this.parameterNames[i] = isCaseSensitive() ? parameterNames[i] : CharOperation.toLowerCase(parameterNames[i]);
+ }
+ } else {
+ this.parameterCount = -1;
+ }
+ this.declaringType = declaringType;
+ ((InternalSearchPattern)this).mustResolve = mustResolve();
+}
+/*
+ * Instanciate a method pattern with signatures for generics search
+ */
+public MethodPattern(
+ boolean findDeclarations,
+ boolean findReferences,
+ char[] selector,
+ char[] declaringQualification,
+ char[] declaringSimpleName,
+ char[][] parameterNames,
+ IMethod method,
+ int matchRule) {
+
+ this(findDeclarations,
+ findReferences,
+ selector,
+ declaringQualification,
+ declaringSimpleName,
+ parameterNames,
+ method.getDeclaringType(),
+ matchRule);
- public String[] parameterNames;
- public char[] selector;
- public boolean findDeclarations;
+ this.varargs = true; // XXX We need to know whether this can take optional args (and what about blocks?)
+}
+public void decodeIndexKey(char[] key) {
+ int last = key.length - 1;
+ this.parameterCount = 0;
+ this.selector = null;
+ int power = 1;
+ for (int i=last; i>=0; i--) {
+ if (key[i] == SEPARATOR) {
+ System.arraycopy(key, 0, this.selector = new char[i], 0, i);
+ break;
+ }
+ if (i == last) {
+ this.parameterCount = key[i] - '0';
+ } else {
+ power *= 10;
+ this.parameterCount += power * (key[i] - '0');
+ }
+ }
+}
+public SearchPattern getBlankPattern() {
+ return new MethodPattern(R_EXACT_MATCH | R_CASE_SENSITIVE);
+}
+public char[][] getIndexCategories() {
+ if (this.findReferences)
+ return this.findDeclarations ? REF_AND_DECL_CATEGORIES : REF_CATEGORIES;
+ if (this.findDeclarations)
+ return DECL_CATEGORIES;
+ return CharOperation.NO_CHAR_CHAR;
+}
+boolean hasMethodArguments() {
+ return methodArguments != null && methodArguments.length > 0;
+}
+boolean isPolymorphicSearch() {
+ return this.findReferences;
+}
+public boolean matchesDecodedKey(SearchPattern decodedPattern) {
+ MethodPattern pattern = (MethodPattern) decodedPattern;
- MethodPattern(int matchRule) {
- super(METHOD_PATTERN, matchRule);
+ return (this.parameterCount == pattern.parameterCount || this.parameterCount == -1 || this.varargs)
+ && matchesName(this.selector, pattern.selector);
+}
+/**
+ * Returns whether a method declaration or message send must be resolved to
+ * find out if this method pattern matches it.
+ */
+protected boolean mustResolve() {
+ // declaring type
+ // If declaring type is specified - even with simple name - always resolves
+ if (declaringSimpleName != null || declaringQualification != null) return true;
+ return false;
+}
+EntryResult[] queryIn(Index index) throws IOException {
+ char[] key = this.selector; // can be null
+ int matchRule = getMatchRule();
+
+ switch(getMatchMode()) {
+ case R_EXACT_MATCH :
+ if (this.isCamelCase) break;
+ if (this.selector != null && this.parameterCount >= 0 && !this.varargs)
+ key = createIndexKey(this.selector, this.parameterCount);
+ else { // do a prefix query with the selector
+ matchRule &= ~R_EXACT_MATCH;
+ matchRule |= R_PREFIX_MATCH;
+ }
+ break;
+ case R_PREFIX_MATCH :
+ // do a prefix query with the selector
+ break;
+ case R_PATTERN_MATCH :
+ if (this.parameterCount >= 0 && !this.varargs)
+ key = createIndexKey(this.selector == null ? ONE_STAR : this.selector, this.parameterCount);
+ else if (this.selector != null && this.selector[this.selector.length - 1] != '*')
+ key = CharOperation.concat(this.selector, ONE_STAR, SEPARATOR);
+ // else do a pattern query with just the selector
+ break;
+ case R_REGEXP_MATCH :
+ // TODO (frederic) implement regular expression match
+ break;
}
+
+ return index.query(getIndexCategories(), key, matchRule); // match rule is irrelevant when the key is null
}
+protected StringBuffer print(StringBuffer output) {
+ if (this.findDeclarations) {
+ output.append(this.findReferences
+ ? "MethodCombinedPattern: " //$NON-NLS-1$
+ : "MethodDeclarationPattern: "); //$NON-NLS-1$
+ } else {
+ output.append("MethodReferencePattern: "); //$NON-NLS-1$
+ }
+ if (declaringQualification != null)
+ output.append(declaringQualification).append('.');
+ if (declaringSimpleName != null)
+ output.append(declaringSimpleName).append('.');
+ else if (declaringQualification != null)
+ output.append("*."); //$NON-NLS-1$
+
+ if (selector != null)
+ output.append(selector);
+ else
+ output.append("*"); //$NON-NLS-1$
+ output.append('(');
+ if (parameterNames == null) {
+ output.append("..."); //$NON-NLS-1$
+ } else {
+ for (int i = 0, max = parameterNames.length; i < max; i++) {
+ if (i > 0) output.append(", "); //$NON-NLS-1$
+ if (parameterNames[i] == null) output.append('*'); else output.append(parameterNames[i]);
+ }
+ }
+ output.append(')');
+ return super.print(output);
+}
+}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java 2007-04-13 14:44:33 UTC (rev 2308)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java 2007-04-13 15:18:20 UTC (rev 2309)
@@ -1493,4 +1493,54 @@
}
return count;
}
+
+public static int lastIndexOf(String toBeFound, char[] typePart) {
+ return new String(typePart).lastIndexOf(toBeFound);
}
+
+/**
+ * Answers the concatenation of the two arrays. It answers null if the two arrays are null.
+ * If the first array is null, then the second array is returned.
+ * If the second array is null, then the first array is returned.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * first = null
+ * second = { 'a' }
+ * => result = { ' a' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { ' a' }
+ * second = null
+ * => result = { ' a' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { ' a' }
+ * second = { ' b' }
+ * => result = { ' a' , ' b' }
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param first the first array to concatenate
+ * @param second the second array to concatenate
+ * @return the concatenation of the two arrays, or null if the two arrays are null.
+ */
+public static final char[] concat(char[] first, char[] second) {
+ if (first == null)
+ return second;
+ if (second == null)
+ return first;
+
+ int length1 = first.length;
+ int length2 = second.length;
+ char[] result = new char[length1 + length2];
+ System.arraycopy(first, 0, result, 0, length1);
+ System.arraycopy(second, 0, result, length1, length2);
+ return result;
+}
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-13 14:44:34
|
Revision: 2308
http://svn.sourceforge.net/rubyeclipse/?rev=2308&view=rev
Author: cawilliams
Date: 2007-04-13 07:44:33 -0700 (Fri, 13 Apr 2007)
Log Message:
-----------
getting closer...
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MethodLocator.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
Added Paths:
-----------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/FieldDeclarationMatch.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/MethodDeclarationMatch.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/TypeDeclarationMatch.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/AndPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeReferencePattern.java
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/FieldDeclarationMatch.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/FieldDeclarationMatch.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/FieldDeclarationMatch.java 2007-04-13 14:44:33 UTC (rev 2308)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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.core.search;
+
+import org.eclipse.core.resources.IResource;
+import org.rubypeople.rdt.core.IRubyElement;
+
+/**
+ * A Java search match that represents a field declaration.
+ * The element is an <code>IField</code>.
+ * <p>
+ * This class is intended to be instantiated and subclassed by clients.
+ * </p>
+ *
+ * @since 3.0
+ */
+public class FieldDeclarationMatch extends SearchMatch {
+
+ /**
+ * Creates a new field declaration match.
+ *
+ * @param element the field declaration
+ * @param accuracy one of A_ACCURATE or A_INACCURATE
+ * @param offset the offset the match starts at, or -1 if unknown
+ * @param length the length of the match, or -1 if unknown
+ * @param participant the search participant that created the match
+ * @param resource the resource of the element
+ */
+ public FieldDeclarationMatch(IRubyElement element, int accuracy, int offset, int length, SearchParticipant participant, IResource resource) {
+ super(element, accuracy, offset, length, participant, resource);
+ }
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/MethodDeclarationMatch.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/MethodDeclarationMatch.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/MethodDeclarationMatch.java 2007-04-13 14:44:33 UTC (rev 2308)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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.core.search;
+
+import org.eclipse.core.resources.IResource;
+import org.rubypeople.rdt.core.IRubyElement;
+
+/**
+ * A Java search match that represents a method declaration.
+ * The element is an <code>IMethod</code>.
+ * <p>
+ * This class is intended to be instantiated and subclassed by clients.
+ * </p>
+ *
+ * @since 3.0
+ */
+public class MethodDeclarationMatch extends SearchMatch {
+
+ /**
+ * Creates a new method declaration match.
+ *
+ * @param element the method declaration
+ * @param accuracy one of A_ACCURATE or A_INACCURATE
+ * @param offset the offset the match starts at, or -1 if unknown
+ * @param length the length of the match, or -1 if unknown
+ * @param participant the search participant that created the match
+ * @param resource the resource of the element
+ */
+ public MethodDeclarationMatch(IRubyElement element, int accuracy, int offset, int length, SearchParticipant participant, IResource resource) {
+ super(element, accuracy, offset, length, participant, resource);
+ }
+
+}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-04-13 14:12:19 UTC (rev 2307)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-04-13 14:44:33 UTC (rev 2308)
@@ -3,7 +3,9 @@
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.internal.core.search.indexing.IIndexConstants;
import org.rubypeople.rdt.internal.core.search.matching.InternalSearchPattern;
+import org.rubypeople.rdt.internal.core.search.matching.OrPattern;
import org.rubypeople.rdt.internal.core.search.matching.QualifiedTypeDeclarationPattern;
+import org.rubypeople.rdt.internal.core.search.matching.TypeReferencePattern;
import org.rubypeople.rdt.internal.core.util.CharOperation;
public abstract class SearchPattern extends InternalSearchPattern {
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/TypeDeclarationMatch.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/TypeDeclarationMatch.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/TypeDeclarationMatch.java 2007-04-13 14:44:33 UTC (rev 2308)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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.core.search;
+
+import org.eclipse.core.resources.IResource;
+import org.rubypeople.rdt.core.IRubyElement;
+
+/**
+ * A Java search match that represents a type declaration.
+ * The element is an <code>IType</code>.
+ * <p>
+ * This class is intended to be instantiated and subclassed by clients.
+ * </p>
+ *
+ * @since 1.0
+ */
+public class TypeDeclarationMatch extends SearchMatch {
+
+ /**
+ * Creates a new type declaration match.
+ *
+ * @param element the type declaration
+ * @param accuracy one of A_ACCURATE or A_INACCURATE
+ * @param offset the offset the match starts at, or -1 if unknown
+ * @param length the length of the match, or -1 if unknown
+ * @param participant the search participant that created the match
+ * @param resource the resource of the element
+ */
+ public TypeDeclarationMatch(IRubyElement element, int accuracy, int offset, int length, SearchParticipant participant, IResource resource) {
+ super(element, accuracy, offset, length, participant, resource);
+ }
+
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/AndPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/AndPattern.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/AndPattern.java 2007-04-13 14:44:33 UTC (rev 2308)
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * 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.matching;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.rubypeople.rdt.core.search.IRubySearchScope;
+import org.rubypeople.rdt.core.search.SearchParticipant;
+import org.rubypeople.rdt.core.search.SearchPattern;
+import org.rubypeople.rdt.internal.compiler.util.SimpleSet;
+import org.rubypeople.rdt.internal.core.index.EntryResult;
+import org.rubypeople.rdt.internal.core.index.Index;
+import org.rubypeople.rdt.internal.core.search.IndexQueryRequestor;
+
+/**
+ * Query the index multiple times and do an 'and' on the results.
+ */
+public abstract class AndPattern extends RubySearchPattern { // TODO should rename IntersectingPattern, and make AndPattern a true subclass
+
+public AndPattern(int patternKind, int matchRule) {
+ super(patternKind, matchRule);
+}
+public void findIndexMatches(Index index, IndexQueryRequestor requestor, SearchParticipant participant, IRubySearchScope scope, IProgressMonitor progressMonitor) throws IOException {
+ if (progressMonitor != null && progressMonitor.isCanceled()) throw new OperationCanceledException();
+
+ this.resetQuery();
+ SimpleSet intersectedNames = null;
+ try {
+ index.startQuery();
+ do {
+ SearchPattern pattern = ((InternalSearchPattern) this).currentPattern();
+ EntryResult[] entries = ((InternalSearchPattern)pattern).queryIn(index);
+ if (entries == null) return;
+
+ SearchPattern decodedResult = pattern.getBlankPattern();
+ SimpleSet newIntersectedNames = new SimpleSet(3);
+ for (int i = 0, l = entries.length; i < l; i++) {
+ if (progressMonitor != null && progressMonitor.isCanceled()) throw new OperationCanceledException();
+
+ EntryResult entry = entries[i];
+ decodedResult.decodeIndexKey(entry.getWord());
+ if (pattern.matchesDecodedKey(decodedResult)) {
+ String[] names = entry.getDocumentNames(index);
+ if (intersectedNames != null) {
+ for (int j = 0, n = names.length; j < n; j++)
+ if (intersectedNames.includes(names[j]))
+ newIntersectedNames.add(names[j]);
+ } else {
+ for (int j = 0, n = names.length; j < n; j++)
+ newIntersectedNames.add(names[j]);
+ }
+ }
+ }
+
+ if (newIntersectedNames.elementSize == 0) return;
+ intersectedNames = newIntersectedNames;
+ } while (this.hasNextQuery());
+ } finally {
+ index.stopQuery();
+ }
+
+ String containerPath = index.containerPath;
+ Object[] names = intersectedNames.values;
+ for (int i = 0, l = names.length; i < l; i++)
+ if (names[i] != null)
+ ((InternalSearchPattern) this).acceptMatch((String) names[i], containerPath, null/*no pattern*/, requestor, participant, scope); // AndPatterns cannot provide the decoded result
+}
+/**
+ * Returns whether another query must be done.
+ */
+protected abstract boolean hasNextQuery();
+/**
+ * Resets the query and prepares this pattern to be queried.
+ */
+protected abstract void resetQuery();
+}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java 2007-04-13 14:12:19 UTC (rev 2307)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java 2007-04-13 14:44:33 UTC (rev 2308)
@@ -14,12 +14,15 @@
import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.search.FieldDeclarationMatch;
import org.rubypeople.rdt.core.search.IRubySearchScope;
+import org.rubypeople.rdt.core.search.MethodDeclarationMatch;
import org.rubypeople.rdt.core.search.SearchDocument;
import org.rubypeople.rdt.core.search.SearchMatch;
import org.rubypeople.rdt.core.search.SearchParticipant;
import org.rubypeople.rdt.core.search.SearchPattern;
import org.rubypeople.rdt.core.search.SearchRequestor;
+import org.rubypeople.rdt.core.search.TypeDeclarationMatch;
import org.rubypeople.rdt.internal.compiler.util.SimpleLookupTable;
import org.rubypeople.rdt.internal.core.ExternalSourceFolderRoot;
import org.rubypeople.rdt.internal.core.Openable;
@@ -74,6 +77,7 @@
// Progress information
int progressStep;
int progressWorked;
+ private PossibleMatch currentPossibleMatch;
public MatchLocator(
SearchPattern pattern,
@@ -427,10 +431,53 @@
protected void locateMatches(RubyProject rubyProject, PossibleMatch[] possibleMatches, int start, int length) throws CoreException {
for (int i = start, maxUnits = start + length; i < maxUnits; i++) {
PossibleMatch possibleMatch = possibleMatches[i];
- RubyScript script = (RubyScript) possibleMatch.openable;
- this.patternLocator.reportMatches(script, this);
+ process(possibleMatch);
possibleMatch.cleanUp();
}
}
+ protected void process(PossibleMatch possibleMatch) {
+ this.currentPossibleMatch = possibleMatch;
+ RubyScript script = (RubyScript) possibleMatch.openable;
+ this.patternLocator.reportMatches(script, this);
+ this.currentPossibleMatch = null;
+ }
+
+ public SearchMatch newDeclarationMatch(
+ IRubyElement element,
+ int accuracy,
+ int offset,
+ int length,
+ SearchParticipant participant,
+ IResource resource) {
+ switch (element.getElementType()) {
+// case IRubyElement.SOURCE_FOLDER:
+// return new PackageDeclarationMatch(element, accuracy, offset, length, participant, resource);
+ case IRubyElement.TYPE:
+ return new TypeDeclarationMatch(element, accuracy, offset, length, participant, resource);
+ case IRubyElement.FIELD:
+ return new FieldDeclarationMatch(element, accuracy, offset, length, participant, resource);
+ case IRubyElement.METHOD:
+ return new MethodDeclarationMatch(element, accuracy, offset, length, participant, resource);
+// case IRubyElement.LOCAL_VARIABLE:
+// return new LocalVariableDeclarationMatch(element, accuracy, offset, length, participant, resource);
+ default:
+ return null;
+ }
+ }
+
+ public SearchMatch newDeclarationMatch(
+ IRubyElement element,
+ int accuracy,
+ int offset,
+ int length) {
+ SearchParticipant participant = getParticipant();
+ IResource resource = this.currentPossibleMatch.resource;
+ return newDeclarationMatch(element, accuracy, offset, length, participant, resource);
+ }
+
+ public SearchParticipant getParticipant() {
+ return this.currentPossibleMatch.document.getParticipant();
+ }
+
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MethodLocator.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MethodLocator.java 2007-04-13 14:12:19 UTC (rev 2307)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MethodLocator.java 2007-04-13 14:44:33 UTC (rev 2308)
@@ -1,8 +1,11 @@
package org.rubypeople.rdt.internal.core.search.matching;
+import org.eclipse.core.runtime.CoreException;
+import org.rubypeople.rdt.core.IMember;
import org.rubypeople.rdt.core.IMethod;
import org.rubypeople.rdt.core.IParent;
import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.ISourceRange;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.internal.core.RubyScript;
@@ -14,7 +17,7 @@
super(pattern);
this.pattern = pattern;
}
-
+
@Override
public void reportMatches(RubyScript script, MatchLocator locator) {
reportMatches((IParent) script, locator);
@@ -26,8 +29,17 @@
for (int i = 0; i < children.length; i++) {
IRubyElement child = children[i];
if (child.isType(IRubyElement.METHOD)) {
- int match = reportMethodDeclaration((IMethod) child);
- if (match != IMPOSSIBLE_MATCH) locator.report(locator.newMethodDeclarationMatch());
+ int accuracy = getAccuracy((IMethod) child);
+ if (accuracy != IMPOSSIBLE_MATCH) {
+ IMember member = (IMember) child;
+ ISourceRange range = member.getSourceRange();
+ try {
+ locator.report(locator.newDeclarationMatch(child, accuracy, range.getOffset(), range.getLength()));
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
}
if (child instanceof IParent) {
IParent parentTwo = (IParent) child;
@@ -37,27 +49,29 @@
} catch (RubyModelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
- private int reportMethodDeclaration(IMethod method) {
- if (!this.pattern.findDeclarations) return IMPOSSIBLE_MATCH;
+ private int getAccuracy(IMethod method) {
+ if (!this.pattern.findDeclarations)
+ return IMPOSSIBLE_MATCH;
// Verify method name
- if (!matchesName(this.pattern.selector, method.getElementName().toCharArray())) return IMPOSSIBLE_MATCH;
-
+ if (!matchesName(this.pattern.selector, method.getElementName().toCharArray()))
+ return IMPOSSIBLE_MATCH;
+
// Verify parameter count
- boolean resolve = ((InternalSearchPattern)this.pattern).mustResolve;
if (this.pattern.parameterNames != null) {
int length = this.pattern.parameterNames.length;
- String[] args = method.getParameterNames();
+ String[] args = null;
+ try {
+ args = method.getParameterNames();
+ } catch (RubyModelException e) {
+ // ignore
+ }
int argsLength = args == null ? 0 : args.length;
- if (length != argsLength) return IMPOSSIBLE_MATCH;
-// for (int i = 0; i < argsLength; i++) {
-// if (args != null && !matchesTypeReference(this.pattern.parameterNames[i], ((Argument) args[i]).type)) {
-// return IMPOSSIBLE_MATCH;
-// }
-// }
+ if (length != argsLength)
+ return IMPOSSIBLE_MATCH;
}
// Method declaration may match pattern
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeReferencePattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeReferencePattern.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeReferencePattern.java 2007-04-13 14:44:33 UTC (rev 2308)
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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.matching;
+
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.search.SearchPattern;
+import org.rubypeople.rdt.internal.core.search.indexing.IIndexConstants;
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+import org.rubypeople.rdt.internal.core.util.Util;
+
+ public class TypeReferencePattern extends AndPattern implements IIndexConstants {
+
+ protected char[] qualification;
+ protected char[] simpleName;
+
+ protected char[] currentCategory;
+
+ /* Optimization: case where simpleName == null */
+ public int segmentsSize;
+ protected char[][] segments;
+ protected int currentSegment;
+
+ protected static char[][] CATEGORIES = { REF };
+
+ public TypeReferencePattern(char[] qualification, char[] simpleName, int matchRule) {
+ this(matchRule);
+
+ this.qualification = isCaseSensitive() ? qualification : CharOperation.toLowerCase(qualification);
+ this.simpleName = (isCaseSensitive() || isCamelCase()) ? simpleName : CharOperation.toLowerCase(simpleName);
+
+ if (simpleName == null)
+ this.segments = this.qualification == null ? ONE_STAR_CHAR : CharOperation.splitOn("::", this.qualification);
+ else
+ this.segments = null;
+
+ if (this.segments == null)
+ if (this.qualification == null)
+ this.segmentsSize = 0;
+ else
+ this.segmentsSize = CharOperation.occurencesOf("::", this.qualification) + 1;
+ else
+ this.segmentsSize = this.segments.length;
+
+ ((InternalSearchPattern)this).mustResolve = true; // always resolve (in case of a simple name reference being a potential match)
+ }
+ TypeReferencePattern(int matchRule) {
+ super(TYPE_REF_PATTERN, matchRule);
+ }
+ public void decodeIndexKey(char[] key) {
+ this.simpleName = key;
+ }
+ public SearchPattern getBlankPattern() {
+ return new TypeReferencePattern(R_EXACT_MATCH | R_CASE_SENSITIVE);
+ }
+ public char[] getIndexKey() {
+ if (this.simpleName != null)
+ return this.simpleName;
+
+ // Optimization, eg. type reference is 'org.eclipse.jdt.core.*'
+ if (this.currentSegment >= 0)
+ return this.segments[this.currentSegment];
+ return null;
+ }
+ public char[][] getIndexCategories() {
+ return CATEGORIES;
+ }
+ protected boolean hasNextQuery() {
+ if (this.segments == null) return false;
+
+ // Optimization, eg. type reference is 'org.eclipse.jdt.core.*'
+ // if package has at least 4 segments, don't look at the first 2 since they are mostly
+ // redundant (eg. in 'org.eclipse.jdt.core.*' 'org.eclipse' is used all the time)
+ return --this.currentSegment >= (this.segments.length >= 4 ? 2 : 0);
+ }
+
+ public boolean matchesDecodedKey(SearchPattern decodedPattern) {
+ return true; // index key is not encoded so query results all match
+ }
+
+ protected void resetQuery() {
+ /* walk the segments from end to start as it will find less potential references using 'lang' than 'java' */
+ if (this.segments != null)
+ this.currentSegment = this.segments.length - 1;
+ }
+ protected StringBuffer print(StringBuffer output) {
+ output.append("TypeReferencePattern: qualification<"); //$NON-NLS-1$
+ if (qualification != null)
+ output.append(qualification);
+ else
+ output.append("*"); //$NON-NLS-1$
+ output.append(">, type<"); //$NON-NLS-1$
+ if (simpleName != null)
+ output.append(simpleName);
+ else
+ output.append("*"); //$NON-NLS-1$
+ output.append(">"); //$NON-NLS-1$
+ return super.print(output);
+ }
+}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java 2007-04-13 14:12:19 UTC (rev 2307)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java 2007-04-13 14:44:33 UTC (rev 2308)
@@ -1469,4 +1469,28 @@
}
return resultEnd;
}
+
+public static char[][] splitOn(String divider, char[] key) {
+ String newKey = new String(key);
+ String[] result = newKey.split(divider);
+ char[][] resultEnd = new char[result.length][];
+ for (int i = 0; i < resultEnd.length; i++) {
+ resultEnd[i] = result[i].toCharArray();
+ }
+ return resultEnd;
+
}
+
+public static int occurencesOf(String toBeFound, char[] originalString) {
+ String newKey = new String(originalString);
+ int count = 0;
+ int index = newKey.indexOf(toBeFound);
+ while (index > -1) {
+ count++;
+ if (newKey.length() < index + toBeFound.length()) break;
+ newKey = newKey.substring(index + toBeFound.length());
+ index = newKey.indexOf(toBeFound);
+ }
+ return count;
+}
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-13 14:12:20
|
Revision: 2307
http://svn.sourceforge.net/rubyeclipse/?rev=2307&view=rev
Author: cawilliams
Date: 2007-04-13 07:12:19 -0700 (Fri, 13 Apr 2007)
Log Message:
-----------
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchConstants.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolder.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchScope.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/RubySearchPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeDeclarationPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
Added Paths:
-----------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/OrPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/QualifiedTypeDeclarationPattern.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchConstants.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchConstants.java 2007-04-13 13:04:55 UTC (rev 2306)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchConstants.java 2007-04-13 14:12:19 UTC (rev 2307)
@@ -8,4 +8,28 @@
* the workspace before starting the search.
*/
int WAIT_UNTIL_READY_TO_SEARCH = IJob.WaitUntilReady;
+
+ /**
+ * The search result is a declaration.
+ * Can be used in conjunction with any of the nature of searched elements
+ * so as to better narrow down the search.
+ */
+ int DECLARATIONS= 0;
+
+ /**
+ * The search result is a reference.
+ * Can be used in conjunction with any of the nature of searched elements
+ * so as to better narrow down the search.
+ * References can contain implementers since they are more generic kind
+ * of matches.
+ */
+ int REFERENCES= 2;
+
+ /**
+ * The search result is a declaration, a reference, or an implementer
+ * of an interface.
+ * Can be used in conjunction with any of the nature of searched elements
+ * so as to better narrow down the search.
+ */
+ int ALL_OCCURRENCES= 3;
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-04-13 13:04:55 UTC (rev 2306)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-04-13 14:12:19 UTC (rev 2307)
@@ -1,6 +1,9 @@
package org.rubypeople.rdt.core.search;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.internal.core.search.indexing.IIndexConstants;
import org.rubypeople.rdt.internal.core.search.matching.InternalSearchPattern;
+import org.rubypeople.rdt.internal.core.search.matching.QualifiedTypeDeclarationPattern;
import org.rubypeople.rdt.internal.core.util.CharOperation;
public abstract class SearchPattern extends InternalSearchPattern {
@@ -238,4 +241,113 @@
return true; // called from findIndexMatches(), override as necessary if index key is encoded
}
+ public static SearchPattern createPattern(int elementType, String stringPattern, int limitTo, int matchRule) {
+ switch (elementType) {
+ case IRubyElement.TYPE:
+ return createTypePattern(stringPattern, limitTo, matchRule, IIndexConstants.TYPE_SUFFIX);
+ case IRubyElement.METHOD:
+ return createMethodOrConstructorPattern(stringPattern, limitTo, matchRule, false/*not a constructor*/);
+ default:
+ break;
+ }
+ return null;
+ }
+
+ /**
+ * Returns whether the given name matches the given pattern.
+ * <p>
+ * This method should be re-implemented in subclasses that need to define how
+ * a name matches a pattern.
+ * </p>
+ *
+ * @param pattern the given pattern, or <code>null</code> to represent "*"
+ * @param name the given name
+ * @return whether the given name matches the given pattern
+ */
+ public boolean matchesName(char[] pattern, char[] name) {
+ if (pattern == null) return true; // null is as if it was "*"
+ if (name != null) {
+ boolean isCaseSensitive = (this.matchRule & R_CASE_SENSITIVE) != 0;
+ boolean isCamelCase = (this.matchRule & R_CAMELCASE_MATCH) != 0;
+ int matchMode = this.matchRule & MODE_MASK;
+ boolean sameLength = pattern.length == name.length;
+ boolean canBePrefix = name.length >= pattern.length;
+ boolean matchFirstChar = !isCaseSensitive || pattern.length == 0 || (name.length > 0 && pattern[0] == name[0]);
+ if (isCamelCase && matchFirstChar && CharOperation.camelCaseMatch(pattern, name)) {
+ return true;
+ }
+ switch (matchMode) {
+ case R_EXACT_MATCH :
+ case R_FULL_MATCH :
+ if (!isCamelCase) {
+ if (sameLength && matchFirstChar) {
+ return CharOperation.equals(pattern, name, isCaseSensitive);
+ }
+ break;
+ }
+ // fall through next case to match as prefix if camel case failed
+ case R_PREFIX_MATCH :
+ if (canBePrefix && matchFirstChar) {
+ return CharOperation.prefixEquals(pattern, name, isCaseSensitive);
+ }
+ break;
+
+ case R_PATTERN_MATCH :
+ if (!isCaseSensitive)
+ pattern = CharOperation.toLowerCase(pattern);
+ return CharOperation.match(pattern, name, isCaseSensitive);
+
+ case R_REGEXP_MATCH :
+ // TODO (frederic) implement regular expression match
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Type pattern are formed by [qualification '.']type [typeArguments].
+ * e.g. java.lang.Object
+ * Runnable
+ * List<String>
+ *
+ * @since 3.1
+ * Type arguments can be specified to search references to parameterized types.
+ * and look as follow: '<' { [ '?' {'extends'|'super'} ] type ( ',' [ '?' {'extends'|'super'} ] type )* | '?' } '>'
+ * Please note that:
+ * - '*' is not valid inside type arguments definition <>
+ * - '?' is treated as a wildcard when it is inside <> (ie. it must be put on first position of the type argument)
+ */
+ private static SearchPattern createTypePattern(String patternString, int limitTo, int matchRule, char indexSuffix) {
+ char[] typeChars = patternString.toCharArray();
+ char[] typePart = patternString.toCharArray();
+ char[] qualificationChars;
+ // get qualification name
+ int lastDotPosition = CharOperation.lastIndexOf('.', typePart);
+ if (lastDotPosition >= 0) {
+ qualificationChars = CharOperation.subarray(typePart, 0, lastDotPosition);
+ if (qualificationChars.length == 1 && qualificationChars[0] == '*')
+ qualificationChars = null;
+ typeChars = CharOperation.subarray(typePart, lastDotPosition+1, typePart.length);
+ } else {
+ typeChars = typePart;
+ }
+ if (typeChars.length == 1 && typeChars[0] == '*') {
+ typeChars = null;
+ }
+ switch (limitTo) {
+ case IRubySearchConstants.DECLARATIONS : // cannot search for explicit member types
+ return new QualifiedTypeDeclarationPattern(qualificationChars, typeChars, indexSuffix, matchRule);
+ case IRubySearchConstants.REFERENCES :
+ return new TypeReferencePattern(qualificationChars, typeChars, matchRule);
+// case IRubySearchConstants.IMPLEMENTORS :
+// return new SuperTypeReferencePattern(qualificationChars, typeChars, SuperTypeReferencePattern.ONLY_SUPER_INTERFACES, indexSuffix, matchRule);
+ case IRubySearchConstants.ALL_OCCURRENCES :
+ return new OrPattern(
+ new QualifiedTypeDeclarationPattern(qualificationChars, typeChars, indexSuffix, matchRule),// cannot search for explicit member types
+ new TypeReferencePattern(qualificationChars, typeChars, matchRule));
+ }
+ return null;
+ }
+
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-04-13 13:04:55 UTC (rev 2306)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-04-13 14:12:19 UTC (rev 2307)
@@ -41,12 +41,15 @@
import org.rubypeople.rdt.core.IType;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.search.IRubySearchConstants;
+import org.rubypeople.rdt.core.search.IRubySearchScope;
+import org.rubypeople.rdt.core.search.SearchParticipant;
+import org.rubypeople.rdt.core.search.SearchPattern;
import org.rubypeople.rdt.internal.core.RubyElement;
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;
import org.rubypeople.rdt.internal.ti.ITypeGuess;
@@ -146,6 +149,11 @@
}
private void suggestTypeNames() {
+ BasicSearchEngine engine = new BasicSearchEngine();
+ SearchParticipant[] participants = new SearchParticipant[] { BasicSearchEngine.getDefaultSearchParticipant() };
+ SearchPattern pattern = SearchPattern.createPattern(IRubyElement.TYPE, "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
+ IRubySearchScope scope = BasicSearchEngine.createRubySearchScope(new IRubyElement[] {fContext.getScript().getRubyProject()});
+ engine.search(pattern, participants, scope, requestor, null);
Set<String> types = BasicSearchEngine.getTypeNames(fContext.getScript());
for (String name : types) {
if (!fContext.prefixStartsWith(name))
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolder.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolder.java 2007-04-13 13:04:55 UTC (rev 2306)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolder.java 2007-04-13 14:12:19 UTC (rev 2307)
@@ -23,7 +23,7 @@
public class SourceFolder extends Openable implements ISourceFolder {
- String[] names;
+ public String[] names;
public SourceFolder(SourceFolderRoot parent, String[] names) {
super(parent);
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java 2007-04-13 13:04:55 UTC (rev 2306)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java 2007-04-13 14:12:19 UTC (rev 2307)
@@ -1,11 +1,13 @@
package org.rubypeople.rdt.internal.core.search;
import java.util.HashMap;
+import java.util.HashSet;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.SubProgressMonitor;
+import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.WorkingCopyOwner;
@@ -17,6 +19,7 @@
import org.rubypeople.rdt.core.search.SearchRequestor;
import org.rubypeople.rdt.internal.core.DefaultWorkingCopyOwner;
import org.rubypeople.rdt.internal.core.RubyModelManager;
+import org.rubypeople.rdt.internal.core.RubyProject;
import org.rubypeople.rdt.internal.core.RubyScript;
import org.rubypeople.rdt.internal.core.search.indexing.IndexManager;
import org.rubypeople.rdt.internal.core.search.matching.MatchLocator;
@@ -41,7 +44,7 @@
/**
* Searches for matches of a given search pattern. Search patterns can be created using helper
- * methods (from a String pattern or a Java element) and encapsulate the description of what is
+ * methods (from a String pattern or a Ruby element) and encapsulate the description of what is
* being searched (for example, search method declarations in a case sensitive way).
*
* @see SearchEngine#search(SearchPattern, SearchParticipant[], IRubySearchScope, SearchRequestor, IProgressMonitor)
@@ -55,6 +58,47 @@
}
/**
+ * @see SearchEngine#createRubySearchScope(IRubyElement[]) for detailed comment.
+ */
+ public static IRubySearchScope createRubySearchScope(IRubyElement[] elements) {
+ return createRubySearchScope(elements, true);
+ }
+
+ /**
+ * @see SearchEngine#createRubySearchScope(IRubyElement[], boolean) for detailed comment.
+ */
+ public static IRubySearchScope createRubySearchScope(IRubyElement[] elements, boolean includeReferencedProjects) {
+ int includeMask = IRubySearchScope.SOURCES | IRubySearchScope.APPLICATION_LIBRARIES | IRubySearchScope.SYSTEM_LIBRARIES;
+ if (includeReferencedProjects) {
+ includeMask |= IRubySearchScope.REFERENCED_PROJECTS;
+ }
+ return createRubySearchScope(elements, includeMask);
+ }
+
+ /**
+ * @see SearchEngine#createRubySearchScope(IRubyElement[], int) for detailed comment.
+ */
+ public static IRubySearchScope createRubySearchScope(IRubyElement[] elements, int includeMask) {
+ RubySearchScope scope = new RubySearchScope();
+ HashSet visitedProjects = new HashSet(2);
+ for (int i = 0, length = elements.length; i < length; i++) {
+ IRubyElement element = elements[i];
+ if (element != null) {
+ try {
+ if (element instanceof RubyProject) {
+ scope.add((RubyProject)element, includeMask, visitedProjects);
+ } else {
+ scope.add(element);
+ }
+ } catch (RubyModelException e) {
+ // ignore
+ }
+ }
+ }
+ return scope;
+ }
+
+ /**
* Searches for matches to a given query. Search queries can be created using helper
* methods (from a String pattern or a Ruby element) and encapsulate the description of what is
* being searched (for example, search method declarations in a case sensitive way).
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchScope.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchScope.java 2007-04-13 13:04:55 UTC (rev 2306)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchScope.java 2007-04-13 14:12:19 UTC (rev 2307)
@@ -5,20 +5,28 @@
import java.util.Map;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.rubypeople.rdt.core.ILoadpathContainer;
import org.rubypeople.rdt.core.ILoadpathEntry;
+import org.rubypeople.rdt.core.IMember;
+import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyModel;
+import org.rubypeople.rdt.core.ISourceFolderRoot;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.search.IRubySearchScope;
import org.rubypeople.rdt.internal.core.LoadpathEntry;
import org.rubypeople.rdt.internal.core.RubyModelManager;
import org.rubypeople.rdt.internal.core.RubyProject;
+import org.rubypeople.rdt.internal.core.SourceFolder;
import org.rubypeople.rdt.internal.core.util.Util;
public class RubySearchScope implements IRubySearchScope {
+ private ArrayList elements;
+
/* The paths of the resources in this search scope
(or the classpath entries' paths if the resources are projects)
*/
@@ -306,5 +314,132 @@
public IPath[] enclosingProjectsAndJars() {
return this.enclosingProjectsAndJars;
}
+
+ /**
+ * Add ruby project all fragment roots to current ruby search scope.
+ * @see #add(RubyProject, IPath, int, HashSet, ILoadpathEntry)
+ */
+ public void add(RubyProject project, int includeMask, HashSet visitedProject) throws RubyModelException {
+ add(project, null, includeMask, visitedProject, null);
+ }
+
+ /**
+ * Add an element to the ruby search scope.
+ * @param element The element we want to add to current ruby search scope
+ * @throws RubyModelException May happen if some Ruby Model info are not available
+ */
+ public void add(IRubyElement element) throws RubyModelException {
+ IPath containerPath = null;
+ String containerPathToString = null;
+ int includeMask = SOURCES | APPLICATION_LIBRARIES | SYSTEM_LIBRARIES;
+ switch (element.getElementType()) {
+ case IRubyElement.RUBY_MODEL:
+ // a workspace sope should be used
+ break;
+ case IRubyElement.RUBY_PROJECT:
+ add((RubyProject)element, null, includeMask, new HashSet(2), null);
+ break;
+ case IRubyElement.SOURCE_FOLDER_ROOT:
+ ISourceFolderRoot root = (ISourceFolderRoot)element;
+ IPath rootPath = root.getPath();
+ containerPath = root.getParent().getPath();
+ containerPathToString = containerPath.getDevice() == null ? containerPath.toString() : containerPath.toOSString();
+ IResource rootResource = root.getResource();
+ if (rootResource != null && rootResource.isAccessible()) {
+ String relativePath = Util.relativePath(rootResource.getFullPath(), containerPath.segmentCount());
+ add(relativePath, containerPathToString, false/*not a package*/);
+ } else {
+ add("", containerPathToString, false/*not a package*/); //$NON-NLS-1$
+ }
+ break;
+ case IRubyElement.SOURCE_FOLDER:
+ root = (ISourceFolderRoot)element.getParent();
+ if (root.isArchive()) {
+ String relativePath = Util.concatWith(((SourceFolder) element).names, '/');
+ containerPath = root.getPath();
+ containerPathToString = containerPath.getDevice() == null ? containerPath.toString() : containerPath.toOSString();
+ add(relativePath, containerPathToString, true/*package*/);
+ } else {
+ IResource resource = element.getResource();
+ if (resource != null) {
+ if (resource.isAccessible()) {
+ containerPath = root.getParent().getPath();
+ } else {
+ // for working copies, get resource container full path
+ containerPath = resource.getParent().getFullPath();
+ }
+ containerPathToString = containerPath.getDevice() == null ? containerPath.toString() : containerPath.toOSString();
+ String relativePath = Util.relativePath(resource.getFullPath(), containerPath.segmentCount());
+ add(relativePath, containerPathToString, true/*package*/);
+ }
+ }
+ break;
+ default:
+ // remember sub-cu (or sub-class file) ruby elements
+ if (element instanceof IMember) {
+ if (this.elements == null) {
+ this.elements = new ArrayList();
+ }
+ this.elements.add(element);
+ }
+ root = (ISourceFolderRoot) element.getAncestor(IRubyElement.SOURCE_FOLDER_ROOT);
+ String relativePath;
+
+ containerPath = root.getParent().getPath();
+ relativePath = Util.relativePath(getPath(element, false/*full path*/), 1/*remove project segmet*/);
+
+ containerPathToString = containerPath.getDevice() == null ? containerPath.toString() : containerPath.toOSString();
+ add(relativePath, containerPathToString, false/*not a package*/);
+ }
+
+ if (containerPath != null)
+ addEnclosingProjectOrJar(containerPath);
+ }
+ /**
+ * Adds the given path to this search scope. Remember if subfolders need to be included
+ * and associated access restriction as well.
+ */
+ private void add(String relativePath, String containerPath, boolean isPackage) {
+ // normalize containerPath and relativePath
+ containerPath = normalize(containerPath);
+ relativePath = normalize(relativePath);
+ int length = this.containerPaths.length,
+ index = (containerPath.hashCode()& 0x7FFFFFFF) % length;
+ String currentRelativePath, currentContainerPath;
+ while ((currentRelativePath = this.relativePaths[index]) != null && (currentContainerPath = this.containerPaths[index]) != null) {
+ if (currentRelativePath.equals(relativePath) && currentContainerPath.equals(containerPath))
+ return;
+ if (++index == length) {
+ index = 0;
+ }
+ }
+ this.relativePaths[index] = relativePath;
+ this.containerPaths[index] = containerPath;
+ this.isPkgPath[index] = isPackage;
+
+ // assumes the threshold is never equal to the size of the table
+ if (++this.pathsCount > this.threshold)
+ rehash();
+ }
+
+ private IPath getPath(IRubyElement element, boolean relativeToRoot) {
+ switch (element.getElementType()) {
+ case IRubyElement.RUBY_MODEL:
+ return Path.EMPTY;
+ case IRubyElement.RUBY_PROJECT:
+ return element.getPath();
+ case IRubyElement.SOURCE_FOLDER_ROOT:
+ if (relativeToRoot)
+ return Path.EMPTY;
+ return element.getPath();
+ case IRubyElement.SOURCE_FOLDER:
+ String relativePath = Util.concatWith(((SourceFolder) element).names, '/');
+ return getPath(element.getParent(), relativeToRoot).append(new Path(relativePath));
+ case IRubyElement.SCRIPT:
+ return getPath(element.getParent(), relativeToRoot).append(new Path(element.getElementName()));
+ default:
+ return getPath(element.getParent(), relativeToRoot);
+ }
+ }
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java 2007-04-13 13:04:55 UTC (rev 2306)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java 2007-04-13 14:12:19 UTC (rev 2307)
@@ -424,12 +424,11 @@
this.patternLocator.clear();
}
- protected void locateMatches(RubyProject javaProject, PossibleMatch[] possibleMatches, int start, int length) throws CoreException {
+ protected void locateMatches(RubyProject rubyProject, PossibleMatch[] possibleMatches, int start, int length) throws CoreException {
for (int i = start, maxUnits = start + length; i < maxUnits; i++) {
PossibleMatch possibleMatch = possibleMatches[i];
RubyScript script = (RubyScript) possibleMatch.openable;
- SearchMatch[] matches = this.patternLocator.reportMatches(script);
- for (int j = 0; j < matches.length; j++) report(matches[j]);
+ this.patternLocator.reportMatches(script, this);
possibleMatch.cleanUp();
}
}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/OrPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/OrPattern.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/OrPattern.java 2007-04-13 14:12:19 UTC (rev 2307)
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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.matching;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.rubypeople.rdt.core.search.IRubySearchScope;
+import org.rubypeople.rdt.core.search.SearchParticipant;
+import org.rubypeople.rdt.core.search.SearchPattern;
+import org.rubypeople.rdt.internal.core.index.Index;
+import org.rubypeople.rdt.internal.core.search.IndexQueryRequestor;
+import org.rubypeople.rdt.internal.core.search.indexing.IIndexConstants;
+
+public class OrPattern extends SearchPattern implements IIndexConstants {
+
+ protected SearchPattern[] patterns;
+
+ /*
+ * Whether this pattern is erasure match.
+ */
+// boolean isErasureMatch;
+
+ /**
+ * One of {@link #R_ERASURE_MATCH}, {@link #R_EQUIVALENT_MATCH}, {@link #R_FULL_MATCH}.
+ */
+ int matchCompatibility;
+
+ public OrPattern(SearchPattern leftPattern, SearchPattern rightPattern) {
+ super(Math.max(leftPattern.getMatchRule(), rightPattern.getMatchRule()));
+ ((InternalSearchPattern)this).kind = OR_PATTERN;
+ ((InternalSearchPattern)this).mustResolve = ((InternalSearchPattern) leftPattern).mustResolve || ((InternalSearchPattern) rightPattern).mustResolve;
+
+ SearchPattern[] leftPatterns = leftPattern instanceof OrPattern ? ((OrPattern) leftPattern).patterns : null;
+ SearchPattern[] rightPatterns = rightPattern instanceof OrPattern ? ((OrPattern) rightPattern).patterns : null;
+ int leftSize = leftPatterns == null ? 1 : leftPatterns.length;
+ int rightSize = rightPatterns == null ? 1 : rightPatterns.length;
+ this.patterns = new SearchPattern[leftSize + rightSize];
+
+ if (leftPatterns == null)
+ this.patterns[0] = leftPattern;
+ else
+ System.arraycopy(leftPatterns, 0, this.patterns, 0, leftSize);
+ if (rightPatterns == null)
+ this.patterns[leftSize] = rightPattern;
+ else
+ System.arraycopy(rightPatterns, 0, this.patterns, leftSize, rightSize);
+
+ // Store erasure match
+ matchCompatibility = 0;
+ for (int i = 0, length = this.patterns.length; i < length; i++) {
+ matchCompatibility |= ((RubySearchPattern) this.patterns[i]).matchCompatibility;
+ }
+ }
+ void findIndexMatches(Index index, IndexQueryRequestor requestor, SearchParticipant participant, IRubySearchScope scope, IProgressMonitor progressMonitor) throws IOException {
+ // per construction, OR pattern can only be used with a PathCollector (which already gather results using a set)
+ try {
+ index.startQuery();
+ for (int i = 0, length = this.patterns.length; i < length; i++)
+ ((InternalSearchPattern)this.patterns[i]).findIndexMatches(index, requestor, participant, scope, progressMonitor);
+ } finally {
+ index.stopQuery();
+ }
+ }
+
+ public SearchPattern getBlankPattern() {
+ return null;
+ }
+
+ boolean isErasureMatch() {
+ return (this.matchCompatibility & R_ERASURE_MATCH) != 0;
+ }
+
+ boolean isPolymorphicSearch() {
+ for (int i = 0, length = this.patterns.length; i < length; i++)
+ if (((InternalSearchPattern) this.patterns[i]).isPolymorphicSearch()) return true;
+ return false;
+ }
+
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(this.patterns[0].toString());
+ for (int i = 1, length = this.patterns.length; i < length; i++) {
+ buffer.append("\n| "); //$NON-NLS-1$
+ buffer.append(this.patterns[i].toString());
+ }
+ return buffer.toString();
+ }
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/QualifiedTypeDeclarationPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/QualifiedTypeDeclarationPattern.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/QualifiedTypeDeclarationPattern.java 2007-04-13 14:12:19 UTC (rev 2307)
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * 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.matching;
+
+import org.rubypeople.rdt.core.search.SearchPattern;
+import org.rubypeople.rdt.internal.core.search.indexing.IIndexConstants;
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+
+public class QualifiedTypeDeclarationPattern extends TypeDeclarationPattern implements IIndexConstants {
+
+public char[] qualification;
+public int packageIndex;
+
+public QualifiedTypeDeclarationPattern(char[] qualification, char[] simpleName, char typeSuffix, int matchRule) {
+ this(matchRule);
+
+ this.qualification = isCaseSensitive() ? qualification : CharOperation.toLowerCase(qualification);
+ this.simpleName = (isCaseSensitive() || isCamelCase()) ? simpleName : CharOperation.toLowerCase(simpleName);
+ this.typeSuffix = typeSuffix;
+
+ ((InternalSearchPattern)this).mustResolve = this.qualification != null || typeSuffix != TYPE_SUFFIX;
+}
+QualifiedTypeDeclarationPattern(int matchRule) {
+ super(matchRule);
+}
+public void decodeIndexKey(char[] key) {
+ int slash = CharOperation.indexOf(SEPARATOR, key, 0);
+ this.simpleName = CharOperation.subarray(key, 0, slash);
+
+ int start = slash + 1;
+ slash = CharOperation.indexOf(SEPARATOR, key, start);
+ int secondSlash = CharOperation.indexOf(SEPARATOR, key, slash + 1);
+ this.packageIndex = -1; // used to compute package vs. enclosingTypeNames in MultiTypeDeclarationPattern
+ if (start + 1 == secondSlash) {
+ this.qualification = CharOperation.NO_CHAR; // no package name or enclosingTypeNames
+ } else if (slash + 1 == secondSlash) {
+ this.qualification = CharOperation.subarray(key, start, slash); // only a package name
+ } else if (slash == start) {
+ this.qualification = CharOperation.subarray(key, slash + 1, secondSlash); // no package name
+ this.packageIndex = 0;
+ } else {
+ this.qualification = CharOperation.subarray(key, start, secondSlash);
+ this.packageIndex = slash - start;
+ this.qualification[this.packageIndex] = '.';
+ }
+
+ // Continue key read by the end to decode modifiers
+ int last = key.length-1;
+ this.secondary = key[last] == 'S';
+ if (this.secondary) {
+ last -= 2;
+ }
+ this.modifiers = key[last-1] + (key[last]<<16);
+ decodeModifiers();
+}
+public SearchPattern getBlankPattern() {
+ return new QualifiedTypeDeclarationPattern(R_EXACT_MATCH | R_CASE_SENSITIVE);
+}
+public char[] getPackageName() {
+ if (this.packageIndex == -1)
+ return this.qualification;
+ return internedPackageNames.add(CharOperation.subarray(this.qualification, 0, this.packageIndex));
+}
+public char[][] getEnclosingTypeNames() {
+ if (this.packageIndex == -1)
+ return CharOperation.NO_CHAR_CHAR;
+ if (this.packageIndex == 0)
+ return CharOperation.splitOn('.', this.qualification);
+
+ char[] names = CharOperation.subarray(this.qualification, this.packageIndex + 1, this.qualification.length);
+ return CharOperation.splitOn('.', names);
+}
+public boolean matchesDecodedKey(SearchPattern decodedPattern) {
+ QualifiedTypeDeclarationPattern pattern = (QualifiedTypeDeclarationPattern) decodedPattern;
+ switch(this.typeSuffix) {
+ case CLASS_SUFFIX :
+ switch (pattern.typeSuffix) {
+ case CLASS_SUFFIX :
+ case CLASS_AND_MODULE_SUFFIX :
+ break;
+ default:
+ return false;
+ }
+ break;
+ case MODULE_SUFFIX :
+ switch (pattern.typeSuffix) {
+ case MODULE_SUFFIX :
+ case CLASS_AND_MODULE_SUFFIX :
+ break;
+ default:
+ return false;
+ }
+ break;
+ case CLASS_AND_MODULE_SUFFIX :
+ switch (pattern.typeSuffix) {
+ case CLASS_SUFFIX :
+ case MODULE_SUFFIX :
+ case CLASS_AND_MODULE_SUFFIX :
+ break;
+ default:
+ return false;
+ }
+ break;
+ }
+
+ return matchesName(this.simpleName, pattern.simpleName) && matchesName(this.qualification, pattern.qualification);
+}
+protected StringBuffer print(StringBuffer output) {
+ switch (this.typeSuffix){
+ case CLASS_SUFFIX :
+ output.append("ClassDeclarationPattern: qualification<"); //$NON-NLS-1$
+ break;
+ case CLASS_AND_MODULE_SUFFIX:
+ output.append("ClassAndInterfaceDeclarationPattern: qualification<"); //$NON-NLS-1$
+ break;
+ case MODULE_SUFFIX :
+ output.append("InterfaceDeclarationPattern: qualification<"); //$NON-NLS-1$
+ break;
+ default :
+ output.append("TypeDeclarationPattern: qualification<"); //$NON-NLS-1$
+ break;
+ }
+ if (this.qualification != null)
+ output.append(this.qualification);
+ else
+ output.append("*"); //$NON-NLS-1$
+ output.append(">, type<"); //$NON-NLS-1$
+ if (simpleName != null)
+ output.append(simpleName);
+ else
+ output.append("*"); //$NON-NLS-1$
+ output.append("> "); //$NON-NLS-1$
+ return super.print(output);
+}
+}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/RubySearchPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/RubySearchPattern.java 2007-04-13 13:04:55 UTC (rev 2306)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/RubySearchPattern.java 2007-04-13 14:12:19 UTC (rev 2307)
@@ -58,6 +58,10 @@
return null;
}
+ int getMatchMode() {
+ return this.matchMode;
+ }
+
boolean isCamelCase() {
return this.isCamelCase;
}
@@ -65,4 +69,36 @@
boolean isCaseSensitive () {
return this.isCaseSensitive;
}
+
+ protected StringBuffer print(StringBuffer output) {
+ output.append(", "); //$NON-NLS-1$
+ if (this.isCamelCase) {
+ output.append("camel case + "); //$NON-NLS-1$
+ }
+ switch(getMatchMode()) {
+ case R_EXACT_MATCH :
+ output.append("exact match,"); //$NON-NLS-1$
+ break;
+ case R_PREFIX_MATCH :
+ output.append("prefix match,"); //$NON-NLS-1$
+ break;
+ case R_PATTERN_MATCH :
+ output.append("pattern match,"); //$NON-NLS-1$
+ break;
+ case R_REGEXP_MATCH :
+ output.append("regexp match, "); //$NON-NLS-1$
+ break;
+ }
+ if (isCaseSensitive())
+ output.append(" case sensitive"); //$NON-NLS-1$
+ else
+ output.append(" case insensitive"); //$NON-NLS-1$
+ if ((this.matchCompatibility & R_ERASURE_MATCH) != 0) {
+ output.append(", erasure only"); //$NON-NLS-1$
+ }
+ if ((this.matchCompatibility & R_EQUIVALENT_MATCH) != 0) {
+ output.append(", equivalent oronly"); //$NON-NLS-1$
+ }
+ return output;
+ }
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeDeclarationPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeDeclarationPattern.java 2007-04-13 13:04:55 UTC (rev 2306)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeDeclarationPattern.java 2007-04-13 14:12:19 UTC (rev 2307)
@@ -1,9 +1,358 @@
+/*******************************************************************************
+ * 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.matching;
-public class TypeDeclarationPattern extends RubySearchPattern {
+import java.io.IOException;
- TypeDeclarationPattern(int matchRule) {
- super(TYPE_DECL_PATTERN, matchRule);
+import org.rubypeople.rdt.core.search.SearchPattern;
+import org.rubypeople.rdt.internal.core.index.EntryResult;
+import org.rubypeople.rdt.internal.core.index.Index;
+import org.rubypeople.rdt.internal.core.search.indexing.IIndexConstants;
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+
+public class TypeDeclarationPattern extends RubySearchPattern implements IIndexConstants {
+
+public char[] simpleName;
+public char[] pkg;
+public char[][] enclosingTypeNames;
+
+// set to CLASS_SUFFIX for only matching classes
+// set to INTERFACE_SUFFIX for only matching interfaces
+// set to ENUM_SUFFIX for only matching enums
+// set to ANNOTATION_TYPE_SUFFIX for only matching annotation types
+// set to TYPE_SUFFIX for matching both classes and interfaces
+public char typeSuffix;
+public int modifiers;
+public boolean secondary = false;
+
+protected static char[][] CATEGORIES = { TYPE_DECL };
+
+// want to save space by interning the package names for each match
+static PackageNameSet internedPackageNames = new PackageNameSet(1001);
+static class PackageNameSet {
+
+public char[][] names;
+public int elementSize; // number of elements in the table
+public int threshold;
+
+PackageNameSet(int size) {
+ this.elementSize = 0;
+ this.threshold = size; // size represents the expected number of elements
+ int extraRoom = (int) (size * 1.5f);
+ if (this.threshold == extraRoom)
+ extraRoom++;
+ this.names = new char[extraRoom][];
+}
+
+char[] add(char[] name) {
+ int length = names.length;
+ int index = CharOperation.hashCode(name) % length;
+ char[] current;
+ while ((current = names[index]) != null) {
+ if (CharOperation.equals(current, name)) return current;
+ if (++index == length) index = 0;
}
+ names[index] = name;
+ // assumes the threshold is never equal to the size of the table
+ if (++elementSize > threshold) rehash();
+ return name;
}
+
+void rehash() {
+ PackageNameSet newSet = new PackageNameSet(elementSize * 2); // double the number of expected elements
+ char[] current;
+ for (int i = names.length; --i >= 0;)
+ if ((current = names[i]) != null)
+ newSet.add(current);
+
+ this.names = newSet.names;
+ this.elementSize = newSet.elementSize;
+ this.threshold = newSet.threshold;
+}
+}
+
+/*
+ * Create index key for type declaration pattern:
+ * key = typeName / packageName / enclosingTypeName / modifiers
+ * or for secondary types
+ * key = typeName / packageName / enclosingTypeName / modifiers / 'S'
+ */
+public static char[] createIndexKey(int modifiers, char[] typeName, char[] packageName, char[][] enclosingTypeNames, boolean secondary) { //, char typeSuffix) {
+ int typeNameLength = typeName == null ? 0 : typeName.length;
+ int packageLength = packageName == null ? 0 : packageName.length;
+ int enclosingNamesLength = 0;
+ if (enclosingTypeNames != null) {
+ for (int i = 0, length = enclosingTypeNames.length; i < length;) {
+ enclosingNamesLength += enclosingTypeNames[i].length;
+ if (++i < length)
+ enclosingNamesLength++; // for the '.' separator
+ }
+ }
+
+ int resultLength = typeNameLength + packageLength + enclosingNamesLength + 5;
+ if (secondary) resultLength += 2;
+ char[] result = new char[resultLength];
+ int pos = 0;
+ if (typeNameLength > 0) {
+ System.arraycopy(typeName, 0, result, pos, typeNameLength);
+ pos += typeNameLength;
+ }
+ result[pos++] = SEPARATOR;
+ if (packageLength > 0) {
+ System.arraycopy(packageName, 0, result, pos, packageLength);
+ pos += packageLength;
+ }
+ result[pos++] = SEPARATOR;
+ if (enclosingTypeNames != null && enclosingNamesLength > 0) {
+ for (int i = 0, length = enclosingTypeNames.length; i < length;) {
+ char[] enclosingName = enclosingTypeNames[i];
+ int itsLength = enclosingName.length;
+ System.arraycopy(enclosingName, 0, result, pos, itsLength);
+ pos += itsLength;
+ if (++i < length)
+ result[pos++] = '.';
+ }
+ }
+ result[pos++] = SEPARATOR;
+ result[pos++] = (char) modifiers;
+ result[pos] = (char) (modifiers>>16);
+ if (secondary) {
+ result[++pos] = SEPARATOR;
+ result[++pos] = 'S';
+ }
+ return result;
+}
+
+public TypeDeclarationPattern(
+ char[] pkg,
+ char[][] enclosingTypeNames,
+ char[] simpleName,
+ char typeSuffix,
+ int matchRule) {
+
+ this(matchRule);
+
+ this.pkg = isCaseSensitive() ? pkg : CharOperation.toLowerCase(pkg);
+ if (isCaseSensitive() || enclosingTypeNames == null) {
+ this.enclosingTypeNames = enclosingTypeNames;
+ } else {
+ int length = enclosingTypeNames.length;
+ this.enclosingTypeNames = new char[length][];
+ for (int i = 0; i < length; i++)
+ this.enclosingTypeNames[i] = CharOperation.toLowerCase(enclosingTypeNames[i]);
+ }
+ this.simpleName = (isCaseSensitive() || isCamelCase()) ? simpleName : CharOperation.toLowerCase(simpleName);
+ this.typeSuffix = typeSuffix;
+
+ ((InternalSearchPattern)this).mustResolve = (this.pkg != null && this.enclosingTypeNames != null) || typeSuffix != TYPE_SUFFIX;
+}
+TypeDeclarationPattern(int matchRule) {
+ super(TYPE_DECL_PATTERN, matchRule);
+}
+/*
+ * Type entries are encoded as:
+ * simpleTypeName / packageName / enclosingTypeName / modifiers
+ * e.g. Object/java.lang//0
+ * e.g. Cloneable/java.lang//512
+ * e.g. LazyValue/javax.swing/UIDefaults/0
+ * or for secondary types as:
+ * simpleTypeName / packageName / enclosingTypeName / modifiers / S
+ */
+public void decodeIndexKey(char[] key) {
+ int slash = CharOperation.indexOf(SEPARATOR, key, 0);
+ this.simpleName = CharOperation.subarray(key, 0, slash);
+
+ int start = ++slash;
+ if (key[start] == SEPARATOR) {
+ this.pkg = CharOperation.NO_CHAR;
+ } else {
+ slash = CharOperation.indexOf(SEPARATOR, key, start);
+ this.pkg = internedPackageNames.add(CharOperation.subarray(key, start, slash));
+ }
+
+ // Continue key read by the end to decode modifiers
+ int last = key.length-1;
+ this.secondary = key[last] == 'S';
+ if (this.secondary) {
+ last -= 2;
+ }
+ this.modifiers = key[last-1] + (key[last]<<16);
+ decodeModifiers();
+
+ // Retrieve enclosing type names
+ start = slash + 1;
+ last -= 2; // position of ending slash
+ if (start == last) {
+ this.enclosingTypeNames = CharOperation.NO_CHAR_CHAR;
+ } else {
+ if (last == (start+1) && key[start] == ZERO_CHAR) {
+ this.enclosingTypeNames = ONE_ZERO_CHAR;
+ } else {
+ this.enclosingTypeNames = CharOperation.splitOn("::", key, start, last);
+ }
+ }
+}
+protected void decodeModifiers() {
+
+ // Extract suffix from modifiers instead of index key
+ switch (this.modifiers & (ClassFileConstants.AccModule)) {
+ case ClassFileConstants.AccModule:
+ this.typeSuffix = MODULE_SUFFIX;
+ break;
+ default:
+ this.typeSuffix = CLASS_SUFFIX;
+ break;
+ }
+}
+public SearchPattern getBlankPattern() {
+ return new TypeDeclarationPattern(R_EXACT_MATCH | R_CASE_SENSITIVE);
+}
+public char[][] getIndexCategories() {
+ return CATEGORIES;
+}
+public boolean matchesDecodedKey(SearchPattern decodedPattern) {
+ TypeDeclarationPattern pattern = (TypeDeclarationPattern) decodedPattern;
+ switch(this.typeSuffix) {
+ case CLASS_SUFFIX :
+ switch (pattern.typeSuffix) {
+ case CLASS_SUFFIX :
+ case CLASS_AND_MODULE_SUFFIX :
+ break;
+ default:
+ return false;
+ }
+ break;
+ case MODULE_SUFFIX :
+ switch (pattern.typeSuffix) {
+ case MODULE_SUFFIX :
+ case CLASS_AND_MODULE_SUFFIX :
+ break;
+ default:
+ return false;
+ }
+ break;
+ case CLASS_AND_MODULE_SUFFIX :
+ switch (pattern.typeSuffix) {
+ case CLASS_SUFFIX :
+ case MODULE_SUFFIX :
+ case CLASS_AND_MODULE_SUFFIX :
+ break;
+ default:
+ return false;
+ }
+ break;
+ }
+
+ if (!matchesName(this.simpleName, pattern.simpleName))
+ return false;
+
+ // check package - exact match only
+ if (this.pkg != null && !CharOperation.equals(this.pkg, pattern.pkg, isCaseSensitive()))
+ return false;
+
+ // check enclosingTypeNames - exact match only
+ if (this.enclosingTypeNames != null) {
+ if (this.enclosingTypeNames.length == 0)
+ return pattern.enclosingTypeNames.length == 0;
+ if (this.enclosingTypeNames.length == 1 && pattern.enclosingTypeNames.length == 1)
+ return CharOperation.equals(this.enclosingTypeNames[0], pattern.enclosingTypeNames[0], isCaseSensitive());
+ if (pattern.enclosingTypeNames == ONE_ZERO_CHAR)
+ return true; // is a local or anonymous type
+ return CharOperation.equals(this.enclosingTypeNames, pattern.enclosingTypeNames, isCaseSensitive());
+ }
+ return true;
+}
+EntryResult[] queryIn(Index index) throws IOException {
+ char[] key = this.simpleName; // can be null
+ int matchRule = getMatchRule();
+
+ switch(getMatchMode()) {
+ case R_PREFIX_MATCH :
+ // do a prefix query with the simpleName
+ break;
+ case R_EXACT_MATCH :
+ if (this.isCamelCase) break;
+ matchRule &= ~R_EXACT_MATCH;
+ if (this.simpleName != null) {
+ matchRule |= R_PREFIX_MATCH;
+ key = this.pkg == null
+ ? CharOperation.append(this.simpleName, SEPARATOR)
+ : CharOperation.concat(this.simpleName, SEPARATOR, this.pkg, SEPARATOR, CharOperation.NO_CHAR);
+ break; // do a prefix query with the simpleName and possibly the pkg
+ }
+ matchRule |= R_PATTERN_MATCH;
+ // fall thru to encode the key and do a pattern query
+ case R_PATTERN_MATCH :
+ if (this.pkg == null) {
+ if (this.simpleName == null) {
+ switch(this.typeSuffix) {
+ case CLASS_SUFFIX :
+ case MODULE_SUFFIX :
+ case CLASS_AND_MODULE_SUFFIX :
+ // null key already returns all types
+ // key = new char[] {ONE_STAR[0], SEPARATOR, ONE_STAR[0]};
+ break;
+ }
+ } else if (this.simpleName[this.simpleName.length - 1] != '*') {
+ key = CharOperation.concat(this.simpleName, ONE_STAR, SEPARATOR);
+ }
+ break; // do a pattern query with the current encoded key
+ }
+ // must decode to check enclosingTypeNames due to the encoding of local types
+ key = CharOperation.concat(
+ this.simpleName == null ? ONE_STAR : this.simpleName, SEPARATOR, this.pkg, SEPARATOR, ONE_STAR);
+ break;
+ case R_REGEXP_MATCH :
+ // TODO (frederic) implement regular expression match
+ break;
+ }
+
+ return index.query(getIndexCategories(), key, matchRule); // match rule is irrelevant when the key is null
+}
+protected StringBuffer print(StringBuffer output) {
+ switch (this.typeSuffix){
+ case CLASS_SUFFIX :
+ output.append("ClassDeclarationPattern: pkg<"); //$NON-NLS-1$
+ break;
+ case CLASS_AND_MODULE_SUFFIX:
+ output.append("ClassAndInterfaceDeclarationPattern: pkg<"); //$NON-NLS-1$
+ break;
+ case MODULE_SUFFIX :
+ output.append("InterfaceDeclarationPattern: pkg<"); //$NON-NLS-1$
+ break;
+ default :
+ output.append("TypeDeclarationPattern: pkg<"); //$NON-NLS-1$
+ break;
+ }
+ if (pkg != null)
+ output.append(pkg);
+ else
+ output.append("*"); //$NON-NLS-1$
+ output.append(">, enclosing<"); //$NON-NLS-1$
+ if (enclosingTypeNames != null) {
+ for (int i = 0; i < enclosingTypeNames.length; i++){
+ output.append(enclosingTypeNames[i]);
+ if (i < enclosingTypeNames.length - 1)
+ output.append('.');
+ }
+ } else {
+ output.append("*"); //$NON-NLS-1$
+ }
+ output.append(">, type<"); //$NON-NLS-1$
+ if (simpleName != null)
+ output.append(simpleName);
+ else
+ output.append("*"); //$NON-NLS-1$
+ output.append(">"); //$NON-NLS-1$
+ return super.print(output);
+}
+}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java 2007-04-13 13:04:55 UTC (rev 2306)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java 2007-04-13 14:12:19 UTC (rev 2307)
@@ -1275,4 +1275,198 @@
System.arraycopy(array, start, result, 0, end - start);
return result;
}
+
+/**
+ * Answers the concatenation of the three arrays inserting the sep1 character between the
+ * first two arrays and sep2 between the last two.
+ * It answers null if the three arrays are null.
+ * If the first array is null, then it answers the concatenation of second and third inserting
+ * the sep2 character between them.
+ * If the second array is null, then it answers the concatenation of first and third inserting
+ * the sep1 character between them.
+ * If the third array is null, then it answers the concatenation of first and second inserting
+ * the sep1 character between them.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * first = null
+ * sep1 = '/'
+ * second = { 'a' }
+ * sep2 = ':'
+ * third = { 'b' }
+ * => result = { ' a' , ':', 'b' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { 'a' }
+ * sep1 = '/'
+ * second = null
+ * sep2 = ':'
+ * third = { 'b' }
+ * => result = { ' a' , '/', 'b' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { 'a' }
+ * sep1 = '/'
+ * second = { 'b' }
+ * sep2 = ':'
+ * third = null
+ * => result = { ' a' , '/', 'b' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { 'a' }
+ * sep1 = '/'
+ * second = { 'b' }
+ * sep2 = ':'
+ * third = { 'c' }
+ * => result = { ' a' , '/', 'b' , ':', 'c' }
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param first the first array to concatenate
+ * @param sep1 the character to insert
+ * @param second the second array to concatenate
+ * @param sep2 the character to insert
+ * @param third the second array to concatenate
+ * @return the concatenation of the three arrays inserting the sep1 character between the
+ * two arrays and sep2 between the last two.
+ */
+public static final char[] concat(
+ char[] first,
+ char sep1,
+ char[] second,
+ char sep2,
+ char[] third) {
+ if (first == null)
+ return concat(second, third, sep2);
+ if (second == null)
+ return concat(first, third, sep1);
+ if (third == null)
+ return concat(first, second, sep1);
+
+ int length1 = first.length;
+ int length2 = second.length;
+ int length3 = third.length;
+ char[] result = new char[length1 + length2 + length3 + 2];
+ System.arraycopy(first, 0, result, 0, length1);
+ result[length1] = sep1;
+ System.arraycopy(second, 0, result, length1 + 1, length2);
+ result[length1 + length2 + 1] = sep2;
+ System.arraycopy(third, 0, result, length1 + length2 + 2, length3);
+ return result;
}
+
+/**
+ * Answers a new array with appending the suffix character at the end of the array.
+ * <br>
+ * <br>
+ * For example:<br>
+ * <ol>
+ * <li><pre>
+ * array = { 'a', 'b' }
+ * suffix = 'c'
+ * => result = { 'a', 'b' , 'c' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * array = null
+ * suffix = 'c'
+ * => result = { 'c' }
+ * </pre></li>
+ * </ol>
+ *
+ * @param array the array that is concanated with the suffix character
+ * @param suffix the suffix character
+ * @return the new array
+ */
+public static final char[] append(char[] array, char suffix) {
+ if (array == null)
+ return new char[] { suffix };
+ int length = array.length;
+ System.arraycopy(array, 0, array = new char[length + 1], 0, length);
+ array[length] = suffix;
+ return array;
+}
+
+/**
+ * If isCaseSensite is true, answers true if the two arrays are identical character
+ * by character, otherwise false.
+ * If it is false, answers true if the two arrays are identical character by
+ * character without checking the case, otherwise false.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * first = null
+ * second = null
+ * isCaseSensitive = true
+ * result => true
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { { } }
+ * second = null
+ * isCaseSensitive = true
+ * result => false
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { { 'A' } }
+ * second = { { 'a' } }
+ * isCaseSensitive = true
+ * result => false
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { { 'A' } }
+ * second = { { 'a' } }
+ * isCaseSensitive = false
+ * result => true
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param first the first array
+ * @param second the second array
+ * @param isCaseSensitive check whether or not the equality should be case sensitive
+ * @return true if the two arrays are identical character by character according to the value
+ * of isCaseSensitive, otherwise false
+ */
+public static final boolean equals(
+ char[][] first,
+ char[][] second,
+ boolean isCaseSensitive) {
+
+ if (isCaseSensitive) {
+ return equals(first, second);
+ }
+ if (first == second)
+ return true;
+ if (first == null || second == null)
+ return false;
+ if (first.length != second.length)
+ return false;
+
+ for (int i = first.length; --i >= 0;)
+ if (!equals(first[i], second[i], false))
+ return false;
+ return true;
+}
+
+public static char[][] splitOn(String divider, char[] key, int start, int last) {
+ String newKey = new String(key);
+ newKey = newKey.substring(start, last);
+ String[] result = newKey.split(divider);
+ char[][] resultEnd = new char[result.length][];
+ for (int i = 0; i < resultEnd.length; i++) {
+ resultEnd[i] = result[i].toCharArray();
+ }
+ return resultEnd;
+}
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mir...@us...> - 2007-04-13 13:04:57
|
Revision: 2306
http://svn.sourceforge.net/rubyeclipse/?rev=2306&view=rev
Author: mirkostocker
Date: 2007-04-13 06:04:55 -0700 (Fri, 13 Apr 2007)
Log Message:
-----------
rename and move the tests
Modified Paths:
--------------
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/TS_Core.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/nodewrapper/TS_NodeWrapper.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_ModuleWithMultipleParents.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_ModuleWithParent.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_SimpleModule.rb
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/TC_ModuleNodeProvider.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_ModuleWithMultipleParents.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_ModuleWithParent.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_SimpleModule.rb
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/nodewrapper/TC_ModuleNodeWrapper.java
Copied: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_ModuleWithMultipleParents.rb (from rev 2305, trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_ModuleWithMultipleParents.rb)
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_ModuleWithMultipleParents.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_ModuleWithMultipleParents.rb 2007-04-13 13:04:55 UTC (rev 2306)
@@ -0,0 +1,10 @@
+module M1
+ module M2
+ module M3
+ module M4
+ module M5
+ end
+ end
+ end
+ end
+end
\ No newline at end of file
Copied: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_ModuleWithParent.rb (from rev 2305, trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_ModuleWithParent.rb)
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_ModuleWithParent.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_ModuleWithParent.rb 2007-04-13 13:04:55 UTC (rev 2306)
@@ -0,0 +1,4 @@
+module OuterModule
+ module Modul
+ end
+end
\ No newline at end of file
Copied: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_SimpleModule.rb (from rev 2305, trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_SimpleModule.rb)
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_SimpleModule.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/TC_ModuleNodeProvider_SimpleModule.rb 2007-04-13 13:04:55 UTC (rev 2306)
@@ -0,0 +1,2 @@
+module Modul
+end
\ No newline at end of file
Deleted: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_ModuleWithMultipleParents.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_ModuleWithMultipleParents.rb 2007-04-13 12:56:14 UTC (rev 2305)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_ModuleWithMultipleParents.rb 2007-04-13 13:04:55 UTC (rev 2306)
@@ -1,10 +0,0 @@
-module M1
- module M2
- module M3
- module M4
- module M5
- end
- end
- end
- end
-end
\ No newline at end of file
Deleted: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_ModuleWithParent.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_ModuleWithParent.rb 2007-04-13 12:56:14 UTC (rev 2305)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_ModuleWithParent.rb 2007-04-13 13:04:55 UTC (rev 2306)
@@ -1,4 +0,0 @@
-module OuterModule
- module Modul
- end
-end
\ No newline at end of file
Deleted: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_SimpleModule.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_SimpleModule.rb 2007-04-13 12:56:14 UTC (rev 2305)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_SimpleModule.rb 2007-04-13 13:04:55 UTC (rev 2306)
@@ -1,2 +0,0 @@
-module Modul
-end
\ No newline at end of file
Copied: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/TC_ModuleNodeProvider.java (from rev 2305, trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/nodewrapper/TC_ModuleNodeWrapper.java)
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/TC_ModuleNodeProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/TC_ModuleNodeProvider.java 2007-04-13 13:04:55 UTC (rev 2306)
@@ -0,0 +1,71 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.tests.core;
+
+import org.rubypeople.rdt.refactoring.core.ModuleNodeProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.ModuleNodeWrapper;
+import org.rubypeople.rdt.refactoring.tests.FileTestCase;
+
+public class TC_ModuleNodeProvider extends FileTestCase {
+
+ public TC_ModuleNodeProvider() {
+ super("Module Node Provider");
+ }
+
+ private ModuleNodeWrapper findModule(String file, int position) {
+ return ModuleNodeProvider.getSelectedModuleNode(getRootNode(file),position);
+ }
+
+ public void testSimpleModule() {
+ ModuleNodeWrapper moduleNode = findModule("TC_ModuleNodeProvider_SimpleModule.rb", 8);
+
+ assertNull(moduleNode.getParentModule());
+ assertNotNull(moduleNode.getWrappedNode());
+ assertEquals("Modul", moduleNode.getName());
+ assertEquals("Modul", moduleNode.getFullName());
+ }
+
+ public void testModuleWithParent() {
+ ModuleNodeWrapper moduleNode = findModule("TC_ModuleNodeProvider_ModuleWithParent.rb", 31);
+
+ assertNotNull(moduleNode.getParentModule());
+ assertNotNull(moduleNode.getParentModule().getWrappedNode());
+ assertNull(moduleNode.getParentModule().getParentModule());
+ assertNotNull(moduleNode.getWrappedNode());
+ assertEquals("Modul", moduleNode.getName());
+ assertEquals("OuterModule::Modul", moduleNode.getFullName());
+ }
+
+ public void testModuleWithMultipleParents() {
+ ModuleNodeWrapper moduleNode = findModule("TC_ModuleNodeProvider_ModuleWithMultipleParents.rb", 68);
+
+ assertEquals("M5", moduleNode.getName());
+ assertEquals("M1::M2::M3::M4::M5", moduleNode.getFullName());
+ }
+}
Modified: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/TS_Core.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/TS_Core.java 2007-04-13 12:56:14 UTC (rev 2305)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/TS_Core.java 2007-04-13 13:04:55 UTC (rev 2306)
@@ -39,6 +39,7 @@
public static Test suite() {
TestSuite suite = createSuite("Core", "enclosing_nodes_test*rb", TC_SelectionNodeProvider.class);
suite.addTestSuite(TC_NodeProvider.class);
+ suite.addTestSuite(TC_ModuleNodeProvider.class);
suite.addTest(TS_NodeWrapper.suite());
suite.addTestSuite(TC_RefactoringConditionChecker.class);
return suite;
Deleted: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/nodewrapper/TC_ModuleNodeWrapper.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/nodewrapper/TC_ModuleNodeWrapper.java 2007-04-13 12:56:14 UTC (rev 2305)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/nodewrapper/TC_ModuleNodeWrapper.java 2007-04-13 13:04:55 UTC (rev 2306)
@@ -1,43 +0,0 @@
-package org.rubypeople.rdt.refactoring.tests.core.nodewrapper;
-
-import org.rubypeople.rdt.refactoring.core.ModuleNodeProvider;
-import org.rubypeople.rdt.refactoring.nodewrapper.ModuleNodeWrapper;
-import org.rubypeople.rdt.refactoring.tests.FileTestCase;
-
-public class TC_ModuleNodeWrapper extends FileTestCase {
-
- public TC_ModuleNodeWrapper() {
- super("Module Node Wrapper");
- }
-
- private ModuleNodeWrapper findModule(String file, int position) {
- return ModuleNodeProvider.getSelectedModuleNode(getRootNode(file),position);
- }
-
- public void testSimpleModule() {
- ModuleNodeWrapper moduleNode = findModule("TC_ModuleNodeWrapper_SimpleModule.rb", 8);
-
- assertNull(moduleNode.getParentModule());
- assertNotNull(moduleNode.getWrappedNode());
- assertEquals("Modul", moduleNode.getName());
- assertEquals("Modul", moduleNode.getFullName());
- }
-
- public void testModuleWithParent() {
- ModuleNodeWrapper moduleNode = findModule("TC_ModuleNodeWrapper_ModuleWithParent.rb", 31);
-
- assertNotNull(moduleNode.getParentModule());
- assertNotNull(moduleNode.getParentModule().getWrappedNode());
- assertNull(moduleNode.getParentModule().getParentModule());
- assertNotNull(moduleNode.getWrappedNode());
- assertEquals("Modul", moduleNode.getName());
- assertEquals("OuterModule::Modul", moduleNode.getFullName());
- }
-
- public void testModuleWithMultipleParents() {
- ModuleNodeWrapper moduleNode = findModule("TC_ModuleNodeWrapper_ModuleWithMultipleParents.rb", 68);
-
- assertEquals("M5", moduleNode.getName());
- assertEquals("M1::M2::M3::M4::M5", moduleNode.getFullName());
- }
-}
Modified: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/nodewrapper/TS_NodeWrapper.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/nodewrapper/TS_NodeWrapper.java 2007-04-13 12:56:14 UTC (rev 2305)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/nodewrapper/TS_NodeWrapper.java 2007-04-13 13:04:55 UTC (rev 2306)
@@ -35,7 +35,6 @@
TestSuite suite = new TestSuite("Node Wrapper");
suite.addTestSuite(TC_FieldNodeWrapper.class);
suite.addTestSuite(TC_MethodNodeWrapper.class);
- suite.addTestSuite(TC_ModuleNodeWrapper.class);
return suite;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mir...@us...> - 2007-04-13 12:56:16
|
Revision: 2305
http://svn.sourceforge.net/rubyeclipse/?rev=2305&view=rev
Author: mirkostocker
Date: 2007-04-13 05:56:14 -0700 (Fri, 13 Apr 2007)
Log Message:
-----------
move from selectionnodeprovider to modulenodeprovider
Added Paths:
-----------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/ModuleNodeProvider.java
Added: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/ModuleNodeProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/ModuleNodeProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/ModuleNodeProvider.java 2007-04-13 12:56:14 UTC (rev 2305)
@@ -0,0 +1,66 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+
+package org.rubypeople.rdt.refactoring.core;
+
+import java.util.ArrayList;
+
+import org.jruby.ast.ModuleNode;
+import org.jruby.ast.Node;
+import org.rubypeople.rdt.refactoring.nodewrapper.ModuleNodeWrapper;
+
+public class ModuleNodeProvider {
+
+ public static ModuleNodeWrapper getSelectedModuleNode(Node root, int pos) {
+
+ ModuleNode module = (ModuleNode) SelectionNodeProvider.getSelectedNodeOfType(root, pos, ModuleNode.class);
+ if(module == null) {
+ return null;
+ }
+
+ ArrayList<ModuleNode> modules = new ArrayList<ModuleNode>();
+ modules.add(module);
+ ModuleNode parent = null;
+
+ while(true) {
+ parent = (ModuleNode) NodeProvider.findParentNode(root, module, ModuleNode.class);
+ if(parent == null)
+ break;
+ modules.add(0, parent);
+ module = parent;
+ }
+
+ ModuleNodeWrapper previousWrapper = null;
+ for (ModuleNode node : modules) {
+ ModuleNodeWrapper nodeWrapper = new ModuleNodeWrapper(node, previousWrapper);
+ previousWrapper = nodeWrapper;
+ }
+ return previousWrapper;
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mir...@us...> - 2007-04-13 12:55:40
|
Revision: 2304
http://svn.sourceforge.net/rubyeclipse/?rev=2304&view=rev
Author: mirkostocker
Date: 2007-04-13 05:55:36 -0700 (Fri, 13 Apr 2007)
Log Message:
-----------
rename and reuse the PartialClassesRenameEditProvider
Modified Paths:
--------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/SelectionNodeProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassEditProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleEditProvider.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/nodewrapper/TC_ModuleNodeWrapper.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/editprovider/ScopingNodeRenameEditProvider.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/PartialClassesRenameEditProvider.java
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-13 12:12:24 UTC (rev 2303)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/SelectionNodeProvider.java 2007-04-13 12:55:36 UTC (rev 2304)
@@ -60,7 +60,6 @@
import org.rubypeople.rdt.refactoring.nodewrapper.AttrAccessorNodeWrapper;
import org.rubypeople.rdt.refactoring.nodewrapper.ClassNodeWrapper;
import org.rubypeople.rdt.refactoring.nodewrapper.INodeWrapper;
-import org.rubypeople.rdt.refactoring.nodewrapper.ModuleNodeWrapper;
import org.rubypeople.rdt.refactoring.nodewrapper.PartialClassNodeWrapper;
import org.rubypeople.rdt.refactoring.util.NodeUtil;
@@ -307,33 +306,6 @@
}
return newNode;
}
-
- public static ModuleNodeWrapper getSelectedModuleNode(Node root, int pos) {
-
- ModuleNode module = (ModuleNode) getSelectedNodeOfType(root, pos, ModuleNode.class);
- if(module == null) {
- return null;
- }
-
- ArrayList<ModuleNode> modules = new ArrayList<ModuleNode>();
- modules.add(module);
- ModuleNode parent = null;
-
- while(true) {
- parent = (ModuleNode) NodeProvider.findParentNode(root, module, ModuleNode.class);
- if(parent == null)
- break;
- modules.add(0, parent);
- module = parent;
- }
-
- ModuleNodeWrapper previousWrapper = null;
- for (ModuleNode node : modules) {
- ModuleNodeWrapper nodeWrapper = new ModuleNodeWrapper(node, previousWrapper);
- previousWrapper = nodeWrapper;
- }
- return previousWrapper;
- }
}
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/PartialClassesRenameEditProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/PartialClassesRenameEditProvider.java 2007-04-13 12:12:24 UTC (rev 2303)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/PartialClassesRenameEditProvider.java 2007-04-13 12:55:36 UTC (rev 2304)
@@ -1,83 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2006 Mirko Stocker <me...@mi...>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-
-package org.rubypeople.rdt.refactoring.core.renameclass;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.jruby.ast.IScopingNode;
-import org.jruby.ast.Node;
-import org.rubypeople.rdt.refactoring.editprovider.FileEditProvider;
-import org.rubypeople.rdt.refactoring.editprovider.ReplaceEditProvider;
-
-public class PartialClassesRenameEditProvider {
-
- private static class ScopingNodeRenameEdit extends ReplaceEditProvider {
-
- private final IScopingNode node;
-
- public ScopingNodeRenameEdit(IScopingNode klass) {
- this.node = klass;
- }
-
- @Override
- protected int getOffsetLength() {
- return node.getCPath().getPosition().getEndOffset() - node.getCPath().getPosition().getStartOffset();
- }
-
- @Override
- protected Node getEditNode(int offset, String document) {
- return node.getCPath();
- }
-
- @Override
- protected int getOffset(String document) {
- return node.getCPath().getPosition().getStartOffset();
- }
- }
-
- private final Collection<? extends IScopingNode> nodes;
- private final String newName;
-
- public PartialClassesRenameEditProvider(Collection<? extends IScopingNode> nodes, String newName) {
- this.nodes = nodes;
- this.newName = newName;
- }
-
- public Collection<FileEditProvider> getEditProviders() {
- Collection<FileEditProvider> edits = new ArrayList<FileEditProvider>();
-
- for(IScopingNode klass : nodes) {
- klass.getCPath().setName(newName);
- edits.add(new FileEditProvider(((Node) klass).getPosition().getFile(), new ScopingNodeRenameEdit(klass)));
- }
-
- return edits;
- }
-}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassEditProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassEditProvider.java 2007-04-13 12:12:24 UTC (rev 2303)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassEditProvider.java 2007-04-13 12:55:36 UTC (rev 2304)
@@ -35,6 +35,7 @@
import org.rubypeople.rdt.refactoring.editprovider.FileMultiEditProvider;
import org.rubypeople.rdt.refactoring.editprovider.IMultiFileEditProvider;
import org.rubypeople.rdt.refactoring.editprovider.MultiFileEditProvider;
+import org.rubypeople.rdt.refactoring.editprovider.ScopingNodeRenameEditProvider;
public class RenameClassEditProvider implements IMultiFileEditProvider {
@@ -51,9 +52,9 @@
return new ChildClassesRenameEditProvider(childClasses, config.getNewName());
}
- private PartialClassesRenameEditProvider createPartialsEditProvider() {
+ private ScopingNodeRenameEditProvider createPartialsEditProvider() {
Collection<ClassNode> classNodes = new ClassFinder(document, config.getSelectedNode().getCPath().getName(), config.getModulePrefix()).findParts();
- return new PartialClassesRenameEditProvider(classNodes, config.getNewName());
+ return new ScopingNodeRenameEditProvider(classNodes, config.getNewName());
}
private ConstructorRenameEditProvider createConstructorEditProvider() {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConditionChecker.java 2007-04-13 12:12:24 UTC (rev 2303)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConditionChecker.java 2007-04-13 12:55:36 UTC (rev 2304)
@@ -1,8 +1,8 @@
package org.rubypeople.rdt.refactoring.core.renamemodule;
import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
+import org.rubypeople.rdt.refactoring.core.ModuleNodeProvider;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
-import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
import org.rubypeople.rdt.refactoring.nodewrapper.ModuleNodeWrapper;
import org.rubypeople.rdt.refactoring.util.NodeUtil;
@@ -27,7 +27,7 @@
public void init(IRefactoringConfig configObj) {
config = (RenameModuleConfig) configObj;
- ModuleNodeWrapper selectedModule = SelectionNodeProvider.getSelectedModuleNode(config.getDocumentProvider().getActiveFileRootNode(), config.getCarretPosition());
+ ModuleNodeWrapper selectedModule = ModuleNodeProvider.getSelectedModuleNode(config.getDocumentProvider().getActiveFileRootNode(), config.getCarretPosition());
config.setSelectedModule(selectedModule);
if(config.getSelectedModule() == null || caretIsNotOnModuleName(selectedModule)) {
return;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleEditProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleEditProvider.java 2007-04-13 12:12:24 UTC (rev 2303)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleEditProvider.java 2007-04-13 12:55:36 UTC (rev 2304)
@@ -4,10 +4,10 @@
import java.util.Collection;
import org.jruby.ast.IScopingNode;
-import org.rubypeople.rdt.refactoring.core.renameclass.PartialClassesRenameEditProvider;
import org.rubypeople.rdt.refactoring.editprovider.FileMultiEditProvider;
import org.rubypeople.rdt.refactoring.editprovider.IMultiFileEditProvider;
import org.rubypeople.rdt.refactoring.editprovider.MultiFileEditProvider;
+import org.rubypeople.rdt.refactoring.editprovider.ScopingNodeRenameEditProvider;
public class RenameModuleEditProvider implements IMultiFileEditProvider {
@@ -17,10 +17,10 @@
this.config = config;
}
- private PartialClassesRenameEditProvider getModuleEditProvider() {
+ private ScopingNodeRenameEditProvider getModuleEditProvider() {
ArrayList<IScopingNode> modules = new ArrayList<IScopingNode>();
modules.add(config.getSelectedModule().getWrappedNode());
- return new PartialClassesRenameEditProvider(modules, config.getNewName());
+ return new ScopingNodeRenameEditProvider(modules, config.getNewName());
}
public Collection<FileMultiEditProvider> getFileEditProviders() {
Copied: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/editprovider/ScopingNodeRenameEditProvider.java (from rev 2303, trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/PartialClassesRenameEditProvider.java)
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/editprovider/ScopingNodeRenameEditProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/editprovider/ScopingNodeRenameEditProvider.java 2007-04-13 12:55:36 UTC (rev 2304)
@@ -0,0 +1,83 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.editprovider;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.jruby.ast.IScopingNode;
+import org.jruby.ast.Node;
+import org.rubypeople.rdt.refactoring.editprovider.FileEditProvider;
+import org.rubypeople.rdt.refactoring.editprovider.ReplaceEditProvider;
+
+public class ScopingNodeRenameEditProvider {
+
+ private static class ScopingNodeRenameEdit extends ReplaceEditProvider {
+
+ private final IScopingNode node;
+
+ public ScopingNodeRenameEdit(IScopingNode klass) {
+ this.node = klass;
+ }
+
+ @Override
+ protected int getOffsetLength() {
+ return node.getCPath().getPosition().getEndOffset() - node.getCPath().getPosition().getStartOffset();
+ }
+
+ @Override
+ protected Node getEditNode(int offset, String document) {
+ return node.getCPath();
+ }
+
+ @Override
+ protected int getOffset(String document) {
+ return node.getCPath().getPosition().getStartOffset();
+ }
+ }
+
+ private final Collection<? extends IScopingNode> nodes;
+ private final String newName;
+
+ public ScopingNodeRenameEditProvider(Collection<? extends IScopingNode> nodes, String newName) {
+ this.nodes = nodes;
+ this.newName = newName;
+ }
+
+ public Collection<FileEditProvider> getEditProviders() {
+ Collection<FileEditProvider> edits = new ArrayList<FileEditProvider>();
+
+ for(IScopingNode klass : nodes) {
+ klass.getCPath().setName(newName);
+ edits.add(new FileEditProvider(((Node) klass).getPosition().getFile(), new ScopingNodeRenameEdit(klass)));
+ }
+
+ return edits;
+ }
+}
Modified: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/nodewrapper/TC_ModuleNodeWrapper.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/nodewrapper/TC_ModuleNodeWrapper.java 2007-04-13 12:12:24 UTC (rev 2303)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/nodewrapper/TC_ModuleNodeWrapper.java 2007-04-13 12:55:36 UTC (rev 2304)
@@ -1,6 +1,6 @@
package org.rubypeople.rdt.refactoring.tests.core.nodewrapper;
-import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
+import org.rubypeople.rdt.refactoring.core.ModuleNodeProvider;
import org.rubypeople.rdt.refactoring.nodewrapper.ModuleNodeWrapper;
import org.rubypeople.rdt.refactoring.tests.FileTestCase;
@@ -11,7 +11,7 @@
}
private ModuleNodeWrapper findModule(String file, int position) {
- return SelectionNodeProvider.getSelectedModuleNode(getRootNode(file),position);
+ return ModuleNodeProvider.getSelectedModuleNode(getRootNode(file),position);
}
public void testSimpleModule() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mir...@us...> - 2007-04-13 12:12:26
|
Revision: 2303
http://svn.sourceforge.net/rubyeclipse/?rev=2303&view=rev
Author: mirkostocker
Date: 2007-04-13 05:12:24 -0700 (Fri, 13 Apr 2007)
Log Message:
-----------
minimal implementation of rename module, not really usable yet
Modified Paths:
--------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/NodeProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/SelectionNodeProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/PartialClassesRenameEditProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConfig.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleEditProvider.java
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_1.activeFile.rb.result
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/FileTestCase.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/nodewrapper/TS_NodeWrapper.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/nodewrapper/ModuleNodeWrapper.java
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_ModuleWithMultipleParents.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_ModuleWithParent.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_SimpleModule.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_2.activeFile.rb.result
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_2.activeFile.rb.source
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_2.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_3.activeFile.rb.result
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_3.activeFile.rb.source
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_3.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_4.activeFile.rb.result
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_4.activeFile.rb.source
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_4.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/nodewrapper/TC_ModuleNodeWrapper.java
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/NodeProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/NodeProvider.java 2007-04-12 23:50:02 UTC (rev 2302)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/NodeProvider.java 2007-04-13 12:12:24 UTC (rev 2303)
@@ -227,7 +227,9 @@
* Returns the parent of a given node.
*/
public static Node findParentNode(Node rootNode, Node child) {
-
+
+ if (child == null) return null;
+
Collection<Node> allNodes = getAllNodes(rootNode);
for (Node node : allNodes) {
if (containsNode(node.childNodes(), child)) {
@@ -238,7 +240,7 @@
}
public static Node findParentNode(Node rootNode, Node child, Class type) {
- while((child = findParentNode(rootNode, child)) != null) {
+ while((child = findParentNode(rootNode, child)) != null && !(child instanceof RootNode)) {
if(child.getClass().isAssignableFrom(type)) {
return child;
}
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-12 23:50:02 UTC (rev 2302)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/SelectionNodeProvider.java 2007-04-13 12:12:24 UTC (rev 2303)
@@ -60,6 +60,7 @@
import org.rubypeople.rdt.refactoring.nodewrapper.AttrAccessorNodeWrapper;
import org.rubypeople.rdt.refactoring.nodewrapper.ClassNodeWrapper;
import org.rubypeople.rdt.refactoring.nodewrapper.INodeWrapper;
+import org.rubypeople.rdt.refactoring.nodewrapper.ModuleNodeWrapper;
import org.rubypeople.rdt.refactoring.nodewrapper.PartialClassNodeWrapper;
import org.rubypeople.rdt.refactoring.util.NodeUtil;
@@ -306,4 +307,33 @@
}
return newNode;
}
+
+ public static ModuleNodeWrapper getSelectedModuleNode(Node root, int pos) {
+
+ ModuleNode module = (ModuleNode) getSelectedNodeOfType(root, pos, ModuleNode.class);
+ if(module == null) {
+ return null;
+ }
+
+ ArrayList<ModuleNode> modules = new ArrayList<ModuleNode>();
+ modules.add(module);
+ ModuleNode parent = null;
+
+ while(true) {
+ parent = (ModuleNode) NodeProvider.findParentNode(root, module, ModuleNode.class);
+ if(parent == null)
+ break;
+ modules.add(0, parent);
+ module = parent;
+ }
+
+ ModuleNodeWrapper previousWrapper = null;
+ for (ModuleNode node : modules) {
+ ModuleNodeWrapper nodeWrapper = new ModuleNodeWrapper(node, previousWrapper);
+ previousWrapper = nodeWrapper;
+ }
+ return previousWrapper;
+ }
}
+
+
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/PartialClassesRenameEditProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/PartialClassesRenameEditProvider.java 2007-04-12 23:50:02 UTC (rev 2302)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/PartialClassesRenameEditProvider.java 2007-04-13 12:12:24 UTC (rev 2303)
@@ -31,53 +31,51 @@
import java.util.ArrayList;
import java.util.Collection;
-import org.jruby.ast.ClassNode;
+import org.jruby.ast.IScopingNode;
import org.jruby.ast.Node;
import org.rubypeople.rdt.refactoring.editprovider.FileEditProvider;
import org.rubypeople.rdt.refactoring.editprovider.ReplaceEditProvider;
public class PartialClassesRenameEditProvider {
- private static class PartialClassRenameEdit extends ReplaceEditProvider {
+ private static class ScopingNodeRenameEdit extends ReplaceEditProvider {
- private final ClassNode klass;
+ private final IScopingNode node;
- public PartialClassRenameEdit(ClassNode klass) {
- this.klass = klass;
+ public ScopingNodeRenameEdit(IScopingNode klass) {
+ this.node = klass;
}
@Override
protected int getOffsetLength() {
- return klass.getCPath().getPosition().getEndOffset() - klass.getCPath().getPosition().getStartOffset();
+ return node.getCPath().getPosition().getEndOffset() - node.getCPath().getPosition().getStartOffset();
}
@Override
protected Node getEditNode(int offset, String document) {
- return klass.getCPath();
+ return node.getCPath();
}
@Override
protected int getOffset(String document) {
- return klass.getCPath().getPosition().getStartOffset();
+ return node.getCPath().getPosition().getStartOffset();
}
-
-
}
- private final Collection<ClassNode> classes;
+ private final Collection<? extends IScopingNode> nodes;
private final String newName;
- public PartialClassesRenameEditProvider(Collection<ClassNode> partials, String newName) {
- this.classes = partials;
+ public PartialClassesRenameEditProvider(Collection<? extends IScopingNode> nodes, String newName) {
+ this.nodes = nodes;
this.newName = newName;
}
- protected Collection<FileEditProvider> getEditProviders() {
+ public Collection<FileEditProvider> getEditProviders() {
Collection<FileEditProvider> edits = new ArrayList<FileEditProvider>();
- for(ClassNode klass : classes) {
+ for(IScopingNode klass : nodes) {
klass.getCPath().setName(newName);
- edits.add(new FileEditProvider(klass.getPosition().getFile(), new PartialClassRenameEdit(klass)));
+ edits.add(new FileEditProvider(((Node) klass).getPosition().getFile(), new ScopingNodeRenameEdit(klass)));
}
return edits;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConditionChecker.java 2007-04-12 23:50:02 UTC (rev 2302)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConditionChecker.java 2007-04-13 12:12:24 UTC (rev 2303)
@@ -1,9 +1,9 @@
package org.rubypeople.rdt.refactoring.core.renamemodule;
-import org.jruby.ast.ModuleNode;
import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.ModuleNodeWrapper;
import org.rubypeople.rdt.refactoring.util.NodeUtil;
public class RenameModuleConditionChecker extends RefactoringConditionChecker {
@@ -27,12 +27,16 @@
public void init(IRefactoringConfig configObj) {
config = (RenameModuleConfig) configObj;
- ModuleNode selectedModule = (ModuleNode) SelectionNodeProvider.getSelectedNodeOfType(config.getDocumentProvider().getActiveFileRootNode(), config.getCarretPosition(), ModuleNode.class);
+ ModuleNodeWrapper selectedModule = SelectionNodeProvider.getSelectedModuleNode(config.getDocumentProvider().getActiveFileRootNode(), config.getCarretPosition());
config.setSelectedModule(selectedModule);
- if(config.getSelectedModule()== null || !NodeUtil.positionIsInNode(config.getCarretPosition(), selectedModule.getCPath())) {
+ if(config.getSelectedModule() == null || caretIsNotOnModuleName(selectedModule)) {
return;
}
- config.setNewName(selectedModule.getCPath().getName());
+ config.setNewName(selectedModule.getName());
}
+ private boolean caretIsNotOnModuleName(ModuleNodeWrapper selectedModule) {
+ return !NodeUtil.positionIsInNode(config.getCarretPosition(), selectedModule.getWrappedNode().getCPath());
+ }
+
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConfig.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConfig.java 2007-04-12 23:50:02 UTC (rev 2302)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConfig.java 2007-04-13 12:12:24 UTC (rev 2303)
@@ -1,15 +1,16 @@
package org.rubypeople.rdt.refactoring.core.renamemodule;
-import org.jruby.ast.ModuleNode;
import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
import org.rubypeople.rdt.refactoring.documentprovider.IDocumentProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.ModuleNodeWrapper;
import org.rubypeople.rdt.refactoring.ui.INewNameReceiver;
public class RenameModuleConfig implements IRefactoringConfig, INewNameReceiver {
private IDocumentProvider doc;
private final int carretPosition;
- private ModuleNode selectedModule;
+ private ModuleNodeWrapper selectedModule;
+ private String newName;
public RenameModuleConfig(IDocumentProvider doc, int carretPosition) {
this.doc = doc;
@@ -24,25 +25,27 @@
this.doc = doc;
}
- public void setNewName(String name) {
- // TODO Auto-generated method stub
-
+ public void setNewName(String newName) {
+ this.newName = newName;
}
public String getSelectedModuleName() {
- // TODO Auto-generated method stub
- return null;
+ return selectedModule != null ? selectedModule.getName() : null;
}
public int getCarretPosition() {
return carretPosition;
}
- public ModuleNode getSelectedModule() {
+ public ModuleNodeWrapper getSelectedModule() {
return selectedModule;
}
- public void setSelectedModule(ModuleNode selectedModule) {
+ public void setSelectedModule(ModuleNodeWrapper selectedModule) {
this.selectedModule = selectedModule;
}
+
+ public String getNewName() {
+ return newName;
+ }
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleEditProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleEditProvider.java 2007-04-12 23:50:02 UTC (rev 2302)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleEditProvider.java 2007-04-13 12:12:24 UTC (rev 2303)
@@ -1,19 +1,33 @@
package org.rubypeople.rdt.refactoring.core.renamemodule;
+import java.util.ArrayList;
import java.util.Collection;
+import org.jruby.ast.IScopingNode;
+import org.rubypeople.rdt.refactoring.core.renameclass.PartialClassesRenameEditProvider;
import org.rubypeople.rdt.refactoring.editprovider.FileMultiEditProvider;
import org.rubypeople.rdt.refactoring.editprovider.IMultiFileEditProvider;
+import org.rubypeople.rdt.refactoring.editprovider.MultiFileEditProvider;
public class RenameModuleEditProvider implements IMultiFileEditProvider {
- public RenameModuleEditProvider(RenameModuleConfig renameModuleConfig) {
- // TODO Auto-generated constructor stub
+ private final RenameModuleConfig config;
+
+ public RenameModuleEditProvider(RenameModuleConfig config) {
+ this.config = config;
}
+
+ private PartialClassesRenameEditProvider getModuleEditProvider() {
+ ArrayList<IScopingNode> modules = new ArrayList<IScopingNode>();
+ modules.add(config.getSelectedModule().getWrappedNode());
+ return new PartialClassesRenameEditProvider(modules, config.getNewName());
+ }
public Collection<FileMultiEditProvider> getFileEditProviders() {
- // TODO Auto-generated method stub
- return null;
+ MultiFileEditProvider fileEdits = new MultiFileEditProvider();
+
+ fileEdits.addEditProviders(getModuleEditProvider().getEditProviders());
+
+ return fileEdits.getFileEditProviders();
}
-
}
Added: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/nodewrapper/ModuleNodeWrapper.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/nodewrapper/ModuleNodeWrapper.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/nodewrapper/ModuleNodeWrapper.java 2007-04-13 12:12:24 UTC (rev 2303)
@@ -0,0 +1,33 @@
+package org.rubypeople.rdt.refactoring.nodewrapper;
+
+import org.jruby.ast.ModuleNode;
+
+public class ModuleNodeWrapper implements INodeWrapper {
+ private final ModuleNode moduleNode;
+ private ModuleNodeWrapper parentModule;
+
+ public ModuleNodeWrapper(ModuleNode moduleNode, ModuleNodeWrapper parentModule) {
+ this.moduleNode = moduleNode;
+ this.parentModule = parentModule;
+ }
+
+ public ModuleNode getWrappedNode() {
+ return moduleNode;
+ }
+
+ public ModuleNodeWrapper getParentModule() {
+ return parentModule;
+ }
+
+ public void setParentModule(ModuleNodeWrapper parentModule) {
+ this.parentModule = parentModule;
+ }
+
+ public String getName() {
+ return moduleNode.getCPath().getName();
+ }
+
+ public String getFullName() {
+ return (parentModule != null ? parentModule.getFullName() + "::" : "") + getName();
+ }
+}
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_ModuleWithMultipleParents.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_ModuleWithMultipleParents.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_ModuleWithMultipleParents.rb 2007-04-13 12:12:24 UTC (rev 2303)
@@ -0,0 +1,10 @@
+module M1
+ module M2
+ module M3
+ module M4
+ module M5
+ end
+ end
+ end
+ end
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_ModuleWithParent.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_ModuleWithParent.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_ModuleWithParent.rb 2007-04-13 12:12:24 UTC (rev 2303)
@@ -0,0 +1,4 @@
+module OuterModule
+ module Modul
+ end
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_SimpleModule.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_SimpleModule.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/nodewrapper/TC_ModuleNodeWrapper_SimpleModule.rb 2007-04-13 12:12:24 UTC (rev 2303)
@@ -0,0 +1,2 @@
+module Modul
+end
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_1.activeFile.rb.result
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_1.activeFile.rb.result 2007-04-12 23:50:02 UTC (rev 2302)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_1.activeFile.rb.result 2007-04-13 12:12:24 UTC (rev 2303)
@@ -1,2 +1,2 @@
-module NewModul
+module NewModule
end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_2.activeFile.rb.result
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_2.activeFile.rb.result (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_2.activeFile.rb.result 2007-04-13 12:12:24 UTC (rev 2303)
@@ -0,0 +1,8 @@
+module Moral
+ VERY_BAD = 0
+ BAD = 1
+ def Moral.sin(badness)
+ end
+end
+
+wrongdoing = Moral.sin(Moral::VERY_BAD)
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_2.activeFile.rb.source
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_2.activeFile.rb.source (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_2.activeFile.rb.source 2007-04-13 12:12:24 UTC (rev 2303)
@@ -0,0 +1,8 @@
+module Modul
+ VERY_BAD = 0
+ BAD = 1
+ def Modul.sin(badness)
+ end
+end
+
+wrongdoing = Modul.sin(Modul::VERY_BAD)
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_2.test_properties
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_2.test_properties (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_2.test_properties 2007-04-13 12:12:24 UTC (rev 2303)
@@ -0,0 +1,3 @@
+name=Debug
+pos=8
+activeFile=activeFile.rb
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_3.activeFile.rb.result
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_3.activeFile.rb.result (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_3.activeFile.rb.result 2007-04-13 12:12:24 UTC (rev 2303)
@@ -0,0 +1,11 @@
+module Debug
+ def who_am_i?
+ "#{self.class.name} (\##{self.object_id}): #{self.to_s}"
+ end
+end
+class Phonograph
+ include Debug
+end
+class EightTrack
+ include Debug
+end
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_3.activeFile.rb.source
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_3.activeFile.rb.source (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_3.activeFile.rb.source 2007-04-13 12:12:24 UTC (rev 2303)
@@ -0,0 +1,11 @@
+module Debugger
+ def who_am_i?
+ "#{self.class.name} (\##{self.object_id}): #{self.to_s}"
+ end
+end
+class Phonograph
+ include Debugger
+end
+class EightTrack
+ include Debugger
+end
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_3.test_properties
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_3.test_properties (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_3.test_properties 2007-04-13 12:12:24 UTC (rev 2303)
@@ -0,0 +1,3 @@
+name=NewModule
+pos=8
+activeFile=activeFile.rb
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_4.activeFile.rb.result
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_4.activeFile.rb.result (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_4.activeFile.rb.result 2007-04-13 12:12:24 UTC (rev 2303)
@@ -0,0 +1,20 @@
+module OuterModule
+ module Module
+ module CentralModule
+ end
+ end
+end
+
+module Module
+ module CentralModule
+ end
+end
+
+module CentralModule
+end
+
+class ModulTest
+ include OuterModule::Module::CentralModule
+ include Module::CentralModule
+ include CentralModule
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_4.activeFile.rb.source
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_4.activeFile.rb.source (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_4.activeFile.rb.source 2007-04-13 12:12:24 UTC (rev 2303)
@@ -0,0 +1,20 @@
+module OuterModule
+ module Module
+ module InnerModule
+ end
+ end
+end
+
+module Module
+ module InnerModule
+ end
+end
+
+module InnerModule
+end
+
+class ModulTest
+ include OuterModule::Module::InnerModule
+ include Module::InnerModule
+ include InnerModule
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_4.test_properties
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_4.test_properties (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_4.test_properties 2007-04-13 12:12:24 UTC (rev 2303)
@@ -0,0 +1,3 @@
+name=NewModule
+pos=8
+activeFile=activeFile.rb
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/FileTestCase.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/FileTestCase.java 2007-04-12 23:50:02 UTC (rev 2302)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/FileTestCase.java 2007-04-13 12:12:24 UTC (rev 2303)
@@ -34,8 +34,8 @@
public abstract class FileTestCase extends RefactoringTestCase
{
- public FileTestCase(String fileName) {
- super(fileName);
+ public FileTestCase(String name) {
+ super(name);
}
protected String getSource(String file){
Added: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/nodewrapper/TC_ModuleNodeWrapper.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/nodewrapper/TC_ModuleNodeWrapper.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/nodewrapper/TC_ModuleNodeWrapper.java 2007-04-13 12:12:24 UTC (rev 2303)
@@ -0,0 +1,43 @@
+package org.rubypeople.rdt.refactoring.tests.core.nodewrapper;
+
+import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.ModuleNodeWrapper;
+import org.rubypeople.rdt.refactoring.tests.FileTestCase;
+
+public class TC_ModuleNodeWrapper extends FileTestCase {
+
+ public TC_ModuleNodeWrapper() {
+ super("Module Node Wrapper");
+ }
+
+ private ModuleNodeWrapper findModule(String file, int position) {
+ return SelectionNodeProvider.getSelectedModuleNode(getRootNode(file),position);
+ }
+
+ public void testSimpleModule() {
+ ModuleNodeWrapper moduleNode = findModule("TC_ModuleNodeWrapper_SimpleModule.rb", 8);
+
+ assertNull(moduleNode.getParentModule());
+ assertNotNull(moduleNode.getWrappedNode());
+ assertEquals("Modul", moduleNode.getName());
+ assertEquals("Modul", moduleNode.getFullName());
+ }
+
+ public void testModuleWithParent() {
+ ModuleNodeWrapper moduleNode = findModule("TC_ModuleNodeWrapper_ModuleWithParent.rb", 31);
+
+ assertNotNull(moduleNode.getParentModule());
+ assertNotNull(moduleNode.getParentModule().getWrappedNode());
+ assertNull(moduleNode.getParentModule().getParentModule());
+ assertNotNull(moduleNode.getWrappedNode());
+ assertEquals("Modul", moduleNode.getName());
+ assertEquals("OuterModule::Modul", moduleNode.getFullName());
+ }
+
+ public void testModuleWithMultipleParents() {
+ ModuleNodeWrapper moduleNode = findModule("TC_ModuleNodeWrapper_ModuleWithMultipleParents.rb", 68);
+
+ assertEquals("M5", moduleNode.getName());
+ assertEquals("M1::M2::M3::M4::M5", moduleNode.getFullName());
+ }
+}
Modified: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/nodewrapper/TS_NodeWrapper.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/nodewrapper/TS_NodeWrapper.java 2007-04-12 23:50:02 UTC (rev 2302)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/nodewrapper/TS_NodeWrapper.java 2007-04-13 12:12:24 UTC (rev 2303)
@@ -35,6 +35,7 @@
TestSuite suite = new TestSuite("Node Wrapper");
suite.addTestSuite(TC_FieldNodeWrapper.class);
suite.addTestSuite(TC_MethodNodeWrapper.class);
+ suite.addTestSuite(TC_ModuleNodeWrapper.class);
return suite;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-04-12 23:50:05
|
Revision: 2302
http://svn.sourceforge.net/rubyeclipse/?rev=2302&view=rev
Author: cawilliams
Date: 2007-04-12 16:50:02 -0700 (Thu, 12 Apr 2007)
Log Message:
-----------
add some unfinished work towards search engine. Still pretty ugly. I need to find a simpler way to do the locator/matching stuff, because biting off all of what JDT has will likely be too much and too difficult to get right at once.
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/SimpleLookupTable.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceParser.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/InternalSearchDocument.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Messages.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Util.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/messages.properties
Added Paths:
-----------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchConstants.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchScope.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchMatch.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchParticipant.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchRequestor.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfLong.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexQueryRequestor.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexSelector.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/PathCollector.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/PatternSearchJob.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchDocument.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchParticipant.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchScope.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubyWorkspaceScope.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFileToIndex.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexAllProject.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexRequest.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/RemoveFromIndex.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SaveIndex.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SourceIndexer.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SourceIndexerRequestor.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/FieldLocator.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/FieldPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/InternalSearchPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchingNodeSet.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MethodLocator.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MethodPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PatternLocator.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PossibleMatch.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PossibleMatchSet.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/RubySearchPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeDeclarationLocator.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeDeclarationPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/VariablePattern.java
Removed Paths:
-------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexAllJob.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-04-12 22:31:15 UTC (rev 2301)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-04-12 23:50:02 UTC (rev 2302)
@@ -321,8 +321,6 @@
List rubyProjects = Arrays.asList(getRubyProjects());
MassIndexUpdaterJob massUpdater = new MassIndexUpdaterJob(indexUpdater, rubyProjects);
massUpdater.schedule();
- addElementChangedListener(IndexManager.instance());
- IndexManager.start();
}
/*
@@ -334,7 +332,6 @@
public void stop(BundleContext context) throws Exception {
try {
RubyModelManager.getRubyModelManager().shutdown();
- removeElementChangedListener(IndexManager.instance());
} finally {
// ensure we call super.stop as the last thing
super.stop(context);
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchConstants.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchConstants.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchConstants.java 2007-04-12 23:50:02 UTC (rev 2302)
@@ -0,0 +1,11 @@
+package org.rubypeople.rdt.core.search;
+
+import org.rubypeople.rdt.internal.core.search.processing.IJob;
+
+public interface IRubySearchConstants {
+ /**
+ * The search operation waits for the underlying indexer to finish indexing
+ * the workspace before starting the search.
+ */
+ int WAIT_UNTIL_READY_TO_SEARCH = IJob.WaitUntilReady;
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchScope.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchScope.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchScope.java 2007-04-12 23:50:02 UTC (rev 2302)
@@ -0,0 +1,71 @@
+package org.rubypeople.rdt.core.search;
+
+import org.eclipse.core.runtime.IPath;
+
+public interface IRubySearchScope {
+
+ /**
+ * Include type constant (bit mask) indicating that source folders should be
+ * considered in the search scope.
+ *
+ * @since 0.9.0
+ */
+ int SOURCES = 1;
+ /**
+ * Include type constant (bit mask) indicating that application libraries
+ * should be considered in the search scope.
+ *
+ * @since 0.9.0
+ */
+ int APPLICATION_LIBRARIES = 2;
+ /**
+ * Include type constant (bit mask) indicating that system libraries should
+ * be considered in the search scope.
+ *
+ * @since 0.9.0
+ */
+ int SYSTEM_LIBRARIES = 4;
+ /**
+ * Include type constant (bit mask) indicating that referenced projects
+ * should be considered in the search scope.
+ *
+ * @since 0.9.0
+ */
+ int REFERENCED_PROJECTS = 8;
+
+ /**
+ * Returns the paths to the enclosing projects and JARs for this search
+ * scope.
+ * <ul>
+ * <li> If the path is a project path, this is the full path of the project
+ * (see <code>IResource.getFullPath()</code>). For example, /MyProject
+ * </li>
+ * <li> If the path is a JAR path and this JAR is internal to the workspace,
+ * this is the full path of the JAR file (see
+ * <code>IResource.getFullPath()</code>). For example,
+ * /MyProject/mylib.jar </li>
+ * <li> If the path is a JAR path and this JAR is external to the workspace,
+ * this is the full OS path to the JAR file on the file system. For example,
+ * d:\libs\mylib.jar </li>
+ * </ul>
+ *
+ * @return an array of paths to the enclosing projects and JARS.
+ */
+ IPath[] enclosingProjectsAndJars();
+
+ /**
+ * Checks whether the resource at the given path is enclosed by this scope.
+ *
+ * @param resourcePath
+ * if the resource is contained in a JAR file, the path is
+ * composed of 2 paths separated by
+ * <code>JAR_FILE_ENTRY_SEPARATOR</code>: the first path is
+ * the full OS path to the JAR (if it is an external JAR), or the
+ * workspace relative <code>IPath</code> to the JAR (if it is
+ * an internal JAR), the second path is the path to the resource
+ * inside the JAR.
+ * @return whether the resource is enclosed by this scope
+ */
+ public boolean encloses(String resourcePath);
+
+}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java 2007-04-12 22:31:15 UTC (rev 2301)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java 2007-04-12 23:50:02 UTC (rev 2302)
@@ -1,135 +1,165 @@
-package org.rubypeople.rdt.core.search;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-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;
-import org.rubypeople.rdt.internal.core.search.indexing.InternalSearchDocument;
-
-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 String documentPath;
-
- 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>();
- 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(documentPath);
- 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]);
- }
-}
+package org.rubypeople.rdt.core.search;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+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.index.EntryResult;
+import org.rubypeople.rdt.internal.core.search.HandleFactory;
+import org.rubypeople.rdt.internal.core.search.indexing.IIndexConstants;
+import org.rubypeople.rdt.internal.core.search.indexing.InternalSearchDocument;
+
+public abstract class SearchDocument extends InternalSearchDocument {
+
+ private static HandleFactory factory = new HandleFactory();
+ private IRubyScript script;
+
+ private String documentPath;
+ private SearchParticipant participant;
+
+ public SearchDocument(String documentPath, SearchParticipant participant) {
+ this.documentPath = documentPath;
+ this.participant = participant;
+ }
+
+ 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>();
+ try {
+ EntryResult[] results = index.query(new char[][] {getCategory(type)}, new char[] {'*'}, SearchPattern.R_PATTERN_MATCH);
+ for (int i = 0; i < results.length; i++) {
+ String name = new String(results[i].getWord());
+ names.add(name);
+ }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ 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(documentPath);
+ 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 void removeElement(IRubyElement element) {
+ // FIXME Rebuild the index?!
+ }
+
+ public void addElement(IRubyElement element) {
+ addIndexEntry(getCategory(element), element.getElementName().toCharArray());
+ }
+
+ private char[] getCategory(IRubyElement element) {
+ return getCategory(element.getElementType());
+ }
+
+ private char[] getCategory(int elementType) {
+ switch (elementType) {
+ case IRubyElement.TYPE:
+ return IIndexConstants.TYPE_DECL;
+ case IRubyElement.METHOD:
+ return IIndexConstants.METHOD_DECL;
+ case IRubyElement.CONSTANT:
+ case IRubyElement.GLOBAL:
+ case IRubyElement.CLASS_VAR:
+ case IRubyElement.INSTANCE_VAR:
+ case IRubyElement.LOCAL_VARIABLE:
+ return IIndexConstants.FIELD_DECL;
+ default:
+ return new char[0];
+ }
+ }
+
+ public IType findType(String name) {
+ return (IType) findElement(IRubyElement.TYPE, name);
+ }
+
+ private IRubyElement findElement(int type, String name) {
+ IRubyScript script = getScript();
+ List<IRubyElement> children = getChildrenOfType(script, type);
+ for (IRubyElement element : children) {
+ if (element.getElementName().equals(name))
+ return element;
+ }
+ return null;
+ }
+
+ /**
+ * Returns the contents of this document.
+ * Contents may be different from actual resource at corresponding document
+ * path due to preprocessing.
+ * <p>
+ * This method must be implemented in subclasses.
+ * </p><p>
+ * Note: some implementation may choose to cache the contents directly on the
+ * document for performance reason. However, this could induce scalability issues due
+ * to the fact that collections of documents are manipulated throughout the search
+ * operation, and cached contents would then consume lots of memory until they are
+ * all released at once in the end.
+ * </p>
+ *
+ * @return the contents of this document,
+ * or <code>null</code> if none
+ */
+ public abstract char[] getCharContents();
+
+ /**
+ * Returns the participant that created this document.
+ *
+ * @return the participant that created this document
+ */
+ public final SearchParticipant getParticipant() {
+ return this.participant;
+ }
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchMatch.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchMatch.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchMatch.java 2007-04-12 23:50:02 UTC (rev 2302)
@@ -0,0 +1,376 @@
+/*******************************************************************************
+ * 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.core.search;
+
+import org.eclipse.core.resources.IResource;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.internal.core.RubyElement;
+
+/**
+ * A search match represents the result of a search query.
+ *
+ * Search matches may be accurate (<code>A_ACCURATE</code>) or they might be
+ * merely potential matches (<code>A_INACCURATE</code>). The latter occurs when
+ * a compile-time problem prevents the search engine from completely resolving
+ * the match.
+ * <p>
+ * This class is intended to be instantiated and subclassed by clients.
+ * </p>
+ *
+ * @see SearchEngine#search(SearchPattern, SearchParticipant[], IJavaSearchScope, SearchRequestor, org.eclipse.core.runtime.IProgressMonitor)
+ * @since 3.0
+ */
+public class SearchMatch {
+
+ /**
+ * The search result corresponds an exact match of the search pattern.
+ *
+ * @see #getAccuracy()
+ */
+ public static final int A_ACCURATE = 0;
+
+ /**
+ * The search result is potentially a match for the search pattern,
+ * but the search engine is unable to fully check it (for example, because
+ * there are errors in the code or the classpath are not correctly set).
+ *
+ * @see #getAccuracy()
+ */
+ public static final int A_INACCURATE = 1;
+
+ private Object element;
+ private int length;
+ private int offset;
+
+ private int accuracy;
+ private SearchParticipant participant;
+ private IResource resource;
+
+ private boolean insideDocComment = false;
+
+ // store the rule used while reporting the match
+ private final static int ALL_GENERIC_FLAVORS = SearchPattern.R_FULL_MATCH |
+ SearchPattern.R_EQUIVALENT_MATCH |
+ SearchPattern.R_ERASURE_MATCH;
+ private int rule = ALL_GENERIC_FLAVORS;
+
+ // store other necessary information
+ private boolean raw = false;
+ private boolean implicit = false;
+
+ /**
+ * Creates a new search match.
+ * <p>
+ * Note that <code>isInsideDocComment()</code> defaults to false.
+ * </p>
+ *
+ * @param element the element that encloses or corresponds to the match,
+ * or <code>null</code> if none
+ * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
+ * @param offset the offset the match starts at, or -1 if unknown
+ * @param length the length of the match, or -1 if unknown
+ * @param participant the search participant that created the match
+ * @param resource the resource of the element, or <code>null</code> if none
+ */
+ public SearchMatch(
+ IRubyElement element,
+ int accuracy,
+ int offset,
+ int length,
+ SearchParticipant participant,
+ IResource resource) {
+ this.element = element;
+ this.offset = offset;
+ this.length = length;
+ this.accuracy = accuracy & A_INACCURATE;
+ if (accuracy > A_INACCURATE) {
+ int genericFlavors = accuracy & ALL_GENERIC_FLAVORS;
+ if (genericFlavors > 0) {
+ this.rule &= ~ALL_GENERIC_FLAVORS; // reset generic flavors
+ }
+ this.rule |= accuracy & ~A_INACCURATE; // accuracy may have also some rule information
+ }
+ this.participant = participant;
+ this.resource = resource;
+ }
+
+ /**
+ * Returns the accuracy of this search match.
+ *
+ * @return one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
+ */
+ public final int getAccuracy() {
+ return this.accuracy;
+ }
+
+ /**
+ * Returns the element of this search match.
+ * In case of a reference match, this is the inner-most enclosing element of the reference.
+ * In case of a declaration match, this is the declaration.
+ *
+ * @return the element of the search match, or <code>null</code> if none
+ */
+ public final Object getElement() {
+ return this.element;
+ }
+
+ /**
+ * Returns the length of this search match.
+ *
+ * @return the length of this search match, or -1 if unknown
+ */
+ public final int getLength() {
+ return this.length;
+ }
+
+ /**
+ * Returns the offset of this search match.
+ *
+ * @return the offset of this search match, or -1 if unknown
+ */
+ public final int getOffset() {
+ return this.offset;
+ }
+
+ /**
+ * Returns the search participant which issued this search match.
+ *
+ * @return the participant which issued this search match
+ */
+ public final SearchParticipant getParticipant() {
+ return this.participant;
+ }
+
+ /**
+ * Returns the resource containing this search match.
+ *
+ * @return the resource of the match, or <code>null</code> if none
+ */
+ public final IResource getResource() {
+ return this.resource;
+ }
+
+ /**
+ * Returns the rule used while creating the match.
+ *
+ * @return one of {@link SearchPattern#R_FULL_MATCH}, {@link SearchPattern#R_EQUIVALENT_MATCH}
+ * or {@link SearchPattern#R_ERASURE_MATCH}
+ * @since 3.1
+ */
+ public final int getRule() {
+ return this.rule;
+ }
+
+ /**
+ * Returns whether match element is compatible with searched pattern or not.
+ * Note that equivalent matches are also erasure ones.
+ *
+ * @return <code>true</code> if match element is compatible
+ * <code>false</code> otherwise
+ * @since 3.1
+ */
+ public final boolean isEquivalent() {
+ return isErasure() && (this.rule & SearchPattern.R_EQUIVALENT_MATCH) != 0;
+ }
+
+ /**
+ * Returns whether match element only has same erasure than searched pattern or not.
+ * Note that this is always true for both generic and non-generic element as soon
+ * as the accuracy is accurate.
+ *
+ * @return <code>true</code> if match element has same erasure
+ * <code>false</code> otherwise
+ * @since 3.1
+ */
+ public final boolean isErasure() {
+ return (this.rule & SearchPattern.R_ERASURE_MATCH) != 0;
+ }
+
+ /**
+ * Returns whether element matches exactly searched pattern or not.
+ * Note that exact matches are also erasure and equivalent ones.
+ *
+ * @return <code>true</code> if match is exact
+ * <code>false</code> otherwise
+ * @since 3.1
+ */
+ public final boolean isExact() {
+ return isEquivalent() && (this.rule & SearchPattern.R_FULL_MATCH) != 0;
+ }
+
+ /**
+ * Returns whether the associated element is implicit or not.
+ *
+ * Note that this piece of information is currently only implemented
+ * for implicit member pair value in annotation.
+ *
+ * @return <code>true</code> if this match is associated to an implicit
+ * element and <code>false</code> otherwise
+ * @since 3.1
+ */
+ public final boolean isImplicit() {
+ return this.implicit;
+ }
+
+ /**
+ * Returns whether the associated element is a raw type/method or not.
+ *
+ * @return <code>true</code> if this match is associated to a raw
+ * type or method and <code>false</code> otherwise
+ * @since 3.1
+ */
+ public final boolean isRaw() {
+ return this.raw;
+ }
+
+ /**
+ * Returns whether this search match is inside a doc comment of a Java
+ * source file.
+ *
+ * @return <code>true</code> if this search match is inside a doc
+ * comment, and <code>false</code> otherwise
+ */
+ public final boolean isInsideDocComment() {
+ // default is outside a doc comment
+ return this.insideDocComment;
+ }
+
+ /**
+ * Sets the accuracy of this match.
+ *
+ * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
+ */
+ public final void setAccuracy (int accuracy) {
+ this.accuracy = accuracy;
+ }
+
+ /**
+ * Sets the element of this search match.
+ *
+ * @param element the element that encloses or corresponds to the match,
+ * or <code>null</code> if none
+ */
+ public final void setElement (Object element) {
+ this.element = element;
+ }
+
+ /**
+ * Sets whether this search match is inside a doc comment of a Java
+ * source file.
+ *
+ * @param insideDoc <code>true</code> if this search match is inside a doc
+ * comment, and <code>false</code> otherwise
+ */
+ public final void setInsideDocComment (boolean insideDoc) {
+ this.insideDocComment = insideDoc;
+ }
+
+ /**
+ * Sets whether the associated element is implicit or not.
+ * Typically, this is the case when match is on an implicit constructor
+ * or an implicit member pair value in annotation.
+ *
+ * @param implicit <code>true</code> if this match is associated to an implicit
+ * element and <code>false</code> otherwise
+ * @since 3.1
+ */
+ public final void setImplicit(boolean implicit) {
+ this.implicit = implicit;
+ }
+
+ /**
+ * Sets the length of this search match.
+ *
+ * @param length the length of the match, or -1 if unknown
+ */
+ public final void setLength(int length) {
+ this.length = length;
+ }
+
+ /**
+ * Sets the offset of this search match.
+ *
+ * @param offset the offset the match starts at, or -1 if unknown
+ */
+ public final void setOffset(int offset) {
+ this.offset = offset;
+ }
+
+ /**
+ * Sets the participant of this match.
+ *
+ * @param participant the search participant that created this match
+ */
+ public final void setParticipant (SearchParticipant participant) {
+ this.participant = participant;
+ }
+
+ /**
+ * Sets the resource of this match.
+ *
+ * @param resource the resource of the match, or <code>null</code> if none
+ */
+ public final void setResource (IResource resource) {
+ this.resource = resource;
+ }
+
+ /**
+ * Set the rule used while reporting the match.
+ *
+ * @param rule one of {@link SearchPattern#R_FULL_MATCH}, {@link SearchPattern#R_EQUIVALENT_MATCH}
+ * or {@link SearchPattern#R_ERASURE_MATCH}
+ * @since 3.1
+ */
+ public final void setRule(int rule) {
+ this.rule = rule;
+ }
+
+ /**
+ * Set whether the associated element is a raw type/method or not.
+ *
+ * @param raw <code>true</code> if this search match is associated to a raw
+ * type or method and <code>false</code> otherwise
+ * @since 3.1
+ */
+ public final void setRaw(boolean raw) {
+ this.raw = raw;
+ }
+
+ /* (non-javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Search match"); //$NON-NLS-1$
+ buffer.append("\n accuracy="); //$NON-NLS-1$
+ buffer.append(this.accuracy == A_ACCURATE ? "ACCURATE" : "INACCURATE"); //$NON-NLS-1$ //$NON-NLS-2$
+ buffer.append("\n rule="); //$NON-NLS-1$
+ if ((this.rule & SearchPattern.R_FULL_MATCH) != 0) {
+ buffer.append("EXACT"); //$NON-NLS-1$
+ } else if ((this.rule & SearchPattern.R_EQUIVALENT_MATCH) != 0) {
+ buffer.append("EQUIVALENT"); //$NON-NLS-1$
+ } else if ((this.rule & SearchPattern.R_ERASURE_MATCH) != 0) {
+ buffer.append("ERASURE"); //$NON-NLS-1$
+ }
+ buffer.append("\n raw="); //$NON-NLS-1$
+ buffer.append(this.raw);
+ buffer.append("\n offset="); //$NON-NLS-1$
+ buffer.append(this.offset);
+ buffer.append("\n length="); //$NON-NLS-1$
+ buffer.append(this.length);
+ if (this.element != null) {
+ buffer.append("\n element="); //$NON-NLS-1$
+ buffer.append(((RubyElement)getElement()).toStringWithAncestors());
+ }
+ buffer.append("\n"); //$NON-NLS-1$
+ return buffer.toString();
+ }
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchParticipant.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchParticipant.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchParticipant.java 2007-04-12 23:50:02 UTC (rev 2302)
@@ -0,0 +1,127 @@
+package org.rubypeople.rdt.core.search;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public abstract class SearchParticipant {
+
+ /**
+ * Indexes the given document in the given index. A search participant
+ * asked to index a document should parse it and call
+ * {@link SearchDocument#addIndexEntry(char[], char[])} as many times as
+ * needed to add index entries to the index. If delegating to another
+ * participant, it should use the original index location (and not the
+ * delegatee's one). In the particular case of delegating to the default
+ * search participant (see {@link SearchEngine#getDefaultSearchParticipant()}),
+ * the provided document's path must be a path ending with one of the
+ * {@link org.eclipse.jdt.core.JavaCore#getJavaLikeExtensions() Java-like extensions}
+ * or with '.class'.
+ * <p>
+ * The given index location must represent a path in the file system to a file that
+ * either already exists or is going to be created. If it exists, it must be an index file,
+ * otherwise its data might be overwritten.
+ * </p><p>
+ * Clients are not expected to call this method.
+ * </p>
+ *
+ * @param document the document to index
+ * @param indexLocation the location in the file system to the index
+ */
+ public abstract void indexDocument(SearchDocument document, IPath indexLocation);
+
+ /**
+ * Returns a search document for the given path.
+ * The given document path is a string that uniquely identifies the document.
+ * Most of the time it is a workspace-relative path, but it can also be a file system path, or a path inside a zip file.
+ * <p>
+ * Implementors of this method can either create an instance of their own subclass of
+ * {@link SearchDocument} or return an existing instance of such a subclass.
+ * </p>
+ *
+ * @param documentPath the path of the document.
+ * @return a search document
+ */
+ public abstract SearchDocument getDocument(String documentPath);
+
+ /**
+ * Returns the collection of index locations to consider when performing the
+ * given search query in the given scope. The search engine calls this
+ * method before locating matches.
+ * <p>
+ * An index location represents a path in the file system to a file that holds index information.
+ * </p><p>
+ * Clients are not expected to call this method.
+ * </p>
+ *
+ * @param query the search pattern to consider
+ * @param scope the given search scope
+ * @return the collection of index paths to consider
+ */
+ public abstract IPath[] selectIndexes(SearchPattern pattern, IRubySearchScope scope);
+
+ /**
+ * Locates the matches in the given documents using the given search pattern
+ * and search scope, and reports them to the givenn search requestor. This
+ * method is called by the search engine once it has search documents
+ * matching the given pattern in the given search scope.
+ * <p>
+ * Note that a participant (e.g. a JSP participant) can pre-process the contents of the given documents,
+ * create its own documents whose contents are Java compilation units and delegate the match location
+ * to the default participant (see {@link SearchEngine#getDefaultSearchParticipant()}). Passing its own
+ * {@link SearchRequestor} this particpant can then map the match positions back to the original
+ * contents, create its own matches and report them to the original requestor.
+ * </p><p>
+ * Implementors of this method should check the progress monitor
+ * for cancelation when it is safe and appropriate to do so. The cancelation
+ * request should be propagated to the caller by throwing
+ * <code>OperationCanceledException</code>.
+ * </p>
+ *
+ * @param documents the documents to locate matches in
+ * @param pattern the search pattern to use when locating matches
+ * @param scope the scope to limit the search to
+ * @param requestor the requestor to report matches to
+ * @param monitor the progress monitor to report progress to,
+ * or <code>null</code> if no progress should be reported
+ * @throws CoreException if the requestor had problem accepting one of the matches
+ */
+ public abstract void locateMatches(SearchDocument[] documents, SearchPattern pattern, IRubySearchScope scope, SearchRequestor requestor, IProgressMonitor monitor) throws CoreException;
+
+
+ /**
+ * Notification that this participant's help is needed in a search.
+ * <p>
+ * This method should be re-implemented in subclasses that need to do something
+ * when the participant is needed in a search.
+ * </p>
+ */
+ public void beginSearching() {
+ // do nothing
+ }
+
+ /**
+ * Notification that this participant's help is no longer needed.
+ * <p>
+ * This method should be re-implemented in subclasses that need to do something
+ * when the participant is no longer needed in a search.
+ * </p>
+ */
+ public void doneSearching() {
+ // do nothing
+ }
+
+ /**
+ * Returns a displayable name of this search participant.
+ * <p>
+ * This method should be re-implemented in subclasses that need to
+ * display a meaningfull name.
+ * </p>
+ *
+ * @return the displayable name of this search participant
+ */
+ public String getDescription() {
+ return "Search participant"; //$NON-NLS-1$
+ }
+
+}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-04-12 22:31:15 UTC (rev 2301)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-04-12 23:50:02 UTC (rev 2302)
@@ -1,132 +1,241 @@
-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;
-
-}
+package org.rubypeople.rdt.core.search;
+
+import org.rubypeople.rdt.internal.core.search.matching.InternalSearchPattern;
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+
+public abstract class SearchPattern extends InternalSearchPattern {
+// 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;
+
+ private int matchRule;
+
+ /**
+ * Creates a search pattern with the rule to apply for matching index keys.
+ * It can be exact match, prefix match, pattern match or regexp match.
+ * Rule can also be combined with a case sensitivity flag.
+ *
+ * @param matchRule one of {@link #R_EXACT_MATCH}, {@link #R_PREFIX_MATCH}, {@link #R_PATTERN_MATCH},
+ * {@link #R_REGEXP_MATCH}, {@link #R_CAMELCASE_MATCH} combined with one of following values:
+ * {@link #R_CASE_SENSITIVE}, {@link #R_ERASURE_MATCH} or {@link #R_EQUIVALENT_MATCH}.
+ * e.g. {@link #R_EXACT_MATCH} | {@link #R_CASE_SENSITIVE} if an exact and case sensitive match is requested,
+ * {@link #R_PREFIX_MATCH} if a prefix non case sensitive match is requested or {@link #R_EXACT_MATCH} | {@link #R_ERASURE_MATCH}
+ * if a non case sensitive and erasure match is requested.<br>
+ * Note that {@link #R_ERASURE_MATCH} or {@link #R_EQUIVALENT_MATCH} have no effect
+ * on non-generic types/methods search.<br>
+ * Note also that default behavior for generic types/methods search is to find exact matches.
+ */
+ public SearchPattern(int matchRule) {
+ this.matchRule = matchRule;
+ // Set full match implicit mode
+ if ((matchRule & (R_EQUIVALENT_MATCH | R_ERASURE_MATCH )) == 0) {
+ this.matchRule |= R_FULL_MATCH;
+ }
+ }
+
+ /**
+ * Returns a blank pattern that can be used as a record to decode an index key.
+ * <p>
+ * Implementors of this method should return a new search pattern that is going to be used
+ * to decode index keys.
+ * </p>
+ *
+ * @return a new blank pattern
+ * @see #decodeIndexKey(char[])
+ */
+ public abstract SearchPattern getBlankPattern();
+
+ /**
+ * Decode the given index key in this pattern. The decoded index key is used by
+ * {@link #matchesDecodedKey(SearchPattern)} to find out if the corresponding index entry
+ * should be considered.
+ * <p>
+ * This method should be re-implemented in subclasses that need to decode an index key.
+ * </p>
+ *
+ * @param key the given index key
+ */
+ public void decodeIndexKey(char[] key) {
+ // called from findIndexMatches(), override as necessary
+ }
+
+ /**
+ * Returns a key to find in relevant index categories, if null then all index entries are matched.
+ * The key will be matched according to some match rule. These potential matches
+ * will be further narrowed by the match locator, but precise match locating can be expensive,
+ * and index query should be as accurate as possible so as to eliminate obvious false hits.
+ * <p>
+ * This method should be re-implemented in subclasses that need to narrow down the
+ * index query.
+ * </p>
+ *
+ * @return an index key from this pattern, or <code>null</code> if all index entries are matched.
+ */
+ public char[] getIndexKey() {
+ return null; // called from queryIn(), override as necessary
+ }
+ /**
+ * Returns an array of index categories to consider for this index query.
+ * These potential matches will be further narrowed by the match locator, but precise
+ * match locating can be expensive, and index query should be as accurate as possible
+ * so as to eliminate obvious false hits.
+ * <p>
+ * This method should be re-implemented in subclasses that need to narrow down the
+ * index query.
+ * </p>
+ *
+ * @return an array of index categories
+ */
+ public char[][] getIndexCategories() {
+ return CharOperation.NO_CHAR_CHAR; // called from queryIn(), override as necessary
+ }
+
+ /**
+ * Returns the rule to apply for matching index keys. Can be exact match, prefix match, pattern match or regexp match.
+ * Rule can also be combined with a case sensitivity flag.
+ *
+ * @return one of R_EXACT_MATCH, R_PREFIX_MATCH, R_PATTERN_MATCH, R_REGEXP_MATCH combined with R_CASE_SENSITIVE,
+ * e.g. R_EXACT_MATCH | R_CASE_SENSITIVE if an exact and case sensitive match is requested,
+ * or R_PREFIX_MATCH if a prefix non case sensitive match is requested.
+ * [TODO (frederic) I hope R_ERASURE_MATCH doesn't need to be on this list. Because it would be a breaking API change.]
+ */
+ public final int getMatchRule() {
+ return this.matchRule;
+ }
+ /**
+ * Returns whether this pattern matches the given pattern (representing a decoded index key).
+ * <p>
+ * This method should be re-implemented in subclasses that need to narrow down the
+ * index query.
+ * </p>
+ *
+ * @param decodedPattern a pattern representing a decoded index key
+ * @return whether this pattern matches the given pattern
+ */
+ public boolean matchesDecodedKey(SearchPattern decodedPattern) {
+ return true; // called from findIndexMatches(), override as necessary if index key is encoded
+ }
+
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchRequestor.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchRequestor.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchRequestor.java 2007-04-12 23:50:02 UTC (rev 2302)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * 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.core.search;
+
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Collects the results from a search engine query.
+ * Clients implement a subclass to pass to <code>SearchEngine.search</code>
+ * and implement the {@link #acceptSearchMatch(SearchMatch)} method, and
+ * possibly override other life cycle methods.
+ * <p>
+ * The search engine calls <code>beginReporting()</code> when a search starts,
+ * then calls <code>acceptSearchMatch(...)</code> for each search result, and
+ * finally calls <code>endReporting()</code>. The order of the search results
+ * is unspecified and may vary from request to request; when displaying results,
+ * clients should not rely on the order but should instead arrange the results
+ * in an order that would be more meaningful to the user.
+ * </p>
+ *
+ * @see SearchEngine
+ * @since 3.0
+ */
+public abstract class SearchRequestor {
+
+ /**
+ * Accepts the given search match.
+ *
+ * @param match the found match
+ * @throws CoreException
+ */
+ public abstract void acceptSearchMatch(SearchMatch match) throws CoreException;
+
+ /**
+ * Notification sent before starting the search action.
+ * Typically, this would tell a search requestor to clear previously
+ * recorded search results.
+ * <p>
+ * The default implementation of this method does nothing. Subclasses
+ * may override.
+ * </p>
+ */
+ public void beginReporting() {
+ // do nothing
+ }
+
+ /**
+ * Notification sent after having completed the search action.
+ * Typically, this would tell a search requestor collector that no more
+ * results will be forthcomping in this search.
+ * <p>
+ * The default implementation of this method does nothing. Subclasses
+ * may override.
+ * </p>
+ */
+ public void endReporting() {
+ // do nothing
+ }
+
+ /**
+ * Intermediate notification sent when the given participant starts to
+ * contribute.
+ * <p>
+ * The default implementation of this method does nothing. Subclasses
+ * may override.
+ * </p>
+ *
+ * @param participant the participant that is starting to contribute
+ */
+ public void enterParticipant(SearchParticipant participant) {
+ // do nothing
+ }
+
+ /**
+ * Intermediate notification sent when the given participant is finished
+ * contributing.
+ * <p>
+ * The default implementation of this method does nothing. Subclasses
+ * may override.
+ * </p>
+ *
+ * @param participant the participant that finished contributing
+ */
+ public void exitParticipant(SearchParticipant participant) {
+ // do nothing
+ }
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfLong.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfLong.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfLong.java 2007-04-12 23:50:02 UTC (rev 2302)
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * 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.compiler.util;
+
+ /**
+ * Hashtable for non-zero long keys.
+ */
+
+public final class HashtableOfLong {
+ // to avoid using Enumerations, walk the individual tables skipping nulls
+ public long[] keyTable;
+ public Object[] valueTable;
+
+ public int elementSize; // number of elements in the table
+ int threshold;
+public HashtableOfLong() {
+ this(13);
+}
+public HashtableOfLong(int size) {
+ this.elementSize = 0;
+ this.threshold = size; // size represents the expected number of elements
+ int extraRoom = (int) (size * 1.75f);
+ if (this.threshold == extraRoom)
+ extraRoom++;
+ this.keyTable = new long[extraRoom];
+ this.valueTable = new Object[extraRoom];
+}
+public boolean containsKey(long key) {
+ int length = keyTable.length,
+ index = ((int)(key >>> 32)) % length;
+ long currentKey;
+ while ((currentKey = keyTable[index]) != 0) {
+ if (currentKey == key)
+ return true;
+ if (++index == length) {
+ index = 0;
+ }
+ }
+ return false;
+}
+public Object get(long key) {
+ int length = keyTable.length,
+ index = ((int)(k...
[truncated message content] |
|
From: <caw...@us...> - 2007-04-12 22:31:17
|
Revision: 2301
http://svn.sourceforge.net/rubyeclipse/?rev=2301&view=rev
Author: cawilliams
Date: 2007-04-12 15:31:15 -0700 (Thu, 12 Apr 2007)
Log Message:
-----------
Merged changes from trunk r2143:2300 into the search engine feature branch
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/META-INF/MANIFEST.MF
branches/search_engine/org.rubypeople.rdt.core/plugin.xml
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/CompletionRequestor.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IOpenable.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IProblemRequestor.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyModelStatusConstants.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/formatter/Indents.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionProposalComparator.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/CompilerOptions.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/Util.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/CreateMethodOperation.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalRubyScript.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/Openable.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ReconcileWorkingCopyOperation.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyElementDeltaBuilder.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelCache.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelStatus.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScript.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptProblemFinder.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/buffer/LRUCache.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CodeDuplicationDetector.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/IMarkerManager.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MarkerManager.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/ProblemRequestorMarkerManager.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/DefaultProblem.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/Error.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/ImmediateWarnings.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/InOrderVisitor.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/MarkerUtility.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/RdtWarnings.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/TaskParser.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/TaskTag.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/Warning.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/ConstantReassignmentVisitor.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/DelegatingVisitor.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/EmptyStatementVisitor.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/ASTUtil.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/DOMFinder.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Messages.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Util.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/messages.properties
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultOccurrencesFinder.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultReferenceFinder.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultTypeInferrer.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/TypeInferenceHelper.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/TypeInferenceVisitor.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/AttributeLocator.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/FirstPrecursorNodeLocator.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/OffsetNodeLocator.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/ScopedNodeLocator.java
Added Paths:
-----------
branches/search_engine/org.rubypeople.rdt.core/schema/compilationParticipant.exsd
branches/search_engine/org.rubypeople.rdt.core/schema/errorProvider.exsd
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/BuildContext.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/CategorizedProblem.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/CompilationParticipant.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/CompilationParticipantResult.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/IProblem.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/ReconcileContext.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/ISourceElementRequestor.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/parser/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/parser/ScannerHelper.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfIntValues.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfObject.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/SimpleLookupTable.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/SimpleSet.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ASTHolderCUInfo.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceParser.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/DiskIndex.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/EntryResult.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/Index.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/MemoryIndex.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/HandleFactory.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IIndexConstants.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexAllJob.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/InternalSearchDocument.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/ReadWriteMonitor.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/processing/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/processing/IJob.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/processing/JobManager.java
Removed Paths:
-------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/BuildContext.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/CategorizedProblem.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/CompilationParticipant.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/CompilationParticipantResult.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/IProblem.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/ReconcileContext.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/parser/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/CategorizedProblem.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/parser/ScannerHelper.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/DiskIndex.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/EntryResult.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/Index.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/MemoryIndex.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/NodeUtil.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/StaticConditionalVisitor.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/ExperimentalIndex.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IIndexConstants.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexAllJob.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/InternalSearchDocument.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/ReadWriteMonitor.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/processing/IJob.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/processing/JobManager.java
Modified: branches/search_engine/org.rubypeople.rdt.core/META-INF/MANIFEST.MF
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/META-INF/MANIFEST.MF 2007-04-12 19:40:45 UTC (rev 2300)
+++ branches/search_engine/org.rubypeople.rdt.core/META-INF/MANIFEST.MF 2007-04-12 22:31:15 UTC (rev 2301)
@@ -9,8 +9,9 @@
Bundle-Localization: plugin
Export-Package: .,
org.rubypeople.rdt.core,
+ org.rubypeople.rdt.core.compiler,
org.rubypeople.rdt.core.formatter,
- org.rubypeople.rdt.core.parser,
+ org.rubypeople.rdt.internal.compiler,
org.rubypeople.rdt.internal.core,
org.rubypeople.rdt.internal.core.buffer,
org.rubypeople.rdt.internal.core.builder,
Modified: branches/search_engine/org.rubypeople.rdt.core/plugin.xml
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/plugin.xml 2007-04-12 19:40:45 UTC (rev 2300)
+++ branches/search_engine/org.rubypeople.rdt.core/plugin.xml 2007-04-12 22:31:15 UTC (rev 2301)
@@ -3,6 +3,8 @@
<plugin>
<extension-point id="loadpathVariableInitializer" name="%loadpathVariableInitializersName" schema="schema/loadpathVariableInitializer.exsd"/>
<extension-point id="loadpathContainerInitializer" name="%loadpathContainerInitializersName" schema="schema/loadpathContainerInitializer.exsd"/>
+ <extension-point id="compilationParticipant" name="%compilationParticipantsName" schema="schema/compilationParticipant.exsd"/>
+ <extension-point id="errorProvider" name="%errorProvidersName" schema="schema/errorProvider.exsd"/>
<extension
id="rubynature"
@@ -110,4 +112,18 @@
<initializer class="org.rubypeople.rdt.internal.core.RubyCorePreferenceInitializer"/>
</extension>
+
+ <extension
+ point="org.rubypeople.rdt.core.errorProvider">
+ <category id="org.rubypeople.rdt.errors.codeComplexity" name="Code Complexity" />
+
+ <category id="org.rubypeople.rdt.errors.potentialProblems" name="Potential programming problems" />
+ <error prefKey="org.rubypeople.rdt.core.compiler.problem.constantReassignment"
+ label="Re-Assignment to a constant"
+ categoryId="org.rubypeople.rdt.errors.potentialProblems"/>
+
+ <category id="org.rubypeople.rdt.errors.unneccesaryCode" name="Unnecessary code" />
+ <error prefKey="org.rubypeople.rdt.core.compiler.problem.emptyStatement" label="Empty Statements"
+ categoryId="org.rubypeople.rdt.errors.unneccesaryCode"/>
+ </extension>
</plugin>
Copied: branches/search_engine/org.rubypeople.rdt.core/schema/compilationParticipant.exsd (from rev 2300, trunk/org.rubypeople.rdt.core/schema/compilationParticipant.exsd)
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/schema/compilationParticipant.exsd (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/schema/compilationParticipant.exsd 2007-04-12 22:31:15 UTC (rev 2301)
@@ -0,0 +1,191 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.rubypeople.rdt.core">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.rubypeople.rdt.core" id="compilationParticipant" name="Compilation Participants"/>
+ </appInfo>
+ <documentation>
+ This extension point allows clients to participate in the compilation process by receiving notifications at various stages of build and reconcile, via a org.rubypeople.rdt.core.compiler.CompilationParticipant.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="compilationParticipant" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="compilationParticipant">
+ <annotation>
+ <documentation>
+ definition of a compilation participant. This definition allows to order participants. Participants are run by group. The group of participants that modify the environment is run first, then the group of participants that create problems is run, finally the group of other participants is run. Inside each group, participants are ordered using their 'requires' attributes. If a 'requires' attribute point to a participant that doesn't belong to the group, it is ignored.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="requires" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="managedMarker" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ the class that implements this compilation participant. This class must implement a public subclass of <code>org.eclipse.jdt.core.compiler.CompilationParticipant</code> with a public 0-argument constructor.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.jdt.core.compiler.CompilationParticipant"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ a unique identifier for this participant
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="modifiesEnvironment" type="boolean">
+ <annotation>
+ <documentation>
+ optionally specify whether this compilation participant modifies the environment, thus affecting binding resolution. If not specified, false is assumed.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="createsProblems" type="boolean">
+ <annotation>
+ <documentation>
+ optionally specifies whether this compilation participant creates problems. If not specified, false is assumed.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="requiredSourceLevel" type="string">
+ <annotation>
+ <documentation>
+ the required source level this participant needs (one of the JavaCore.VERSION* constants). If a project's source level is below this required source level, the participant will not be invoked. If this attribute is not specified, the participant will be invoked for any source level.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="requires">
+ <annotation>
+ <documentation>
+ a participant that is required to run this compilation participant
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ the unique identifier of the participant that is required
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="managedMarker">
+ <annotation>
+ <documentation>
+ a managed marker is created from the recorded problems (see BuildContext#recordNewProblems(CategorizedProblem[])) and is removed when the corresponding source file is re-built or when the project is cleaned
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="markerType" type="string" use="required">
+ <annotation>
+ <documentation>
+ the type of the managed marker
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 0.9.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ Example of a declaration of a <code>compilationParticipant</code>: <pre>
+<extension
+ id="apt"
+ name="%annotationProcessingName"
+ point="org.rubypeoplee.rdt.core.compilationParticipant">
+ <compilationParticipant
+ class="org.eclipse.jdt.apt.core.internal.AptCompilationParticipant"
+ id="APT">
+ <managedMarker markerType="org.rubypeople.rdt.apt.core.compile.problem"/>
+ </compilationParticipant>
+</extension>
+</pre>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2006 BEA Systems, Inc and others.<br>
+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
+<a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ </documentation>
+ </annotation>
+
+</schema>
Copied: branches/search_engine/org.rubypeople.rdt.core/schema/errorProvider.exsd (from rev 2300, trunk/org.rubypeople.rdt.core/schema/errorProvider.exsd)
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/schema/errorProvider.exsd (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/schema/errorProvider.exsd 2007-04-12 22:31:15 UTC (rev 2301)
@@ -0,0 +1,183 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.rubypeople.rdt.core">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.rubypeople.rdt.core" id="errorProvider" name="%errorProviderName"/>
+ </appInfo>
+ <documentation>
+ This extension point allows plugins to participate in surfacing their error/warning markers through the preference page. Use this point to add new categories (or groups) of errors/warnings, and to add hooks to set teh severity and argumnets for your new/custom error/warning markers. This point is likely to be used in conjucntion with the compilationParticipants (which would do the actual parsing/AST analysis).
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <choice>
+ <element ref="category"/>
+ <element ref="error"/>
+ </choice>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="category">
+ <annotation>
+ <documentation>
+ Categories group togetehr a set of Errors/Warnings in the preference page.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ A unique identifier for this category. Errors references this with their categoryId to be placed within this category.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+ The text used in the preference page to group the errors.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="error">
+ <annotation>
+ <documentation>
+ An error is a type of Error/Warning that can be configured by the user.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="0" maxOccurs="1">
+ <element ref="argument"/>
+ </sequence>
+ <attribute name="prefKey" type="string" use="required">
+ <annotation>
+ <documentation>
+ the preference key used to store the severity of the error/warning (which will be RubyCore.IGNORE, RubyCore.WARNING, or RubyCore.ERROR).
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="label" type="string" use="required">
+ <annotation>
+ <documentation>
+ The text used on the preference page to describe the error/warning.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="categoryId" type="string" use="required">
+ <annotation>
+ <documentation>
+ the id of the category under which this error/warning resides.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="argument">
+ <annotation>
+ <documentation>
+ If this preference has a particular value or argument associated with it, this element is used.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="prefKey" type="string" use="required">
+ <annotation>
+ <documentation>
+ The preference key to store the value.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="type" use="default" value="int">
+ <annotation>
+ <documentation>
+ The type of value. Defaults to int.
+ </documentation>
+ </annotation>
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="int">
+ </enumeration>
+ <enumeration value="string">
+ </enumeration>
+ </restriction>
+ </simpleType>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 0.9.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ (C) 2007 Big Day Coming
+ </documentation>
+ </annotation>
+
+</schema>
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/CompletionRequestor.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/CompletionRequestor.java 2007-04-12 19:40:45 UTC (rev 2300)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/CompletionRequestor.java 2007-04-12 22:31:15 UTC (rev 2301)
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.rubypeople.rdt.core;
-import org.rubypeople.rdt.core.parser.IProblem;
+import org.rubypeople.rdt.core.compiler.IProblem;
/**
* Abstract base class for a completion requestor which is passed completion
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IOpenable.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IOpenable.java 2007-04-12 19:40:45 UTC (rev 2300)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IOpenable.java 2007-04-12 22:31:15 UTC (rev 2301)
@@ -170,4 +170,18 @@
* </ul>
*/
public void save(IProgressMonitor progress, boolean force) throws RubyModelException;
+
+ /**
+ * Finds and returns the recommended line separator for this element.
+ * The element's buffer is first searched and the first line separator in this buffer is returned if any.
+ * Otherwise the preference {@link org.eclipse.core.runtime.Platform#PREF_LINE_SEPARATOR}
+ * on this element's project or workspace is returned.
+ * Finally if no such preference is set, the system line separator is returned.
+ *
+ * @return the recommended line separator for this element
+ * @exception RubyModelException if this element does not exist or if an
+ * exception occurs while accessing its corresponding resource.
+ * @since 0.9.0
+ */
+ public String findRecommendedLineSeparator() throws RubyModelException;
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IProblemRequestor.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IProblemRequestor.java 2007-04-12 19:40:45 UTC (rev 2300)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IProblemRequestor.java 2007-04-12 22:31:15 UTC (rev 2301)
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.rubypeople.rdt.core;
-import org.rubypeople.rdt.core.parser.IProblem;
+import org.rubypeople.rdt.core.compiler.IProblem;
/**
* A callback interface for receiving ruby problem as they are discovered
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyModelStatusConstants.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyModelStatusConstants.java 2007-04-12 19:40:45 UTC (rev 2300)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyModelStatusConstants.java 2007-04-12 22:31:15 UTC (rev 2301)
@@ -307,4 +307,5 @@
* @since 3.1
*/
// public static final int INVALID_COMPILER_OPTION = 1007;
+ public static final int PROJECT_HAS_NO_RUBY_NATURE = 1007;
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-04-12 19:40:45 UTC (rev 2300)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-04-12 22:31:15 UTC (rev 2301)
@@ -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.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;
@@ -231,52 +231,14 @@
* @see #getDefaultOptions()
* @since 0.9.0
*/
- public static final String COMPILER_PB_ENSURE_BLOCK_NOT_COMPLETING = PLUGIN_ID + ".compiler.problem.ensureBlockNotCompletingNormally"; //$NON-NLS-1$
- /**
- * Possible configurable option ID.
- * @see #getDefaultOptions()
- * @since 0.9.0
- */
public static final String COMPILER_PB_EMPTY_STATEMENT = PLUGIN_ID + ".compiler.problem.emptyStatement"; //$NON-NLS-1$
+
/**
* Possible configurable option ID.
* @see #getDefaultOptions()
- */
- public static final String COMPILER_PB_HIDDEN_RESCUE_BLOCK = PLUGIN_ID + ".compiler.problem.hiddenRescueBlock"; //$NON-NLS-1$
- /**
- * Possible configurable option ID.
- * @see #getDefaultOptions()
* @since 0.9.0
*/
- public static final String COMPILER_PB_FALLTHROUGH_CASE = PLUGIN_ID + ".compiler.problem.fallthroughCase"; //$NON-NLS-1$
- /**
- * Possible configurable option ID.
- * @see #getDefaultOptions()
- * @since 0.9.0
- */
- public static final String COMPILER_PB_NULL_REFERENCE = PLUGIN_ID + ".compiler.problem.nullReference"; //$NON-NLS-1$
- /**
- * Possible configurable option ID.
- * @see #getDefaultOptions()
- */
- public static final String COMPILER_PB_UNUSED_LOCAL = PLUGIN_ID + ".compiler.problem.unusedLocal"; //$NON-NLS-1$
- /**
- * Possible configurable option ID.
- * @see #getDefaultOptions()
- */
- public static final String COMPILER_PB_UNUSED_PARAMETER = PLUGIN_ID + ".compiler.problem.unusedParameter"; //$NON-NLS-1$
- /**
- * Possible configurable option ID.
- * @see #getDefaultOptions()
- * @since 0.9.0
- */
- public static final String COMPILER_PB_UNUSED_PRIVATE_MEMBER = PLUGIN_ID + ".compiler.problem.unusedPrivateMember"; //$NON-NLS-1$
- /**
- * Possible configurable option ID.
- * @see #getDefaultOptions()
- * @since 0.9.0
- */
- public static final String COMPILER_PB_UNNECESSARY_ELSE = PLUGIN_ID + ".compiler.problem.unnecessaryElse"; //$NON-NLS-1$
+ public static final String COMPILER_PB_CONSTANT_REASSIGNMENT = PLUGIN_ID + ".compiler.problem.constantReassignment"; //$NON-NLS-1$
/**
* Possible configurable option ID.
@@ -359,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();
}
/*
@@ -372,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);
Copied: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler (from rev 2300, trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler)
Deleted: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/BuildContext.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/BuildContext.java 2007-04-12 19:40:45 UTC (rev 2300)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/BuildContext.java 2007-04-12 22:31:15 UTC (rev 2301)
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.core.compiler;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.rubypeople.rdt.internal.core.util.Util;
-
-/**
- * The context of a build event that is notified to interested compilation
- * participants when {@link CompilationParticipant#buildStarting(BuildContext[], boolean) a build is starting},
- * or to annotations processors when {@link CompilationParticipant#processAnnotations(BuildContext[]) a source file has annotations}.
- * <p>
- * This class is not intended to be instanciated or subclassed by clients.
- * </p>
- * @since 0.9.0
- */
-public class BuildContext extends CompilationParticipantResult {
-
-/**
- * Creates a build context for the given source file.
- * <p>
- * This constructor is not intended to be called by clients.
- * </p>
- *
- * @param sourceFile the source file being built
- */
-public BuildContext(IFile resource) {
- super(resource);
-}
-
-/**
- * Returns the contents of the compilation unit.
- *
- * @return the contents of the compilation unit
- */
-public char[] getContents() {
- try {
- return Util.getResourceContentsAsCharArray(this.resource);
- } catch (CoreException e) {
- throw new RuntimeException("Missing source file: " + this.resource);
- }
-}
-
-/**
- * Returns the <code>IFile</code> representing the compilation unit.
- *
- * @return the <code>IFile</code> representing the compilation unit
- */
-public IFile getFile() {
- return this.resource;
-}
-
-/**
- * Returns whether the compilation unit contained any annotations when it was compiled.
- *
- * NOTE: This is only valid during {@link CompilationParticipant#processAnnotations(BuildContext[])}.
- *
- * @return whether the compilation unit contained any annotations when it was compiled
- */
-public boolean hasAnnotations() {
- return this.hasAnnotations; // only set during processAnnotations
-}
-
-/**
- * Record new problems to report against this compilationUnit.
- * Markers are persisted for these problems only for the declared managed marker type
- * (see the 'compilationParticipant' extension point).
- *
- * @param newProblems the problems to report
- */
-public void recordNewProblems(CategorizedProblem[] newProblems) {
- int length2 = newProblems.length;
- if (length2 == 0) return;
-
- int length1 = this.problems == null ? 0 : this.problems.length;
- CategorizedProblem[] merged = new CategorizedProblem[length1 + length2];
- if (length1 > 0) // always make a copy even if currently empty
- System.arraycopy(this.problems, 0, merged, 0, length1);
- System.arraycopy(newProblems, 0, merged, length1, length2);
- this.problems = merged;
-}
-
-}
Copied: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/BuildContext.java (from rev 2300, trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/BuildContext.java)
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/BuildContext.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/BuildContext.java 2007-04-12 22:31:15 UTC (rev 2301)
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 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.core.compiler;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.rubypeople.rdt.internal.core.util.Util;
+
+/**
+ * The context of a build event that is notified to interested compilation
+ * participants when {@link CompilationParticipant#buildStarting(BuildContext[], boolean) a build is starting},
+ * or to annotations processors when {@link CompilationParticipant#processAnnotations(BuildContext[]) a source file has annotations}.
+ * <p>
+ * This class is not intended to be instanciated or subclassed by clients.
+ * </p>
+ * @since 0.9.0
+ */
+public class BuildContext extends CompilationParticipantResult {
+
+/**
+ * Creates a build context for the given source file.
+ * <p>
+ * This constructor is not intended to be called by clients.
+ * </p>
+ *
+ * @param sourceFile the source file being built
+ */
+public BuildContext(IFile resource) {
+ super(resource);
+}
+
+/**
+ * Returns the contents of the compilation unit.
+ *
+ * @return the contents of the compilation unit
+ */
+public char[] getContents() {
+ try {
+ return Util.getResourceContentsAsCharArray(this.resource);
+ } catch (CoreException e) {
+ throw new RuntimeException("Missing source file: " + this.resource);
+ }
+}
+
+/**
+ * Returns the <code>IFile</code> representing the compilation unit.
+ *
+ * @return the <code>IFile</code> representing the compilation unit
+ */
+public IFile getFile() {
+ return this.resource;
+}
+
+/**
+ * Returns whether the compilation unit contained any annotations when it was compiled.
+ *
+ * NOTE: This is only valid during {@link CompilationParticipant#processAnnotations(BuildContext[])}.
+ *
+ * @return whether the compilation unit contained any annotations when it was compiled
+ */
+public boolean hasAnnotations() {
+ return this.hasAnnotations; // only set during processAnnotations
+}
+
+/**
+ * Record new problems to report against this compilationUnit.
+ * Markers are persisted for these problems only for the declared managed marker type
+ * (see the 'compilationParticipant' extension point).
+ *
+ * @param newProblems the problems to report
+ */
+public void recordNewProblems(CategorizedProblem[] newProblems) {
+ int length2 = newProblems.length;
+ if (length2 == 0) return;
+
+ int length1 = this.problems == null ? 0 : this.problems.length;
+ CategorizedProblem[] merged = new CategorizedProblem[length1 + length2];
+ if (length1 > 0) // always make a copy even if currently empty
+ System.arraycopy(this.problems, 0, merged, 0, length1);
+ System.arraycopy(newProblems, 0, merged, length1, length2);
+ this.problems = merged;
+}
+
+}
Deleted: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/CategorizedProblem.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/CategorizedProblem.java 2007-04-12 19:40:45 UTC (rev 2300)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/CategorizedProblem.java 2007-04-12 22:31:15 UTC (rev 2301)
@@ -1,143 +0,0 @@
-/*******************************************************************************
- * 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.core.compiler;
-
-import org.rubypeople.rdt.internal.core.util.CharOperation;
-
-
-/**
- * Richer description of a Ruby problem, as detected by the compiler or some of the underlying
- * technology reusing the compiler. With the introduction of <code>CompilationParticipant</code>,
- * the simpler problem interface <code>IProblem</code> did not carry enough information to better
- * separate and categorize Java problems. In order to minimize impact on existing API, Java problems
- * are still passed around as <code>IProblem</code>, though actual implementations should explicitly
- * extend <code>CategorizedProblem</code>. Participants can produce their own problem definitions,
- * and given these are categorized problems, they can be better handled by clients (such as user
- * interface).
- *
- * A categorized problem provides access to:
- * <ul>
- * <li> its location (originating source file name, source position, line number), </li>
- * <li> its message description and a predicate to check its severity (warning or error). </li>
- * <li> its ID : a number identifying the very nature of this problem. All possible IDs for standard Java
- * problems are listed as constants on <code>IProblem</code>, </li>
- * <li> its marker type : a string identfying the problem creator. It corresponds to the marker type
- * chosen if this problem was to be persisted. Standard Java problems are associated to marker
- * type "org.eclipse.jdt.core.problem"), </li>
- * <li> its category ID : a number identifying the category this problem belongs to. All possible IDs for
- * standard Java problem categories are listed in this class. </li>
- * </ul>
- *
- * Note: the compiler produces IProblems internally, which are turned into markers by the JavaBuilder
- * so as to persist problem descriptions. This explains why there is no API allowing to reach IProblem detected
- * when compiling. However, the Java problem markers carry equivalent information to IProblem, in particular
- * their ID (attribute "id") is set to one of the IDs defined on this interface.
- *
- * Note: Standard Java problems produced by Java default tooling will be subclasses of this class. Technically, most
- * API methods dealing with problems are referring to <code>IProblem</code> for backward compatibility reason.
- * It is intended that <code>CategorizedProblem</code> will be subclassed for custom problem implementation when
- * participating in compilation operations, so as to allow participant to contribute their own marker types, and thus
- * defining their own domain specific problem/category IDs.
- *
- * @since 3.2
- */
-public abstract class CategorizedProblem implements IProblem {
-
- /**
- * List of standard category IDs used by Ruby problems, more categories will be added
- * in the future.
- */
- public static final int CAT_UNSPECIFIED = 0;
- /** Category for problems related to buildpath */
- public static final int CAT_BUILDPATH = 10;
- /** Category for fatal problems related to syntax */
- public static final int CAT_SYNTAX = 20;
- /** Category for fatal problems in import statements */
- public static final int CAT_IMPORT = 30;
- /** Category for fatal problems related to types, could be addressed by some type change */
- public static final int CAT_TYPE = 40;
- /** Category for fatal problems related to type members, could be addressed by some field or method change */
- public static final int CAT_MEMBER = 50;
- /** Category for fatal problems which could not be addressed by external changes, but require an edit to be addressed */
- public static final int CAT_INTERNAL = 60;
- /** Category for optional problems in Javadoc */
- public static final int CAT_JAVADOC = 70;
- /** Category for optional problems related to coding style practices */
- public static final int CAT_CODE_STYLE = 80;
- /** Category for optional problems related to potential programming flaws */
- public static final int CAT_POTENTIAL_PROGRAMMING_PROBLEM = 90;
- /** Category for optional problems related to naming conflicts */
- public static final int CAT_NAME_SHADOWING_CONFLICT = 100;
- /** Category for optional problems related to deprecation */
- public static final int CAT_DEPRECATION = 110;
- /** Category for optional problems related to unnecessary code */
- public static final int CAT_UNNECESSARY_CODE = 120;
- /** Category for optional problems related to type safety in generics */
- public static final int CAT_UNCHECKED_RAW = 130;
- /** Category for optional problems related to internationalization of String literals */
- public static final int CAT_NLS = 140;
- /** Category for optional problems related to access restrictions */
- public static final int CAT_RESTRICTION = 150;
-
-/**
- * Returns an integer identifying the category of this problem. Categories, like problem IDs are
- * defined in the context of some marker type. Custom implementations of <code>CategorizedProblem</code>
- * may choose arbitrary values for problem/category IDs, as long as they are associated with a different
- * marker type.
- * Standard Java problem markers (i.e. marker type is "org.eclipse.jdt.core.problem") carry an
- * attribute "categoryId" persisting the originating problem category ID as defined by this method).
- * @return id - an integer identifying the category of this problem
- */
-//public abstract int getCategoryID(); FIXME Uncomment when we're ready to do categorization...
-
-/**
- * Returns the marker type associated to this problem, if it gets persisted into a marker by the JavaBuilder
- * Standard Java problems are associated to marker type "org.eclipse.jdt.core.problem").
- * Note: problem markers are expected to extend "org.eclipse.core.resources.problemmarker" marker type.
- * @return the type of the marker which would be associated to the problem
- */
-public abstract String getMarkerType();
-
-/**
- * Returns the names of the extra marker attributes associated to this problem when persisted into a marker
- * by the JavaBuilder. Extra attributes are only optional, and are allowing client customization of generated
- * markers. By default, no EXTRA attributes is persisted, and a categorized problem only persists the following attributes:
- * <ul>
- * <li> <code>IMarker#MESSAGE</code> -> {@link IProblem#getMessage()}</li>
- * <li> <code>IMarker#SEVERITY</code> -> <code> IMarker#SEVERITY_ERROR</code> or
- * <code>IMarker#SEVERITY_WARNING</code> depending on {@link IProblem#isError()} or {@link IProblem#isWarning()}</li>
- * <li> <code>IJavaModelMarker#ID</code> -> {@link IProblem#getID()}</li>
- * <li> <code>IMarker#CHAR_START</code> -> {@link IProblem#getSourceStart()}</li>
- * <li> <code>IMarker#CHAR_END</code> -> {@link IProblem#getSourceEnd()}</li>
- * <li> <code>IMarker#LINE_NUMBER</code> -> {@link IProblem#getSourceLineNumber()}</li>
- * <li> <code>IJavaModelMarker#ARGUMENTS</code> -> some <code>String[]</code> used to compute quickfixes </li>
- * </ul>
- * The names must be eligible for marker creation, as defined by <code>IMarker#setAttributes(String[], Object[])</code>,
- * and there must be as many names as values according to {@link #getExtraMarkerAttributeValues()}.
- * Note that extra marker attributes will be inserted after default ones (as described in {@link CategorizedProblem#getMarkerType()},
- * and thus could be used to override defaults.
- * @return the names of the corresponding marker attributes
- */
-public String[] getExtraMarkerAttributeNames() {
- return CharOperation.NO_STRINGS;
-}
-
-/**
- * Returns the respective values for the extra marker attributes associated to this problem when persisted into
- * a marker by the JavaBuilder. Each value must correspond to a matching attribute name, as defined by
- * {@link #getExtraMarkerAttributeNames()}.
- * The values must be eligible for marker creation, as defined by <code>IMarker#setAttributes(String[], Object[])</code>.
- * @return the values of the corresponding extra marker attributes
- */
-public Object[] getExtraMarkerAttributeValues() {
- return new Object[] {};
-}
-}
Copied: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/CategorizedProblem.java (from rev 2300, trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/CategorizedProblem.java)
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/CategorizedProblem.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/CategorizedProblem.java 2007-04-12 22:31:15 UTC (rev 2301)
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * 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.core.compiler;
+
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+
+
+/**
+ * Richer description of a Ruby problem, as detected by the compiler or some of the underlying
+ * technology reusing the compiler. With the introduction of <code>CompilationParticipant</code>,
+ * the simpler problem interface <code>IProblem</code> did not carry enough information to better
+ * separate and categorize Java problems. In order to minimize impact on existing API, Java problems
+ * are still passed around as <code>IProblem</code>, though actual implementations should explicitly
+ * extend <code>CategorizedProblem</code>. Participants can produce their own problem definitions,
+ * and given these are categorized problems, they can be better handled by clients (such as user
+ * interface).
+ *
+ * A categorized problem provides access to:
+ * <ul>
+ * <li> its location (originating source file name, source position, line number), </li>
+ * <li> its message description and a predicate to check its severity (warning or error). </li>
+ * <li> its ID : a number identifying the very nature of this problem. All possible IDs for standard Java
+ * problems are listed as constants on <code>IProblem</code>, </li>
+ * <li> its marker type : a string identfying the problem creator. It corresponds to the marker type
+ * chosen if this problem was to be persisted. Standard Java problems are associated to marker
+ * type "org.eclipse.jdt.core.problem"), </li>
+ * <li> its category ID : a number identifying the category this problem belongs to. All possible IDs for
+ * standard Java problem categories are listed in this class. </li>
+ * </ul>
+ *
+ * Note: the compiler produces IProblems internally, which are turned into markers by the JavaBuilder
+ * so as to persist problem descriptions. This explains why there is no API allowing to reach IProblem detected
+ * when compiling. However, the Java problem markers carry equivalent information to IProblem, in particular
+ * their ID (attribute "id") is set to one of the IDs defined on this interface.
+ *
+ * Note: Standard Java problems produced by Java default tooling will be subclasses of this class. Technically, most
+ * API methods dealing with problems are referring to <code>IProblem</code> for backward compatibility reason.
+ * It is intended that <code>CategorizedProblem</code> will be subclassed for custom problem implementation when
+ * participating in compilation operations, so as to allow participant to contribute their own marker types, and thus
+ * defining their own domain specific problem/category IDs.
+ *
+ * @since 3.2
+ */
+public abstract class CategorizedProblem implements IProblem {
+
+ /**
+ * List of standard category IDs used by Ruby problems, more categories will be added
+ * in the future.
+ */
+ public static final int CAT_UNSPECIFIED = 0;
+ /** Category for problems related to buildpath */
+ public static final int CAT_BUILDPATH = 10;
+ /** Category for fatal problems related to syntax */
+ public static final int CAT_SYNTAX = 20;
+ /** Category for fatal problems in import statements */
+ public static final int CAT_IMPORT = 30;
+ /** Category for fatal problems related to types, could be addressed by some type change */
+ public static final int CAT_TYPE = 40;
+ /** Category for fatal problems related to type members, could be addressed by some field or method change */
+ public static final int CAT_MEMBER = 50;
+ /** Category for fatal problems which could not be addressed by external changes, but require an edit to be addressed */
+ public static final int CAT_INTERNAL = 60;
+ /** Category for optional problems in Javadoc */
+ public static final int CAT_JAVADOC = 70;
+ /** Category for optional problems related to coding style practices */
+ public static final int CAT_CODE_STYLE = 80;
+ /** Category for optional problems related to potential programming flaws *...
[truncated message content] |
|
From: <caw...@us...> - 2007-04-12 19:40:48
|
Revision: 2300
http://svn.sourceforge.net/rubyeclipse/?rev=2300&view=rev
Author: cawilliams
Date: 2007-04-12 12:40:45 -0700 (Thu, 12 Apr 2007)
Log Message:
-----------
Rolling back branch to beginning (r2143)
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/parser/IProblem.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/Util.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LoadpathEntry.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolder.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Messages.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Util.java
Removed Paths:
-------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/SourceElementParser.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/ast/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/impl/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/lookup/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/parser/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/CompoundNameVector.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfIntValues.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfLong.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfObject.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/SimpleLookupTable.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/SimpleNameVector.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/SimpleSet.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/AbstractSearchScope.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexQueryRequestor.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexSelector.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/PatternSearchJob.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchDocument.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchParticipant.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchScope.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubyWorkspaceScope.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/processing/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/HandleFactory.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-04-12 13:55:24 UTC (rev 2299)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-04-12 19:40:45 UTC (rev 2300)
@@ -317,7 +317,6 @@
private static final boolean VERBOSE = false;
- public static final boolean DEBUG = false;
private SymbolIndex symbolIndex;
private ISymbolFinder symbolFinder;
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/parser/IProblem.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/parser/IProblem.java 2007-04-12 13:55:24 UTC (rev 2299)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/parser/IProblem.java 2007-04-12 19:40:45 UTC (rev 2300)
@@ -34,23 +34,6 @@
public interface IProblem {
/**
- * Problem Categories
- * The high bits of a problem ID contains information about the category of a problem.
- * For example, (problemID & TypeRelated) != 0, indicates that this problem is type related.
- *
- * A problem category can help to implement custom problem filters. Indeed, when numerous problems
- * are listed, focusing on import related problems first might be relevant.
- *
- * When a problem is tagged as Internal, it means that no change other than a local source code change
- * can fix the corresponding problem. A type related problem could be addressed by changing the type
- * involved in it.
- */
- int TypeRelated = 0x01000000;
-
- int ForbiddenReference = TypeRelated + 307;
- int DiscouragedReference = TypeRelated + 280;
-
- /**
* Answer a localized, human-readable message string which describes the
* problem.
*
Deleted: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/SourceElementParser.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/SourceElementParser.java 2007-04-12 13:55:24 UTC (rev 2299)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/SourceElementParser.java 2007-04-12 19:40:45 UTC (rev 2300)
@@ -1,5 +0,0 @@
-package org.rubypeople.rdt.internal.compiler;
-
-public class SourceElementParser {
-
-}
Deleted: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/CompoundNameVector.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/CompoundNameVector.java 2007-04-12 13:55:24 UTC (rev 2299)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/CompoundNameVector.java 2007-04-12 19:40:45 UTC (rev 2300)
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * 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.compiler.util;
-
-import org.rubypeople.rdt.internal.core.util.CharOperation;
-
-public final class CompoundNameVector {
- static int INITIAL_SIZE = 10;
-
- public int size;
- int maxSize;
- char[][][] elements;
-public CompoundNameVector() {
- maxSize = INITIAL_SIZE;
- size = 0;
- elements = new char[maxSize][][];
-}
-public void add(char[][] newElement) {
- if (size == maxSize) // knows that size starts <= maxSize
- System.arraycopy(elements, 0, (elements = new char[maxSize *= 2][][]), 0, size);
- elements[size++] = newElement;
-}
-public void addAll(char[][][] newElements) {
- if (size + newElements.length >= maxSize) {
- maxSize = size + newElements.length; // assume no more elements will be added
- System.arraycopy(elements, 0, (elements = new char[maxSize][][]), 0, size);
- }
- System.arraycopy(newElements, 0, elements, size, newElements.length);
- size += newElements.length;
-}
-public boolean contains(char[][] element) {
- for (int i = size; --i >= 0;)
- if (CharOperation.equals(element, elements[i]))
- return true;
- return false;
-}
-public char[][] elementAt(int index) {
- return elements[index];
-}
-public char[][] remove(char[][] element) {
- // assumes only one occurrence of the element exists
- for (int i = size; --i >= 0;)
- if (element == elements[i]) {
- // shift the remaining elements down one spot
- System.arraycopy(elements, i + 1, elements, i, --size - i);
- elements[size] = null;
- return element;
- }
- return null;
-}
-public void removeAll() {
- for (int i = size; --i >= 0;)
- elements[i] = null;
- size = 0;
-}
-public String toString() {
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < size; i++) {
- buffer.append(CharOperation.toString(elements[i])).append("\n"); //$NON-NLS-1$
- }
- return buffer.toString();
-}
-}
Deleted: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfIntValues.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfIntValues.java 2007-04-12 13:55:24 UTC (rev 2299)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfIntValues.java 2007-04-12 19:40:45 UTC (rev 2300)
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * 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.compiler.util;
-
-import org.rubypeople.rdt.internal.core.util.CharOperation;
-
-/**
- * Hashtable of {char[] --> int}
- */
-public final class HashtableOfIntValues implements Cloneable {
-
- public static final int NO_VALUE = Integer.MIN_VALUE;
-
- // to avoid using Enumerations, walk the individual tables skipping nulls
- public char[] keyTable[];
- public int valueTable[];
-
- public int elementSize; // number of elements in the table
- int threshold;
-
- public HashtableOfIntValues() {
- this(13);
- }
-
- public HashtableOfIntValues(int size) {
-
- this.elementSize = 0;
- this.threshold = size; // size represents the expected number of elements
- int extraRoom = (int) (size * 1.75f);
- if (this.threshold == extraRoom)
- extraRoom++;
- this.keyTable = new char[extraRoom][];
- this.valueTable = new int[extraRoom];
- }
-
- public Object clone() throws CloneNotSupportedException {
- HashtableOfIntValues result = (HashtableOfIntValues) super.clone();
- result.elementSize = this.elementSize;
- result.threshold = this.threshold;
-
- int length = this.keyTable.length;
- result.keyTable = new char[length][];
- System.arraycopy(this.keyTable, 0, result.keyTable, 0, length);
-
- length = this.valueTable.length;
- result.valueTable = new int[length];
- System.arraycopy(this.valueTable, 0, result.valueTable, 0, length);
- return result;
- }
-
- public boolean containsKey(char[] key) {
- int length = keyTable.length,
- index = CharOperation.hashCode(key) % length;
- int keyLength = key.length;
- char[] currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
- return true;
- if (++index == length) {
- index = 0;
- }
- }
- return false;
- }
-
- public int get(char[] key) {
- int length = keyTable.length,
- index = CharOperation.hashCode(key) % length;
- int keyLength = key.length;
- char[] currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
- return valueTable[index];
- if (++index == length) {
- index = 0;
- }
- }
- return NO_VALUE;
- }
-
- public int put(char[] key, int value) {
- int length = keyTable.length,
- index = CharOperation.hashCode(key) % length;
- int keyLength = key.length;
- char[] currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
- return valueTable[index] = value;
- if (++index == length) {
- index = 0;
- }
- }
- keyTable[index] = key;
- valueTable[index] = value;
-
- // assumes the threshold is never equal to the size of the table
- if (++elementSize > threshold)
- rehash();
- return value;
- }
-
- public int removeKey(char[] key) {
- int length = keyTable.length,
- index = CharOperation.hashCode(key) % length;
- int keyLength = key.length;
- char[] currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.length == keyLength && CharOperation.equals(currentKey, key)) {
- int value = valueTable[index];
- elementSize--;
- keyTable[index] = null;
- valueTable[index] = NO_VALUE;
- rehash();
- return value;
- }
- if (++index == length) {
- index = 0;
- }
- }
- return NO_VALUE;
- }
-
- private void rehash() {
-
- HashtableOfIntValues newHashtable = new HashtableOfIntValues(elementSize * 2); // double the number of expected elements
- char[] currentKey;
- for (int i = keyTable.length; --i >= 0;)
- if ((currentKey = keyTable[i]) != null)
- newHashtable.put(currentKey, valueTable[i]);
-
- this.keyTable = newHashtable.keyTable;
- this.valueTable = newHashtable.valueTable;
- this.threshold = newHashtable.threshold;
- }
-
- public int size() {
- return elementSize;
- }
-
- public String toString() {
- String s = ""; //$NON-NLS-1$
- char[] key;
- for (int i = 0, length = valueTable.length; i < length; i++)
- if ((key = keyTable[i]) != null)
- s += new String(key) + " -> " + valueTable[i] + "\n"; //$NON-NLS-2$ //$NON-NLS-1$
- return s;
- }
-}
Deleted: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfLong.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfLong.java 2007-04-12 13:55:24 UTC (rev 2299)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfLong.java 2007-04-12 19:40:45 UTC (rev 2300)
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * 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.compiler.util;
-
-
- /**
- * Hashtable for non-zero long keys.
- */
-
-public final class HashtableOfLong {
- // to avoid using Enumerations, walk the individual tables skipping nulls
- public long[] keyTable;
- public Object[] valueTable;
-
- public int elementSize; // number of elements in the table
- int threshold;
-public HashtableOfLong() {
- this(13);
-}
-public HashtableOfLong(int size) {
- this.elementSize = 0;
- this.threshold = size; // size represents the expected number of elements
- int extraRoom = (int) (size * 1.75f);
- if (this.threshold == extraRoom)
- extraRoom++;
- this.keyTable = new long[extraRoom];
- this.valueTable = new Object[extraRoom];
-}
-public boolean containsKey(long key) {
- int length = keyTable.length,
- index = ((int)(key >>> 32)) % length;
- long currentKey;
- while ((currentKey = keyTable[index]) != 0) {
- if (currentKey == key)
- return true;
- if (++index == length) {
- index = 0;
- }
- }
- return false;
-}
-public Object get(long key) {
- int length = keyTable.length,
- index = ((int)(key >>> 32)) % length;
- long currentKey;
- while ((currentKey = keyTable[index]) != 0) {
- if (currentKey == key) return valueTable[index];
- if (++index == length) {
- index = 0;
- }
- }
- return null;
-}
-public Object put(long key, Object value) {
- int length = keyTable.length,
- index = ((int)(key >>> 32)) % length;
- long currentKey;
- while ((currentKey = keyTable[index]) != 0) {
- if (currentKey == key) return valueTable[index] = value;
- if (++index == length) {
- index = 0;
- }
- }
- keyTable[index] = key;
- valueTable[index] = value;
-
- // assumes the threshold is never equal to the size of the table
- if (++elementSize > threshold)
- rehash();
- return value;
-}
-private void rehash() {
- HashtableOfLong newHashtable = new HashtableOfLong(elementSize * 2); // double the number of expected elements
- long currentKey;
- for (int i = keyTable.length; --i >= 0;)
- if ((currentKey = keyTable[i]) != 0)
- newHashtable.put(currentKey, valueTable[i]);
-
- this.keyTable = newHashtable.keyTable;
- this.valueTable = newHashtable.valueTable;
- this.threshold = newHashtable.threshold;
-}
-public int size() {
- return elementSize;
-}
-public String toString() {
- String s = ""; //$NON-NLS-1$
- Object object;
- for (int i = 0, length = valueTable.length; i < length; i++)
- if ((object = valueTable[i]) != null)
- s += keyTable[i] + " -> " + object.toString() + "\n"; //$NON-NLS-2$ //$NON-NLS-1$
- return s;
-}
-}
Deleted: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfObject.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfObject.java 2007-04-12 13:55:24 UTC (rev 2299)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfObject.java 2007-04-12 19:40:45 UTC (rev 2300)
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * 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.compiler.util;
-
-import org.rubypeople.rdt.internal.core.util.CharOperation;
-
-/**
- * Hashtable of {char[] --> Object }
- */
-public final class HashtableOfObject implements Cloneable {
-
- // to avoid using Enumerations, walk the individual tables skipping nulls
- public char[] keyTable[];
- public Object valueTable[];
-
- public int elementSize; // number of elements in the table
- int threshold;
-
- public HashtableOfObject() {
- this(13);
- }
-
- public HashtableOfObject(int size) {
-
- this.elementSize = 0;
- this.threshold = size; // size represents the expected number of elements
- int extraRoom = (int) (size * 1.75f);
- if (this.threshold == extraRoom)
- extraRoom++;
- this.keyTable = new char[extraRoom][];
- this.valueTable = new Object[extraRoom];
- }
-
- public void clear() {
- for (int i = this.keyTable.length; --i >= 0;) {
- this.keyTable[i] = null;
- this.valueTable[i] = null;
- }
- this.elementSize = 0;
- }
-
- public Object clone() throws CloneNotSupportedException {
- HashtableOfObject result = (HashtableOfObject) super.clone();
- result.elementSize = this.elementSize;
- result.threshold = this.threshold;
-
- int length = this.keyTable.length;
- result.keyTable = new char[length][];
- System.arraycopy(this.keyTable, 0, result.keyTable, 0, length);
-
- length = this.valueTable.length;
- result.valueTable = new Object[length];
- System.arraycopy(this.valueTable, 0, result.valueTable, 0, length);
- return result;
- }
-
- public boolean containsKey(char[] key) {
- int length = keyTable.length,
- index = CharOperation.hashCode(key) % length;
- int keyLength = key.length;
- char[] currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
- return true;
- if (++index == length) {
- index = 0;
- }
- }
- return false;
- }
-
- public Object get(char[] key) {
- int length = keyTable.length,
- index = CharOperation.hashCode(key) % length;
- int keyLength = key.length;
- char[] currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
- return valueTable[index];
- if (++index == length) {
- index = 0;
- }
- }
- return null;
- }
-
- public Object put(char[] key, Object value) {
- int length = keyTable.length,
- index = CharOperation.hashCode(key) % length;
- int keyLength = key.length;
- char[] currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
- return valueTable[index] = value;
- if (++index == length) {
- index = 0;
- }
- }
- keyTable[index] = key;
- valueTable[index] = value;
-
- // assumes the threshold is never equal to the size of the table
- if (++elementSize > threshold)
- rehash();
- return value;
- }
-
- public Object removeKey(char[] key) {
- int length = keyTable.length,
- index = CharOperation.hashCode(key) % length;
- int keyLength = key.length;
- char[] currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.length == keyLength && CharOperation.equals(currentKey, key)) {
- Object value = valueTable[index];
- elementSize--;
- keyTable[index] = null;
- valueTable[index] = null;
- rehash();
- return value;
- }
- if (++index == length) {
- index = 0;
- }
- }
- return null;
- }
-
- private void rehash() {
-
- HashtableOfObject newHashtable = new HashtableOfObject(elementSize * 2); // double the number of expected elements
- char[] currentKey;
- for (int i = keyTable.length; --i >= 0;)
- if ((currentKey = keyTable[i]) != null)
- newHashtable.put(currentKey, valueTable[i]);
-
- this.keyTable = newHashtable.keyTable;
- this.valueTable = newHashtable.valueTable;
- this.threshold = newHashtable.threshold;
- }
-
- public int size() {
- return elementSize;
- }
-
- public String toString() {
- String s = ""; //$NON-NLS-1$
- Object object;
- for (int i = 0, length = valueTable.length; i < length; i++)
- if ((object = valueTable[i]) != null)
- s += new String(keyTable[i]) + " -> " + object.toString() + "\n"; //$NON-NLS-2$ //$NON-NLS-1$
- return s;
- }
-}
Deleted: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/SimpleLookupTable.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/SimpleLookupTable.java 2007-04-12 13:55:24 UTC (rev 2299)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/SimpleLookupTable.java 2007-04-12 19:40:45 UTC (rev 2300)
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * 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.compiler.util;
-
-/**
- * A simple lookup table is a non-synchronized Hashtable, whose keys
- * and values are Objects. It also uses linear probing to resolve collisions
- * rather than a linked list of hash table entries.
- */
-public final class SimpleLookupTable implements Cloneable {
-
-// to avoid using Enumerations, walk the individual tables skipping nulls
-public Object[] keyTable;
-public Object[] valueTable;
-public int elementSize; // number of elements in the table
-public int threshold;
-
-public SimpleLookupTable() {
- this(13);
-}
-
-public SimpleLookupTable(int size) {
- this.elementSize = 0;
- this.threshold = size; // size represents the expected number of elements
- int extraRoom = (int) (size * 1.5f);
- if (this.threshold == extraRoom)
- extraRoom++;
- this.keyTable = new Object[extraRoom];
- this.valueTable = new Object[extraRoom];
-}
-
-public Object clone() throws CloneNotSupportedException {
- SimpleLookupTable result = (SimpleLookupTable) super.clone();
- result.elementSize = this.elementSize;
- result.threshold = this.threshold;
-
- int length = this.keyTable.length;
- result.keyTable = new Object[length];
- System.arraycopy(this.keyTable, 0, result.keyTable, 0, length);
-
- length = this.valueTable.length;
- result.valueTable = new Object[length];
- System.arraycopy(this.valueTable, 0, result.valueTable, 0, length);
- return result;
-}
-
-public boolean containsKey(Object key) {
- int length = keyTable.length;
- int index = (key.hashCode() & 0x7FFFFFFF) % length;
- Object currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.equals(key)) return true;
- if (++index == length) index = 0;
- }
- return false;
-}
-
-public Object get(Object key) {
- int length = keyTable.length;
- int index = (key.hashCode() & 0x7FFFFFFF) % length;
- Object currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.equals(key)) return valueTable[index];
- if (++index == length) index = 0;
- }
- return null;
-}
-
-public Object keyForValue(Object valueToMatch) {
- if (valueToMatch != null)
- for (int i = 0, l = keyTable.length; i < l; i++)
- if (keyTable[i] != null && valueToMatch.equals(valueTable[i]))
- return keyTable[i];
- return null;
-}
-
-public Object put(Object key, Object value) {
- int length = keyTable.length;
- int index = (key.hashCode() & 0x7FFFFFFF) % length;
- Object currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.equals(key)) return valueTable[index] = value;
- if (++index == length) index = 0;
- }
- keyTable[index] = key;
- valueTable[index] = value;
-
- // assumes the threshold is never equal to the size of the table
- if (++elementSize > threshold) rehash();
- return value;
-}
-
-public Object removeKey(Object key) {
- int length = keyTable.length;
- int index = (key.hashCode() & 0x7FFFFFFF) % length;
- Object currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.equals(key)) {
- elementSize--;
- Object oldValue = valueTable[index];
- keyTable[index] = null;
- valueTable[index] = null;
- if (keyTable[index + 1 == length ? 0 : index + 1] != null)
- rehash(); // only needed if a possible collision existed
- return oldValue;
- }
- if (++index == length) index = 0;
- }
- return null;
-}
-
-public void removeValue(Object valueToRemove) {
- boolean rehash = false;
- for (int i = 0, l = valueTable.length; i < l; i++) {
- Object value = valueTable[i];
- if (value != null && value.equals(valueToRemove)) {
- elementSize--;
- keyTable[i] = null;
- valueTable[i] = null;
- if (!rehash && keyTable[i + 1 == l ? 0 : i + 1] != null)
- rehash = true; // only needed if a possible collision existed
- }
- }
- if (rehash) rehash();
-}
-
-private void rehash() {
- SimpleLookupTable newLookupTable = new SimpleLookupTable(elementSize * 2); // double the number of expected elements
- Object currentKey;
- for (int i = keyTable.length; --i >= 0;)
- if ((currentKey = keyTable[i]) != null)
- newLookupTable.put(currentKey, valueTable[i]);
-
- this.keyTable = newLookupTable.keyTable;
- this.valueTable = newLookupTable.valueTable;
- this.elementSize = newLookupTable.elementSize;
- this.threshold = newLookupTable.threshold;
-}
-
-public String toString() {
- String s = ""; //$NON-NLS-1$
- Object object;
- for (int i = 0, l = valueTable.length; i < l; i++)
- if ((object = valueTable[i]) != null)
- s += keyTable[i].toString() + " -> " + object.toString() + "\n"; //$NON-NLS-2$ //$NON-NLS-1$
- return s;
-}
-}
Deleted: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/SimpleNameVector.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/SimpleNameVector.java 2007-04-12 13:55:24 UTC (rev 2299)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/SimpleNameVector.java 2007-04-12 19:40:45 UTC (rev 2300)
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * 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.compiler.util;
-
-import org.rubypeople.rdt.internal.core.util.CharOperation;
-
-public final class SimpleNameVector {
-
- static int INITIAL_SIZE = 10;
-
- public int size;
- int maxSize;
- char[][] elements;
-
- public SimpleNameVector() {
-
- this.maxSize = INITIAL_SIZE;
- this.size = 0;
- this.elements = new char[this.maxSize][];
- }
-
- public void add(char[] newElement) {
-
- if (this.size == this.maxSize) // knows that size starts <= maxSize
- System.arraycopy(this.elements, 0, (this.elements = new char[this.maxSize *= 2][]), 0, this.size);
- this.elements[size++] = newElement;
- }
-
- public void addAll(char[][] newElements) {
-
- if (this.size + newElements.length >= this.maxSize) {
- this.maxSize = this.size + newElements.length; // assume no more elements will be added
- System.arraycopy(this.elements, 0, (this.elements = new char[this.maxSize][]), 0, this.size);
- }
- System.arraycopy(newElements, 0, this.elements, this.size, newElements.length);
- this.size += newElements.length;
- }
-
- public void copyInto(Object[] targetArray){
-
- System.arraycopy(this.elements, 0, targetArray, 0, this.size);
- }
-
- public boolean contains(char[] element) {
-
- for (int i = this.size; --i >= 0;)
- if (CharOperation.equals(element, this.elements[i]))
- return true;
- return false;
- }
-
- public char[] elementAt(int index) {
- return this.elements[index];
- }
-
- public char[] remove(char[] element) {
-
- // assumes only one occurrence of the element exists
- for (int i = this.size; --i >= 0;)
- if (element == this.elements[i]) {
- // shift the remaining elements down one spot
- System.arraycopy(this.elements, i + 1, this.elements, i, --this.size - i);
- this.elements[this.size] = null;
- return element;
- }
- return null;
- }
-
- public void removeAll() {
-
- for (int i = this.size; --i >= 0;)
- this.elements[i] = null;
- this.size = 0;
- }
-
- public int size(){
-
- return this.size;
- }
-
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < this.size; i++) {
- buffer.append(this.elements[i]).append("\n"); //$NON-NLS-1$
- }
- return buffer.toString();
- }
-}
Deleted: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/SimpleSet.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/SimpleSet.java 2007-04-12 13:55:24 UTC (rev 2299)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/SimpleSet.java 2007-04-12 19:40:45 UTC (rev 2300)
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * 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.compiler.util;
-
-/**
- * A simple lookup table is a non-synchronized Hashtable, whose keys
- * and values are Objects. It also uses linear probing to resolve collisions
- * rather than a linked list of hash table entries.
- */
-public final class SimpleSet implements Cloneable {
-
-// to avoid using Enumerations, walk the individual values skipping nulls
-public Object[] values;
-public int elementSize; // number of elements in the table
-public int threshold;
-
-public SimpleSet() {
- this(13);
-}
-
-public SimpleSet(int size) {
- if (size < 3) size = 3;
- this.elementSize = 0;
- this.threshold = size + 1; // size is the expected number of elements
- this.values = new Object[2 * size + 1];
-}
-
-public Object add(Object object) {
- int length = this.values.length;
- int index = (object.hashCode() & 0x7FFFFFFF) % length;
- Object current;
- while ((current = this.values[index]) != null) {
- if (current.equals(object)) return this.values[index] = object;
- if (++index == length) index = 0;
- }
- this.values[index] = object;
-
- // assumes the threshold is never equal to the size of the table
- if (++this.elementSize > this.threshold) rehash();
- return object;
-}
-
-public void asArray(Object[] copy) {
- if (this.elementSize != copy.length)
- throw new IllegalArgumentException();
- int index = this.elementSize;
- for (int i = 0, l = this.values.length; i < l && index > 0; i++)
- if (this.values[i] != null)
- copy[--index] = this.values[i];
-}
-
-public void clear() {
- for (int i = this.values.length; --i >= 0;)
- this.values[i] = null;
- this.elementSize = 0;
-}
-
-public Object clone() throws CloneNotSupportedException {
- SimpleSet result = (SimpleSet) super.clone();
- result.elementSize = this.elementSize;
- result.threshold = this.threshold;
-
- int length = this.values.length;
- result.values = new Object[length];
- System.arraycopy(this.values, 0, result.values, 0, length);
- return result;
-}
-
-public boolean includes(Object object) {
- int length = values.length;
- int index = (object.hashCode() & 0x7FFFFFFF) % length;
- Object current;
- while ((current = values[index]) != null) {
- if (current.equals(object)) return true;
- if (++index == length) index = 0;
- }
- return false;
-}
-
-public Object remove(Object object) {
- int length = values.length;
- int index = (object.hashCode() & 0x7FFFFFFF) % length;
- Object current;
- while ((current = values[index]) != null) {
- if (current.equals(object)) {
- elementSize--;
- Object oldValue = values[index];
- values[index] = null;
- if (values[index + 1 == length ? 0 : index + 1] != null)
- rehash(); // only needed if a possible collision existed
- return oldValue;
- }
- if (++index == length) index = 0;
- }
- return null;
-}
-
-private void rehash() {
- SimpleSet newSet = new SimpleSet(elementSize * 2); // double the number of expected elements
- Object current;
- for (int i = values.length; --i >= 0;)
- if ((current = values[i]) != null)
- newSet.add(current);
-
- this.values = newSet.values;
- this.elementSize = newSet.elementSize;
- this.threshold = newSet.threshold;
-}
-
-public String toString() {
- String s = ""; //$NON-NLS-1$
- Object object;
- for (int i = 0, l = values.length; i < l; i++)
- if ((object = values[i]) != null)
- s += object.toString() + "\n"; //$NON-NLS-1$
- return s;
-}
-}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/Util.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/Util.java 2007-04-12 13:55:24 UTC (rev 2299)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/Util.java 2007-04-12 19:40:45 UTC (rev 2300)
@@ -4,11 +4,7 @@
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 {
@@ -119,92 +115,4 @@
});
}
- /**
- * 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;
- }
-
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LoadpathEntry.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LoadpathEntry.java 2007-04-12 13:55:24 UTC (rev 2299)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LoadpathEntry.java 2007-04-12 19:40:45 UTC (rev 2300)
@@ -16,7 +16,6 @@
import org.rubypeople.rdt.core.IRubyModelStatus;
import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.RubyCore;
-import org.rubypeople.rdt.internal.compiler.env.AccessRuleSet;
import org.rubypeople.rdt.internal.core.util.CharOperation;
import org.rubypeople.rdt.internal.core.util.Messages;
import org.w3c.dom.DOMException;
@@ -85,8 +84,6 @@
* The extra attributes
*/
ILoadpathAttribute[] extraAttributes;
-
- private AccessRuleSet accessRuleSet;
public LoadpathEntry(IProject project) {
this(ILoadpathEntry.CPE_PROJECT, project.getFullPath(), INCLUDE_ALL, EXCLUDE_NONE, NO_EXTRA_ATTRIBUTES, true);
@@ -627,8 +624,4 @@
public ILoadpathAttribute[] getExtraAttributes() {
return extraAttributes;
}
-
- public AccessRuleSet getAccessRuleSet() {
- return this.accessRuleSet;
- }
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java 2007-04-12 13:55:24 UTC (rev 2299)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java 2007-04-12 19:40:45 UTC (rev 2300)
@@ -81,8 +81,6 @@
import org.rubypeople.rdt.internal.compiler.util.HashtableOfObjectToInt;
import org.rubypeople.rdt.internal.core.buffer.BufferManager;
import org.rubypeople.rdt.internal.core.builder.RubyBuilder;
-import org.rubypeople.rdt.internal.core.search.RubyWorkspaceScope;
-import org.rubypeople.rdt.internal.core.search.indexing.IndexManager;
import org.rubypeople.rdt.internal.core.util.Messages;
import org.rubypeople.rdt.internal.core.util.Util;
import org.rubypeople.rdt.internal.core.util.WeakHashSet;
@@ -192,13 +190,6 @@
private static boolean verbose = false;
public static boolean CP_RESOLVE_VERBOSE = false;
public static boolean ZIP_ACCESS_VERBOSE = false;
-
- public IndexManager indexManager = null;
-
- /*
- * The unique workspace scope
- */
- public RubyWorkspaceScope workspaceScope;
// Preferences
HashSet optionNames = new HashSet(20);
@@ -250,7 +241,6 @@
*/
private RubyModelManager() {
// singleton: prevent others from creating a new instance
- if (Platform.isRunning()) this.indexManager = new IndexManager();
}
/**
@@ -260,13 +250,6 @@
return MANAGER;
}
- public RubyWorkspaceScope getWorkspaceScope() {
- if (this.workspaceScope == null) {
- this.workspaceScope = new RubyWorkspaceScope();
- }
- return this.workspaceScope;
- }
-
/**
* Initialize preferences lookups for JavaCore plugin.
*/
@@ -1116,10 +1099,6 @@
workspace.removeResourceChangeListener(this.deltaState);
workspace.removeSaveParticipant(javaCore);
- if (this.indexManager != null){ // no more indexing
- this.indexManager.shutdown();
- }
-
// wait for the initialization job to finish
try {
Platform.getJobManager().join(RubyCore.PLUGIN_ID, null);
@@ -1150,13 +1129,13 @@
// clean up indexes on workspace full save
// (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=52347)
- IndexManager manager = this.indexManager;
- if (manager != null
- // don't force initialization of workspace scope as we could be shutting down
- // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=93941)
- && this.workspaceScope != null) {
- manager.cleanUpIndexes();
- }
+// IndexManager manager = this.indexManager;
+// if (manager != null
+// // don't force initialization of workspace scope as we could be shutting down
+// // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=93941)
+// && this.workspaceScope != null) {
+// manager.cleanUpIndexes();
+// }
}
IProject savedProject = context.getProject();
@@ -2644,8 +2623,4 @@
}
}
- public IndexManager getIndexManager() {
- return this.indexManager;
- }
-
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java 2007-04-12 13:55:24 UTC (rev 2299)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java 2007-04-12 19:40:45 UTC (rev 2300)
@@ -2208,10 +2208,10 @@
}
public ISourceFolderRoot getSourceFolderRoot(String string) {
- return getSourceFolderRoot0(RubyProject.canonicalizedPath(new Path(string)));
+ return getPackageFragmentRoot0(RubyProject.canonicalizedPath(new Path(string)));
}
- public ISourceFolderRoot getSourceFolderRoot0(IPath path) {
+ private ISourceFolderRoot getPackageFragmentRoot0(IPath path) {
return new ExternalSourceFolderRoot(path, this);
}
@@ -2431,7 +2431,7 @@
IPath path = new Path(rootPath);
RubyElement root;
if(path.isAbsolute()) {
- root = (RubyElement) getSourceFolderRoot0(path);
+ root = (RubyElement) getPackageFragmentRoot0(path);
} else
root = (RubyElement)getSourceFolderRoot(path);
if (token != null && token.charAt(0) == JEM_SOURCE_FOLDER) {
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolder.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolder.java 2007-04-12 13:55:24 UTC (rev 2299)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolder.java 2007-04-12 19:40:45 UTC (rev 2300)
@@ -23,7 +23,7 @@
public class SourceFolder extends Openable implements ISourceFolder {
- public String[] names;
+ String[] names;
public SourceFolder(SourceFolderRoot parent, String[] names) {
super(parent);
Deleted: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/AbstractSearchScope.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/AbstractSearchScope.java 2007-04-12 13:55:24 UTC (rev 2299)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/AbstractSearchScope.java 2007-04-12 19:40:45 UTC (rev 2300)
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * 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;
-
-import org.rubypeople.rdt.core.IRubyElementDelta;
-import org.rubypeople.rdt.core.search.IRubySearchScope;
-
-public abstract class AbstractSearchScope implements IRubySearchScope {
-
-/**
- * @see IRubySearchScope#includesBinaries()
- * @deprecated
- */
-public boolean includesBinaries() {
- return true;
-}
-
-/**
- * @see IRubySearchScope#includesClasspaths()
- * @deprecated
- */
-public boolean includesClasspaths() {
- return true;
-}
-
-/* (non-Rubydoc)
- * Process the given delta and refresh its internal state if needed.
- * Returns whether the internal state was refreshed.
- */
-public abstract void processDelta(IRubyElementDelta delta);
-
-/**
- * @see IRubySearchScope#setIncludesBinaries(boolean)
- * @deprecated
- */
-public void setIncludesBinaries(boolean includesBinaries) {
- // implements interface method
-}
-
-/**
- * @see IRubySearchScope#setIncludesClasspaths(boolean)
- * @deprecated
- */
-public void setIncludesClasspaths(boolean includesClasspaths) {
- // implements interface method
-}
-
-}
Deleted: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java 2007-04-12 13:55:24 UTC (rev 2299)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java 2007-04-12 19:40:45 UTC (rev 2300)
@@ -1,29 +0,0 @@
-package org.rubypeople.rdt.internal.core.search;
-
-import org.rubypeople.rdt.core.search.IRubySearchScope;
-import org.rubypeople.rdt.core.search.SearchEngine;
-import org.rubypeople.rdt.core.search.SearchParticipant;
-import org.rubypeople.rdt.internal.core.RubyModelManager;
-
-public class BasicSearchEngine {
-
- public static final boolean VERBOSE = false;
-
- /**
- * @see SearchEngine#createWorkspaceScope() for detailed comment.
- */
- public static IRubySearchScope createWorkspaceScope() {
- return RubyModelManager.getRubyModelManager().getWorkspaceScope();
- }
-
- /**
- * Returns a new default Ruby search participant.
- *
- * @return a new default Ruby search participant
- * @since 3.0
- */
- public static SearchParticipant getDefaultSearchParticipant() {
- return new RubySearchParticipant();
- }
-
-}
Deleted: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexQueryRequestor.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexQueryRequestor.java 2007-04-12 13:55:24 UTC (rev 2299)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexQueryRequestor.java 2007-04-12 19:40:45 UTC (rev 2300)
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * 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;
-
-import org.rubypeople.rdt.core.search.SearchParticipant;
-import org.rubypeople.rdt.core.search.SearchPattern;
-import org.rubypeople.rdt.internal.compiler.env.AccessRuleSet;
-
-/**
- * TODO add spec
- */
-public abstract class IndexQueryRequestor {
-
- // answer false if requesting cancel
- public abstract boolean acceptIndexMatch(String documentPath, SearchPattern indexRecord, SearchParticipant participant, AccessRuleSet access);
-
-}
Deleted: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexSelector.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexSelector.java 2007-04-12 13:55:24 UTC (rev 2299)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexSelector.java 2007-04-12 19:40:45 UTC (rev 2300)
@@ -1,205 +0,0 @@
-package org.rubypeople.rdt.internal.core.search;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.rubypeople.rdt.core.ILoadpathEntry;
-import org.rubypeople.rdt.core.IRubyElement;
-import org.rubypeople.rdt.core.IRubyModel;
-import org.rubypeople.rdt.core.IRubyProject;
-import org.rubypeople.rdt.core.RubyModelException;
-import org.rubypeople.rdt.core.search.IRubySearchScope;
-import org.rubypeople.rdt.core.search.SearchPattern;
-import org.rubypeople.rdt.internal.compiler.util.SimpleSet;
-import org.rubypeople.rdt.internal.core.ExternalSourceFolderRoot;
-import org.rubypeople.rdt.internal.core.RubyModelManager;
-import org.rubypeople.rdt.internal.core.RubyProject;
-import org.rubypeople.rdt.internal.core.search.indexing.IndexManager;
-import org.rubypeople.rdt.internal.core.search.matching.MatchLocator;
-
-public class IndexSelector {
- IRubySearchScope searchScope;
- SearchPattern pattern;
- IPath[] indexLocations; // cache of the keys for looking index up
-
-public IndexSelector(
- IRubySearchScope searchScope,
- SearchPattern pattern) {
-
- this.searchScope = searchScope;
- this.pattern = pattern;
-}
-/**
- * Returns whether elements of the given project or jar can see the given focus (an IRubyProject or
- * a JarPackageFragmentRot) either because the focus is part of the project or the jar, or because it is
- * accessible throught the project's classpath
- */
-public static boolean canSeeFocus(IRubyElement focus, boolean isPolymorphicSearch, IPath projectOrJarPath) {
- try {
- ILoadpathEntry[] focusEntries = null;
- if (isPolymorphicSearch) {
- RubyProject focusProject = focus instanceof ExternalSourceFolderRoot ? (RubyProject) focus.getParent() : (RubyProject) focus;
- focusEntries = focusProject.getExpandedLoadpath(true);
- }
- IRubyModel model = focus.getRubyModel();
- IRubyProject project = getRubyProject(projectOrJarPath, model);
- if (project != null)
- return canSeeFocus(focus, (RubyProject) project, focusEntries);
-
- // projectOrJarPath is a jar
- // it can see the focus only if it is on the classpath of a project that can see the focus
- IRubyProject[] allProjects = model.getRubyProjects();
- for (int i = 0, length = allProjects.length; i < length; i++) {
- RubyProject otherProject = (RubyProject) allProjects[i];
- ILoadpathEntry[] entries = otherProject.getResolvedLoadpath(true/*ignoreUnresolvedEntry*/, false/*don't generateMarkerOnError*/, false/*don't returnResolutionInProgress*/);
- for (int j = 0, length2 = entries.length; j < length2; j++) {
- ILoadpathEntry entry = entries[j];
- if (entry.getEntryKind() == ILoadpathEntry.CPE_LIBRARY && entry.getPath().equals(projectOrJarPath))
- if (canSeeFocus(focus, otherProject, focusEntries))
- return true;
- }
- }
- return false;
- } catch (RubyModelException e) {
- return false;
- }
-}
-public static boolean canSeeFocus(IRubyElement focus, RubyProject javaProject, ILoadpathEntry[] focusEntriesForPolymorphicSearch) {
- try {
- if (focus.equals(javaProject))
- return true;
-
- if (focusEntriesForPolymorphicSearch != null) {
- // look for refering project
- IPath projectPath = javaProject.getProject().getFullPath();
- for (int i = 0, length = focusEntriesForPolymorphicSearch.length; i < length; i++) {
- ILoadpathEntry entry = focusEntriesForPolymorphicSearch[i];
- if (entry.getEntryKind() == ILoadpathEntry.CPE_PROJECT && entry.getPath().equals(projectPath))
- return true;
- }
- }
- if (focus instanceof ExternalSourceFolderRoot) {
- // focus is part of a jar
- IPath focusPath = focus.getPath();
- ILoadpathEntry[] entries = javaProject.getExpandedLoadpath(true);
- for (int i = 0, length = entries.length; i < length; i++) {
- ILoadpathEntry entry = entries[i];
- if (entry.getEntryKind() == ILoadpathEntry.CPE_LIBRARY && entry.getPath().equals(focusPath))
- return true;
- }
- return false;
- }
- // look for dependent projects
- IPath focusPath = ((RubyProject) focus).getProject().getFullPath();
- ILoadpathEntry[] entries = javaProject.getExpandedLoadpath(true);
- for (int i = 0, length = entries.length; i < length; i++) {
- ILoadpathEntry entry = entries[i];
- if (entry.getEntryKind() == ILoadpathEntry.CPE_PROJECT && entry.getPath().equals(focusPath))
- return true;
- }
- return false;
- } catch (RubyModelException e) {
- return false;
- }
-}
-/*
- * Compute the list of paths which are keying index files.
- */
-private void initializeIndexLocations() {
- IPath[] projectsAndJars = this.searchScope.enclosingProjectsAndJars();
- IndexManager manager = RubyModelManager.getRubyModelManager().getIndexManager();
- SimpleSet locations = new SimpleSet();
- IRubyElement focus = MatchLocator.projectOrJarFocus(this.pattern);
- if (focus == null) {
- for (int i = 0; i < projectsAndJars.length; i++)
- locations.add(manager.computeIndexLocation(projectsAndJars[i]));
- } else {
- try {
- // find the projects from projectsAndJars that see the focus then walk those projects looking for the jars from projectsAndJars
- int length = projectsAndJars.length;
- RubyProject[] projectsCanSeeFocus = new RubyProject[length];
- SimpleSet visitedProjects = new SimpleSet(length);
- int projectIndex = 0;
- SimpleSet jarsToCheck = new SimpleSet(length);
- ILoadpathEntry[] focusEntries = null;
- if (this.pattern != null && MatchLocator.isPolymorphicSearch(this.pattern)) { // isPolymorphicSearch
- RubyProject focusProject = focus instanceof ExternalSourceFolderRoot ? (RubyProject) focus.getParent() : (RubyProject) focus;
- focusEntries = focusProject.getExpandedLoadpath(true);
- }
- IRubyModel model = RubyModelManager.getRubyModelManager().getRubyModel();
- for (int i = 0; i < length; i++) {
- IPath path = projectsAndJars[i];
- RubyProject project = (RubyProject) getRubyProject(path, model);
- if (project != null) {
- visitedProjects.add(project);
- if (canSeeFocus(focus, project, focusEntries)) {
- locations.add(manager.computeIndexLocation(path));
- projectsCanSeeFocus[projectIndex++] = project;
- }
- } else {
- jarsToCheck.add(path);
- }
- }
- for (int i = 0; i < projectIndex && jarsToCheck.elementSize > 0; i++) {
- ILoadpathEntry[] entries = projectsCanSeeFocus[i].getResolvedLoadpath(true/*ignoreUnresolvedEntry*/, false/*don't generateMarkerOnError*/, false/*don't returnResolutionInProgress*/);
- for (int j = entries.length; --j >= 0;) {
- ILoadpathEntry entry = entries[j];
- if (entry.getEntryKind() == ILoadpathEntry.CPE_LIBRARY) {
- IPath path = entry.getPath();
- if (jarsToCheck.includes(path)) {
- locations.add(manager.computeIndexLocation(entry.getPath()));
- jarsToCheck.remove(path);
- }
- }
- }
- }
- // jar files can be included in the search scope without including one of the projects that references them, so scan all projects that have not been visited
- if (jarsToCheck.elementSize > 0) {
- IRubyProject[] allProjects = model.getRubyProjects();
- for (int i = 0, l = allProjects.length; i < l && jarsToCheck.elementSize > 0; i++) {
- RubyProject project = (RubyProject) allProjects[i];
- if (!visitedProjects.includes(project)) {
- IL...
[truncated message content] |
|
From: <mir...@us...> - 2007-04-12 13:55:26
|
Revision: 2299
http://svn.sourceforge.net/rubyeclipse/?rev=2299&view=rev
Author: mirkostocker
Date: 2007-04-12 06:55:24 -0700 (Thu, 12 Apr 2007)
Log Message:
-----------
stubs for the rename module refactoring
Modified Paths:
--------------
trunk/org.rubypeople.rdt.refactoring/META-INF/MANIFEST.MF
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/rename/RenameConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/rename/RenameRefactoring.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/ClassFinder.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/ClassInstanciationFinder.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassEditProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassRefactoring.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/RenameFieldRefactoring.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocal/IAbortCondition.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemethod/RenameMethodRefactoring.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/NewNameListener.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/util/NameValidator.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/util/NodeUtil.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/TS_All.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/rename/RenameTester.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renameclass/TC_ClassFinder.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/util/TC_NameValidator.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/ConstNameValidator.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/IValidator.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConfig.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleEditProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleRefactoring.java
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamefield/rename_class_checker_test_1.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/conditionchecker/
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/conditionchecker/rename_module_checker_test_1.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/conditionchecker/rename_module_checker_test_1.test_source
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_1.activeFile.rb.result
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_1.activeFile.rb.source
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_1.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/ModuleRenameTester.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/TS_RenameModule.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/conditionchecker/
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/conditionchecker/RenameModuleConditionTester.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/conditionchecker/TS_RenameModuleChecks.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/IValidator.java
Modified: trunk/org.rubypeople.rdt.refactoring/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/META-INF/MANIFEST.MF 2007-04-11 16:09:58 UTC (rev 2298)
+++ trunk/org.rubypeople.rdt.refactoring/META-INF/MANIFEST.MF 2007-04-12 13:55:24 UTC (rev 2299)
@@ -32,6 +32,7 @@
org.rubypeople.rdt.refactoring.core.renamelocal,
org.rubypeople.rdt.refactoring.core.renamemethod,
org.rubypeople.rdt.refactoring.core.renamemethod.methoditems,
+ org.rubypeople.rdt.refactoring.core.renamemodule,
org.rubypeople.rdt.refactoring.core.splitlocal,
org.rubypeople.rdt.refactoring.documentprovider,
org.rubypeople.rdt.refactoring.editprovider,
Added: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/ConstNameValidator.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/ConstNameValidator.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/ConstNameValidator.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -0,0 +1,37 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.core;
+
+import org.rubypeople.rdt.refactoring.util.NameValidator;
+
+public class ConstNameValidator implements IValidator {
+ public boolean isValid(String test) {
+ return NameValidator.isValidConstName(test);
+ }
+}
\ No newline at end of file
Copied: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/IValidator.java (from rev 2298, trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/IValidator.java)
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/IValidator.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/IValidator.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -0,0 +1,33 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.core;
+
+public interface IValidator {
+ boolean isValid(String test);
+}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/rename/RenameConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/rename/RenameConditionChecker.java 2007-04-11 16:09:58 UTC (rev 2298)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/rename/RenameConditionChecker.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -40,12 +40,14 @@
import org.rubypeople.rdt.refactoring.core.renamelocal.RenameLocalConfig;
import org.rubypeople.rdt.refactoring.core.renamemethod.RenameMethodConditionChecker;
import org.rubypeople.rdt.refactoring.core.renamemethod.RenameMethodConfig;
+import org.rubypeople.rdt.refactoring.core.renamemodule.RenameModuleConditionChecker;
+import org.rubypeople.rdt.refactoring.core.renamemodule.RenameModuleConfig;
import org.rubypeople.rdt.refactoring.documentprovider.IDocumentProvider;
public class RenameConditionChecker extends RefactoringConditionChecker {
private enum RenameType {
- INVALID, LOCAL, FIELD, METHOD, CLASS
+ INVALID, LOCAL, FIELD, METHOD, CLASS, MODULE
};
private RenameType selectedType;
@@ -57,6 +59,8 @@
private RefactoringConditionChecker methodConditionChecker;
private RefactoringConditionChecker classConditionChecker;
+
+ private RefactoringConditionChecker moduleConditionChecker;
public RenameConditionChecker(RenameConfig config) {
super(config);
@@ -74,6 +78,7 @@
addErrorIfNotDefaultError(fieldConditionChecker, RenameFieldConditionChecker.DEFAULT_ERROR);
addErrorIfNotDefaultError(methodConditionChecker, RenameMethodConditionChecker.DEFAULT_ERROR);
addErrorIfNotDefaultError(classConditionChecker, RenameClassConditionChecker.DEFAULT_ERROR);
+ addErrorIfNotDefaultError(moduleConditionChecker, RenameClassConditionChecker.DEFAULT_ERROR);
if (!hasErrors()) {
addError(Messages.RenameConditionChecker_NothingSelected);
@@ -92,11 +97,14 @@
public void init(IRefactoringConfig configObj) {
RenameConfig config = (RenameConfig) configObj;
int offset = config.getOffset();
- IDocumentProvider docProvider = config.getDocumentProvider();
- localConditionChecker = new RenameLocalConditionChecker(new RenameLocalConfig(docProvider, offset));
- fieldConditionChecker = new RenameFieldConditionChecker(new RenameFieldConfig(docProvider, offset));
- methodConditionChecker = new RenameMethodConditionChecker(new RenameMethodConfig(docProvider, offset));
- classConditionChecker = new RenameClassConditionChecker(new RenameClassConfig(docProvider, offset));
+ IDocumentProvider doc = config.getDocumentProvider();
+
+ localConditionChecker = new RenameLocalConditionChecker(new RenameLocalConfig(doc, offset));
+ fieldConditionChecker = new RenameFieldConditionChecker(new RenameFieldConfig(doc, offset));
+ methodConditionChecker = new RenameMethodConditionChecker(new RenameMethodConfig(doc, offset));
+ classConditionChecker = new RenameClassConditionChecker(new RenameClassConfig(doc, offset));
+ moduleConditionChecker = new RenameModuleConditionChecker(new RenameModuleConfig(doc, offset));
+
if (localConditionChecker.shouldPerform()) {
selectedType = RenameType.LOCAL;
} else if (fieldConditionChecker.shouldPerform()) {
@@ -105,6 +113,8 @@
selectedType = RenameType.METHOD;
} else if (classConditionChecker.shouldPerform()) {
selectedType = RenameType.CLASS;
+ } else if (moduleConditionChecker.shouldPerform()) {
+ selectedType = RenameType.MODULE;
} else {
selectedType = RenameType.INVALID;
}
@@ -125,4 +135,8 @@
public boolean shouldRenameClass() {
return selectedType == RenameType.CLASS;
}
+
+ public boolean shouldRenameModule() {
+ return selectedType == RenameType.MODULE;
+ }
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/rename/RenameRefactoring.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/rename/RenameRefactoring.java 2007-04-11 16:09:58 UTC (rev 2298)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/rename/RenameRefactoring.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -12,6 +12,7 @@
* rights and limitations under the License.
*
* Copyright (C) 2006 Lukas Felber <lf...@hs...>
+ * Copyright (C) 2007 Mirko Stocker <me...@mi...>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@@ -36,6 +37,7 @@
import org.rubypeople.rdt.refactoring.core.renamefield.RenameFieldRefactoring;
import org.rubypeople.rdt.refactoring.core.renamelocal.RenameLocalRefactoring;
import org.rubypeople.rdt.refactoring.core.renamemethod.RenameMethodRefactoring;
+import org.rubypeople.rdt.refactoring.core.renamemodule.RenameModuleRefactoring;
public class RenameRefactoring extends RubyRefactoring {
@@ -57,6 +59,8 @@
delegateRenameRefactoring = new RenameMethodRefactoring(selectionProvider);
} else if(checker.shouldRenameClass()) {
delegateRenameRefactoring = new RenameClassRefactoring(selectionProvider);
+ } else if(checker.shouldRenameModule()) {
+ delegateRenameRefactoring = new RenameModuleRefactoring(selectionProvider);
}
IRefactoringConditionChecker delegateConditionChecker = delegateRenameRefactoring.getConditionChecker();
setRefactoringConditionChecker(delegateConditionChecker);
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/ClassFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/ClassFinder.java 2007-04-11 16:09:58 UTC (rev 2298)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/ClassFinder.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -33,7 +33,6 @@
import org.jruby.ast.ClassNode;
import org.rubypeople.rdt.refactoring.documentprovider.IDocumentProvider;
-import org.rubypeople.rdt.refactoring.documentprovider.StringDocumentProvider;
import org.rubypeople.rdt.refactoring.nodewrapper.ClassNodeWrapper;
import org.rubypeople.rdt.refactoring.nodewrapper.PartialClassNodeWrapper;
@@ -42,25 +41,23 @@
private Collection<ClassNodeWrapper> classNodes;
private final String modulePrefix;
+ private interface INodeAcceptor {
+ boolean accept(PartialClassNodeWrapper node);
+ }
+
public ClassFinder(IDocumentProvider doc, String name, String modulePrefix) {
this.name = name;
this.modulePrefix = modulePrefix;
classNodes = new ArrayList<ClassNodeWrapper>();
-
- for(String fileName : doc.getFileNames()) {
- if(! fileName.equals(doc.getActiveFileName())) {
- classNodes.addAll(new StringDocumentProvider(fileName, doc.getFileContent(fileName)).getClassNodeProvider().getAllClassNodes());
- }
- }
-
- classNodes.addAll(new StringDocumentProvider(doc.getActiveFileName(), doc.getActiveFileContent()).getClassNodeProvider().getAllClassNodes());
+ classNodes.addAll(doc.getProjectClassNodeProvider().getAllClassNodes());
}
- public Collection<ClassNode> findParts() {
+
+ private Collection<ClassNode> find(INodeAcceptor acceptor) {
Collection<ClassNode> found = new ArrayList<ClassNode>();
for (ClassNodeWrapper classNode : classNodes) {
for(PartialClassNodeWrapper node : classNode.getPartialClassNodes()) {
- if(node.getClassName().equals(modulePrefix + name)) {
+ if(acceptor.accept(node)) {
found.add((ClassNode) node.getWrappedNode());
}
}
@@ -68,17 +65,20 @@
return found;
}
+
+ public Collection<ClassNode> findParts() {
+ return find(new INodeAcceptor(){
+ public boolean accept(PartialClassNodeWrapper node) {
+ return node.getClassName().equals(modulePrefix + name);
+
+ }});
+ }
+
public Collection<ClassNode> findChildren() {
- Collection<ClassNode> found = new ArrayList<ClassNode>();
-
- for (ClassNodeWrapper classNode : classNodes) {
- for(PartialClassNodeWrapper node : classNode.getPartialClassNodes()) {
- if((node.getModulePrefix() + node.getSuperClassName()).equals(modulePrefix + name)) {
- found.add((ClassNode) node.getWrappedNode());
- }
- }
- }
-
- return found;
+ return find(new INodeAcceptor(){
+ public boolean accept(PartialClassNodeWrapper node) {
+ return (node.getModulePrefix() + node.getSuperClassName()).equals(modulePrefix + name);
+
+ }});
}
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/ClassInstanciationFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/ClassInstanciationFinder.java 2007-04-11 16:09:58 UTC (rev 2298)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/ClassInstanciationFinder.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -70,11 +70,22 @@
}
private boolean isConstructorFor(String name, CallNode call) {
- if(!call.getName().equals("new")) { //$NON-NLS-1$
- return false;
- }
- return ((modulePrefix == null || "".equals(modulePrefix)) && call.getReceiverNode() instanceof ConstNode && ((ConstNode) call.getReceiverNode()).getName().equals(name)) //$NON-NLS-1$
- || (call.getReceiverNode() instanceof Colon2Node && NameHelper.getFullyQualifiedName(call.getReceiverNode()).equals(modulePrefix + name ));
+ return isCallToNew(call) && ((isNotInModule() && createsAnInstance(name, call)) || createsAnInstanceWithFullModulePath(name, call));
}
+ private boolean isCallToNew(CallNode call) {
+ return call.getName().equals("new");//$NON-NLS-1$
+ }
+
+ private boolean createsAnInstanceWithFullModulePath(String name, CallNode call) {
+ return (call.getReceiverNode() instanceof Colon2Node && NameHelper.getFullyQualifiedName(call.getReceiverNode()).equals(modulePrefix + name ));
+ }
+
+ private boolean isNotInModule() {
+ return modulePrefix == null || "".equals(modulePrefix);//$NON-NLS-1$
+ }
+
+ private boolean createsAnInstance(String name, CallNode call) {
+ return call.getReceiverNode() instanceof ConstNode && ((ConstNode) call.getReceiverNode()).getName().equals(name);
+ }
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassConditionChecker.java 2007-04-11 16:09:58 UTC (rev 2298)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassConditionChecker.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -35,6 +35,7 @@
import org.rubypeople.rdt.refactoring.documentprovider.DocumentWithIncluding;
import org.rubypeople.rdt.refactoring.exception.NoClassNodeException;
import org.rubypeople.rdt.refactoring.nodewrapper.ClassNodeWrapper;
+import org.rubypeople.rdt.refactoring.util.NodeUtil;
public class RenameClassConditionChecker extends RefactoringConditionChecker {
@@ -52,17 +53,17 @@
ClassNodeWrapper classNode = null;
try {
classNode = SelectionNodeProvider.getSelectedClassNode(config.getDocumentProvider().getActiveFileRootNode(), config.getOffset());
- int nameStart = ((ClassNode) classNode.getWrappedNode()).getCPath().getPosition().getStartOffset();
- int nameEnd = ((ClassNode) classNode.getWrappedNode()).getCPath().getPosition().getEndOffset();
- if(config.getOffset() < nameStart || config.getOffset() > nameEnd) {
+ if(!NodeUtil.positionIsInNode(config.getOffset(), ((ClassNode) classNode.getWrappedNode()).getCPath())) {
return;
}
} catch (NoClassNodeException e) {return;}
+
config.setModulePrefix(classNode.getFirstPartialClassNode().getModulePrefix());
config.setSelectedNode((ClassNode) classNode.getFirstPartialClassNode().getWrappedNode());
config.setNewName(classNode.getName());
}
+
@Override
protected void checkInitialConditions() {
if (config.getSelectedNode() == null) {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassEditProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassEditProvider.java 2007-04-11 16:09:58 UTC (rev 2298)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassEditProvider.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -48,8 +48,7 @@
private ChildClassesRenameEditProvider createChildrenEditProvider() {
Collection<ClassNode> childClasses = new ClassFinder(document, config.getSelectedNode().getCPath().getName(), config.getModulePrefix()).findChildren();
- ChildClassesRenameEditProvider childClassesRenameEditProvider = new ChildClassesRenameEditProvider(childClasses, config.getNewName());
- return childClassesRenameEditProvider;
+ return new ChildClassesRenameEditProvider(childClasses, config.getNewName());
}
private PartialClassesRenameEditProvider createPartialsEditProvider() {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassRefactoring.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassRefactoring.java 2007-04-11 16:09:58 UTC (rev 2298)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassRefactoring.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -30,21 +30,14 @@
import java.util.ArrayList;
+import org.rubypeople.rdt.refactoring.core.ConstNameValidator;
import org.rubypeople.rdt.refactoring.core.RubyRefactoring;
import org.rubypeople.rdt.refactoring.core.TextSelectionProvider;
-import org.rubypeople.rdt.refactoring.ui.IValidator;
import org.rubypeople.rdt.refactoring.ui.NewNameListener;
import org.rubypeople.rdt.refactoring.ui.pages.RenamePage;
-import org.rubypeople.rdt.refactoring.util.NameValidator;
public class RenameClassRefactoring extends RubyRefactoring {
- private static final class ClassNameValidator implements IValidator {
- public boolean isValid(String test) {
- return NameValidator.isValidClassName(test);
- }
- }
-
public static final String NAME = Messages.RenameClassRefactoring_Name;
public RenameClassRefactoring(TextSelectionProvider selectionProvider) {
@@ -57,7 +50,7 @@
setEditProvider(editProvider);
pages.add(new RenamePage(NAME, renameClassConfig.getSelectedNode().getCPath().getName(),
- new NewNameListener(renameClassConfig, new ClassNameValidator(), new ArrayList<String>())));
+ new NewNameListener(renameClassConfig, new ConstNameValidator(), new ArrayList<String>())));
}
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/RenameFieldRefactoring.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/RenameFieldRefactoring.java 2007-04-11 16:09:58 UTC (rev 2298)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/RenameFieldRefactoring.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -30,10 +30,10 @@
package org.rubypeople.rdt.refactoring.core.renamefield;
+import org.rubypeople.rdt.refactoring.core.IValidator;
import org.rubypeople.rdt.refactoring.core.RubyRefactoring;
import org.rubypeople.rdt.refactoring.core.TextSelectionProvider;
import org.rubypeople.rdt.refactoring.documentprovider.DocumentWithIncluding;
-import org.rubypeople.rdt.refactoring.ui.IValidator;
import org.rubypeople.rdt.refactoring.ui.NewNameListener;
import org.rubypeople.rdt.refactoring.ui.pages.OccurenceReplaceSelectionPage;
import org.rubypeople.rdt.refactoring.ui.pages.RenameFieldPage;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocal/IAbortCondition.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocal/IAbortCondition.java 2007-04-11 16:09:58 UTC (rev 2298)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocal/IAbortCondition.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -31,5 +31,5 @@
import org.jruby.ast.Node;
public interface IAbortCondition {
- public boolean abort(Node currentNode);
+ boolean abort(Node currentNode);
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemethod/RenameMethodRefactoring.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemethod/RenameMethodRefactoring.java 2007-04-11 16:09:58 UTC (rev 2298)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemethod/RenameMethodRefactoring.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -30,9 +30,9 @@
package org.rubypeople.rdt.refactoring.core.renamemethod;
+import org.rubypeople.rdt.refactoring.core.IValidator;
import org.rubypeople.rdt.refactoring.core.RubyRefactoring;
import org.rubypeople.rdt.refactoring.core.TextSelectionProvider;
-import org.rubypeople.rdt.refactoring.ui.IValidator;
import org.rubypeople.rdt.refactoring.ui.NewNameListener;
import org.rubypeople.rdt.refactoring.ui.pages.OccurenceReplaceSelectionPage;
import org.rubypeople.rdt.refactoring.ui.pages.RenamePage;
Added: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConditionChecker.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConditionChecker.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -0,0 +1,38 @@
+package org.rubypeople.rdt.refactoring.core.renamemodule;
+
+import org.jruby.ast.ModuleNode;
+import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
+import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
+import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
+import org.rubypeople.rdt.refactoring.util.NodeUtil;
+
+public class RenameModuleConditionChecker extends RefactoringConditionChecker {
+
+ public static final String DEFAULT_ERROR = "Please select the name of a module definition.";
+
+ private RenameModuleConfig config;
+
+ public RenameModuleConditionChecker(IRefactoringConfig config) {
+ super(config);
+ }
+
+ @Override
+ protected void checkInitialConditions() {
+ if (config.getSelectedModule() == null) {
+ addError(DEFAULT_ERROR);
+ }
+ }
+
+ @Override
+ public void init(IRefactoringConfig configObj) {
+ config = (RenameModuleConfig) configObj;
+
+ ModuleNode selectedModule = (ModuleNode) SelectionNodeProvider.getSelectedNodeOfType(config.getDocumentProvider().getActiveFileRootNode(), config.getCarretPosition(), ModuleNode.class);
+ config.setSelectedModule(selectedModule);
+ if(config.getSelectedModule()== null || !NodeUtil.positionIsInNode(config.getCarretPosition(), selectedModule.getCPath())) {
+ return;
+ }
+ config.setNewName(selectedModule.getCPath().getName());
+ }
+
+}
Added: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConfig.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConfig.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConfig.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -0,0 +1,48 @@
+package org.rubypeople.rdt.refactoring.core.renamemodule;
+
+import org.jruby.ast.ModuleNode;
+import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
+import org.rubypeople.rdt.refactoring.documentprovider.IDocumentProvider;
+import org.rubypeople.rdt.refactoring.ui.INewNameReceiver;
+
+public class RenameModuleConfig implements IRefactoringConfig, INewNameReceiver {
+
+ private IDocumentProvider doc;
+ private final int carretPosition;
+ private ModuleNode selectedModule;
+
+ public RenameModuleConfig(IDocumentProvider doc, int carretPosition) {
+ this.doc = doc;
+ this.carretPosition = carretPosition;
+ }
+
+ public IDocumentProvider getDocumentProvider() {
+ return doc;
+ }
+
+ public void setDocumentProvider(IDocumentProvider doc) {
+ this.doc = doc;
+ }
+
+ public void setNewName(String name) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public String getSelectedModuleName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getCarretPosition() {
+ return carretPosition;
+ }
+
+ public ModuleNode getSelectedModule() {
+ return selectedModule;
+ }
+
+ public void setSelectedModule(ModuleNode selectedModule) {
+ this.selectedModule = selectedModule;
+ }
+}
Added: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleEditProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleEditProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleEditProvider.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -0,0 +1,19 @@
+package org.rubypeople.rdt.refactoring.core.renamemodule;
+
+import java.util.Collection;
+
+import org.rubypeople.rdt.refactoring.editprovider.FileMultiEditProvider;
+import org.rubypeople.rdt.refactoring.editprovider.IMultiFileEditProvider;
+
+public class RenameModuleEditProvider implements IMultiFileEditProvider {
+
+ public RenameModuleEditProvider(RenameModuleConfig renameModuleConfig) {
+ // TODO Auto-generated constructor stub
+ }
+
+ public Collection<FileMultiEditProvider> getFileEditProviders() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleRefactoring.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleRefactoring.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleRefactoring.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -0,0 +1,57 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.core.renamemodule;
+
+import java.util.ArrayList;
+
+import org.rubypeople.rdt.refactoring.core.ConstNameValidator;
+import org.rubypeople.rdt.refactoring.core.RubyRefactoring;
+import org.rubypeople.rdt.refactoring.core.TextSelectionProvider;
+import org.rubypeople.rdt.refactoring.ui.NewNameListener;
+import org.rubypeople.rdt.refactoring.ui.pages.RenamePage;
+
+public class RenameModuleRefactoring extends RubyRefactoring {
+
+ public static final String NAME = "Rename Module";
+
+ public RenameModuleRefactoring(TextSelectionProvider selectionProvider) {
+ super(NAME);
+ RenameModuleConfig renameModuleConfig = new RenameModuleConfig(getDocumentProvider(), selectionProvider.getCarretPosition());
+ RenameModuleConditionChecker conditionChecker = new RenameModuleConditionChecker(renameModuleConfig);
+ setRefactoringConditionChecker(conditionChecker);
+ if(conditionChecker.shouldPerform()) {
+ RenameModuleEditProvider editProvider = new RenameModuleEditProvider(renameModuleConfig);
+ setEditProvider(editProvider);
+
+ pages.add(new RenamePage(NAME, renameModuleConfig.getSelectedModuleName(),
+ new NewNameListener(renameModuleConfig, new ConstNameValidator(), new ArrayList<String>())));
+
+ }
+ }
+}
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/IValidator.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/IValidator.java 2007-04-11 16:09:58 UTC (rev 2298)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/IValidator.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -1,33 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2006 Mirko Stocker <me...@mi...>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-
-package org.rubypeople.rdt.refactoring.ui;
-
-public interface IValidator {
- boolean isValid(String test);
-}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/NewNameListener.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/NewNameListener.java 2007-04-11 16:09:58 UTC (rev 2298)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/NewNameListener.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -32,6 +32,7 @@
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Text;
+import org.rubypeople.rdt.refactoring.core.IValidator;
public class NewNameListener implements IErrorMessageGenerator {
private final INewNameReceiver receiver;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/util/NameValidator.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/util/NameValidator.java 2007-04-11 16:09:58 UTC (rev 2298)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/util/NameValidator.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -48,7 +48,7 @@
return validate(methodNameRegexp, name);
}
- public static boolean isValidClassName(String name) {
+ public static boolean isValidConstName(String name) {
return validate(classNameRegexp, name);
}
@@ -59,7 +59,7 @@
public static boolean isValidConstantName(String newName) {
// FIXME Check for valid constant name
- return isValidClassName(newName);
+ return isValidConstName(newName);
}
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/util/NodeUtil.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/util/NodeUtil.java 2007-04-11 16:09:58 UTC (rev 2298)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/util/NodeUtil.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -32,6 +32,7 @@
import java.lang.reflect.Method;
import java.util.List;
+import org.jruby.ast.Colon3Node;
import org.jruby.ast.IterNode;
import org.jruby.ast.MethodDefNode;
import org.jruby.ast.Node;
@@ -148,4 +149,7 @@
}
+ public static boolean positionIsInNode(int offset, Colon3Node path) {
+ return offset >= path.getPosition().getStartOffset() && offset <= path.getPosition().getEndOffset();
+ }
}
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamefield/rename_class_checker_test_1.test_properties
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamefield/rename_class_checker_test_1.test_properties (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamefield/rename_class_checker_test_1.test_properties 2007-04-12 13:55:24 UTC (rev 2299)
@@ -0,0 +1,3 @@
+caretPosition=42
+newName=nix
+initialError0=Please select the name of a class declaration.
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/conditionchecker/rename_module_checker_test_1.test_properties
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/conditionchecker/rename_module_checker_test_1.test_properties (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/conditionchecker/rename_module_checker_test_1.test_properties 2007-04-12 13:55:24 UTC (rev 2299)
@@ -0,0 +1,3 @@
+caretPosition=42
+newName=nix
+initialError0=Please select the name of a module definition.
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/conditionchecker/rename_module_checker_test_1.test_source
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/conditionchecker/rename_module_checker_test_1.test_source (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/conditionchecker/rename_module_checker_test_1.test_source 2007-04-12 13:55:24 UTC (rev 2299)
@@ -0,0 +1,6 @@
+class Test
+ def method
+ end
+end
+
+Test.new
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_1.activeFile.rb.result
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_1.activeFile.rb.result (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_1.activeFile.rb.result 2007-04-12 13:55:24 UTC (rev 2299)
@@ -0,0 +1,2 @@
+module NewModul
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_1.activeFile.rb.source
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_1.activeFile.rb.source (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_1.activeFile.rb.source 2007-04-12 13:55:24 UTC (rev 2299)
@@ -0,0 +1,2 @@
+module Modul
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_1.test_properties
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_1.test_properties (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_1.test_properties 2007-04-12 13:55:24 UTC (rev 2299)
@@ -0,0 +1,3 @@
+name=NewModule
+pos=8
+activeFile=activeFile.rb
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/TS_All.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/TS_All.java 2007-04-11 16:09:58 UTC (rev 2298)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/TS_All.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -54,6 +54,7 @@
import org.rubypeople.rdt.refactoring.tests.core.renamefield.TS_RenameField;
import org.rubypeople.rdt.refactoring.tests.core.renamelocal.TS_RenameLocal;
import org.rubypeople.rdt.refactoring.tests.core.renamemethod.TS_RenameMethod;
+import org.rubypeople.rdt.refactoring.tests.core.renamemodule.TS_RenameModule;
import org.rubypeople.rdt.refactoring.tests.core.splitlocal.TS_SplitLocal;
import org.rubypeople.rdt.refactoring.tests.util.TS_Util;
@@ -83,6 +84,7 @@
suite.addTest(TS_RenameField.suite());
suite.addTest(TS_RenameClass.suite());
suite.addTest(TS_RenameMethod.suite());
+ suite.addTest(TS_RenameModule.suite());
suite.addTest(TS_InlineClass.suite());
suite.addTest(TS_MoveMethod.suite());
suite.addTest(TS_MoveField.suite());
Modified: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/rename/RenameTester.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/rename/RenameTester.java 2007-04-11 16:09:58 UTC (rev 2298)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/rename/RenameTester.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -39,10 +39,12 @@
import org.rubypeople.rdt.refactoring.tests.RefactoringTestCase;
public class RenameTester extends RefactoringTestCase {
-
+
private static final String NONE = "none";
private static final String RENAME_CLASS = "renameClass";
+
+ private static final String RENAME_MODULE = "renameModule";
private static final String RENAME_METHOD = "renameMethod";
@@ -63,16 +65,13 @@
String delegateRenameRefactoring = testData.getProperty("delegateRenameRefactoring");
assertTrue(isValidParam(delegateRenameRefactoring));
-// assertFalse(delegateRenameRefactoring.equals(NONE) && checker.shouldPerform());
+
check(!checker.shouldPerform(), delegateRenameRefactoring.equals(NONE));
check(checker.shouldRenameClass(), delegateRenameRefactoring.equals(RENAME_CLASS));
+ check(checker.shouldRenameModule(), delegateRenameRefactoring.equals(RENAME_MODULE));
check(checker.shouldRenameMethod(), delegateRenameRefactoring.equals(RENAME_METHOD));
check(checker.shouldRenameField(), delegateRenameRefactoring.equals(RENAME_FIELD));
check(checker.shouldRenameLocal(), delegateRenameRefactoring.equals(RENAME_LOCAL));
-// assertFalse(checker.shouldRenameClass() && !delegateRenameRefactoring.equals(RENAME_CLASS));
-// assertFalse(checker.shouldRenameMethod() && !delegateRenameRefactoring.equals(RENAME_METHOD));
-// assertFalse(checker.shouldRenameField() && !delegateRenameRefactoring.equals(RENAME_FIELD));
-// assertFalse(checker.shouldRenameLocal() && !delegateRenameRefactoring.equals(RENAME_LOCAL));
}
private void check(boolean shouldPerform, boolean isRightRefactoring) {
@@ -84,6 +83,7 @@
private boolean isValidParam(String paramName) {
return paramName.equals(NONE)
|| paramName.equals(RENAME_CLASS)
+ || paramName.equals(RENAME_MODULE)
|| paramName.equals(RENAME_METHOD)
|| paramName.equals(RENAME_FIELD)
|| paramName.equals(RENAME_LOCAL);
Modified: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renameclass/TC_ClassFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renameclass/TC_ClassFinder.java 2007-04-11 16:09:58 UTC (rev 2298)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renameclass/TC_ClassFinder.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -85,10 +85,10 @@
assertEquals(4, classNodes.length);
- assertEquals("Subclass3", classNodes[0].getCPath().getName());
+ assertEquals("Subclass1", classNodes[0].getCPath().getName());
assertEquals("Subclass1", classNodes[1].getCPath().getName());
- assertEquals("Subclass1", classNodes[2].getCPath().getName());
- assertEquals("Subclass2", classNodes[3].getCPath().getName());
+ assertEquals("Subclass2", classNodes[2].getCPath().getName());
+ assertEquals("Subclass3", classNodes[3].getCPath().getName());
}
}
Added: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/ModuleRenameTester.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/ModuleRenameTester.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/ModuleRenameTester.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -0,0 +1,64 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.tests.core.renamemodule;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.rubypeople.rdt.refactoring.core.renamemodule.RenameModuleConditionChecker;
+import org.rubypeople.rdt.refactoring.core.renamemodule.RenameModuleConfig;
+import org.rubypeople.rdt.refactoring.core.renamemodule.RenameModuleEditProvider;
+import org.rubypeople.rdt.refactoring.tests.FileTestCase;
+import org.rubypeople.rdt.refactoring.tests.MultiFileTestData;
+
+public class ModuleRenameTester extends FileTestCase {
+
+ public ModuleRenameTester(String fileName) {
+ super(fileName);
+ }
+
+ @Override
+ public void runTest() throws FileNotFoundException, IOException, BadLocationException {
+
+ MultiFileTestData testData = new MultiFileTestData(getName());
+
+ int caretPosition = testData.getIntProperty("pos");
+
+
+ RenameModuleConfig renameModuleConfig = new RenameModuleConfig(testData, caretPosition);
+ new RenameModuleConditionChecker(renameModuleConfig);
+
+ renameModuleConfig.setNewName(testData.getProperty("name"));
+
+ RenameModuleEditProvider editProvider = new RenameModuleEditProvider(renameModuleConfig);
+
+ checkMultiFileEdits(editProvider, testData);
+ }
+}
Added: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/TS_RenameModule.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/TS_RenameModule.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/TS_RenameModule.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -0,0 +1,43 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.tests.core.renamemodule;
+
+import junit.framework.TestSuite;
+
+import org.rubypeople.rdt.refactoring.tests.FileTestSuite;
+import org.rubypeople.rdt.refactoring.tests.core.renamemodule.conditionchecker.TS_RenameModuleChecks;
+
+public class TS_RenameModule extends FileTestSuite {
+ public static TestSuite suite() {
+ TestSuite suite = createSuite("Rename Module", "rename_module_test_*active*source", ModuleRenameTester.class);
+
+ suite.addTest(TS_RenameModuleChecks.suite());
+ return suite;
+ }
+}
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/conditionchecker/RenameModuleConditionTester.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/conditionchecker/RenameModuleConditionTester.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/conditionchecker/RenameModuleConditionTester.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -0,0 +1,63 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.tests.core.renamemodule.conditionchecker;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.rubypeople.rdt.refactoring.core.renamemodule.RenameModuleConditionChecker;
+import org.rubypeople.rdt.refactoring.core.renamemodule.RenameModuleConfig;
+import org.rubypeople.rdt.refactoring.core.renamemodule.RenameModuleEditProvider;
+import org.rubypeople.rdt.refactoring.tests.FilePropertyData;
+import org.rubypeople.rdt.refactoring.tests.FileTestData;
+import org.rubypeople.rdt.refactoring.tests.RefactoringConditionTestCase;
+
+public class RenameModuleConditionTester extends RefactoringConditionTestCase {
+
+ private FilePropertyData testData;
+ private RenameModuleConfig renameModuleConfig;
+
+ public RenameModuleConditionTester(String fileName) {
+ super(fileName);
+ }
+
+ @Override
+ public void runTest() throws FileNotFoundException, IOException {
+ testData = new FileTestData(getName(), ".test_source", ".test_source");
+ renameModuleConfig = new RenameModuleConfig(testData, testData.getIntProperty("caretPosition"));
+ RenameModuleConditionChecker checker = new RenameModuleConditionChecker(renameModuleConfig);
+
+ checkConditions(checker, testData);
+ }
+
+ @Override
+ protected void createEditProviderAndSetUserInput() {
+ new RenameModuleEditProvider(renameModuleConfig);
+ }
+}
Added: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/conditionchecker/TS_RenameModuleChecks.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/conditionchecker/TS_RenameModuleChecks.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/conditionchecker/TS_RenameModuleChecks.java 2007-04-12 13:55:24 UTC (rev 2299)
@@ -0,0 +1,41 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.tests.core.renamemodule.conditionchecker;
+
+
+import junit.framework.Test;
+
+import org...
[truncated message content] |
|
From: <caw...@us...> - 2007-04-11 16:10:00
|
Revision: 2298
http://svn.sourceforge.net/rubyeclipse/?rev=2298&view=rev
Author: cawilliams
Date: 2007-04-11 09:09:58 -0700 (Wed, 11 Apr 2007)
Log Message:
-----------
remove feature branch which has already been merged to trunk
Removed Paths:
-------------
branches/jruby_integration/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|