|
From: <cal...@us...> - 2007-03-05 09:00:02
|
Revision: 2082
http://svn.sourceforge.net/rubyeclipse/?rev=2082&view=rev
Author: callandor1983
Date: 2007-03-05 00:59:46 -0800 (Mon, 05 Mar 2007)
Log Message:
-----------
JRuby updated to head (contains position-fixes).
Modified Paths:
--------------
trunk/org.jruby/META-INF/MANIFEST.MF
trunk/org.jruby/lib/jruby.jar
trunk/org.rubypeople.rdt-feature/feature.xml
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/InOrderVisitor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/ASTUtil.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/RefactoringPlugin.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/classnodeprovider/IncludedClassesProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/NodeFactory.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/NodeProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/SelectionNodeProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractMethodConditionChecker.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/documentprovider/DocumentWithIncluding.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/util/NodeUtil.java
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_22.result.rb
Added Paths:
-----------
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_23.result.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_23.source.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_23.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_24.result.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_24.source.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_24.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_25.result.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_25.source.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_25.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_26.result.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_26.source.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_26.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_27.result.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_27.source.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_27.test_properties
Removed Paths:
-------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/signatureprovider/JRubyClassSignatureProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/util/ArityEvaluator.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/util/TC_ArityEvaluator.java
Modified: trunk/org.jruby/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.jruby/META-INF/MANIFEST.MF 2007-03-05 01:24:39 UTC (rev 2081)
+++ trunk/org.jruby/META-INF/MANIFEST.MF 2007-03-05 08:59:46 UTC (rev 2082)
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: JRuby Plug-in
Bundle-SymbolicName: org.jruby
-Bundle-Version: 0.9.2.2944
+Bundle-Version: 0.9.2.3129
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime
Eclipse-LazyStart: false
Modified: trunk/org.jruby/lib/jruby.jar
===================================================================
(Binary files differ)
Modified: trunk/org.rubypeople.rdt-feature/feature.xml
===================================================================
--- trunk/org.rubypeople.rdt-feature/feature.xml 2007-03-05 01:24:39 UTC (rev 2081)
+++ trunk/org.rubypeople.rdt-feature/feature.xml 2007-03-05 08:59:46 UTC (rev 2082)
@@ -337,7 +337,7 @@
id="org.jruby"
download-size="0"
install-size="0"
- version="0.9.2.2944"
+ version="0.9.2.3129"
unpack="false"/>
<plugin
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java 2007-03-05 01:24:39 UTC (rev 2081)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java 2007-03-05 08:59:46 UTC (rev 2082)
@@ -696,7 +696,7 @@
*/
public Instruction visitDSymbolNode(DSymbolNode iVisited) {
handleNode(iVisited);
- visitNode(iVisited.getNode());
+ visitIter(iVisited.iterator());
return null;
}
@@ -953,12 +953,12 @@
for (; iter.hasNext();) {
Node mixinNameNode = (Node) iter.next();
if ( mixinNameNode instanceof StrNode ) {
- mixins.add( ((StrNode)mixinNameNode).getValue() );
+ mixins.add( ((StrNode)mixinNameNode).getValue().toString() );
}
if ( mixinNameNode instanceof DStrNode ) {
Node next = (Node)((DStrNode)mixinNameNode).iterator().next();
if ( next instanceof StrNode ) {
- mixins.add( ((StrNode)next).getValue() );
+ mixins.add( ((StrNode)next).getValue().toString() );
}
}
if (mixinNameNode instanceof ConstNode) {
@@ -1006,7 +1006,7 @@
}
if (tmp instanceof StrNode) {
StrNode strNode = (StrNode) tmp;
- return strNode.getValue();
+ return strNode.getValue().toString();
}
return null;
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/InOrderVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/InOrderVisitor.java 2007-03-05 01:24:39 UTC (rev 2081)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/InOrderVisitor.java 2007-03-05 08:59:46 UTC (rev 2082)
@@ -425,7 +425,7 @@
*/
public Instruction visitDSymbolNode(DSymbolNode iVisited) {
handleNode(iVisited);
- acceptNode(iVisited.getNode());
+ visitIter(iVisited.iterator());
return null;
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/ASTUtil.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/ASTUtil.java 2007-03-05 01:24:39 UTC (rev 2081)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/ASTUtil.java 2007-03-05 08:59:46 UTC (rev 2082)
@@ -112,7 +112,7 @@
if (node instanceof DStrNode)
return stringRepresentation((DStrNode) node);
if (node instanceof StrNode)
- return ((StrNode) node).getValue();
+ return ((StrNode) node).getValue().toString();
log("Reached node type we don't know how to represent: "
+ node.getClass().getName());
return node.toString();
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/RefactoringPlugin.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/RefactoringPlugin.java 2007-03-05 01:24:39 UTC (rev 2081)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/RefactoringPlugin.java 2007-03-05 08:59:46 UTC (rev 2082)
@@ -30,7 +30,6 @@
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.jruby.IRuby;
import org.jruby.Ruby;
import org.osgi.framework.BundleContext;
@@ -41,7 +40,7 @@
private static RefactoringPlugin plugin;
- private static IRuby ruby;
+ private static Ruby ruby;
/**
* The constructor.
@@ -84,7 +83,7 @@
return AbstractUIPlugin.imageDescriptorFromPlugin("org.rubypeople.rdt.refactoring", path);
}
- public static IRuby getRuby() {
+ public static Ruby getRuby() {
if (ruby == null)
ruby = Ruby.getDefaultInstance();
return ruby;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/classnodeprovider/IncludedClassesProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/classnodeprovider/IncludedClassesProvider.java 2007-03-05 01:24:39 UTC (rev 2081)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/classnodeprovider/IncludedClassesProvider.java 2007-03-05 08:59:46 UTC (rev 2082)
@@ -77,7 +77,7 @@
for (Object o : arrayNode.childNodes()) {
if (o instanceof StrNode) {
StrNode strNode = (StrNode) o;
- appendPath(strNode.getValue());
+ appendPath(strNode.getValue().toString());
}
}
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/NodeFactory.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/NodeFactory.java 2007-03-05 01:24:39 UTC (rev 2081)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/NodeFactory.java 2007-03-05 08:59:46 UTC (rev 2082)
@@ -366,6 +366,6 @@
}
public static Node createConstDeclNode(String name, Node valueNode) {
- return new ConstDeclNode(pos, null, name, valueNode);
+ return new ConstDeclNode(pos, name, null, valueNode);
}
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/NodeProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/NodeProvider.java 2007-03-05 01:24:39 UTC (rev 2081)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/NodeProvider.java 2007-03-05 08:59:46 UTC (rev 2082)
@@ -209,15 +209,15 @@
return lastMatch;
}
- public static boolean hasChildNode(Node parent, Class childClass) {
+ public static boolean hasChildNode(Node parent, Class<? extends Node> childClass) {
return getFirstChildNode(parent, childClass) != null;
}
- public static Node getFirstChildNode(Node parent, Class childClass) {
+ public static Node getFirstChildNode(Node parent, Class<? extends Node> childClass) {
Collection<Node> childList = getChildren(parent);
for (Object o : childList) {
Node node = unwrap(o);
- if (node.getClass().isAssignableFrom(childClass))
+ if (childClass.isAssignableFrom(node.getClass()))
return node;
}
return null;
@@ -356,7 +356,7 @@
return candidates;
}
- public static Collection<Node> getSubNodes(Node baseNode, Class<?>... klasses) {
+ public static Collection<Node> getSubNodes(Node baseNode, Class... klasses) {
Collection<Node> allNodes = getAllNodes(baseNode);
Collection<Node> resultNodes = new ArrayList<Node>();
for (Node aktNode : allNodes) {
@@ -367,11 +367,11 @@
return resultNodes;
}
- public static boolean hasSubNodes(Node baseNode, Class<?>... klasses) {
+ public static boolean hasSubNodes(Node baseNode, Class... klasses) {
return !getSubNodes(baseNode, klasses).isEmpty();
}
- public static Node getEnclosingNodeOfType(Node baseNode, Node enclosedNode, Class<? extends Object>... klasses) {
+ public static Node getEnclosingNodeOfType(Node baseNode, Node enclosedNode, Class... klasses) {
return SelectionNodeProvider.getSelectedNodeOfType(baseNode, enclosedNode.getPosition().getStartOffset(), klasses);
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/SelectionNodeProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/SelectionNodeProvider.java 2007-03-05 01:24:39 UTC (rev 2081)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/SelectionNodeProvider.java 2007-03-05 08:59:46 UTC (rev 2082)
@@ -138,7 +138,7 @@
return (enclosingPos.getStartOffset() <= enclosedPos.getStartOffset() && enclosingPos.getEndOffset() >= enclosedPos.getEndOffset());
}
- public static Node getEnclosingNode(Node rootNode, SelectionInformation selection, Class<?>... classes) {
+ public static Node getEnclosingNode(Node rootNode, SelectionInformation selection, Class... classes) {
Collection<Node> enclosingNodes = getEnclosingNodes(rootNode, selection, classes);
Node lastNode = null;
Node secondLastNode = null;
@@ -176,7 +176,7 @@
return sameStart && sameEnd && isCallNode && isAsgnNode;
}
- public static Collection<Node> getEnclosingNodes(Node rootNode, SelectionInformation selection, Class<?>... classes) {
+ public static Collection<Node> getEnclosingNodes(Node rootNode, SelectionInformation selection, Class... classes) {
Collection<Node> allNodes = NodeProvider.getAllNodes(rootNode);
Collection<Node> enclosingStartNodes = getSelectedNodesOfType(allNodes, selection.getStartOfSelection(), classes);
Collection<Node> enclosingNodes = new ArrayList<Node>();
@@ -190,11 +190,11 @@
return enclosingNodes;
}
- public static Node getSelectedNodeOfType(Node baseNode, int position, Class<?>... klasses) {
+ public static Node getSelectedNodeOfType(Node baseNode, int position, Class... klasses) {
return getSelectedNodeOfType(NodeProvider.getAllNodes(baseNode), position, klasses);
}
- public static Node getSelectedNodeOfType(Collection<? extends Node> nodes, int position, Class<?>... klasses) {
+ public static Node getSelectedNodeOfType(Collection<? extends Node> nodes, int position, Class... klasses) {
return returnLast(getSelectedNodesOfType(nodes, position, klasses));
}
@@ -214,7 +214,7 @@
return candidate;
}
- public static Collection<Node> getSelectedNodesOfType(Collection<? extends Node> nodes, int position, Class<?>... klasses) {
+ public static Collection<Node> getSelectedNodesOfType(Collection<? extends Node> nodes, int position, Class... klasses) {
ArrayList<Node> candidates = new ArrayList<Node>();
for (Node n : nodes) {
if (nodeContainsPosition(n, position) && !(n instanceof NewlineNode) && NodeUtil.nodeAssignableFrom(n, klasses)) {
@@ -224,7 +224,7 @@
return candidates;
}
- public static Collection<Node> getSelectedNodesOfType(Node baseNode, int position, Class<?>... klasses) {
+ public static Collection<Node> getSelectedNodesOfType(Node baseNode, int position, Class... klasses) {
return getSelectedNodesOfType(NodeProvider.getAllNodes(baseNode), position, klasses);
}
@@ -254,7 +254,7 @@
}
- private static ClassNodeWrapper getSelectedClassNode(Node rootNode, int position, Class<?>... classes) throws NoClassNodeException {
+ private static ClassNodeWrapper getSelectedClassNode(Node rootNode, int position, Class... classes) throws NoClassNodeException {
Node enclosingClassNode = getSelectedNodeOfType(rootNode, position, classes);
PartialClassNodeWrapper partialClassNode = PartialClassNodeWrapper.getPartialClassNodeWrapper(enclosingClassNode, rootNode);
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractMethodConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractMethodConditionChecker.java 2007-03-05 01:24:39 UTC (rev 2081)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractMethodConditionChecker.java 2007-03-05 08:59:46 UTC (rev 2082)
@@ -35,17 +35,25 @@
import org.jruby.ast.ArgsNode;
import org.jruby.ast.ArgumentNode;
import org.jruby.ast.ArrayNode;
+import org.jruby.ast.BlockNode;
+import org.jruby.ast.BreakNode;
import org.jruby.ast.CaseNode;
import org.jruby.ast.ClassNode;
import org.jruby.ast.DefnNode;
+import org.jruby.ast.ForNode;
+import org.jruby.ast.IterNode;
import org.jruby.ast.MethodDefNode;
import org.jruby.ast.ModuleNode;
import org.jruby.ast.MultipleAsgnNode;
+import org.jruby.ast.NextNode;
import org.jruby.ast.Node;
+import org.jruby.ast.RedoNode;
+import org.jruby.ast.RetryNode;
import org.jruby.ast.RootNode;
import org.jruby.ast.SClassNode;
import org.jruby.ast.SuperNode;
import org.jruby.ast.WhenNode;
+import org.jruby.ast.WhileNode;
import org.jruby.ast.YieldNode;
import org.jruby.ast.ZSuperNode;
import org.rubypeople.rdt.refactoring.core.NodeProvider;
@@ -101,9 +109,13 @@
}
}
+ //Check on loopControlNodes (Break, Redo, Next, Retry)
+ if(containsLoopControlNode(selectedNode)) {
+ selectedNode = getLoopOrItsParent(rootNode, selectedNode);
+ }
+
//Check if content of an ArgsNode is selected
- ArgsNode enclosingArgsNode = (ArgsNode) SelectionNodeProvider.getEnclosingNode(rootNode, config.getSelection(), ArgsNode.class);
- if(enclosingArgsNode != null) {
+ if(SelectionNodeProvider.getEnclosingNode(rootNode, config.getSelection(), ArgsNode.class) != null) {
return SelectionNodeProvider.getEnclosingNode(rootNode, config.getSelection(), MethodDefNode.class);
}
@@ -115,7 +127,7 @@
//check if the selected Nodes are contained in an enclosing arrayNode
//if not the fowllowing checks arent necessary anymore.
ArrayNode enclosingArrayNode = (ArrayNode) SelectionNodeProvider.getEnclosingNode(rootNode, config.getSelection(), ArrayNode.class);
- if(!sectedNodesInArrayNode(enclosingArrayNode, selectedNode)) {
+ if(!sectedNodesInArrayNode(enclosingArrayNode, selectedNode) || !NodeUtil.nodeAssignableFrom(selectedNode, ArrayNode.class)) {
return selectedNode;
}
@@ -139,6 +151,21 @@
return selectedNode;
}
+ private Node getLoopOrItsParent(RootNode rootNode, Node selectedNode) {
+ Node loopNode = NodeProvider.getEnclosingNodeOfType(rootNode, selectedNode, WhileNode.class, ForNode.class, IterNode.class);
+ if(loopNode != null) {
+ selectedNode = loopNode;
+ }
+ if(NodeUtil.nodeAssignableFrom(loopNode, IterNode.class)) {
+ selectedNode = NodeProvider.findParentNode(rootNode, loopNode);
+ }
+ return selectedNode;
+ }
+
+ private boolean containsLoopControlNode(Node selectedNode) {
+ return !NodeProvider.getSubNodes(selectedNode, BreakNode.class, RedoNode.class, NextNode.class, RetryNode.class).isEmpty();
+ }
+
private boolean sectedNodesInArrayNode(ArrayNode arrayNode, Node selectedNode) {
if(arrayNode == null) {
return false;
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-03-05 01:24:39 UTC (rev 2081)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/TargetClassFinder.java 2007-03-05 08:59:46 UTC (rev 2082)
@@ -72,7 +72,7 @@
}
private String getSurroundingClass(final MethodCallNodeWrapper call, final DocumentProvider doc) {
- ClassNode classNode = ((ClassNode) NodeProvider.getEnclosingNodeOfType(doc.getActiveFileRootNode(), call.getWrappedNode(), new Class<?>[]{ClassNode.class}));
+ ClassNode classNode = ((ClassNode) NodeProvider.getEnclosingNodeOfType(doc.getActiveFileRootNode(), call.getWrappedNode(), ClassNode.class));
if(classNode != null) {
return classNode.getCPath().getName();
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/documentprovider/DocumentWithIncluding.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/documentprovider/DocumentWithIncluding.java 2007-03-05 01:24:39 UTC (rev 2081)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/documentprovider/DocumentWithIncluding.java 2007-03-05 08:59:46 UTC (rev 2082)
@@ -116,7 +116,7 @@
}
private String getRequiredFilename(FCallNode node) {
- return ((StrNode) node.getArgsNode().childNodes().iterator().next()).getValue();
+ return ((StrNode) node.getArgsNode().childNodes().iterator().next()).getValue().toString();
}
private Collection<FCallNode> getRequires(String fileName) {
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/signatureprovider/JRubyClassSignatureProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/signatureprovider/JRubyClassSignatureProvider.java 2007-03-05 01:24:39 UTC (rev 2081)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/signatureprovider/JRubyClassSignatureProvider.java 2007-03-05 08:59:46 UTC (rev 2082)
@@ -1,83 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2006 Lukas Felber <lf...@hs...>
- *
- * 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.signatureprovider;
-
-import java.util.Map;
-
-import org.jruby.RubyClass;
-import org.jruby.internal.runtime.methods.AbstractMethod;
-import org.rubypeople.rdt.refactoring.util.ArityEvaluator;
-import org.rubypeople.rdt.refactoring.util.Constants;
-
-public class JRubyClassSignatureProvider extends ClassSignatureProvider {
-
- private RubyClass klass;
-
- public JRubyClassSignatureProvider(RubyClass klass) {
- super(getSuperProvider(klass));
- this.klass = klass;
- createMethodSignatures();
- }
-
- private void createMethodSignatures() {
- Map methods = klass.getMethods();
- for (Object o : methods.keySet()) {
- String key = (String) o;
- AbstractMethod method = (AbstractMethod) methods.get(key);
- addMethodSignature(key, method);
- }
- }
-
- private static IClassSignatureProvider getSuperProvider(RubyClass klass) {
- if (klass.getSuperClass() == null)
- return null;
- else if (klass.getSuperClass().getName().equals(Constants.OBJECT_NAME))
- return null;
- else
- return new JRubyClassSignatureProvider(klass.getSuperClass());
- }
-
- public String getClassName() {
- return klass.getName();
- }
-
- @Override
- protected MethodSignature getSignature(String methodName, Object data) {
- AbstractMethod method = (AbstractMethod) data;
- ArityEvaluator arityEvaluator = new ArityEvaluator(getClassName(), methodName);
- boolean isModule = ((klass.isIncluded()));
- int argCount = arityEvaluator.evaluateRequiredArity(method.getArity(), isModule);
-
- return new MethodSignature(methodName, argCount);
- }
-
- public AbstractMethod getMethod(String methodName) {
- return (AbstractMethod) getData(methodName);
- }
-}
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/util/ArityEvaluator.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/util/ArityEvaluator.java 2007-03-05 01:24:39 UTC (rev 2081)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/util/ArityEvaluator.java 2007-03-05 08:59:46 UTC (rev 2082)
@@ -1,124 +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 Lukas Felber <lf...@hs...>
- *
- * 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.util;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.jruby.RubyClass;
-import org.jruby.ast.Node;
-import org.jruby.exceptions.RaiseException;
-import org.jruby.runtime.Arity;
-import org.rubypeople.rdt.refactoring.RefactoringPlugin;
-import org.rubypeople.rdt.refactoring.core.NodeProvider;
-
-public class ArityEvaluator {
-
- private String className;
-
- private String methodName;
-
- public ArityEvaluator(String className, String methodName) {
- this.className = className;
- this.methodName = methodName;
- }
-
- public int evaluateRequiredArity(Arity arity, boolean isModule) {
- int value = arity.getValue();
- if (value >= 0)
- return value;
- if (value < -1)
- return -(1 + value);
- String script;
- if (methodName.equals("initialize")) {
- script = className + ".new";
- return evaluateArity(script, true);
- }
- if (isModule) {
- script = className + '.' + methodName;
- return evaluateArity(script, true);
- }
- int constructorArity = evaluateArity(className + ".new", false);
- String constructorArgs = getDummyArgs(constructorArity);
- script = "x = " + className + ".new" + constructorArgs + "\nx." + methodName;
- return evaluateArity(script, true);
- }
-
- private int evaluateArity(String scriptPart, boolean ignoreExceptions) {
- int arityGuess = 0;
- boolean success = false;
- while (!success) {
- String args = getDummyArgs(arityGuess);
- String script = scriptPart + args;
- String error = getScriptEvaluationError(script, ignoreExceptions);
- if (error.equals(""))
- success = true;
- else {
- int errorGuess = getArityFromError(error);
- if (errorGuess > arityGuess)
- arityGuess = errorGuess;
- else
- arityGuess++;
- }
- }
- return arityGuess;
- }
-
- private String getScriptEvaluationError(String script, boolean ignoreExceptions) {
- Node node = NodeProvider.getRootNode("test", script);
- try {
- RefactoringPlugin.getRuby().eval(node);
- } catch (RaiseException e) {
- RubyClass metaClass = e.getException().getMetaClass();
- if (metaClass.getName().equalsIgnoreCase(Constants.ARGUMENT_ERROR))
- return e.getMessage();
- else if (!ignoreExceptions)
- throw e;
- }
- return "";
- }
-
- private int getArityFromError(String error) {
- Pattern pattern = Pattern.compile("\\(([0-9])+ for ([0-9]+)\\)");
- Matcher matcher = pattern.matcher(error);
- if (!matcher.find())
- return 0;
- return Integer.parseInt(matcher.group(2));
- }
-
- private String getDummyArgs(int argGuess) {
- if (argGuess == 0)
- return "";
- StringBuilder args = new StringBuilder(" ");
- for (int i = 0; i < argGuess; i++)
- args.append("\"\", ");
- return args.substring(0, args.length() - 2);
- }
-
-}
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-03-05 01:24:39 UTC (rev 2081)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/util/NodeUtil.java 2007-03-05 08:59:46 UTC (rev 2082)
@@ -62,7 +62,7 @@
return null;
}
- public static boolean nodeAssignableFrom(Node n, Class<?>... klasses) {
+ public static boolean nodeAssignableFrom(Node n, Class... klasses) {
if(n == null) {
return false;
}
Modified: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_22.result.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_22.result.rb 2007-03-05 01:24:39 UTC (rev 2081)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_22.result.rb 2007-03-05 08:59:46 UTC (rev 2082)
@@ -1,9 +1,9 @@
def method1 arg0, arg1
- dd
+ method1 dd, 1
i = "asdf"
i += 1
end
def dd
- method1(0, 1)
+ 0
end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_23.result.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_23.result.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_23.result.rb 2007-03-05 08:59:46 UTC (rev 2082)
@@ -0,0 +1,9 @@
+def ddd
+
+ for i in [1, 2, 3, 4]
+ p i
+ break
+ end
+end
+
+ddd
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_23.source.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_23.source.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_23.source.rb 2007-03-05 08:59:46 UTC (rev 2082)
@@ -0,0 +1,4 @@
+for i in [1,2,3,4]
+ p i
+ break
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_23.test_properties
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_23.test_properties (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_23.test_properties 2007-03-05 08:59:46 UTC (rev 2082)
@@ -0,0 +1,4 @@
+start=29
+end=29
+name=ddd
+visibility=none
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_24.result.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_24.result.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_24.result.rb 2007-03-05 08:59:46 UTC (rev 2082)
@@ -0,0 +1,10 @@
+def ddd
+
+ for i in [1, 2, 3, 4]
+ p i
+ break
+ p i
+ end
+end
+
+ddd
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_24.source.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_24.source.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_24.source.rb 2007-03-05 08:59:46 UTC (rev 2082)
@@ -0,0 +1,5 @@
+for i in [1,2,3,4]
+ p i
+ break
+ p i
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_24.test_properties
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_24.test_properties (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_24.test_properties 2007-03-05 08:59:46 UTC (rev 2082)
@@ -0,0 +1,4 @@
+start=21
+end=38
+name=ddd
+visibility=none
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_25.result.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_25.result.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_25.result.rb 2007-03-05 08:59:46 UTC (rev 2082)
@@ -0,0 +1,7 @@
+def ddd
+ loop do
+ redo
+ end
+end
+
+ddd
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_25.source.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_25.source.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_25.source.rb 2007-03-05 08:59:46 UTC (rev 2082)
@@ -0,0 +1,3 @@
+loop do
+ redo
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_25.test_properties
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_25.test_properties (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_25.test_properties 2007-03-05 08:59:46 UTC (rev 2082)
@@ -0,0 +1,4 @@
+start=13
+end=13
+name=ddd
+visibility=none
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_26.result.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_26.result.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_26.result.rb 2007-03-05 08:59:46 UTC (rev 2082)
@@ -0,0 +1,7 @@
+def dd
+ while line = gets
+ next
+ end
+end
+
+dd
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_26.source.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_26.source.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_26.source.rb 2007-03-05 08:59:46 UTC (rev 2082)
@@ -0,0 +1,3 @@
+while line = gets
+ next
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_26.test_properties
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_26.test_properties (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_26.test_properties 2007-03-05 08:59:46 UTC (rev 2082)
@@ -0,0 +1,4 @@
+start=21
+end=22
+name=dd
+visibility=none
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_27.result.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_27.result.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_27.result.rb 2007-03-05 08:59:46 UTC (rev 2082)
@@ -0,0 +1,8 @@
+def ddd
+ [1, 2, 3].each do |i|
+ puts i
+ retry
+ end
+end
+
+ddd
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_27.source.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_27.source.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_27.source.rb 2007-03-05 08:59:46 UTC (rev 2082)
@@ -0,0 +1,4 @@
+[1,2,3].each do |i|
+ puts i
+ retry
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_27.test_properties
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_27.test_properties (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractmethod/extract_method_test_27.test_properties 2007-03-05 08:59:46 UTC (rev 2082)
@@ -0,0 +1,4 @@
+start=32
+end=32
+name=ddd
+visibility=none
\ No newline at end of file
Deleted: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/util/TC_ArityEvaluator.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/util/TC_ArityEvaluator.java 2007-03-05 01:24:39 UTC (rev 2081)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/util/TC_ArityEvaluator.java 2007-03-05 08:59:46 UTC (rev 2082)
@@ -1,90 +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 Lukas Felber <lf...@hs...>
- *
- * 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.util;
-
-import junit.framework.TestCase;
-
-import org.jruby.internal.runtime.methods.AbstractMethod;
-import org.jruby.runtime.Arity;
-import org.rubypeople.rdt.refactoring.RefactoringPlugin;
-import org.rubypeople.rdt.refactoring.signatureprovider.JRubyClassSignatureProvider;
-import org.rubypeople.rdt.refactoring.util.ArityEvaluator;
-import org.rubypeople.rdt.refactoring.util.Constants;
-
-public class TC_ArityEvaluator extends TestCase
-{
-
- public void testClassString()
- {
- check("String", Constants.CONSTRUCTOR_NAME, 0);
- }
-
- public void testClassDir()
- {
- check("Dir", Constants.CONSTRUCTOR_NAME, 1);
- }
-
- public void testClassHash()
- {
- check("Hash", Constants.CONSTRUCTOR_NAME, 0);
- }
-
- public void testClassRange()
- {
- check("Range", Constants.CONSTRUCTOR_NAME, 2);
- }
-
- public void testClassFile()
- {
- check("File", Constants.CONSTRUCTOR_NAME, 1);
- }
-
- private void check(String className, String methodName, int expectedValue)
- {
- ArityEvaluator arityEvaluator = new ArityEvaluator(className,
- methodName);
- Arity arity = getArity(className, methodName);
- assertEquals(expectedValue, arityEvaluator.evaluateRequiredArity(arity,
- isModule(className)));
- }
-
- private boolean isModule(String className)
- {
- return RefactoringPlugin.getRuby().getClass(className).isIncluded();
- }
-
- private Arity getArity(String className, String methodName)
- {
- JRubyClassSignatureProvider signatureProvider = new JRubyClassSignatureProvider(
- RefactoringPlugin.getRuby().getClass(className));
- AbstractMethod method = signatureProvider.getMethod(methodName);
- assertNotNull(method);
- return method.getArity();
- }
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|