|
From: <mir...@us...> - 2007-04-17 11:42:44
|
Revision: 2323
http://svn.sourceforge.net/rubyeclipse/?rev=2323&view=rev
Author: mirkostocker
Date: 2007-04-17 04:42:39 -0700 (Tue, 17 Apr 2007)
Log Message:
-----------
rename method almost completed
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/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/nodewrapper/ClassNodeWrapper.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/nodewrapper/PartialClassNodeWrapper.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/TS_RenameModule.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/IncludeRenameEditProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/ModuleIncludeFinder.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/ModuleIncludeWrapper.java
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_IncludeFromWithinSameNamespace.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_IncludeWithNamespace.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_ModulesWithEqualNamesInDifferentNamespaces.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_MultipleDirectIncludes.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_NoIncludes.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_SingleDirectInclude.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_7.activeFile.rb.result
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_7.activeFile.rb.source
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_7.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/TC_ModuleInclusionFinder.java
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 09:07:25 UTC (rev 2322)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/ModuleNodeProvider.java 2007-04-17 11:42:39 UTC (rev 2323)
@@ -46,7 +46,7 @@
return null;
}
return createModuleNodeWrapper(root, module);
- }
+ }
public static Collection<ModuleNodeWrapper> findOtherParts(IDocumentProvider doc, ModuleNodeWrapper module) {
ArrayList<ModuleNodeWrapper> modules = new ArrayList<ModuleNodeWrapper>();
Added: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/IncludeRenameEditProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/IncludeRenameEditProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/IncludeRenameEditProvider.java 2007-04-17 11:42:39 UTC (rev 2323)
@@ -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.core.renamemodule;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.rubypeople.rdt.refactoring.editprovider.FileEditProvider;
+import org.rubypeople.rdt.refactoring.editprovider.SimpleNodeEditProvider;
+
+public class IncludeRenameEditProvider {
+
+ private RenameModuleConfig config;
+
+ public IncludeRenameEditProvider(RenameModuleConfig config) {
+ this.config = config;
+ }
+
+ public Collection<FileEditProvider> getEditProviders() {
+ Collection<FileEditProvider> edits = new ArrayList<FileEditProvider>();
+
+ for(ModuleIncludeWrapper include : new ModuleIncludeFinder(config.getDocumentProvider()).find(config.getOriginalFullName())) {
+ include.setNewName(config.getOriginalName(), config.getNewName());
+ edits.add(new FileEditProvider(include.getWrappedNode().getPosition().getFile(), new SimpleNodeEditProvider(include.getWrappedNode())));
+ }
+
+ return edits;
+ }
+}
Added: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/ModuleIncludeFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/ModuleIncludeFinder.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/ModuleIncludeFinder.java 2007-04-17 11:42:39 UTC (rev 2323)
@@ -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) 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"),
+ * 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.rubypeople.rdt.refactoring.documentprovider.IDocumentProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.ClassNodeWrapper;
+
+public class ModuleIncludeFinder {
+
+ private final IDocumentProvider document;
+
+ public ModuleIncludeFinder(IDocumentProvider document) {
+ this.document = document;
+ }
+
+ public Collection<ModuleIncludeWrapper> find(String name) {
+ ArrayList<ModuleIncludeWrapper> includes = new ArrayList<ModuleIncludeWrapper>();
+
+ for (ModuleIncludeWrapper includeWrapper : findAllIncludes()) {
+ if(includeWrapper.getFullName().startsWith(name)) {
+ includes.add(includeWrapper);
+ }
+ }
+
+ return includes;
+ }
+
+ private ArrayList<ModuleIncludeWrapper> findAllIncludes() {
+ ArrayList<ModuleIncludeWrapper> includes = new ArrayList<ModuleIncludeWrapper>();
+
+ for(ClassNodeWrapper classNodeWrapper : document.getIncludedClassNodeProvider().getAllClassNodes()) {
+ includes.addAll(classNodeWrapper.getIncludes());
+ }
+
+ return includes;
+ }
+}
Added: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/ModuleIncludeWrapper.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/ModuleIncludeWrapper.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/ModuleIncludeWrapper.java 2007-04-17 11:42:39 UTC (rev 2323)
@@ -0,0 +1,121 @@
+/***** 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) 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"),
+ * 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.jruby.ast.Colon2Node;
+import org.jruby.ast.ConstNode;
+import org.jruby.ast.Node;
+import org.jruby.ast.types.INameNode;
+import org.rubypeople.rdt.refactoring.core.NodeProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.INodeWrapper;
+import org.rubypeople.rdt.refactoring.util.NameHelper;
+
+public abstract class ModuleIncludeWrapper implements INodeWrapper {
+
+ protected String modulePrefix;
+
+ private static class Colon2IncludeWrapper extends ModuleIncludeWrapper {
+ protected Colon2Node node;
+
+ public Colon2IncludeWrapper(Colon2Node node, String modulePrefix) {
+ this.node = node;
+ this.modulePrefix = modulePrefix;
+ }
+
+ @Override
+ public String getIncludeName() {
+ return NameHelper.getFullyQualifiedName(node);
+ }
+
+ @Override
+ public Node getWrappedNode() {
+ return node;
+ }
+
+ @Override
+ public void setNewName(String oldName, String newName) {
+ for (Node node : NodeProvider.getSubNodes(this.node, Colon2Node.class, ConstNode.class)) {
+ INameNode nameNode = (INameNode) node;
+ if(!nameNode.getName().equals(oldName)) {
+ continue;
+ }
+
+ if(node instanceof Colon2Node) {
+ ((Colon2Node) node).setName(newName);
+ return;
+ } else {
+ ((ConstNode) node).setName(newName);
+ return;
+ }
+ }
+ }
+ }
+
+ private static class ConstIncludeWrapper extends ModuleIncludeWrapper {
+ protected ConstNode node;
+
+ public ConstIncludeWrapper(ConstNode node, String modulePrefix) {
+ this.node = node;
+ this.modulePrefix = modulePrefix;
+ }
+
+ @Override
+ public String getIncludeName() {
+ return node.getName();
+ }
+
+ @Override
+ public Node getWrappedNode() {
+ return node;
+ }
+
+ @Override
+ public void setNewName(String oldName, String newName) {
+ node.setName(newName);
+ }
+ }
+
+ public static ModuleIncludeWrapper create(Node node, String modulePrefix) {
+
+ if(node instanceof Colon2Node) {
+ return new Colon2IncludeWrapper((Colon2Node) node, modulePrefix);
+ } else {
+ return new ConstIncludeWrapper((ConstNode) node, modulePrefix);
+ }
+ }
+
+ public abstract Node getWrappedNode();
+
+ public abstract String getIncludeName();
+
+ public String getFullName() {
+ return modulePrefix + getIncludeName();
+ }
+ public abstract void setNewName(String oldName, String newName);
+}
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 09:07:25 UTC (rev 2322)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConditionChecker.java 2007-04-17 11:42:39 UTC (rev 2323)
@@ -56,10 +56,10 @@
config = (RenameModuleConfig) configObj;
ModuleNodeWrapper selectedModule = ModuleNodeProvider.getSelectedModuleNode(config.getDocumentProvider().getActiveFileRootNode(), config.getCarretPosition());
- config.setSelectedModule(selectedModule);
- if(config.getSelectedModule() == null || caretIsNotOnModuleName(selectedModule)) {
+ if(selectedModule == null || caretIsNotOnModuleName(selectedModule)) {
return;
}
+ config.setSelectedModule(selectedModule);
config.setNewName(selectedModule.getName());
config.setModuleParts(ModuleNodeProvider.findOtherParts(config.getDocumentProvider(), config.getSelectedModule()));
}
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 09:07:25 UTC (rev 2322)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleConfig.java 2007-04-17 11:42:39 UTC (rev 2323)
@@ -43,6 +43,8 @@
private ModuleNodeWrapper selectedModule;
private String newName;
private Collection<ModuleNodeWrapper> moduleParts;
+ private String originalFullName;
+ private String originalName;
public RenameModuleConfig(IDocumentProvider doc, int carretPosition) {
this.doc = doc;
@@ -75,6 +77,8 @@
public void setSelectedModule(ModuleNodeWrapper selectedModule) {
this.selectedModule = selectedModule;
+ this.originalFullName = selectedModule.getFullName();
+ this.originalName = selectedModule.getName();
}
public String getNewName() {
@@ -88,4 +92,12 @@
public Collection<ModuleNodeWrapper> getModuleParts() {
return moduleParts;
}
+
+ public String getOriginalFullName() {
+ return originalFullName;
+ }
+
+ public String getOriginalName() {
+ return originalName;
+ }
}
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 09:07:25 UTC (rev 2322)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemodule/RenameModuleEditProvider.java 2007-04-17 11:42:39 UTC (rev 2323)
@@ -26,7 +26,6 @@
* 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;
@@ -57,16 +56,21 @@
return new ScopingNodeRenameEditProvider(modules, config.getNewName());
}
-
+
private ModuleMethodDefRenameEditProvider getModuleModuleMethodDefEditProvider() {
return new ModuleMethodDefRenameEditProvider(ModuleNodeProvider.getAllModuleMethodDefinitions(config.getModuleParts()), config.getNewName());
}
+
+ private IncludeRenameEditProvider getIncludeRenameEditProvider() {
+ return new IncludeRenameEditProvider(config);
+ }
public Collection<FileMultiEditProvider> getFileEditProviders() {
MultiFileEditProvider fileEdits = new MultiFileEditProvider();
fileEdits.addEditProviders(getModuleEditProvider().getEditProviders());
fileEdits.addEditProviders(getModuleModuleMethodDefEditProvider().getEditProviders());
+ fileEdits.addEditProviders(getIncludeRenameEditProvider().getEditProviders());
return fileEdits.getFileEditProviders();
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/nodewrapper/ClassNodeWrapper.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/nodewrapper/ClassNodeWrapper.java 2007-04-16 09:07:25 UTC (rev 2322)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/nodewrapper/ClassNodeWrapper.java 2007-04-17 11:42:39 UTC (rev 2323)
@@ -37,6 +37,7 @@
import org.jruby.ast.Node;
import org.jruby.ast.SymbolNode;
import org.rubypeople.rdt.refactoring.core.NodeFactory;
+import org.rubypeople.rdt.refactoring.core.renamemodule.ModuleIncludeWrapper;
import org.rubypeople.rdt.refactoring.nodewrapper.VisibilityNodeWrapper.METHOD_VISIBILITY;
public class ClassNodeWrapper implements INodeWrapper {
@@ -60,7 +61,16 @@
}
return fields;
}
+
+ public Collection<ModuleIncludeWrapper> getIncludes() {
+ ArrayList<ModuleIncludeWrapper> fields = new ArrayList<ModuleIncludeWrapper>();
+ for (PartialClassNodeWrapper partialClassNode : partialClassNodes) {
+ fields.addAll(partialClassNode.getIncludeCalls());
+ }
+ return fields;
+ }
+
public Collection<MethodNodeWrapper> getMethods() {
Collection<MethodNodeWrapper> methodNodes = new ArrayList<MethodNodeWrapper>();
for (PartialClassNodeWrapper partialClassNode : partialClassNodes) {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/nodewrapper/PartialClassNodeWrapper.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/nodewrapper/PartialClassNodeWrapper.java 2007-04-16 09:07:25 UTC (rev 2322)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/nodewrapper/PartialClassNodeWrapper.java 2007-04-17 11:42:39 UTC (rev 2323)
@@ -45,6 +45,7 @@
import org.jruby.ast.SymbolNode;
import org.jruby.ast.VCallNode;
import org.rubypeople.rdt.refactoring.core.NodeProvider;
+import org.rubypeople.rdt.refactoring.core.renamemodule.ModuleIncludeWrapper;
import org.rubypeople.rdt.refactoring.exception.NoClassNodeException;
import org.rubypeople.rdt.refactoring.nodewrapper.VisibilityNodeWrapper.METHOD_VISIBILITY;
import org.rubypeople.rdt.refactoring.util.NodeUtil;
@@ -202,25 +203,23 @@
}
public Collection<Node> getInstFieldOccurences() {
- Collection<Node> allOccurences = NodeProvider.getInstFieldOccurences(wrappedNode);
-
- for (Node node : allOccurences) {
- if (isDirectChild(node)){
- allOccurences.remove(node);
- }
- }
- return allOccurences;
+ return NodeProvider.getInstFieldOccurences(wrappedNode);
}
public Collection<Node> getClassFieldOccurences() {
- Collection<Node> classFieldOccurences = NodeProvider.getClassFieldOccurences(wrappedNode);
+ return NodeProvider.getClassFieldOccurences(wrappedNode);
+ }
+
+ public Collection<ModuleIncludeWrapper> getIncludeCalls() {
+ Collection<ModuleIncludeWrapper> includes = new ArrayList<ModuleIncludeWrapper>();
- for (Node node : classFieldOccurences) {
- if (isDirectChild(node)){
- classFieldOccurences.remove(node);
+ for (Node node : NodeProvider.getSubNodes(wrappedNode, FCallNode.class)) {
+ FCallNode call = (FCallNode) node;
+ if("include".equals(call.getName())) { //$NON-NLS-1$
+ includes.add(ModuleIncludeWrapper.create(((ArrayNode) call.getArgsNode()).get(0), getModulePrefix()));
}
}
- return classFieldOccurences;
+ return includes;
}
public Collection<MethodCallNodeWrapper> getMethodCalls(MethodDefNode decoratedMethod) {
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_IncludeFromWithinSameNamespace.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_IncludeFromWithinSameNamespace.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_IncludeFromWithinSameNamespace.rb 2007-04-17 11:42:39 UTC (rev 2323)
@@ -0,0 +1,11 @@
+module Modul
+ module M
+ end
+ class Klass
+ include M
+ end
+end
+
+class Klasse
+ include Modul::M
+end
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_IncludeWithNamespace.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_IncludeWithNamespace.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_IncludeWithNamespace.rb 2007-04-17 11:42:39 UTC (rev 2323)
@@ -0,0 +1,8 @@
+module Namespace
+ module M1
+ end
+end
+
+class C1
+ include Namespace::M1
+end
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_ModulesWithEqualNamesInDifferentNamespaces.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_ModulesWithEqualNamesInDifferentNamespaces.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_ModulesWithEqualNamesInDifferentNamespaces.rb 2007-04-17 11:42:39 UTC (rev 2323)
@@ -0,0 +1,5 @@
+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/TC_ModuleInclusionFinder_MultipleDirectIncludes.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_MultipleDirectIncludes.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_MultipleDirectIncludes.rb 2007-04-17 11:42:39 UTC (rev 2323)
@@ -0,0 +1,10 @@
+module M1
+end
+
+class C1
+ include M1
+end
+
+class C2
+ include M1
+end
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_NoIncludes.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_NoIncludes.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_NoIncludes.rb 2007-04-17 11:42:39 UTC (rev 2323)
@@ -0,0 +1,8 @@
+module M1
+end
+
+class C1
+end
+
+class C2
+end
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_SingleDirectInclude.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_SingleDirectInclude.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/TC_ModuleInclusionFinder_SingleDirectInclude.rb 2007-04-17 11:42:39 UTC (rev 2323)
@@ -0,0 +1,6 @@
+module M1
+end
+
+class C1
+ include M1
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_7.activeFile.rb.result
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_7.activeFile.rb.result (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_7.activeFile.rb.result 2007-04-17 11:42:39 UTC (rev 2323)
@@ -0,0 +1,13 @@
+module NewModule
+ module Module
+ module CentralModule
+ end
+ end
+end
+
+class ModulTest
+ include NewModule::Module::CentralModule
+ include Module::InnerModule
+ include InnerModule
+ include NewModule
+end
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_7.activeFile.rb.source
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_7.activeFile.rb.source (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_7.activeFile.rb.source 2007-04-17 11:42:39 UTC (rev 2323)
@@ -0,0 +1,13 @@
+module OuterModule
+ module Module
+ module CentralModule
+ end
+ end
+end
+
+class ModulTest
+ include OuterModule::Module::CentralModule
+ include Module::InnerModule
+ include InnerModule
+ include OuterModule
+end
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_7.test_properties
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_7.test_properties (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemodule/rename_module_test_7.test_properties 2007-04-17 11:42:39 UTC (rev 2323)
@@ -0,0 +1,3 @@
+name=NewModule
+pos=12
+activeFile=activeFile.rb
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/TC_ModuleInclusionFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/TC_ModuleInclusionFinder.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/TC_ModuleInclusionFinder.java 2007-04-17 11:42:39 UTC (rev 2323)
@@ -0,0 +1,102 @@
+/***** 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) 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"),
+ * 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 org.rubypeople.rdt.refactoring.core.renamemodule.ModuleIncludeFinder;
+import org.rubypeople.rdt.refactoring.core.renamemodule.ModuleIncludeWrapper;
+import org.rubypeople.rdt.refactoring.documentprovider.IDocumentProvider;
+import org.rubypeople.rdt.refactoring.documentprovider.StringDocumentProvider;
+import org.rubypeople.rdt.refactoring.tests.FileTestCase;
+
+public class TC_ModuleInclusionFinder extends FileTestCase {
+
+ public TC_ModuleInclusionFinder() {
+ super("ModuleInclusionFinder");
+ }
+
+ public void testSingleDirectInclude() {
+ IDocumentProvider document = getDocument("TC_ModuleInclusionFinder_SingleDirectInclude.rb");
+
+ ModuleIncludeWrapper[] includes = new ModuleIncludeFinder(document).find("M1").toArray(new ModuleIncludeWrapper[]{});
+
+ assertEquals(1, includes.length);
+ assertNotNull(includes[0].getWrappedNode());
+ assertEquals("M1", includes[0].getFullName());
+ }
+
+ public void testMultipleDirectIncludes() {
+ IDocumentProvider document = getDocument("TC_ModuleInclusionFinder_MultipleDirectIncludes.rb");
+
+ ModuleIncludeWrapper[] includes = new ModuleIncludeFinder(document).find("M1").toArray(new ModuleIncludeWrapper[]{});
+
+ assertEquals(2, includes.length);
+ assertEquals("M1", includes[0].getFullName());
+ assertEquals("M1", includes[1].getFullName());
+ }
+
+ public void testIncludeWithNamespace() {
+ IDocumentProvider document = getDocument("TC_ModuleInclusionFinder_IncludeWithNamespace.rb");
+
+ ModuleIncludeWrapper[] includes = new ModuleIncludeFinder(document).find("Namespace::M1").toArray(new ModuleIncludeWrapper[]{});
+
+ assertEquals(1, includes.length);
+ assertEquals("Namespace::M1", includes[0].getFullName());
+ }
+
+ public void testIncludeFromWithinSameNamespace() {
+ IDocumentProvider document = getDocument("TC_ModuleInclusionFinder_IncludeFromWithinSameNamespace.rb");
+
+ ModuleIncludeWrapper[] includes = new ModuleIncludeFinder(document).find("Modul::M").toArray(new ModuleIncludeWrapper[]{});
+
+ assertEquals(2, includes.length);
+ assertEquals("Modul::M", includes[0].getFullName());
+ assertEquals("Modul::M", includes[1].getFullName());
+ }
+
+ public void testModulesWithEqualNamesInDifferentNamespaces() {
+ IDocumentProvider document = getDocument("TC_ModuleInclusionFinder_ModulesWithEqualNamesInDifferentNamespaces.rb");
+
+ ModuleIncludeWrapper[] includes = new ModuleIncludeFinder(document).find("Module::InnerModule").toArray(new ModuleIncludeWrapper[]{});
+
+ assertEquals(1, includes.length);
+ assertEquals("Module::InnerModule", includes[0].getFullName());
+ }
+
+ public void testNoIncludes() {
+ IDocumentProvider document = getDocument("TC_ModuleInclusionFinder_NoIncludes.rb");
+
+ ModuleIncludeWrapper[] includes = new ModuleIncludeFinder(document).find("M1").toArray(new ModuleIncludeWrapper[]{});
+
+ assertEquals(0, includes.length);
+ }
+
+ private IDocumentProvider getDocument(String name) {
+ return new StringDocumentProvider(name, getSource(name));
+ }
+}
Modified: 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 2007-04-16 09:07:25 UTC (rev 2322)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamemodule/TS_RenameModule.java 2007-04-17 11:42:39 UTC (rev 2323)
@@ -36,7 +36,7 @@
public class TS_RenameModule extends FileTestSuite {
public static TestSuite suite() {
TestSuite suite = createSuite("Rename Module", "rename_module_test_*active*source", ModuleRenameTester.class);
-
+ suite.addTestSuite(TC_ModuleInclusionFinder.class);
suite.addTest(TS_RenameModuleChecks.suite());
return suite;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|