|
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] |