|
From: <mir...@us...> - 2007-02-22 12:51:04
|
Revision: 1995
http://svn.sourceforge.net/rubyeclipse/?rev=1995&view=rev
Author: mirkostocker
Date: 2007-02-22 04:50:59 -0800 (Thu, 22 Feb 2007)
Log Message:
-----------
Remove duplicated code.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/IParameterReplacer.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/ISelectedCallFinder.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/ITargetClassFinder.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/InlineMethodConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/InlineMethodConfig.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/InlineMethodEditProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodBodyStatementReplacer.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/ParameterReplacer.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/SelectedCallFinder.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/TargetClassFinder.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/FieldProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/inlinemethod/TargetClassFinderUI.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/inlinemethod/FinderTestsBase.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/inlinemethod/TC_ParameterReplacer.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/inlinemethod/TC_SelectedCallFinder.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/inlinemethod/TC_TargetClassFinder.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/IMethodCallNode.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodCallNode.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodCallNodeFactory.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodFCallNode.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodVCallNode.java
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/IMethodCallNode.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/IMethodCallNode.java 2007-02-22 07:34:12 UTC (rev 1994)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/IMethodCallNode.java 2007-02-22 12:50:59 UTC (rev 1995)
@@ -1,41 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2006 Mirko Stocker <me...@mi...>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-
-package org.rubypeople.rdt.refactoring.core.inlinemethod;
-
-import org.jruby.ast.Node;
-
-/**
- * Interface to represent the similarities of the different call nodes (Call, VCall, FCall) we have.
- */
-public interface IMethodCallNode {
- Node getReceiver();
- Node getArguments();
- String getName();
- Node getNode();
-}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/IParameterReplacer.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/IParameterReplacer.java 2007-02-22 07:34:12 UTC (rev 1994)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/IParameterReplacer.java 2007-02-22 12:50:59 UTC (rev 1995)
@@ -31,6 +31,7 @@
import org.jruby.ast.MethodDefNode;
import org.rubypeople.rdt.refactoring.documentprovider.DocumentProvider;
import org.rubypeople.rdt.refactoring.documentprovider.IDocumentProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.MethodCallNodeWrapper;
/**
@@ -40,5 +41,5 @@
* The return value contains the method body and, if necessary, the assigments for the method parameters.
*/
public interface IParameterReplacer {
- DocumentProvider replace(IDocumentProvider doc, IMethodCallNode call, MethodDefNode definition);
+ DocumentProvider replace(IDocumentProvider doc, MethodCallNodeWrapper call, MethodDefNode definition);
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/ISelectedCallFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/ISelectedCallFinder.java 2007-02-22 07:34:12 UTC (rev 1994)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/ISelectedCallFinder.java 2007-02-22 12:50:59 UTC (rev 1995)
@@ -29,7 +29,8 @@
package org.rubypeople.rdt.refactoring.core.inlinemethod;
import org.rubypeople.rdt.refactoring.documentprovider.DocumentProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.MethodCallNodeWrapper;
public interface ISelectedCallFinder {
- IMethodCallNode findSelectedCall(int pos, DocumentProvider doc);
+ MethodCallNodeWrapper findSelectedCall(int pos, DocumentProvider doc);
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/ITargetClassFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/ITargetClassFinder.java 2007-02-22 07:34:12 UTC (rev 1994)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/ITargetClassFinder.java 2007-02-22 12:50:59 UTC (rev 1995)
@@ -29,11 +29,12 @@
package org.rubypeople.rdt.refactoring.core.inlinemethod;
import org.rubypeople.rdt.refactoring.documentprovider.DocumentProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.MethodCallNodeWrapper;
public interface ITargetClassFinder {
/**
* Try to find the receiver's type from a call.
*/
- String findTargetClass(IMethodCallNode call, DocumentProvider doc);
+ String findTargetClass(MethodCallNodeWrapper call, DocumentProvider doc);
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/InlineMethodConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/InlineMethodConditionChecker.java 2007-02-22 07:34:12 UTC (rev 1994)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/InlineMethodConditionChecker.java 2007-02-22 12:50:59 UTC (rev 1995)
@@ -70,7 +70,7 @@
}
private void renameDuplicates(DocumentProvider doc) {
- StaticScope parent = NodeUtil.getScope(SelectionNodeProvider.getEnclosingScope(doc.getRootNode(), config.getSelectedCall().getNode()));
+ StaticScope parent = NodeUtil.getScope(SelectionNodeProvider.getEnclosingScope(doc.getRootNode(), config.getSelectedCall().getWrappedNode()));
ArrayList<String> localNames = new ArrayList<String>();
if(parent.getVariables() != null) {
@@ -114,8 +114,8 @@
private void createInlinedMethodBody(DocumentProvider doc) {
MethodBodyStatementReplacer bodyReplacer = new MethodBodyStatementReplacer();
- if(config.getSelectedCall().getReceiver() != null) {
- final String name = ((INameNode)config.getSelectedCall().getReceiver()).getName();
+ if(config.getSelectedCall().getReceiverNode() != null) {
+ final String name = ((INameNode)config.getSelectedCall().getReceiverNode()).getName();
config.setMethodDefDoc(bodyReplacer.replaceSelfWithObject(config.getMethodDefDoc(), name));
config.setMethodDefDoc(bodyReplacer.prefixCallsWithObject(config.getMethodDefDoc(), new IncludedClassesProvider(doc), config.getClassName(), name));
Collection<String> usedMembers = new HashSet<String>();
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/InlineMethodConfig.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/InlineMethodConfig.java 2007-02-22 07:34:12 UTC (rev 1994)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/InlineMethodConfig.java 2007-02-22 12:50:59 UTC (rev 1995)
@@ -34,11 +34,12 @@
import org.jruby.ast.Node;
import org.rubypeople.rdt.refactoring.core.NodeProvider;
import org.rubypeople.rdt.refactoring.documentprovider.DocumentProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.MethodCallNodeWrapper;
public class InlineMethodConfig {
private Boolean singleReturnStatement;
- private IMethodCallNode selectedCall;
+ private MethodCallNodeWrapper selectedCall;
private String className;
private MethodDefNode methodDefinitionNode;
private DocumentProvider methodDefDoc;
@@ -55,7 +56,7 @@
}
public Node getCallParent() {
- return NodeProvider.findParentNode(originalDocument.getRootNode(), selectedCall.getNode());
+ return NodeProvider.findParentNode(originalDocument.getRootNode(), selectedCall.getWrappedNode());
}
public String getClassName() {
@@ -70,7 +71,7 @@
return methodDefinitionNode;
}
- public IMethodCallNode getSelectedCall() {
+ public MethodCallNodeWrapper getSelectedCall() {
return selectedCall;
}
@@ -94,7 +95,7 @@
this.methodDefDoc = methodDefDoc;
}
- public void setSelectedCall(IMethodCallNode selectedCall) {
+ public void setSelectedCall(MethodCallNodeWrapper selectedCall) {
this.selectedCall = selectedCall;
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/InlineMethodEditProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/InlineMethodEditProvider.java 2007-02-22 07:34:12 UTC (rev 1994)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/InlineMethodEditProvider.java 2007-02-22 12:50:59 UTC (rev 1995)
@@ -52,7 +52,7 @@
if(parent instanceof AssignableNode) {
this.node = parent;
} else {
- this.node = config.getSelectedCall().getNode();
+ this.node = config.getSelectedCall().getWrappedNode();
}
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodBodyStatementReplacer.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodBodyStatementReplacer.java 2007-02-22 07:34:12 UTC (rev 1994)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodBodyStatementReplacer.java 2007-02-22 12:50:59 UTC (rev 1995)
@@ -43,6 +43,7 @@
import org.rubypeople.rdt.refactoring.core.NodeProvider;
import org.rubypeople.rdt.refactoring.documentprovider.DocumentProvider;
import org.rubypeople.rdt.refactoring.documentprovider.StringDocumentProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.MethodCallNodeWrapper;
import org.rubypeople.rdt.refactoring.nodewrapper.MethodNodeWrapper;
public class MethodBodyStatementReplacer implements IMethodBodyStatementReplacer {
@@ -95,20 +96,20 @@
DocumentProvider result = new StringDocumentProvider(doc);
- IMethodCallNode call = null;
+ MethodCallNodeWrapper call = null;
while((call = findCallToMethodInClass(result, provider, className)) != null) {
StringBuilder src = new StringBuilder(result.getActiveFileContent());
- src.insert(call.getNode().getPosition().getStartOffset(), object + '.');
+ src.insert(call.getWrappedNode().getPosition().getStartOffset(), object + '.');
result = new StringDocumentProvider(src.toString());
}
return result;
}
- private IMethodCallNode findCallToMethodInClass(DocumentProvider doc, IncludedClassesProvider provider, String className) {
+ private MethodCallNodeWrapper findCallToMethodInClass(DocumentProvider doc, IncludedClassesProvider provider, String className) {
Collection<MethodNodeWrapper> definedMethods = provider.getAllMethodsFor(className);
- for (IMethodCallNode node : findFAndVCalls(doc)) {
+ for (MethodCallNodeWrapper node : findFAndVCalls(doc)) {
for (MethodNodeWrapper methods : definedMethods) {
if(methods.getName().equals(node.getName())) {
return node;
@@ -118,10 +119,10 @@
return null;
}
- private Collection<IMethodCallNode> findFAndVCalls(DocumentProvider doc) {
- Collection<IMethodCallNode> methodCalls = new ArrayList<IMethodCallNode>();
+ private Collection<MethodCallNodeWrapper> findFAndVCalls(DocumentProvider doc) {
+ Collection<MethodCallNodeWrapper> methodCalls = new ArrayList<MethodCallNodeWrapper>();
for (Node node : NodeProvider.gatherNodesOfTypeInAktScopeNode(doc.getRootNode().getBodyNode(), VCallNode.class, FCallNode.class)) {
- methodCalls.add(MethodCallNodeFactory.create(node));
+ methodCalls.add(new MethodCallNodeWrapper(node));
}
return methodCalls;
}
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodCallNode.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodCallNode.java 2007-02-22 07:34:12 UTC (rev 1994)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodCallNode.java 2007-02-22 12:50:59 UTC (rev 1995)
@@ -1,58 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2006 Mirko Stocker <me...@mi...>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-
-package org.rubypeople.rdt.refactoring.core.inlinemethod;
-
-import org.jruby.ast.CallNode;
-import org.jruby.ast.Node;
-
-public class MethodCallNode implements IMethodCallNode {
-
- private final CallNode method;
-
- public MethodCallNode(CallNode method) {
- this.method = method;
- }
-
- public Node getArguments() {
- return method.getArgsNode();
- }
-
- public String getName() {
- return method.getName();
- }
-
- public Node getReceiver() {
- return method.getReceiverNode();
- }
-
- public CallNode getNode() {
- return method;
- }
-
-}
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodCallNodeFactory.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodCallNodeFactory.java 2007-02-22 07:34:12 UTC (rev 1994)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodCallNodeFactory.java 2007-02-22 12:50:59 UTC (rev 1995)
@@ -1,52 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2006 Mirko Stocker <me...@mi...>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-
-package org.rubypeople.rdt.refactoring.core.inlinemethod;
-
-import org.jruby.ast.CallNode;
-import org.jruby.ast.FCallNode;
-import org.jruby.ast.Node;
-import org.jruby.ast.VCallNode;
-
-public class MethodCallNodeFactory {
-
- public static IMethodCallNode create(final Node node) {
-
- IMethodCallNode call = null;
-
- if(node instanceof CallNode) {
- call = new MethodCallNode((CallNode) node);
- } else if (node instanceof FCallNode) {
- call = new MethodFCallNode((FCallNode) node);
- } else if (node instanceof VCallNode) {
- call = new MethodVCallNode((VCallNode) node);
- }
-
- return call;
- }
-}
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodFCallNode.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodFCallNode.java 2007-02-22 07:34:12 UTC (rev 1994)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodFCallNode.java 2007-02-22 12:50:59 UTC (rev 1995)
@@ -1,58 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2006 Mirko Stocker <me...@mi...>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-
-package org.rubypeople.rdt.refactoring.core.inlinemethod;
-
-import org.jruby.ast.FCallNode;
-import org.jruby.ast.Node;
-
-public class MethodFCallNode implements IMethodCallNode {
-
- private final FCallNode method;
-
- public MethodFCallNode(FCallNode method) {
- this.method = method;
- }
-
- public Node getArguments() {
- return method.getArgsNode();
- }
-
- public String getName() {
- return method.getName();
- }
-
- public Node getReceiver() {
- return null;
- }
-
- public FCallNode getNode() {
- return method;
- }
-
-}
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodVCallNode.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodVCallNode.java 2007-02-22 07:34:12 UTC (rev 1994)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodVCallNode.java 2007-02-22 12:50:59 UTC (rev 1995)
@@ -1,58 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2006 Mirko Stocker <me...@mi...>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-
-package org.rubypeople.rdt.refactoring.core.inlinemethod;
-
-import org.jruby.ast.Node;
-import org.jruby.ast.VCallNode;
-
-public class MethodVCallNode implements IMethodCallNode {
-
- private final VCallNode method;
-
- public MethodVCallNode(VCallNode method) {
- this.method = method;
- }
-
- public Node getArguments() {
- return null;
- }
-
- public String getName() {
- return method.getName();
- }
-
- public Node getReceiver() {
- return null;
- }
-
- public VCallNode getNode() {
- return method;
- }
-
-}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/ParameterReplacer.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/ParameterReplacer.java 2007-02-22 07:34:12 UTC (rev 1994)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/ParameterReplacer.java 2007-02-22 12:50:59 UTC (rev 1995)
@@ -46,11 +46,12 @@
import org.rubypeople.rdt.refactoring.documentprovider.DocumentProvider;
import org.rubypeople.rdt.refactoring.documentprovider.IDocumentProvider;
import org.rubypeople.rdt.refactoring.documentprovider.StringDocumentProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.MethodCallNodeWrapper;
import org.rubypeople.rdt.refactoring.util.FileHelper;
public class ParameterReplacer implements IParameterReplacer {
- public DocumentProvider replace(IDocumentProvider doc, IMethodCallNode call, MethodDefNode definition) {
+ public DocumentProvider replace(IDocumentProvider doc, MethodCallNodeWrapper call, MethodDefNode definition) {
DocumentProvider strDoc = new StringDocumentProvider(doc.getActiveFileContent().substring(definition.getPosition().getStartOffset(), definition.getPosition().getEndOffset() + 1));
@@ -58,9 +59,9 @@
ArrayNode tailList = new ArrayNode(new SourcePosition());
- if(definition.getArgsNode().getArgs() != null && call.getArguments() != null) {
+ if(definition.getArgsNode().getArgs() != null && call.getArgsNode() != null) {
Object[] defnArguments = definition.getArgsNode().getArgs().childNodes().toArray();
- Object[] arguments = call.getArguments().childNodes().toArray();
+ Object[] arguments = call.getArgsNode().childNodes().toArray();
for(int i = 0; i < defnArguments.length; i++) {
strDoc = processArguments(strDoc, headList, tailList, (Node) arguments[i], (ArgumentNode) defnArguments[i]);
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/SelectedCallFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/SelectedCallFinder.java 2007-02-22 07:34:12 UTC (rev 1994)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/SelectedCallFinder.java 2007-02-22 12:50:59 UTC (rev 1995)
@@ -34,14 +34,14 @@
import org.jruby.ast.VCallNode;
import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
import org.rubypeople.rdt.refactoring.documentprovider.DocumentProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.MethodCallNodeWrapper;
public class SelectedCallFinder implements ISelectedCallFinder {
- public IMethodCallNode findSelectedCall(final int pos, final DocumentProvider doc) {
+ public MethodCallNodeWrapper findSelectedCall(final int pos, final DocumentProvider doc) {
final Node selectedNode = SelectionNodeProvider.getSelectedNodeOfType(doc.getAllNodes(), pos, CallNode.class, FCallNode.class, VCallNode.class);
- return MethodCallNodeFactory.create(selectedNode);
+ return selectedNode != null ? new MethodCallNodeWrapper(selectedNode) : null;
}
-
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/TargetClassFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/TargetClassFinder.java 2007-02-22 07:34:12 UTC (rev 1994)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/TargetClassFinder.java 2007-02-22 12:50:59 UTC (rev 1995)
@@ -47,16 +47,17 @@
import org.rubypeople.rdt.refactoring.exception.NoClassNodeException;
import org.rubypeople.rdt.refactoring.nodewrapper.ClassNodeWrapper;
import org.rubypeople.rdt.refactoring.nodewrapper.FieldNodeWrapper;
+import org.rubypeople.rdt.refactoring.nodewrapper.MethodCallNodeWrapper;
import org.rubypeople.rdt.refactoring.util.NameHelper;
import org.rubypeople.rdt.refactoring.util.NodeUtil;
public class TargetClassFinder implements ITargetClassFinder {
- public String findTargetClass(final IMethodCallNode call, final DocumentProvider doc) {
+ public String findTargetClass(final MethodCallNodeWrapper call, final DocumentProvider doc) {
String name = "";
- if(call.getReceiver() == null) {
+ if(call.getReceiverNode() == null) {
name = getSurroundingClass(call, doc);
}
@@ -70,21 +71,21 @@
return name;
}
- private String getSurroundingClass(final IMethodCallNode call, final DocumentProvider doc) {
- ClassNode classNode = ((ClassNode) NodeProvider.getEnclosingNodeOfType(doc.getRootNode(), call.getNode(), new Class<?>[]{ClassNode.class}));
+ private String getSurroundingClass(final MethodCallNodeWrapper call, final DocumentProvider doc) {
+ ClassNode classNode = ((ClassNode) NodeProvider.getEnclosingNodeOfType(doc.getRootNode(), call.getWrappedNode(), new Class<?>[]{ClassNode.class}));
if(classNode != null) {
return classNode.getCPath().getName();
}
return "";
}
- private AssignableNode getAssignableNode(final IMethodCallNode call, final DocumentProvider doc) {
+ private AssignableNode getAssignableNode(final MethodCallNodeWrapper call, final DocumentProvider doc) {
AssignableNode receiverType = null;
- if(call.getReceiver() instanceof LocalVarNode) {
- receiverType = localAsgnFromLocalVar((LocalVarNode) call.getReceiver(), doc);
- } else if(call.getReceiver() instanceof InstVarNode) {
- receiverType = instVarFromCall((InstVarNode) call.getReceiver(), doc);
+ if(call.getReceiverNode() instanceof LocalVarNode) {
+ receiverType = localAsgnFromLocalVar((LocalVarNode) call.getReceiverNode(), doc);
+ } else if(call.getReceiverNode() instanceof InstVarNode) {
+ receiverType = instVarFromCall((InstVarNode) call.getReceiverNode(), doc);
}
return receiverType;
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/FieldProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/FieldProvider.java 2007-02-22 07:34:12 UTC (rev 1994)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/FieldProvider.java 2007-02-22 12:50:59 UTC (rev 1995)
@@ -90,13 +90,13 @@
private void initClassFields(ClassNodeWrapper classWrapper) {
- Collection<Node> allOccurances = classWrapper
+ Collection<Node> allOccurences = classWrapper
.getClassFieldOccurences();
- for (Node currentAttr : allOccurances) {
+ for (Node currentAttr : allOccurences) {
if (currentAttr instanceof ClassVarNode) {
ClassVarNode classVar = (ClassVarNode) currentAttr;
- if (!isVarSubNodeOfAsgn(classVar, allOccurances, ClassVarAsgnNode.class)) {
+ if (!isVarSubNodeOfAsgn(classVar, allOccurences, ClassVarAsgnNode.class)) {
addClassVar(classVar);
}
} else if (currentAttr instanceof ClassVarAsgnNode) {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/inlinemethod/TargetClassFinderUI.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/inlinemethod/TargetClassFinderUI.java 2007-02-22 07:34:12 UTC (rev 1994)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/inlinemethod/TargetClassFinderUI.java 2007-02-22 12:50:59 UTC (rev 1995)
@@ -30,10 +30,10 @@
import org.eclipse.jface.window.Window;
import org.jruby.ast.types.INameNode;
-import org.rubypeople.rdt.refactoring.core.inlinemethod.IMethodCallNode;
import org.rubypeople.rdt.refactoring.core.inlinemethod.ITargetClassFinder;
import org.rubypeople.rdt.refactoring.core.inlinemethod.TargetClassFinder;
import org.rubypeople.rdt.refactoring.documentprovider.DocumentProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.MethodCallNodeWrapper;
import org.rubypeople.rdt.refactoring.ui.IncludedClassesSelectionDialog;
public class TargetClassFinderUI implements ITargetClassFinder {
@@ -44,13 +44,13 @@
targetClassFinder = new TargetClassFinder();
}
- public String findTargetClass(IMethodCallNode call, DocumentProvider doc) {
+ public String findTargetClass(MethodCallNodeWrapper call, DocumentProvider doc) {
String result = targetClassFinder.findTargetClass(call, doc);
- if("".equals(result) && call.getReceiver() == null) {
+ if("".equals(result) && call.getReceiverNode() == null) {
return "";
}
if(result == null || "".equals(result)) {
- final String title = "Please choose the type of the variable " + ((INameNode) call.getReceiver()).getName() + ':';
+ final String title = "Please choose the type of the variable " + ((INameNode) call.getReceiverNode()).getName() + ':';
IncludedClassesSelectionDialog dialog = new IncludedClassesSelectionDialog(doc, title, call.getName());
if (dialog.open() == Window.OK) {
result = dialog.getSelectedName();
Modified: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/inlinemethod/FinderTestsBase.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/inlinemethod/FinderTestsBase.java 2007-02-22 07:34:12 UTC (rev 1994)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/inlinemethod/FinderTestsBase.java 2007-02-22 12:50:59 UTC (rev 1995)
@@ -29,10 +29,10 @@
package org.rubypeople.rdt.refactoring.tests.core.inlinemethod;
import org.jruby.ast.MethodDefNode;
-import org.rubypeople.rdt.refactoring.core.inlinemethod.IMethodCallNode;
import org.rubypeople.rdt.refactoring.core.inlinemethod.MethodFinder;
import org.rubypeople.rdt.refactoring.core.inlinemethod.SelectedCallFinder;
import org.rubypeople.rdt.refactoring.core.inlinemethod.TargetClassFinder;
+import org.rubypeople.rdt.refactoring.nodewrapper.MethodCallNodeWrapper;
import org.rubypeople.rdt.refactoring.tests.FileTestCase;
import org.rubypeople.rdt.refactoring.tests.core.MultipleDocumentsInOneProvider;
@@ -48,18 +48,18 @@
super(fileName);
}
- protected IMethodCallNode findSelected(int pos, String file) {
+ protected MethodCallNodeWrapper findSelected(int pos, String file) {
SelectedCallFinder finder = new SelectedCallFinder();
doc.setActive(file);
return finder.findSelectedCall(pos, doc);
}
protected MethodDefNode findDefinition(int pos, String file) {
- IMethodCallNode methodCallNode = findSelected(pos, file);
+ MethodCallNodeWrapper methodCallNode = findSelected(pos, file);
return findDefinition(methodCallNode);
}
- protected MethodDefNode findDefinition(IMethodCallNode methodCallNode) {
+ protected MethodDefNode findDefinition(MethodCallNodeWrapper methodCallNode) {
String className = new TargetClassFinder().findTargetClass(methodCallNode, doc);
return new MethodFinder().find(className, methodCallNode.getName(), doc);
}
Modified: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/inlinemethod/TC_ParameterReplacer.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/inlinemethod/TC_ParameterReplacer.java 2007-02-22 07:34:12 UTC (rev 1994)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/inlinemethod/TC_ParameterReplacer.java 2007-02-22 12:50:59 UTC (rev 1995)
@@ -32,12 +32,12 @@
import java.io.IOException;
import org.jruby.ast.MethodDefNode;
-import org.rubypeople.rdt.refactoring.core.inlinemethod.IMethodCallNode;
import org.rubypeople.rdt.refactoring.core.inlinemethod.MethodFinder;
import org.rubypeople.rdt.refactoring.core.inlinemethod.ParameterReplacer;
import org.rubypeople.rdt.refactoring.core.inlinemethod.SelectedCallFinder;
import org.rubypeople.rdt.refactoring.core.inlinemethod.TargetClassFinder;
import org.rubypeople.rdt.refactoring.documentprovider.IDocumentProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.MethodCallNodeWrapper;
import org.rubypeople.rdt.refactoring.tests.FileTestData;
@@ -54,7 +54,7 @@
int caretPosition = testData.getIntProperty("pos");
SelectedCallFinder finder = new SelectedCallFinder();
- IMethodCallNode node = finder.findSelectedCall(caretPosition, testData);
+ MethodCallNodeWrapper node = finder.findSelectedCall(caretPosition, testData);
String className = new TargetClassFinder().findTargetClass(node, testData);
MethodDefNode definitionNode = new MethodFinder().find(className, node.getName(), testData);
Modified: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/inlinemethod/TC_SelectedCallFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/inlinemethod/TC_SelectedCallFinder.java 2007-02-22 07:34:12 UTC (rev 1994)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/inlinemethod/TC_SelectedCallFinder.java 2007-02-22 12:50:59 UTC (rev 1995)
@@ -28,50 +28,42 @@
package org.rubypeople.rdt.refactoring.tests.core.inlinemethod;
-import org.jruby.ast.ArgumentNode;
-import org.rubypeople.rdt.refactoring.core.inlinemethod.IMethodCallNode;
-import org.rubypeople.rdt.refactoring.core.inlinemethod.MethodCallNodeFactory;
-import org.rubypeople.rdt.refactoring.core.inlinemethod.MethodFCallNode;
-import org.rubypeople.rdt.refactoring.core.inlinemethod.MethodVCallNode;
+import org.rubypeople.rdt.refactoring.nodewrapper.MethodCallNodeWrapper;
import org.rubypeople.rdt.refactoring.tests.core.MultipleDocumentsInOneProvider;
public class TC_SelectedCallFinder extends FinderTestsBase {
public void testFindSelectedCall4() {
- MethodFCallNode node = (MethodFCallNode) findSelected(2, "test4");
+ MethodCallNodeWrapper node = findSelected(2, "test4");
assertEquals("call", node.getName());
- assertNotNull(node.getArguments());
- assertNotNull(node.getNode());
- assertNull(node.getReceiver());
+ assertNotNull(node.getArgsNode());
+ assertNotNull(node.getWrappedNode());
+ assertNull(node.getReceiverNode());
}
public void testFindSelectedCall3() {
- MethodVCallNode node = (MethodVCallNode) findSelected(4, "test3");
+ MethodCallNodeWrapper node = findSelected(4, "test3");
assertEquals("call", node.getName());
- assertNull(node.getArguments());
- assertNotNull(node.getNode());
- assertNull(node.getReceiver());
+ assertNull(node.getArgsNode());
+ assertNotNull(node.getWrappedNode());
+ assertNull(node.getReceiverNode());
}
public void testFindSelectedCall2() {
- IMethodCallNode node = findSelected(9, "test2");
+ MethodCallNodeWrapper node = findSelected(9, "test2");
assertEquals("method", node.getName());
- assertNull(node.getArguments());
- assertNotNull(node.getNode());
- assertNotNull(node.getReceiver());
+ assertNull(node.getArgsNode());
+ assertNotNull(node.getWrappedNode());
+ assertNotNull(node.getReceiverNode());
}
public void testFindSelectedCall1() {
- IMethodCallNode node = findSelected(8, "test1");
+ MethodCallNodeWrapper node = findSelected(8, "test1");
assertEquals("method", node.getName());
- assertNotNull(node.getArguments());
- assertNotNull(node.getNode());
- assertNotNull(node.getReceiver());
+ assertNotNull(node.getArgsNode());
+ assertNotNull(node.getWrappedNode());
+ assertNotNull(node.getReceiverNode());
}
-
- public void testMethodCallNodeFactory() {
- assertNull(MethodCallNodeFactory.create(new ArgumentNode(null, "")));
- }
@Override
protected void setUp() throws Exception {
Modified: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/inlinemethod/TC_TargetClassFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/inlinemethod/TC_TargetClassFinder.java 2007-02-22 07:34:12 UTC (rev 1994)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/inlinemethod/TC_TargetClassFinder.java 2007-02-22 12:50:59 UTC (rev 1995)
@@ -117,12 +117,12 @@
private LocalAsgnNode findLocalAsgnNode(int pos, String file) {
TargetClassFinder finder = new TargetClassFinder();
- return finder.localAsgnFromLocalVar( (LocalVarNode) ((CallNode) findSelected(pos, file).getNode()).getReceiverNode(), doc);
+ return finder.localAsgnFromLocalVar( (LocalVarNode) ((CallNode) findSelected(pos, file).getWrappedNode()).getReceiverNode(), doc);
}
private InstAsgnNode findInstAsgnNode(int pos, String file) {
TargetClassFinder finder = new TargetClassFinder();
- return finder.instVarFromCall( (InstVarNode) ((CallNode) findSelected(pos, file).getNode()).getReceiverNode(), doc);
+ return finder.instVarFromCall( (InstVarNode) ((CallNode) findSelected(pos, file).getWrappedNode()).getReceiverNode(), doc);
}
private String findTargetClass(int pos, String file) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|