You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
(41) |
Apr
(9) |
May
|
Jun
|
Jul
(39) |
Aug
(38) |
Sep
(135) |
Oct
(220) |
Nov
(75) |
Dec
(74) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(44) |
Feb
(160) |
Mar
(49) |
Apr
(69) |
May
(40) |
Jun
(52) |
Jul
(47) |
Aug
(51) |
Sep
(19) |
Oct
(22) |
Nov
(36) |
Dec
(76) |
| 2007 |
Jan
(154) |
Feb
(165) |
Mar
(186) |
Apr
(143) |
May
(175) |
Jun
(133) |
Jul
(203) |
Aug
(177) |
Sep
(136) |
Oct
|
Nov
|
Dec
|
|
From: <caw...@us...> - 2007-02-23 19:57:58
|
Revision: 2022
http://svn.sourceforge.net/rubyeclipse/?rev=2022&view=rev
Author: cawilliams
Date: 2007-02-23 11:57:57 -0800 (Fri, 23 Feb 2007)
Log Message:
-----------
refactor out some common code (to Util which may not be the best place for it) so we can handle code completion for variables whose declared type is a fully qualified/complex/namespaced name).
an example is invoking method completion on a avriable whose type is "TMail::Mail"
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Util.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultTypeInferrer.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java 2007-02-23 19:38:55 UTC (rev 2021)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java 2007-02-23 19:57:57 UTC (rev 2022)
@@ -16,6 +16,7 @@
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.internal.core.search.ExperimentalIndex;
+import org.rubypeople.rdt.internal.core.util.Util;
public class RubyElementRequestor {
@@ -27,7 +28,16 @@
this.script = script;
}
- public IType[] findType(String typeName) {
+ public IType[] findType(String fullyQualifiedName) {
+ IType[] types = findTypeWithSimpleName(Util.getSimpleName(fullyQualifiedName));
+ List<IType> matches = new ArrayList<IType>();
+ for (int i = 0; i < types.length; i++) {
+ if (Util.parentsMatch(types[i], fullyQualifiedName)) matches.add(types[i]);
+ }
+ return matches.toArray(new IType[matches.size()]);
+ }
+
+ private IType[] findTypeWithSimpleName(String typeName) {
List<IType> types = new ArrayList<IType>();
IRubyProject rubyProject = script.getRubyProject();
try {
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java 2007-02-23 19:38:55 UTC (rev 2021)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java 2007-02-23 19:57:57 UTC (rev 2022)
@@ -25,6 +25,7 @@
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.internal.core.parser.RubyParser;
import org.rubypeople.rdt.internal.core.util.ASTUtil;
@@ -49,16 +50,11 @@
String simpleName = ((Colon2Node)selected).getName();
String fullyQualifiedName = ASTUtil.getFullyQualifiedName((Colon2Node) selected);
IRubyElement element = findChild(simpleName, IRubyElement.TYPE, script);
- if (element != null && parentsMatch((IType)element, fullyQualifiedName)) {
+ if (element != null && Util.parentsMatch((IType)element, fullyQualifiedName)) {
return new IRubyElement[] { element };
}
RubyElementRequestor completer = new RubyElementRequestor(script);
- IType[] types = completer.findType(simpleName);
- List<IType> matches = new ArrayList<IType>();
- for (int i = 0; i < types.length; i++) {
- if (parentsMatch(types[i], fullyQualifiedName)) matches.add(types[i]);
- }
- return matches.toArray(new IType[matches.size()]);
+ return completer.findType(fullyQualifiedName);
}
if (selected instanceof ConstNode) {
ConstNode constNode = (ConstNode) selected;
@@ -120,22 +116,6 @@
return new IRubyElement[0];
}
- private boolean parentsMatch(IType type, String fullyQualifiedName) {
- String[] names = getTrimmedSimpleNames(fullyQualifiedName);
- for (int i = names.length - 2; i >= 0; i--) { // Start at second last name piece, go all the way to first
- IType parent = type.getDeclaringType();
- if (parent == null || !names[i].equals(parent.getElementName())) {
- return false;
- }
- type = parent;
- }
- return true;
- }
-
- private String[] getTrimmedSimpleNames(String fullyQualifiedName) {
- return fullyQualifiedName.split("::");
- }
-
private IRubyElement findChild(String name, int type,
IParent parent) {
try {
@@ -150,8 +130,7 @@
}
}
} catch (RubyModelException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ RubyCore.log(e);
}
return null;
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Util.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Util.java 2007-02-23 19:38:55 UTC (rev 2021)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Util.java 2007-02-23 19:57:57 UTC (rev 2022)
@@ -29,6 +29,7 @@
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyModelStatusConstants;
import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.IType;
import org.rubypeople.rdt.core.RubyConventions;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
@@ -42,6 +43,7 @@
private static boolean ENABLE_RUBY_LIKE_EXTENSIONS = true;
private static char[][] RUBY_LIKE_EXTENSIONS;
private static char[][] RUBY_LIKE_FILENAMES;
+ private static final String NAMESPACE_DELIMETER = "::";
private Util() {
// cannot be instantiated
@@ -769,4 +771,25 @@
return true;
}
+ public static String getSimpleName(String fullyQualifiedName) {
+ String[] names = getTypeNameParts(fullyQualifiedName);
+ return names[names.length - 1];
+ }
+
+ public static boolean parentsMatch(IType type, String fullyQualifiedName) {
+ String[] names = getTypeNameParts(fullyQualifiedName);
+ for (int i = names.length - 2; i >= 0; i--) { // Start at second last name piece, go all the way to first
+ IType parent = type.getDeclaringType();
+ if (parent == null || !names[i].equals(parent.getElementName())) {
+ return false;
+ }
+ type = parent;
+ }
+ return true;
+ }
+
+ private static String[] getTypeNameParts(String fullyQualifiedName) {
+ return fullyQualifiedName.split(NAMESPACE_DELIMETER);
+ }
+
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultTypeInferrer.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultTypeInferrer.java 2007-02-23 19:38:55 UTC (rev 2021)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultTypeInferrer.java 2007-02-23 19:57:57 UTC (rev 2022)
@@ -20,6 +20,7 @@
import org.jruby.ast.LocalVarNode;
import org.jruby.ast.Node;
import org.jruby.ast.RootNode;
+import org.jruby.ast.VCallNode;
import org.rubypeople.rdt.internal.core.parser.RubyParser;
import org.rubypeople.rdt.internal.core.util.ASTUtil;
import org.rubypeople.rdt.internal.ti.data.LiteralNodeTypeNames;
@@ -201,14 +202,18 @@
}
private void tryLocalVarNode(Node node, List<ITypeGuess> guesses) {
+ if (node instanceof VCallNode) {
+ // FIXME How do we handle local variables who show up as VCallNodes?
+ return;
+ }
+
if (!(node instanceof LocalVarNode))
return;
LocalVarNode localVarNode = (LocalVarNode) node;
int nodeStart = node.getPosition().getStartOffset();
final String localVarName = TypeInferenceHelper.Instance().getVarName(localVarNode);
- // See if it has been assigned to, earlier [todo: in this local
- // scope].
+ // See if it has been assigned to, earlier [TODO: in this local scope].
// Find first assignment to this var name that occurs before the
// reference
// TODO: This will find assignments in other local scopes that
@@ -281,7 +286,7 @@
if (callNode.getReceiverNode() instanceof ConstNode) {
name = ((ConstNode) callNode.getReceiverNode()).getName();
} else if (callNode.getReceiverNode() instanceof Colon2Node) {
- ASTUtil.getFullyQualifiedName((Colon2Node) node);
+ name = ASTUtil.getFullyQualifiedName((Colon2Node) callNode.getReceiverNode());
}
if (name != null)
guesses.add(new BasicTypeGuess(name, 100));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-02-23 19:38:56
|
Revision: 2021
http://svn.sourceforge.net/rubyeclipse/?rev=2021&view=rev
Author: cawilliams
Date: 2007-02-23 11:38:55 -0800 (Fri, 23 Feb 2007)
Log Message:
-----------
rename the class to better representw hat it does (and avoid confusion with actual ConstNodes)
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/data/LiteralNodeTypeNames.java
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/data/LiteralNodeTypeNames.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/data/LiteralNodeTypeNames.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/data/LiteralNodeTypeNames.java 2007-02-23 19:38:55 UTC (rev 2021)
@@ -0,0 +1,34 @@
+package org.rubypeople.rdt.internal.ti.data;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Maps from JRuby AST Literal Node classnames to the Ruby type they represent.
+ * @author Jason
+ *
+ */
+public class LiteralNodeTypeNames {
+ public static String get(String nodeType)
+ {
+ return CONST_NODE_TYPE_NAMES.get(nodeType);
+ }
+
+ private static final Map<String,String> CONST_NODE_TYPE_NAMES = new HashMap<String,String>();
+ static {
+ CONST_NODE_TYPE_NAMES.put("FixnumNode", "Fixnum");
+ CONST_NODE_TYPE_NAMES.put("DStrNode", "String");
+ CONST_NODE_TYPE_NAMES.put("StrNode", "String");
+ CONST_NODE_TYPE_NAMES.put("ZArrayNode", "Array");
+ CONST_NODE_TYPE_NAMES.put("ArrayNode", "Array");
+ CONST_NODE_TYPE_NAMES.put("TrueNode", "TrueClass");
+ CONST_NODE_TYPE_NAMES.put("FalseNode", "FalseClass");
+ CONST_NODE_TYPE_NAMES.put("NilNode", "NilClass");
+ CONST_NODE_TYPE_NAMES.put("FloatNode", "Float");
+ CONST_NODE_TYPE_NAMES.put("BignumNode", "Bignum");
+ CONST_NODE_TYPE_NAMES.put("SymbolNode", "Symbol");
+ CONST_NODE_TYPE_NAMES.put("DSymbolNode","Symbol");
+ CONST_NODE_TYPE_NAMES.put("HashNode", "Hash");
+ CONST_NODE_TYPE_NAMES.put("RegexpNode", "Regexp");
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-02-23 19:37:34
|
Revision: 2020
http://svn.sourceforge.net/rubyeclipse/?rev=2020&view=rev
Author: cawilliams
Date: 2007-02-23 11:37:32 -0800 (Fri, 23 Feb 2007)
Log Message:
-----------
clean up some of the Type Inferrencing stuf
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DataFlowTypeInferrer.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultTypeInferrer.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/TypeInferenceVisitor.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/data/ConstNodeTypeNames.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DataFlowTypeInferrer.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DataFlowTypeInferrer.java 2007-02-23 19:19:38 UTC (rev 2019)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DataFlowTypeInferrer.java 2007-02-23 19:37:32 UTC (rev 2020)
@@ -28,7 +28,7 @@
import org.jruby.ast.SelfNode;
import org.jruby.ast.VCallNode;
import org.rubypeople.rdt.internal.core.parser.RubyParser;
-import org.rubypeople.rdt.internal.ti.data.ConstNodeTypeNames;
+import org.rubypeople.rdt.internal.ti.data.LiteralNodeTypeNames;
import org.rubypeople.rdt.internal.ti.util.ClosestSpanningNodeLocator;
import org.rubypeople.rdt.internal.ti.util.INodeAcceptor;
import org.rubypeople.rdt.internal.ti.util.MethodDefinitionLocator;
@@ -194,15 +194,15 @@
}
private boolean isConstantNode(Node node) {
- return ( node instanceof ConstNode ) || ( null != ConstNodeTypeNames.get(node.getClass().getSimpleName() ) );
+ return ( node instanceof ConstNode ) || ( null != LiteralNodeTypeNames.get(node.getClass().getSimpleName() ) );
}
- // Look up from ConstNodeTypeNames
+ // Look up from LiteralNodeTypeNames
private ITypeGuess getConstantNodeType(Node node) {
if ( node instanceof ConstNode ) {
return new BasicTypeGuess( ((ConstNode)node).getName(), 100 );
} else {
- return new BasicTypeGuess( ConstNodeTypeNames.get(node.getClass().getSimpleName()), 100 );
+ return new BasicTypeGuess( LiteralNodeTypeNames.get(node.getClass().getSimpleName()), 100 );
}
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultTypeInferrer.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultTypeInferrer.java 2007-02-23 19:19:38 UTC (rev 2019)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultTypeInferrer.java 2007-02-23 19:37:32 UTC (rev 2020)
@@ -7,6 +7,7 @@
import org.jruby.ast.ArgsNode;
import org.jruby.ast.ArgumentNode;
import org.jruby.ast.CallNode;
+import org.jruby.ast.Colon2Node;
import org.jruby.ast.ConstNode;
import org.jruby.ast.DefnNode;
import org.jruby.ast.DefsNode;
@@ -20,7 +21,8 @@
import org.jruby.ast.Node;
import org.jruby.ast.RootNode;
import org.rubypeople.rdt.internal.core.parser.RubyParser;
-import org.rubypeople.rdt.internal.ti.data.ConstNodeTypeNames;
+import org.rubypeople.rdt.internal.core.util.ASTUtil;
+import org.rubypeople.rdt.internal.ti.data.LiteralNodeTypeNames;
import org.rubypeople.rdt.internal.ti.data.TypicalMethodReturnNames;
import org.rubypeople.rdt.internal.ti.util.FirstPrecursorNodeLocator;
import org.rubypeople.rdt.internal.ti.util.INodeAcceptor;
@@ -28,6 +30,7 @@
public class DefaultTypeInferrer implements ITypeInferrer {
+ private static final String CONSTRUCTOR_INVOKE_NAME = "new";
private RootNode rootNode;
/**
@@ -55,7 +58,7 @@
*/
private List<ITypeGuess> infer(Node node) {
List<ITypeGuess> guesses = new LinkedList<ITypeGuess>();
- tryConstantNode(node, guesses);
+ tryLiteralNode(node, guesses);
tryAsgnNode(node, guesses);
// TODO refactor these 3 by common features into 1 (or 1+3) method(s)
@@ -77,16 +80,16 @@
}
/**
- * Infers type if node is a constant node; i.e. 5, 'foo', [1,2,3]
+ * Infers type if node is a literal node; i.e. 5, 'foo', [1,2,3]
*
* @param node
* Node to infer type of.
* @param guesses
* List of ITypeGuess objects to insert guesses into.
*/
- private void tryConstantNode(Node node, List<ITypeGuess> guesses) {
+ private void tryLiteralNode(Node node, List<ITypeGuess> guesses) {
// Try seeing if the rvalue is a constant (5, "foo", [1,2,3], etc.)
- String concreteGuess = ConstNodeTypeNames.get(node.getClass().getSimpleName());
+ String concreteGuess = LiteralNodeTypeNames.get(node.getClass().getSimpleName());
if (concreteGuess != null) {
guesses.add(new BasicTypeGuess(concreteGuess, 100));
}
@@ -119,185 +122,177 @@
}
private void tryInstVarNode(Node node, List<ITypeGuess> guesses) {
- if (node instanceof InstVarNode) {
- final InstVarNode instVarNode = (InstVarNode) node;
- int nodeStart = node.getPosition().getStartOffset();
+ if (!(node instanceof InstVarNode))
+ return;
+ final InstVarNode instVarNode = (InstVarNode) node;
+ int nodeStart = node.getPosition().getStartOffset();
- // todo: see if there is attr_reader/attr_writer, maybe?
- // todo: find calls to the reader/writers
- // todo: for STI on InstVar, find references within this ClassNode
- // to this InstVar... record 'em
+ // TODO: see if there is attr_reader/attr_writer, maybe?
+ // TODO: find calls to the reader/writers
+ // TODO: for STI on InstVar, find references within this ClassNode
+ // to this InstVar... record 'em
- // Find first assignment to this var name that occurs before the
- // reference
- // todo: This will find assignments in other local scopes that
- // precede this reference but have the same variable name.
- // To mitigate, ensure that the closest spanning ScopeNode for both
- // this LocalVarNode and the AsgnNode are the name ScopeNode.
- // Or scopingNode. Still not sure whether IterNodes count or not...
- // silly block-local-var ambiguity ;)
- Node initialAssignmentNode = FirstPrecursorNodeLocator.Instance().findFirstPrecursor(rootNode, nodeStart, new INodeAcceptor() {
- public boolean doesAccept(Node node) {
- String name = null;
- if (node instanceof LocalAsgnNode)
- name = ((LocalAsgnNode) node).getName();
- if (node instanceof InstAsgnNode)
- name = ((InstAsgnNode) node).getName();
- if (node instanceof GlobalAsgnNode)
- name = ((GlobalAsgnNode) node).getName();
- return (name != null && name.equals(instVarNode.getName()));
- /**
- * refactor to common INodeAcceptor for
- * instVarName,localVarName,globalVarName
- */
- }
- });
- if (initialAssignmentNode != null) {
- tryAsgnNode(initialAssignmentNode, guesses);
+ // Find first assignment to this var name that occurs before the
+ // reference
+ // todo: This will find assignments in other local scopes that
+ // precede this reference but have the same variable name.
+ // To mitigate, ensure that the closest spanning ScopeNode for both
+ // this LocalVarNode and the AsgnNode are the name ScopeNode.
+ // Or scopingNode. Still not sure whether IterNodes count or not...
+ // silly block-local-var ambiguity ;)
+ Node initialAssignmentNode = FirstPrecursorNodeLocator.Instance().findFirstPrecursor(rootNode, nodeStart, new INodeAcceptor() {
+ public boolean doesAccept(Node node) {
+ String name = null;
+ if (node instanceof LocalAsgnNode)
+ name = ((LocalAsgnNode) node).getName();
+ if (node instanceof InstAsgnNode)
+ name = ((InstAsgnNode) node).getName();
+ if (node instanceof GlobalAsgnNode)
+ name = ((GlobalAsgnNode) node).getName();
+ return (name != null && name.equals(instVarNode.getName()));
+ /**
+ * refactor to common INodeAcceptor for
+ * instVarName,localVarName,globalVarName
+ */
}
+ });
+ if (initialAssignmentNode != null) {
+ tryAsgnNode(initialAssignmentNode, guesses);
}
}
private void tryGlobalVarNode(Node node, List<ITypeGuess> guesses) {
- if (node instanceof GlobalVarNode) {
- final GlobalVarNode globalVarNode = (GlobalVarNode) node;
- int nodeStart = node.getPosition().getStartOffset();
+ if (!(node instanceof GlobalVarNode))
+ return;
+ final GlobalVarNode globalVarNode = (GlobalVarNode) node;
+ int nodeStart = node.getPosition().getStartOffset();
- // todo: for STI on GlobalVar, find references within this ClassNode
- // to this GlobalVar... record 'em
- // todo: p.s. globals are low-priority.
+ // TODO: for STI on GlobalVar, find references within this ClassNode
+ // to this GlobalVar... record 'em
+ // TODO: p.s. globals are low-priority.
- // Find first assignment to this var name that occurs before the
- // reference
- // todo: This will find assignments in other local scopes that
- // precede this reference but have the same variable name.
- // To mitigate, ensure that the closest spanning ScopeNode for both
- // this LocalVarNode and the AsgnNode are the name ScopeNode.
- // Or scopingNode. Still not sure whether IterNodes count or not...
- // silly block-local-var ambiguity ;)
- Node initialAssignmentNode = FirstPrecursorNodeLocator.Instance().findFirstPrecursor(rootNode, nodeStart, new INodeAcceptor() {
- public boolean doesAccept(Node node) {
- String name = null;
- if (node instanceof LocalAsgnNode)
- name = ((LocalAsgnNode) node).getName();
- if (node instanceof InstAsgnNode)
- name = ((InstAsgnNode) node).getName();
- if (node instanceof GlobalAsgnNode)
- name = ((GlobalAsgnNode) node).getName();
- return (name != null && name.equals(globalVarNode.getName()));
- /**
- * refactor to common INodeAcceptor for
- * instVarName,localVarName,globalVarName
- */
- }
- });
- if (initialAssignmentNode != null) {
- tryAsgnNode(initialAssignmentNode, guesses);
+ // Find first assignment to this var name that occurs before the
+ // reference
+ // TODO: This will find assignments in other local scopes that
+ // precede this reference but have the same variable name.
+ // To mitigate, ensure that the closest spanning ScopeNode for both
+ // this LocalVarNode and the AsgnNode are the name ScopeNode.
+ // Or scopingNode. Still not sure whether IterNodes count or not...
+ // silly block-local-var ambiguity ;)
+ Node initialAssignmentNode = FirstPrecursorNodeLocator.Instance().findFirstPrecursor(rootNode, nodeStart, new INodeAcceptor() {
+ public boolean doesAccept(Node node) {
+ String name = null;
+ if (node instanceof LocalAsgnNode)
+ name = ((LocalAsgnNode) node).getName();
+ if (node instanceof InstAsgnNode)
+ name = ((InstAsgnNode) node).getName();
+ if (node instanceof GlobalAsgnNode)
+ name = ((GlobalAsgnNode) node).getName();
+ return (name != null && name.equals(globalVarNode.getName()));
+ /**
+ * refactor to common INodeAcceptor for
+ * instVarName,localVarName,globalVarName
+ */
}
+ });
+ if (initialAssignmentNode != null) {
+ tryAsgnNode(initialAssignmentNode, guesses);
}
}
private void tryLocalVarNode(Node node, List<ITypeGuess> guesses) {
- // System.out.println(node.getClass().getName());
- if (node instanceof LocalVarNode) {
- LocalVarNode localVarNode = (LocalVarNode) node;
- int nodeStart = node.getPosition().getStartOffset();
- final String localVarName = TypeInferenceHelper.Instance().getVarName(localVarNode);
+ if (!(node instanceof LocalVarNode))
+ return;
+ LocalVarNode localVarNode = (LocalVarNode) node;
+ int nodeStart = node.getPosition().getStartOffset();
+ final String localVarName = TypeInferenceHelper.Instance().getVarName(localVarNode);
- // See if it has been assigned to, earlier [todo: in this local
- // scope].
- // Find first assignment to this var name that occurs before the
- // reference
- // todo: This will find assignments in other local scopes that
- // precede this reference but have the same variable name.
- // To mitigate, ensure that the closest spanning ScopeNode for both
- // this LocalVarNode and the AsgnNode are the name ScopeNode.
- // Or scopingNode. Still not sure whether IterNodes count or not...
- // silly block-local-var ambiguity ;)
- Node initialAssignmentNode = FirstPrecursorNodeLocator.Instance().findFirstPrecursor(rootNode, nodeStart, new INodeAcceptor() {
- public boolean doesAccept(Node node) {
- String name = null;
- if (node instanceof LocalAsgnNode)
- name = ((LocalAsgnNode) node).getName();
- if (node instanceof InstAsgnNode)
- name = ((InstAsgnNode) node).getName();
- if (node instanceof GlobalAsgnNode)
- name = ((GlobalAsgnNode) node).getName();
- return (name != null && name.equals(localVarName));
- }
- });
- if (initialAssignmentNode != null) {
- tryAsgnNode(initialAssignmentNode, guesses);
+ // See if it has been assigned to, earlier [todo: in this local
+ // scope].
+ // Find first assignment to this var name that occurs before the
+ // reference
+ // TODO: This will find assignments in other local scopes that
+ // precede this reference but have the same variable name.
+ // To mitigate, ensure that the closest spanning ScopeNode for both
+ // this LocalVarNode and the AsgnNode are the name ScopeNode.
+ // Or scopingNode. Still not sure whether IterNodes count or not...
+ // silly block-local-var ambiguity ;)
+ Node initialAssignmentNode = FirstPrecursorNodeLocator.Instance().findFirstPrecursor(rootNode, nodeStart, new INodeAcceptor() {
+ public boolean doesAccept(Node node) {
+ String name = null;
+ if (node instanceof LocalAsgnNode)
+ name = ((LocalAsgnNode) node).getName();
+ if (node instanceof InstAsgnNode)
+ name = ((InstAsgnNode) node).getName();
+ if (node instanceof GlobalAsgnNode)
+ name = ((GlobalAsgnNode) node).getName();
+ return (name != null && name.equals(localVarName));
}
- // See if it is a param into this scope
- ArgsNode argsNode = (ArgsNode) FirstPrecursorNodeLocator.Instance().findFirstPrecursor(rootNode, nodeStart, new INodeAcceptor() {
+ });
+ if (initialAssignmentNode != null) {
+ tryAsgnNode(initialAssignmentNode, guesses);
+ }
+ // See if it is a param into this scope
+ ArgsNode argsNode = (ArgsNode) FirstPrecursorNodeLocator.Instance().findFirstPrecursor(rootNode, nodeStart, new INodeAcceptor() {
+ public boolean doesAccept(Node node) {
+ return ((node instanceof ArgsNode) && (doesArgsNodeContainsVariable((ArgsNode) node, localVarName)));
+ }
+ });
+ // If so, find its enclosing method
+ if (argsNode != null) {
+ // Find enclosing method
+ Node defNode = FirstPrecursorNodeLocator.Instance().findFirstPrecursor(rootNode, nodeStart, new INodeAcceptor() {
public boolean doesAccept(Node node) {
- return ((node instanceof ArgsNode) && (doesArgsNodeContainsVariable((ArgsNode) node, localVarName)));
+ ArgsNode argsNode = null;
+ if (node instanceof DefnNode)
+ argsNode = ((DefnNode) node).getArgsNode();
+ if (node instanceof DefsNode)
+ argsNode = ((DefsNode) node).getArgsNode();
+ return ((argsNode != null) && (doesArgsNodeContainsVariable(argsNode, localVarName)));
}
});
- // If so, find its enclosing method
- if (argsNode != null) {
- int argNumber = getArgumentIndex(argsNode, localVarName);
- // System.out.println("Variable " + localVarName + " is the " +
- // argNumber + "th argument to the enclosing method ");
-
- // Find enclosing method
- Node defNode = FirstPrecursorNodeLocator.Instance().findFirstPrecursor(rootNode, nodeStart, new INodeAcceptor() {
- public boolean doesAccept(Node node) {
- // System.out.println("Looking for enclosing method,
- // checking: " + node.getClass().getName() + "[" +
- // node.getPosition().getStartOffset() + ".." +
- // node.getPosition().getEndOffset() + "]" );
- ArgsNode argsNode = null;
- if (node instanceof DefnNode)
- argsNode = ((DefnNode) node).getArgsNode();
- if (node instanceof DefsNode)
- argsNode = ((DefsNode) node).getArgsNode();
- return ((argsNode != null) && (doesArgsNodeContainsVariable(argsNode, localVarName)));
- }
- });
- if (defNode != null) {
- String methodName = null;
- if (defNode instanceof DefnNode)
- methodName = ((DefnNode) defNode).getName();
- if (defNode instanceof DefsNode)
- methodName = ((DefsNode) defNode).getName();
-
- // System.out.println("Variable " + localVarName + " is the
- // " + argNumber + "th argument to method " + methodName );
-
- // Find all invocations of the surrounding method.
- // todo: from easiest to hardest:
- // It may be a global function, where simply a CallNode
- // where method name must be matched.
- // It may be a DefsNode static class method, where a
- // CallNode whose receiverNode is a ConstNode whose name is
- // the surrounding class
- // It may be an DefnNode method defined in a class, where a
- // CallNode whose receiverNode must be type-matched to the
- // surrounding class
-
- }
+ if (defNode != null) {
+ String methodName = null;
+ if (defNode instanceof DefnNode)
+ methodName = ((DefnNode) defNode).getName();
+ if (defNode instanceof DefsNode)
+ methodName = ((DefsNode) defNode).getName();
+ // Find all invocations of the surrounding method.
+ // TODO: from easiest to hardest:
+ // It may be a global function, where simply a CallNode
+ // where method name must be matched.
+ // It may be a DefsNode static class method, where a
+ // CallNode whose receiverNode is a ConstNode whose name is
+ // the surrounding class
+ // It may be an DefnNode method defined in a class, where a
+ // CallNode whose receiverNode must be type-matched to the
+ // surrounding class
}
}
}
private void tryWellKnownMethodCalls(Node node, List<ITypeGuess> guesses) {
- if (node instanceof CallNode) {
- CallNode callNode = (CallNode) node;
-
- String method = callNode.getName();
- if (method.equals("new") && callNode.getReceiverNode() instanceof ConstNode) {
- guesses.add(new BasicTypeGuess(((ConstNode) callNode.getReceiverNode()).getName(), 100));
- } else {
- // todo: this NEEDS to be done with a multimap and various
- // confidences for each. i.e. X.slice, X is 50/50 Array or
- // String
- String methodReturnTypeGuess = TypicalMethodReturnNames.get(method);
- if (methodReturnTypeGuess != null) {
- guesses.add(new BasicTypeGuess(methodReturnTypeGuess, 100));
- }
+ if (!(node instanceof CallNode))
+ return;
+ CallNode callNode = (CallNode) node;
+ String method = callNode.getName();
+ if (method.equals(CONSTRUCTOR_INVOKE_NAME)) {
+ String name = null;
+ if (callNode.getReceiverNode() instanceof ConstNode) {
+ name = ((ConstNode) callNode.getReceiverNode()).getName();
+ } else if (callNode.getReceiverNode() instanceof Colon2Node) {
+ ASTUtil.getFullyQualifiedName((Colon2Node) node);
}
+ if (name != null)
+ guesses.add(new BasicTypeGuess(name, 100));
+ } else {
+ // TODO: this NEEDS to be done with a multimap and various
+ // confidences for each. i.e. X.slice, X is 50/50 Array or
+ // String
+ String methodReturnTypeGuess = TypicalMethodReturnNames.get(method);
+ if (methodReturnTypeGuess != null) {
+ guesses.add(new BasicTypeGuess(methodReturnTypeGuess, 100));
+ }
}
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/TypeInferenceVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/TypeInferenceVisitor.java 2007-02-23 19:19:38 UTC (rev 2019)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/TypeInferenceVisitor.java 2007-02-23 19:37:32 UTC (rev 2020)
@@ -12,7 +12,7 @@
import org.jruby.ast.Node;
import org.jruby.evaluator.Instruction;
import org.rubypeople.rdt.internal.core.parser.InOrderVisitor;
-import org.rubypeople.rdt.internal.ti.data.ConstNodeTypeNames;
+import org.rubypeople.rdt.internal.ti.data.LiteralNodeTypeNames;
import org.rubypeople.rdt.internal.ti.data.TypicalMethodReturnNames;
public class TypeInferenceVisitor extends InOrderVisitor {
@@ -180,7 +180,7 @@
Node valueNode = iVisited.getValueNode();
// Try seeing if the rvalue is a constant (5, "foo", [1,2,3], etc.)
- String concreteGuess = ConstNodeTypeNames.get(valueNode.getClass().getSimpleName());
+ String concreteGuess = LiteralNodeTypeNames.get(valueNode.getClass().getSimpleName());
if ( concreteGuess != null )
{
var.getTypeGuesses().add( new BasicTypeGuess( concreteGuess, 100 ) );
Deleted: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/data/ConstNodeTypeNames.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/data/ConstNodeTypeNames.java 2007-02-23 19:19:38 UTC (rev 2019)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/data/ConstNodeTypeNames.java 2007-02-23 19:37:32 UTC (rev 2020)
@@ -1,34 +0,0 @@
-package org.rubypeople.rdt.internal.ti.data;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Maps from JRuby AST Const Node classnames to the Ruby type they represent.
- * @author Jason
- *
- */
-public class ConstNodeTypeNames {
- public static String get(String nodeType)
- {
- return CONST_NODE_TYPE_NAMES.get(nodeType);
- }
-
- private static final Map<String,String> CONST_NODE_TYPE_NAMES = new HashMap<String,String>();
- static {
- CONST_NODE_TYPE_NAMES.put("FixnumNode", "Fixnum");
- CONST_NODE_TYPE_NAMES.put("DStrNode", "String");
- CONST_NODE_TYPE_NAMES.put("StrNode", "String");
- CONST_NODE_TYPE_NAMES.put("ZArrayNode", "Array");
- CONST_NODE_TYPE_NAMES.put("ArrayNode", "Array");
- CONST_NODE_TYPE_NAMES.put("TrueNode", "TrueClass");
- CONST_NODE_TYPE_NAMES.put("FalseNode", "FalseClass");
- CONST_NODE_TYPE_NAMES.put("NilNode", "NilClass");
- CONST_NODE_TYPE_NAMES.put("FloatNode", "Float");
- CONST_NODE_TYPE_NAMES.put("BignumNode", "Bignum");
- CONST_NODE_TYPE_NAMES.put("SymbolNode", "Symbol");
- CONST_NODE_TYPE_NAMES.put("DSymbolNode","Symbol");
- CONST_NODE_TYPE_NAMES.put("HashNode", "Hash");
- CONST_NODE_TYPE_NAMES.put("RegexpNode", "Regexp");
- }
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-02-23 19:19:47
|
Revision: 2019
http://svn.sourceforge.net/rubyeclipse/?rev=2019&view=rev
Author: cawilliams
Date: 2007-02-23 11:19:38 -0800 (Fri, 23 Feb 2007)
Log Message:
-----------
fix empty task markers (to have a quick description)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultOccurrencesFinder.java
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/infoviews/RIView.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchPage.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultOccurrencesFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultOccurrencesFinder.java 2007-02-23 19:15:24 UTC (rev 2018)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultOccurrencesFinder.java 2007-02-23 19:19:38 UTC (rev 2019)
@@ -253,11 +253,7 @@
// Find the search space
Node searchSpace = FirstPrecursorNodeLocator.Instance().findFirstPrecursor(root, orig.getPosition().getStartOffset(), new INodeAcceptor() {
public boolean doesAccept(Node node) {
- return ((node instanceof DefnNode) || (node instanceof DefsNode) /*
- * TODO:
- * Block
- * Body?
- */);
+ return ((node instanceof DefnNode) || (node instanceof DefsNode) ); // TODO: Block Body?
}
});
@@ -302,11 +298,7 @@
// Find the search space
Node searchSpace = FirstPrecursorNodeLocator.Instance().findFirstPrecursor(root, orig.getPosition().getStartOffset(), new INodeAcceptor() {
public boolean doesAccept(Node node) {
- return ((node instanceof DefnNode) || (node instanceof DefsNode) /*
- * TODO:
- * Block
- * Body?
- */);
+ return ((node instanceof DefnNode) || (node instanceof DefsNode) ); // TODO: Block Body?
}
});
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java 2007-02-23 19:15:24 UTC (rev 2018)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java 2007-02-23 19:19:38 UTC (rev 2019)
@@ -275,7 +275,7 @@
try {
System.setProperty(DEBUGGER_ACTIVE_KEY, "true");
- // TODO
+ // TODO Update threads?
//getDebugTarget().updateThreads();
RdtDebugCorePlugin.debug("Waiting for breakpoints.");
while (true) {
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/infoviews/RIView.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/infoviews/RIView.java 2007-02-23 19:15:24 UTC (rev 2018)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/infoviews/RIView.java 2007-02-23 19:19:38 UTC (rev 2019)
@@ -248,7 +248,7 @@
}
}
catch (IOException e) {
- // TODO
+ RubyPlugin.log(e);
}
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchPage.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchPage.java 2007-02-23 19:15:24 UTC (rev 2018)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchPage.java 2007-02-23 19:19:38 UTC (rev 2019)
@@ -103,7 +103,7 @@
settings.put("scope", scope); //$NON-NLS-1$
settings.put("pattern", pattern); //$NON-NLS-1$
settings.put("limitTo", limitTo); //$NON-NLS-1$
- // TODO
+ // TODO set "rubyElement"
// settings.put("rubyElement", rubyElement != null ?
// rubyElement.getHandleIdentifier() : ""); //$NON-NLS-1$
// //$NON-NLS-2$
@@ -146,7 +146,7 @@
int scope = settings.getInt("scope"); //$NON-NLS-1$
int limitTo = settings.getInt("limitTo"); //$NON-NLS-1$
boolean isCaseSensitive = settings.getBoolean("isCaseSensitive"); //$NON-NLS-1$
- // TODO
+ // TODO Get "rubyElement" setting
IRubyElement elem = null; // settings.get("rubyElement") ;
return new SearchPatternData(searchFor, limitTo, pattern, isCaseSensitive, scope,
workingSets);
@@ -391,7 +391,7 @@
// Pattern text + info
Label label = new Label(result, SWT.LEFT);
- // TODO
+ // TODO Use translated string
label.setText("Expression"); //$NON-NLS-1$
// label.setText(SearchMessages.SearchPage_expression_label);
label.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false, 2, 1));
@@ -419,11 +419,12 @@
// Ignore case checkbox
fCaseSensitive = new Button(result, SWT.CHECK);
- // TODO
+ // TODO Use translated string
fCaseSensitive.setText("CaseSensitive"); //$NON-NLS-1$
fCaseSensitive.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
+ // TODO Care about case sensitivity option
// fIsCaseSensitive = fCaseSensitive.getSelection();
}
});
@@ -435,7 +436,7 @@
// private boolean isValidSearchPattern() {
// if (getPattern().length() == 0) { return false; }
- // // TODO
+ // // TODO Validate search patterns
// return true;
// // return SearchPattern.createPattern(getPattern(), getSearchFor(),
// // getLimitTo(), SearchPattern.R_EXACT_MATCH) != null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-02-23 19:15:28
|
Revision: 2018
http://svn.sourceforge.net/rubyeclipse/?rev=2018&view=rev
Author: cawilliams
Date: 2007-02-23 11:15:24 -0800 (Fri, 23 Feb 2007)
Log Message:
-----------
set super class name properly. Extract constants. Traverse up inheritance hierarchy for suggesting method completions.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-02-23 18:53:28 UTC (rev 2017)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-02-23 19:15:24 UTC (rev 2018)
@@ -52,6 +52,7 @@
import org.rubypeople.rdt.internal.ti.util.ScopedNodeLocator;
public class CompletionEngine {
+ private static final String CONSTRUCTOR_INVOKE_NAME = "new";
private CompletionRequestor requestor;
private CompletionContext context;
@@ -142,6 +143,15 @@
for (int k = 0; k < methods.length; k++) {
suggestMethod(methods[k], type.getElementName(), confidence);
}
+ // FIXME If a method name matches an existing suggestion (i.e. its overriden in the subclass), don't suggest it again!
+ String superClass = type.getSuperclassName();
+ if (superClass == null) return;
+ RubyElementRequestor requestor = new RubyElementRequestor(type.getRubyScript());
+ IType[] supers = requestor.findType(superClass);
+ for (int i = 0; i < supers.length; i++) {
+ IType superType = supers[i];
+ suggestMethods(confidence, superType);
+ }
}
private void suggestMethod(IMethod method, String typeName, int confidence) {
@@ -151,7 +161,7 @@
if (method.isSingleton()) {
flags |= Flags.AccStatic;
if (method.isConstructor())
- name = "new";
+ name = CONSTRUCTOR_INVOKE_NAME;
else
name = name.substring(typeName.length() + 1);
} else {
@@ -184,7 +194,11 @@
proposal.setReplaceRange(start, start + name.length());
proposal.setFlags(flags);
proposal.setName(name);
- proposal.setDeclaringType(typeName);
+ IType declaringType = method.getDeclaringType();
+ String declaringName = typeName;
+ if (declaringType != null)
+ declaringName = declaringType.getElementName();
+ proposal.setDeclaringType(declaringName);
requestor.accept(proposal);
}
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-02-23 18:53:28 UTC (rev 2017)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java 2007-02-23 19:15:24 UTC (rev 2018)
@@ -144,6 +144,13 @@
*/
public class RubyScriptStructureBuilder implements NodeVisitor {
+ private static final String MODULE = "Module";
+ private static final String MODULE_KEYWORD = "module";
+ private static final String METHOD_KEYWORD = "def";
+ private static final String CONSTRUCTOR_NAME = "initialize";
+ private static final String NAMESPACE_DELIMETER = "::";
+ private static final String CLASS_KEYWORD = "class";
+ private static final String OBJECT = "Object";
private InfoStack infoStack = new InfoStack();
private HandleStack modelStack = new HandleStack();
private RubyScriptElementInfo scriptInfo;
@@ -186,7 +193,7 @@
// TODO Use the visibility for the original method that this is aliasing
Visibility visibility = currentVisibility;
- if (name.equals("initialize"))
+ if (name.equals(CONSTRUCTOR_NAME))
visibility = Visibility.PROTECTED;
// TODO Find the existing method and steal it's parameter names
@@ -511,11 +518,13 @@
RubyTypeElementInfo info = new RubyTypeElementInfo();
info.setHandle(handle);
ISourcePosition pos = iVisited.getPosition();
- setKeywordRange("class", pos, info, name);
+ setKeywordRange(CLASS_KEYWORD, pos, info, name);
- String superClass = getSuperClassName(iVisited.getSuperNode());
- info.setSuperclassName(superClass);
-
+ if (!name.equals(OBJECT)) {
+ String superClass = getSuperClassName(iVisited.getSuperNode());
+ info.setSuperclassName(superClass);
+ }
+// TODO Collect the included modules and set them here!
info.setIncludedModuleNames(new String[] {});
infoStack.push(info);
@@ -524,7 +533,7 @@
visitNode(iVisited.getSuperNode());
visitNode(iVisited.getBodyNode());
- // TODO Collect the included modules and set them here!
+
modelStack.pop();
infoStack.pop();
return null;
@@ -553,7 +562,7 @@
*/
private String getSuperClassName(Node superNode) {
if (superNode == null)
- return "Object";
+ return OBJECT;
return getFullyQualifiedName(superNode);
}
@@ -568,7 +577,7 @@
Colon2Node colonNode = (Colon2Node) node;
String prefix = getFullyQualifiedName(colonNode.getLeftNode());
if (prefix.length() > 0)
- prefix = prefix + "::";
+ prefix = prefix + NAMESPACE_DELIMETER;
return prefix + colonNode.getName();
}
return "";
@@ -736,7 +745,7 @@
String name = iVisited.getName();
Visibility visibility = currentVisibility;
- if (name.equals("initialize"))
+ if (name.equals(CONSTRUCTOR_NAME))
visibility = Visibility.PROTECTED;
RubyElement type = getCurrentType();
@@ -752,7 +761,7 @@
// TODO Set more information
info.setVisibility(convertVisibility(visibility));
ISourcePosition pos = iVisited.getPosition();
- setKeywordRange("def", pos, info, name);
+ setKeywordRange(METHOD_KEYWORD, pos, info, name);
infoStack.push(info);
newElements.put(method, info);
@@ -841,7 +850,7 @@
// TODO Set more info!
infoStack.push(info);
ISourcePosition pos = iVisited.getPosition();
- setKeywordRange("def", pos, info, fullName);
+ setKeywordRange(METHOD_KEYWORD, pos, info, fullName);
info.setArgumentNames(parameterNames);
info.setVisibility(convertVisibility(visibility));
@@ -1166,7 +1175,7 @@
} else if (value instanceof BignumNode) {
return "Bignum";
}
- return "Object";
+ return OBJECT;
}
/*
@@ -1327,9 +1336,9 @@
RubyTypeElementInfo info = new RubyTypeElementInfo();
info.setHandle(module);
ISourcePosition pos = iVisited.getPosition();
- setKeywordRange("module", pos, info, name);
- info.setSuperclassName("Module");
- // TODO Set more info!
+ setKeywordRange(MODULE_KEYWORD, pos, info, name);
+ // TODO Set super module better! set Module if null, set nothing if name is Module.
+ info.setSuperclassName(MODULE);
infoStack.push(info);
newElements.put(module, info);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-02-23 18:53:30
|
Revision: 2017
http://svn.sourceforge.net/rubyeclipse/?rev=2017&view=rev
Author: cawilliams
Date: 2007-02-23 10:53:28 -0800 (Fri, 23 Feb 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/OpenActionUtil.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/browsing/TypesView.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/AppearanceAwareLabelProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyElementLabels.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/OpenActionUtil.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/OpenActionUtil.java 2007-02-23 18:44:06 UTC (rev 2016)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/OpenActionUtil.java 2007-02-23 18:53:28 UTC (rev 2017)
@@ -9,6 +9,7 @@
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.internal.ui.rubyeditor.EditorUtility;
import org.rubypeople.rdt.ui.RubyElementLabelProvider;
+import org.rubypeople.rdt.ui.RubyElementLabels;
public class OpenActionUtil {
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/browsing/TypesView.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/browsing/TypesView.java 2007-02-23 18:44:06 UTC (rev 2016)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/browsing/TypesView.java 2007-02-23 18:53:28 UTC (rev 2017)
@@ -9,7 +9,6 @@
import org.rubypeople.rdt.internal.ui.viewsupport.RubyElementImageProvider;
import org.rubypeople.rdt.internal.ui.viewsupport.RubyUILabelProvider;
import org.rubypeople.rdt.ui.PreferenceConstants;
-import org.rubypeople.rdt.ui.RubyElementLabels;
public class TypesView extends RubyBrowsingPart {
@@ -31,7 +30,7 @@
protected RubyUILabelProvider createLabelProvider() {
return new AppearanceAwareLabelProvider(
- AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | RubyElementLabels.T_DECLARATION_POINT,
+ AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS,
AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS
| RubyElementImageProvider.SMALL_ICONS);
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/AppearanceAwareLabelProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/AppearanceAwareLabelProvider.java 2007-02-23 18:44:06 UTC (rev 2016)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/AppearanceAwareLabelProvider.java 2007-02-23 18:53:28 UTC (rev 2017)
@@ -23,7 +23,7 @@
*/
public class AppearanceAwareLabelProvider extends RubyUILabelProvider implements IPropertyChangeListener {
- public final static long DEFAULT_TEXTFLAGS= RubyElementLabels.M_PARAMETER_NAMES | RubyElementLabels.ROOT_VARIABLE | RubyElementLabels.REFERENCED_ROOT_POST_QUALIFIED;
+ public final static long DEFAULT_TEXTFLAGS= RubyElementLabels.M_PARAMETER_NAMES | RubyElementLabels.T_POST_QUALIFIED | RubyElementLabels.ROOT_VARIABLE | RubyElementLabels.REFERENCED_ROOT_POST_QUALIFIED;
public final static int DEFAULT_IMAGEFLAGS= RubyElementImageProvider.OVERLAY_ICONS;
private long fTextFlagMask;
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyElementLabels.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyElementLabels.java 2007-02-23 18:44:06 UTC (rev 2016)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyElementLabels.java 2007-02-23 18:53:28 UTC (rev 2017)
@@ -178,8 +178,6 @@
* another project.
*/
public final static long REFERENCED_ROOT_POST_QUALIFIED = 1L << 45;
-
- static public final long T_DECLARATION_POINT = 1L << 46;
/**
* Specified to use the resolved information of a IType, IMethod or IField.
@@ -540,20 +538,6 @@
}
}
buf.append(typeName);
-
- if (getFlag(flags, T_DECLARATION_POINT)) {
- buf.append(" [");
- buf.append(type.getPath().makeRelative().toOSString());
- try {
- int offset = type.getNameRange().getOffset();
- buf.append(", offset: ");
- buf.append(offset);
- } catch (RubyModelException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- buf.append("] ");
- }
// post qualification
if (getFlag(flags, T_POST_QUALIFIED)) {
@@ -574,6 +558,13 @@
getSourceFolderLabel(type.getSourceFolder(), flags & QUALIFIER_FLAGS, buf);
}
getRubyScriptLabel(type.getRubyScript(), (flags & QUALIFIER_FLAGS), buf);
+ try {
+ int offset = type.getNameRange().getOffset();
+ buf.append(", offset: ");
+ buf.append(offset);
+ } catch (RubyModelException e) {
+ RubyPlugin.log(e);
+ }
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-02-23 18:44:07
|
Revision: 2016
http://svn.sourceforge.net/rubyeclipse/?rev=2016&view=rev
Author: cawilliams
Date: 2007-02-23 10:44:06 -0800 (Fri, 23 Feb 2007)
Log Message:
-----------
hopefully make this work cross-platform
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVM.java
trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RubyRuntime.java
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVM.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVM.java 2007-02-23 18:33:32 UTC (rev 2015)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVM.java 2007-02-23 18:44:06 UTC (rev 2016)
@@ -133,15 +133,15 @@
private IPath generateCoreStubs(File rubyExecutable) {
if (rubyExecutable == null) return null;
//locate the script to generate our core stubs
- File file = LaunchingPlugin.getFileInPlugin(new Path("ruby/core_stubber.rb")); //$NON-NLS-1$
- if (file.exists()) {
- IPath path = new Path(file.getParentFile().getAbsolutePath() + fgSeparator + getId() + fgSeparator + "lib"); //$NON-NLS-1$
- if (path.toFile().exists()) {
- return path; // we've already created the stubs for this VM
+ File coreStubber = LaunchingPlugin.getFileInPlugin(new Path("ruby" + fgSeparator + "core_stubber.rb")); //$NON-NLS-1$ //$NON-NLS-2$
+ if (coreStubber.exists()) {
+ IPath stubFolder = new Path(coreStubber.getParentFile().getAbsolutePath() + fgSeparator + getId() + fgSeparator + "lib"); //$NON-NLS-1$
+ if (stubFolder.toFile().exists()) {
+ return stubFolder; // we've already created the stubs for this VM
}
- path.toFile().mkdirs(); // Make the directory structure to throw the files into
+ stubFolder.toFile().mkdirs(); // Make the directory structure to throw the files into
String rubyExecutablePath = rubyExecutable.getAbsolutePath();
- String[] cmdLine = new String[] {rubyExecutablePath, file.getAbsolutePath(), path.toOSString()};
+ String[] cmdLine = new String[] {rubyExecutablePath, coreStubber.getAbsolutePath(), stubFolder.toOSString()};
Process p = null;
try {
p = Runtime.getRuntime().exec(cmdLine);
@@ -156,7 +156,7 @@
} catch (InterruptedException e) {
}
}
- return path;
+ return stubFolder;
} catch (IOException ioe) {
LaunchingPlugin.log(ioe);
} finally {
Modified: trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RubyRuntime.java
===================================================================
--- trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RubyRuntime.java 2007-02-23 18:33:32 UTC (rev 2015)
+++ trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RubyRuntime.java 2007-02-23 18:44:06 UTC (rev 2016)
@@ -51,25 +51,29 @@
}
public void testGetInstalledInterpreters() {
+ String vmOneName = "InterpreterOne";
+ String vmOneId = vmOneName;
+ String vmTwoName = "InterpreterTwo";
+ String vmTwoId = vmTwoName;
try {
- VMStandin standin = new VMStandin(vmType, "InterpreterOne");
+ VMStandin standin = new VMStandin(vmType, vmOneId);
standin.setInstallLocation(new File("C:/RubyInstallRootOne"));
- standin.setName("InterpreterOne");
+ standin.setName(vmOneName);
standin.convertToRealVM();
- VMStandin standin2 = new VMStandin(vmType, "InterpreterTwo");
+ VMStandin standin2 = new VMStandin(vmType, vmTwoId);
standin2.setInstallLocation(new File("C:/RubyInstallRootTwo"));
- standin2.setName("InterpreterTwo");
+ standin2.setName(vmTwoName);
standin2.convertToRealVM();
IVMInstallType myType = RubyRuntime.getVMInstallType(VM_TYPE_ID);
IVMInstall[] installs = myType.getVMInstalls();
assertEquals(2, installs.length);
- assertEquals("InterpreterOne", installs[0].getName());
- assertEquals("InterpreterTwo", installs[1].getName());
+ assertEquals(vmOneName, installs[0].getName());
+ assertEquals(vmTwoName, installs[1].getName());
} finally {
- vmType.disposeVMInstall("InterpreterOne");
- vmType.disposeVMInstall("InterpreterTwo");
+ vmType.disposeVMInstall(vmOneId);
+ vmType.disposeVMInstall(vmTwoId);
}
}
@@ -86,7 +90,7 @@
RubyRuntime.setDefaultVMInstall(one, null,true);
IPath vmOneLocation = folderOne.getLocation();
assertEquals(
- "XML should indicate only one interpreter with it being the selected.",
+ "XML should indicate only one interpreter with it being the one selected.",
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" +
"<vmSettings defaultVM=\"43,org.rubypeople.rdt.launching.StandardVMType14," + vmOneId + "\">\r\n" +
"<vmType id=\"org.rubypeople.rdt.launching.StandardVMType\">\r\n" +
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-02-23 18:33:37
|
Revision: 2015
http://svn.sourceforge.net/rubyeclipse/?rev=2015&view=rev
Author: cawilliams
Date: 2007-02-23 10:33:32 -0800 (Fri, 23 Feb 2007)
Log Message:
-----------
make tests work cross-platform (hopefully) and not just win32
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMDebugger.java
trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RunnerLaunching.java
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMDebugger.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMDebugger.java 2007-02-23 17:20:06 UTC (rev 2014)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMDebugger.java 2007-02-23 18:33:32 UTC (rev 2015)
@@ -9,6 +9,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.debug.core.ILaunch;
@@ -146,7 +147,7 @@
List<String> arguments = new ArrayList<String>();
// FIXME Somehow hook this into the loadpath stuff?
arguments.add("-I");
- arguments.add(LaunchingPlugin.osDependentPath(getDirectoryOfRubyDebuggerFile().replace('/', File.separatorChar)));
+ arguments.add(new Path(getDirectoryOfRubyDebuggerFile()).toOSString());
if (!debugTarget.isUsingDefaultPort()) {
arguments.add("-r" + debugTarget.getDebugParameterFile().getAbsolutePath());
}
Modified: trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RunnerLaunching.java
===================================================================
--- trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RunnerLaunching.java 2007-02-23 17:20:06 UTC (rev 2014)
+++ trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RunnerLaunching.java 2007-02-23 18:33:32 UTC (rev 2015)
@@ -11,6 +11,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -78,22 +79,24 @@
protected String getCommandLine(IProject project, String debugFile, boolean debug) {
StringBuffer buffer = new StringBuffer();
buffer.append(" \"");
- buffer.append(interpreter.getInstallLocation());
- buffer.append("\\bin\\ruby\" ");
+ buffer.append(new Path(interpreter.getInstallLocation().getAbsolutePath()).append("bin").append("ruby").toOSString());
+ buffer.append("\" ");
buffer.append(INTERPRETER_ARGUMENTS);
buffer.append(" -I \"");
buffer.append(project.getLocation().toOSString());
buffer.append("\"");
if (debug) {
buffer.append(" -I \"");
- buffer.append(StandardVMDebugger.getDirectoryOfRubyDebuggerFile().replace('/', '\\'));
+ buffer.append(new Path(StandardVMDebugger.getDirectoryOfRubyDebuggerFile()).toOSString());
buffer.append("\"");
buffer.append(" -r");
buffer.append(debugFile);
buffer.append(" -rclassic-debug");
}
buffer.append(" -- ");
- buffer.append(RUBY_LIB_DIR + "\\" + RUBY_FILE_NAME);
+ buffer.append(RUBY_LIB_DIR);
+ buffer.append(File.separator);
+ buffer.append(RUBY_FILE_NAME);
buffer.append(' ');
buffer.append(PROGRAM_ARGUMENTS);
return buffer.toString();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-02-23 17:20:12
|
Revision: 2014
http://svn.sourceforge.net/rubyeclipse/?rev=2014&view=rev
Author: cawilliams
Date: 2007-02-23 09:20:06 -0800 (Fri, 23 Feb 2007)
Log Message:
-----------
fix broken test
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVM.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMDebugger.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/AbstractVMRunner.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/IVMRunner.java
trunk/org.rubypeople.rdt.launching.tests/plugin.xml
trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RunnerLaunching.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestRubyDebugDebugger.java
trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestVM.java
trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestVMDebugger.java
trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestVMRunner.java
trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestVMType.java
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVM.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVM.java 2007-02-23 16:01:27 UTC (rev 2013)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVM.java 2007-02-23 17:20:06 UTC (rev 2014)
@@ -40,7 +40,7 @@
return null;
}
- private boolean useRDebug() {
+ protected boolean useRDebug() {
return LaunchingPlugin.getDefault().getPluginPreferences().getBoolean(PreferenceConstants.USE_RUBY_DEBUG);
}
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMDebugger.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMDebugger.java 2007-02-23 16:01:27 UTC (rev 2013)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMDebugger.java 2007-02-23 17:20:06 UTC (rev 2014)
@@ -139,11 +139,14 @@
}
protected RubyDebuggerProxy getDebugProxy(RubyDebugTarget debugTarget) {
- return new RubyDebuggerProxy(debugTarget, RDebugVMDebugger.getDirectoryOfRubyDebuggerFile(), false);
+ return new RubyDebuggerProxy(debugTarget, getDirectoryOfRubyDebuggerFile(), false);
}
protected List<String> debugSpecificVMArgs(RubyDebugTarget debugTarget) {
List<String> arguments = new ArrayList<String>();
+// FIXME Somehow hook this into the loadpath stuff?
+ arguments.add("-I");
+ arguments.add(LaunchingPlugin.osDependentPath(getDirectoryOfRubyDebuggerFile().replace('/', File.separatorChar)));
if (!debugTarget.isUsingDefaultPort()) {
arguments.add("-r" + debugTarget.getDebugParameterFile().getAbsolutePath());
}
@@ -153,9 +156,6 @@
} else {
arguments.add("-rclassic-debug");
}
- // FIXME Somehow hook this into the loadpath stuff?
- arguments.add("-I");
- arguments.add(LaunchingPlugin.osDependentPath(getDirectoryOfRubyDebuggerFile().replace('/', File.separatorChar)));
return arguments;
}
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/AbstractVMRunner.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/AbstractVMRunner.java 2007-02-23 16:01:27 UTC (rev 2013)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/AbstractVMRunner.java 2007-02-23 17:20:06 UTC (rev 2014)
@@ -68,7 +68,7 @@
* @see DebugPlugin#exec(String[], File, String[])
*/
protected Process exec(String[] cmdLine, File workingDirectory, String[] envp) throws CoreException {
- LaunchingPlugin.debug("Starting: " + getCmdLineAsString(cmdLine)) ;
+// LaunchingPlugin.debug("Starting: " + getCmdLineAsString(cmdLine)) ;
return DebugPlugin.exec(cmdLine, workingDirectory, envp);
}
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/IVMRunner.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/IVMRunner.java 2007-02-23 16:01:27 UTC (rev 2013)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/IVMRunner.java 2007-02-23 17:20:06 UTC (rev 2014)
@@ -26,7 +26,7 @@
public interface IVMRunner {
/**
- * Launches a Java VM as specified in the given configuration,
+ * Launches a Ruby VM as specified in the given configuration,
* contributing results (debug targets and processes), to the
* given launch.
*
Modified: trunk/org.rubypeople.rdt.launching.tests/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.launching.tests/plugin.xml 2007-02-23 16:01:27 UTC (rev 2013)
+++ trunk/org.rubypeople.rdt.launching.tests/plugin.xml 2007-02-23 17:20:06 UTC (rev 2014)
@@ -21,6 +21,15 @@
<import plugin="org.rubypeople.eclipse.testutils"/>
<import plugin="org.rubypeople.rdt.core"/>
<import plugin="org.rubypeople.rdt.core.tests"/>
+ <import plugin="org.rubypeople.rdt.debug.core"/>
</requires>
+
+ <extension
+ point="org.rubypeople.rdt.launching.vmInstallTypes">
+ <vmInstallType
+ class="org.rubypeople.rdt.internal.launching.TestVMType"
+ id="org.rubypeople.rdt.launching.TestVMType">
+ </vmInstallType>
+ </extension>
</plugin>
Modified: trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RunnerLaunching.java
===================================================================
--- trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RunnerLaunching.java 2007-02-23 16:01:27 UTC (rev 2013)
+++ trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RunnerLaunching.java 2007-02-23 17:20:06 UTC (rev 2014)
@@ -1,8 +1,6 @@
package org.rubypeople.rdt.internal.launching;
import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -20,10 +18,11 @@
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.Launch;
+import org.eclipse.debug.core.model.IProcess;
import org.rubypeople.eclipse.shams.debug.core.ShamLaunchConfigurationType;
import org.rubypeople.rdt.core.IRubyProject;
-import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.tests.ModifyingResourceTest;
+import org.rubypeople.rdt.internal.debug.core.model.RubyDebugTarget;
import org.rubypeople.rdt.launching.IRubyLaunchConfigurationConstants;
import org.rubypeople.rdt.launching.IVMInstall;
import org.rubypeople.rdt.launching.IVMInstallType;
@@ -33,19 +32,17 @@
public class TC_RunnerLaunching extends ModifyingResourceTest {
private final static String PROJECT_NAME = "Simple Project";
- private final static String RUBY_LIB_DIR = "someRubyDir"; // dir inside project
- private final static String RUBY_FILE_NAME = "rubyFile.rb";
+ private final static String RUBY_LIB_DIR = "someRubyDir"; // dir inside
+ // project
+ private final static String RUBY_FILE_NAME = "rubyFile.rb";
private final static String INTERPRETER_ARGUMENTS = "interpreter Arguments";
private final static String PROGRAM_ARGUMENTS = "programArguments";
- private final static String RUBY_COMMAND = "rubyw";
-
- private static final String VM_TYPE_ID = "org.rubypeople.rdt.launching.StandardVMType";
+
+ private static final String VM_TYPE_ID = "org.rubypeople.rdt.launching.TestVMType";
private IVMInstallType vmType;
private IVMInstall interpreter;
private IRubyProject project;
-
- // XXX This test class desperately needs to be rewritten...
-
+
public TC_RunnerLaunching(String name) {
super(name);
}
@@ -55,95 +52,76 @@
super.setUp();
project = createRubyProject('/' + PROJECT_NAME);
IFolder location = createFolder('/' + PROJECT_NAME + "/interpreterOne");
- createFolder('/' + PROJECT_NAME +"/interpreterOne/lib");
- createFolder('/' + PROJECT_NAME +"/interpreterOne/bin");
- createFile('/' + PROJECT_NAME +"/interpreterOne/bin/ruby", "");
-
+ createFolder('/' + PROJECT_NAME + "/interpreterOne/lib");
+ createFolder('/' + PROJECT_NAME + "/interpreterOne/bin");
+ createFile('/' + PROJECT_NAME + "/interpreterOne/bin/ruby", "");
+
vmType = RubyRuntime.getVMInstallType(VM_TYPE_ID);
VMStandin standin = new VMStandin(vmType, "fake");
standin.setName("fake");
standin.setInstallLocation(location.getLocation().toFile());
interpreter = standin.convertToRealVM();
- RubyRuntime.setDefaultVMInstall(interpreter, null, true);
+ RubyRuntime.setDefaultVMInstall(interpreter, null, true);
}
-
+
@Override
protected void tearDown() throws Exception {
super.tearDown();
deleteProject('/' + PROJECT_NAME);
vmType.disposeVMInstall(interpreter.getId());
}
-
+
protected ILaunchManager getLaunchManager() {
return DebugPlugin.getDefault().getLaunchManager();
}
- protected List getCommandLine(IProject project, boolean debug) {
- List commandLine = new ArrayList();
+ protected String getCommandLine(IProject project, String debugFile, boolean debug) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(" \"");
+ buffer.append(interpreter.getInstallLocation());
+ buffer.append("\\bin\\ruby\" ");
+ buffer.append(INTERPRETER_ARGUMENTS);
+ buffer.append(" -I \"");
+ buffer.append(project.getLocation().toOSString());
+ buffer.append("\"");
if (debug) {
- commandLine.add("-rclassic-debug");
+ buffer.append(" -I \"");
+ buffer.append(StandardVMDebugger.getDirectoryOfRubyDebuggerFile().replace('/', '\\'));
+ buffer.append("\"");
+ buffer.append(" -r");
+ buffer.append(debugFile);
+ buffer.append(" -rclassic-debug");
}
- // The include paths and the executed ruby file is quoted on windows
- if (debug) {
- String dirOfRubyDebuggerFile = getDirectoryOfRubyDebuggerFile().replace('/', File.separatorChar) ;
- if (dirOfRubyDebuggerFile.startsWith("\\")) {
- dirOfRubyDebuggerFile = dirOfRubyDebuggerFile.substring(1) ;
- }
- commandLine.add("-I");
- commandLine.add(dirOfRubyDebuggerFile);
- }
- commandLine.add("-I");
- commandLine.add(project.getLocation().toOSString());
- commandLine.add("-I");
- commandLine.add(project.getLocation().toOSString() + File.separator + RUBY_LIB_DIR ) ;
- commandLine.addAll(Arrays.asList(INTERPRETER_ARGUMENTS.split("\\s+")));
- commandLine.add("--");
- // use always forward slashes for path relative to project dir
- commandLine.add(project.getLocation().toOSString() + "/" + RUBY_LIB_DIR + "/" + RUBY_FILE_NAME );
- commandLine.add(PROGRAM_ARGUMENTS);
- return commandLine;
+ buffer.append(" -- ");
+ buffer.append(RUBY_LIB_DIR + "\\" + RUBY_FILE_NAME);
+ buffer.append(' ');
+ buffer.append(PROGRAM_ARGUMENTS);
+ return buffer.toString();
}
- private String getDirectoryOfRubyDebuggerFile() {
- return RubyCore.getOSDirectory(LaunchingPlugin.getDefault()) + "ruby";
- }
-
public void testDebugEnabled() throws Exception {
// check if debugging is enabled in plugin.xml
- ILaunchConfigurationType launchConfigurationType =
- getLaunchManager().getLaunchConfigurationType(
- RubyLaunchConfigurationAttribute.RUBY_LAUNCH_CONFIGURATION_TYPE);
+ ILaunchConfigurationType launchConfigurationType = getLaunchManager().getLaunchConfigurationType(RubyLaunchConfigurationAttribute.RUBY_LAUNCH_CONFIGURATION_TYPE);
assertEquals("Ruby Application", launchConfigurationType.getName());
- assertTrue(
- "LaunchConfiguration supports debug",
- launchConfigurationType.supportsMode(ILaunchManager.DEBUG_MODE));
+ assertTrue("LaunchConfiguration supports debug", launchConfigurationType.supportsMode(ILaunchManager.DEBUG_MODE));
}
public void launch(boolean debug) throws Exception {
ILaunchConfiguration configuration = new ShamLaunchConfiguration();
ILaunch launch = new Launch(configuration, debug ? ILaunchManager.DEBUG_MODE : ILaunchManager.RUN_MODE, null);
- ILaunchConfigurationType launchConfigurationType =
- getLaunchManager().getLaunchConfigurationType(
- RubyLaunchConfigurationAttribute.RUBY_LAUNCH_CONFIGURATION_TYPE);
- launchConfigurationType.getDelegate(debug ? "debug" : "run").launch(
- configuration,
- debug ? ILaunchManager.DEBUG_MODE : ILaunchManager.RUN_MODE,
- launch,
- null);
+ ILaunchConfigurationType launchConfigurationType = getLaunchManager().getLaunchConfigurationType(RubyLaunchConfigurationAttribute.RUBY_LAUNCH_CONFIGURATION_TYPE);
+ launchConfigurationType.getDelegate(debug ? "debug" : "run").launch(configuration, debug ? ILaunchManager.DEBUG_MODE : ILaunchManager.RUN_MODE, launch, null);
- assertEquals("One process has been spawned", 1, launch.getProcesses().length);
- List expected = getCommandLine(project.getProject(), debug);
- String[] actual = interpreter.getVMArguments();
+ RubyDebugTarget debugTarget = (RubyDebugTarget) launch.getDebugTarget();
+ String debugFile = "";
if (debug) {
- // we must cheat with the first argument, because it is a temporary file which
- // contains is different for every call
- expected.add(0, actual[0]) ;
+ debugFile = debugTarget.getDebugParameterFile().getAbsolutePath();
}
- assertEquals("Assembled command line.", expected, actual);
- assertEquals(
- "Process label.",
- "Ruby " + RUBY_COMMAND + " : " + RUBY_LIB_DIR + "/" + RUBY_FILE_NAME,
- launch.getProcesses()[0].getLabel());
+
+ assertEquals("Only one process should have been spawned", 1, launch.getProcesses().length);
+ IProcess process = launch.getProcesses()[0];
+ String expected = getCommandLine(project.getProject(), debugFile, debug);
+ assertEquals(expected, process.getAttribute(IProcess.ATTR_CMDLINE));
}
public void testRunInDebugMode() throws Exception {
@@ -163,8 +141,7 @@
return null;
}
- public void delete() throws CoreException {
- }
+ public void delete() throws CoreException {}
public boolean exists() {
return true;
@@ -193,12 +170,10 @@
return RUBY_LIB_DIR + File.separator + RUBY_FILE_NAME;
} else if (attributeName.equals(RubyLaunchConfigurationAttribute.WORKING_DIRECTORY)) {
return '/' + PROJECT_NAME;
- } else if (attributeName.equals(RubyLaunchConfigurationAttribute.INTERPRETER_ARGUMENTS)) {
- return INTERPRETER_ARGUMENTS;
} else if (attributeName.equals(RubyLaunchConfigurationAttribute.PROGRAM_ARGUMENTS)) {
return PROGRAM_ARGUMENTS;
} else if (attributeName.equals(IRubyLaunchConfigurationConstants.ATTR_VM_ARGUMENTS)) {
- return "";
+ return INTERPRETER_ARGUMENTS;
}
return defaultValue;
@@ -260,28 +235,31 @@
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.ILaunchConfiguration#launch(java.lang.String, org.eclipse.core.runtime.IProgressMonitor, boolean, boolean)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.core.ILaunchConfiguration#launch(java.lang.String,
+ * org.eclipse.core.runtime.IProgressMonitor, boolean, boolean)
*/
public ILaunch launch(String mode, IProgressMonitor monitor, boolean build, boolean register) throws CoreException {
// TODO Auto-generated method stub
return null;
}
- public IResource[] getMappedResources() throws CoreException {
- // TODO Auto-generated method stub
- return null;
- }
+ public IResource[] getMappedResources() throws CoreException {
+ // TODO Auto-generated method stub
+ return null;
+ }
- public boolean isMigrationCandidate() throws CoreException {
- // TODO Auto-generated method stub
- return false;
- }
+ public boolean isMigrationCandidate() throws CoreException {
+ // TODO Auto-generated method stub
+ return false;
+ }
- public void migrate() throws CoreException {
- // TODO Auto-generated method stub
-
- }
+ public void migrate() throws CoreException {
+ // TODO Auto-generated method stub
+
+ }
}
}
Added: trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestRubyDebugDebugger.java
===================================================================
--- trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestRubyDebugDebugger.java (rev 0)
+++ trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestRubyDebugDebugger.java 2007-02-23 17:20:06 UTC (rev 2014)
@@ -0,0 +1,41 @@
+package org.rubypeople.rdt.internal.launching;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.rubypeople.rdt.internal.debug.core.RubyDebuggerProxy;
+import org.rubypeople.rdt.internal.debug.core.model.IRubyDebugTarget;
+import org.rubypeople.rdt.internal.debug.core.model.RubyDebugTarget;
+import org.rubypeople.rdt.internal.debug.core.model.RubyProcessingException;
+import org.rubypeople.rdt.launching.IVMInstall;
+import org.rubypeople.rdt.launching.IVMRunner;
+
+public class TestRubyDebugDebugger extends RDebugVMDebugger implements IVMRunner {
+
+ public TestRubyDebugDebugger(IVMInstall vmInstance) {
+ super(vmInstance);
+ }
+ @Override
+ protected Process exec(String[] cmdLine, File workingDirectory, String[] envp) throws CoreException {
+ return new ShamProcess();
+ }
+
+ @Override
+ protected RubyDebuggerProxy getDebugProxy(RubyDebugTarget debugTarget) {
+ return new TestDebuggerProxy(debugTarget, getDirectoryOfRubyDebuggerFile(), true);
+ }
+
+ private static class TestDebuggerProxy extends RubyDebuggerProxy {
+
+ public TestDebuggerProxy(IRubyDebugTarget debugTarget, String rubyFileDirectory, boolean isRubyDebug) {
+ super(debugTarget, rubyFileDirectory, isRubyDebug);
+ }
+
+ @Override
+ public void start() throws RubyProcessingException, IOException {
+ // intentionally empty
+ }
+
+ }
+}
Added: trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestVM.java
===================================================================
--- trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestVM.java (rev 0)
+++ trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestVM.java 2007-02-23 17:20:06 UTC (rev 2014)
@@ -0,0 +1,25 @@
+package org.rubypeople.rdt.internal.launching;
+
+import org.eclipse.debug.core.ILaunchManager;
+import org.rubypeople.rdt.launching.IVMInstall;
+import org.rubypeople.rdt.launching.IVMInstallType;
+import org.rubypeople.rdt.launching.IVMRunner;
+
+public class TestVM extends StandardVM implements IVMInstall {
+
+ public TestVM(IVMInstallType type, String id) {
+ super(type, id);
+ }
+ @Override
+ public IVMRunner getVMRunner(String mode) {
+ if (ILaunchManager.RUN_MODE.equals(mode)) {
+ return new TestVMRunner(this);
+ } else if (ILaunchManager.DEBUG_MODE.equals(mode)) {
+ if (useRDebug()) {
+ return new TestRubyDebugDebugger(this);
+ }
+ return new TestVMDebugger(this);
+ }
+ return null;
+ }
+}
Added: trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestVMDebugger.java
===================================================================
--- trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestVMDebugger.java (rev 0)
+++ trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestVMDebugger.java 2007-02-23 17:20:06 UTC (rev 2014)
@@ -0,0 +1,43 @@
+package org.rubypeople.rdt.internal.launching;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.rubypeople.rdt.internal.debug.core.RubyDebuggerProxy;
+import org.rubypeople.rdt.internal.debug.core.model.IRubyDebugTarget;
+import org.rubypeople.rdt.internal.debug.core.model.RubyDebugTarget;
+import org.rubypeople.rdt.internal.debug.core.model.RubyProcessingException;
+import org.rubypeople.rdt.launching.IVMInstall;
+import org.rubypeople.rdt.launching.IVMRunner;
+
+public class TestVMDebugger extends StandardVMDebugger implements IVMRunner {
+
+ public TestVMDebugger(IVMInstall vmInstance) {
+ super(vmInstance);
+ }
+
+ @Override
+ protected Process exec(String[] cmdLine, File workingDirectory, String[] envp) throws CoreException {
+ return new ShamProcess();
+ }
+
+ @Override
+ protected RubyDebuggerProxy getDebugProxy(RubyDebugTarget debugTarget) {
+ return new TestDebuggerProxy(debugTarget, getDirectoryOfRubyDebuggerFile(), false);
+ }
+
+ private static class TestDebuggerProxy extends RubyDebuggerProxy {
+
+ public TestDebuggerProxy(IRubyDebugTarget debugTarget, String rubyFileDirectory, boolean isRubyDebug) {
+ super(debugTarget, rubyFileDirectory, isRubyDebug);
+ }
+
+ @Override
+ public void start() throws RubyProcessingException, IOException {
+ // intentionally empty
+ }
+
+ }
+
+}
Added: trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestVMRunner.java
===================================================================
--- trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestVMRunner.java (rev 0)
+++ trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestVMRunner.java 2007-02-23 17:20:06 UTC (rev 2014)
@@ -0,0 +1,20 @@
+package org.rubypeople.rdt.internal.launching;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.CoreException;
+import org.rubypeople.rdt.launching.IVMInstall;
+import org.rubypeople.rdt.launching.IVMRunner;
+
+public class TestVMRunner extends StandardVMRunner implements IVMRunner {
+
+ public TestVMRunner(IVMInstall vmInstance) {
+ super(vmInstance);
+ }
+
+ @Override
+ protected Process exec(String[] cmdLine, File workingDirectory, String[] envp) throws CoreException {
+ return new ShamProcess();
+ }
+
+}
Added: trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestVMType.java
===================================================================
--- trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestVMType.java (rev 0)
+++ trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestVMType.java 2007-02-23 17:20:06 UTC (rev 2014)
@@ -0,0 +1,11 @@
+package org.rubypeople.rdt.internal.launching;
+
+import org.rubypeople.rdt.launching.IVMInstall;
+
+public class TestVMType extends StandardVMType {
+
+ @Override
+ protected IVMInstall doCreateVMInstall(String id) {
+ return new TestVM(this, id);
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-02-23 16:01:29
|
Revision: 2013
http://svn.sourceforge.net/rubyeclipse/?rev=2013&view=rev
Author: cawilliams
Date: 2007-02-23 08:01:27 -0800 (Fri, 23 Feb 2007)
Log Message:
-----------
fix up the ruby browsing view
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalRubyScript.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolder.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolderInfo.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolderRoot.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolderRoot.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolderRootInfo.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/LibraryLabelProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/RubyElementImageProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/ISharedImages.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/icons/full/obj16/fldr_root_obj.gif
Removed Paths:
-------------
trunk/org.rubypeople.rdt.ui/icons/full/obj16/jar_lsrc_obj.gif
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalRubyScript.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalRubyScript.java 2007-02-23 15:23:45 UTC (rev 2012)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalRubyScript.java 2007-02-23 16:01:27 UTC (rev 2013)
@@ -8,6 +8,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.jruby.ast.Node;
import org.jruby.lexer.yacc.SyntaxException;
import org.rubypeople.rdt.core.IBuffer;
@@ -108,4 +109,9 @@
// TODO Auto-generated method stub
return null;
}
+
+ @Override
+ public IPath getPath() {
+ return getParent().getPath().append(getElementName());
+ }
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolder.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolder.java 2007-02-23 15:23:45 UTC (rev 2012)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolder.java 2007-02-23 16:01:27 UTC (rev 2013)
@@ -31,6 +31,10 @@
public boolean isReadOnly() {
return true;
}
+
+ protected Object[] storedNonRubyResources() throws RubyModelException {
+ return ((ExternalSourceFolderInfo) getElementInfo()).getNonRubyResources();
+ }
protected boolean computeChildren(OpenableElementInfo info) {
ArrayList<IRubyElement> vChildren = new ArrayList<IRubyElement>();
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolderInfo.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolderInfo.java 2007-02-23 15:23:45 UTC (rev 2012)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolderInfo.java 2007-02-23 16:01:27 UTC (rev 2013)
@@ -1,5 +1,10 @@
package org.rubypeople.rdt.internal.core;
public class ExternalSourceFolderInfo extends SourceFolderInfo {
-
+ /**
+ * Returns an array of non-ruby resources contained in the receiver.
+ */
+ Object[] getNonRubyResources() {
+ return this.nonRubyResources;
+ }
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolderRoot.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolderRoot.java 2007-02-23 15:23:45 UTC (rev 2012)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolderRoot.java 2007-02-23 16:01:27 UTC (rev 2013)
@@ -26,6 +26,18 @@
super(null, project);
this.folderPath = resource;
}
+
+ public String getElementName() {
+ return this.folderPath.toPortableString();
+ }
+
+ /**
+ * Returns an array of non-ruby resources contained in the receiver.
+ */
+ public Object[] getNonRubyResources() throws RubyModelException {
+ // We want to show non ruby resources of the default src folder at the root (see PR #1G58NB8)
+ return ((ExternalSourceFolder) getSourceFolder(CharOperation.NO_STRINGS)).storedNonRubyResources();
+ }
@Override
protected boolean computeChildren(OpenableElementInfo info, Map newElements) throws RubyModelException {
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolderRoot.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolderRoot.java 2007-02-23 15:23:45 UTC (rev 2012)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolderRoot.java 2007-02-23 16:01:27 UTC (rev 2013)
@@ -178,6 +178,12 @@
public int getElementType() {
return IRubyElement.SOURCE_FOLDER_ROOT;
}
+
+ public String getElementName() {
+ if (this.resource instanceof IFolder)
+ return ((IFolder) this.resource).getName();
+ return ""; //$NON-NLS-1$
+ }
public ISourceFolder createSourceFolder(String names, boolean force, IProgressMonitor monitor) throws RubyModelException {
CreateSourceFolderOperation op = new CreateSourceFolderOperation(this, names, force);
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolderRootInfo.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolderRootInfo.java 2007-02-23 15:23:45 UTC (rev 2012)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolderRootInfo.java 2007-02-23 16:01:27 UTC (rev 2013)
@@ -149,24 +149,24 @@
* Returns an array of non-java resources contained in the receiver.
*/
synchronized Object[] getNonRubyResources(IRubyProject project, IResource underlyingResource, SourceFolderRoot handle) {
- Object[] nonJavaResources = this.fNonRubyResources;
- if (nonJavaResources == null) {
- nonJavaResources = this.computeNonRubyResources(project, underlyingResource, handle);
- this.fNonRubyResources = nonJavaResources;
+ Object[] nonRubyResources = this.fNonRubyResources;
+ if (nonRubyResources == null) {
+ nonRubyResources = this.computeNonRubyResources(project, underlyingResource, handle);
+ this.fNonRubyResources = nonRubyResources;
}
- return nonJavaResources;
+ return nonRubyResources;
}
- /**
- * Compute the non-package resources of this package fragment root.
+/**
+ * Compute the non-ruby resources of this source folder root.
*/
private Object[] computeNonRubyResources(IRubyProject project, IResource underlyingResource, SourceFolderRoot handle) {
- Object[] nonJavaResources = NO_NON_RUBY_RESOURCES;
+ Object[] nonRubyResources = NO_NON_RUBY_RESOURCES;
try {
// the underlying resource may be a folder or a project (in the case that the project folder
- // is actually the package fragment root)
+ // is actually the source folder root)
if (underlyingResource.getType() == IResource.FOLDER || underlyingResource.getType() == IResource.PROJECT) {
- nonJavaResources =
+ nonRubyResources =
computeFolderNonRubyResources(
(RubyProject)project,
(IContainer) underlyingResource,
@@ -176,6 +176,6 @@
} catch (RubyModelException e) {
// ignore
}
- return nonJavaResources;
+ return nonRubyResources;
}
}
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/LibraryLabelProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/LibraryLabelProvider.java 2007-02-23 15:23:45 UTC (rev 2012)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/LibraryLabelProvider.java 2007-02-23 16:01:27 UTC (rev 2013)
@@ -29,7 +29,7 @@
public Image getImage(Object element) {
if (element instanceof LibraryStandin) {
LibraryStandin library= (LibraryStandin) element;
- String key = ISharedImages.IMG_OBJS_EXTERNAL_ARCHIVE;
+ String key = ISharedImages.IMG_OBJS_LIBRARY;
IStatus status = library.validate();
if (!status.isOK()) {
ImageDescriptor base = RubyUI.getSharedImages().getImageDescriptor(key);
Added: trunk/org.rubypeople.rdt.ui/icons/full/obj16/fldr_root_obj.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/obj16/fldr_root_obj.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: trunk/org.rubypeople.rdt.ui/icons/full/obj16/jar_lsrc_obj.gif
===================================================================
(Binary files differ)
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java 2007-02-23 15:23:45 UTC (rev 2012)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java 2007-02-23 16:01:27 UTC (rev 2013)
@@ -38,8 +38,6 @@
public static final String IMG_MISC_PROTECTED= NAME_PREFIX + "methpro_obj.gif"; //$NON-NLS-1$
public static final String IMG_MISC_PRIVATE= NAME_PREFIX + "methpri_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJS_EXTJAR_WSRC= NAME_PREFIX + "jar_lsrc_obj.gif"; //$NON-NLS-1$
-
public static final String IMG_OBJS_ERROR = NAME_PREFIX + "error_obj.gif";
public static final String IMG_OBJS_WARNING = NAME_PREFIX + "warning_obj.gif";
public static final String IMG_OBJS_INFO = NAME_PREFIX + "info_obj.gif";
@@ -52,6 +50,7 @@
private static final String IMG_OBJS_MODULEALT= NAME_PREFIX + "modulefo_obj.gif"; //$NON-NLS-1$
private static final String IMG_OBJS_RUBY_MODEL= NAME_PREFIX + "ruby_model_obj.gif"; //$NON-NLS-1$
private static final String IMG_OBJS_SOURCE_FOLDER= NAME_PREFIX + "fldr_obj.gif"; //$NON-NLS-1$
+ private static final String IMG_OBJS_SOURCE_FOLDER_ROOT= NAME_PREFIX + "fldr_root_obj.gif"; //$NON-NLS-1$
private static final String IMG_OBJS_SCRIPT= NAME_PREFIX + "rscript_obj.gif"; //$NON-NLS-1$
private static final String IMG_OBJS_RUBY_RESOURCE= NAME_PREFIX + "rscript_resource_obj.gif"; //$NON-NLS-1$
private static final String IMG_OBJS_UNKNOWN= NAME_PREFIX + "unknown_obj.gif"; //$NON-NLS-1$
@@ -88,8 +87,7 @@
public static final ImageDescriptor DESC_OBJ_OVERRIDES= createUnManaged(T_OBJ, "over_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJ_IMPLEMENTS= createUnManaged(T_OBJ, "implm_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJS_LIBRARY= createManagedFromKey(T_OBJ, IMG_OBJS_LIBRARY);
- public static final ImageDescriptor DESC_OBJS_EXTJAR_WSRC= createManagedFromKey(T_OBJ, IMG_OBJS_EXTJAR_WSRC);
-
+
public static final ImageDescriptor DESC_OVR_STATIC= createUnManaged(T_OVR, "static_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_FINAL= createUnManaged(T_OVR, "final_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_ABSTRACT= createUnManaged(T_OVR, "abstract_co.gif"); //$NON-NLS-1$
@@ -113,6 +111,7 @@
public static final ImageDescriptor DESC_OBJS_RUBY_MODEL= createManagedFromKey(T_OBJ, IMG_OBJS_RUBY_MODEL);
public static final ImageDescriptor DESC_OBJS_SOURCE_FOLDER= createManagedFromKey(T_OBJ, IMG_OBJS_SOURCE_FOLDER);
+ public static final ImageDescriptor DESC_OBJS_SOURCE_FOLDER_ROOT= createManagedFromKey(T_OBJ, IMG_OBJS_SOURCE_FOLDER_ROOT);
public static final ImageDescriptor DESC_OBJS_LOCAL_VAR = createManagedFromKey(T_OBJ, IMG_CTOOLS_RUBY_LOCAL_VAR);
public static final ImageDescriptor DESC_OBJS_GLOBAL = createManagedFromKey(T_OBJ, IMG_CTOOLS_RUBY_GLOBAL);
public static final ImageDescriptor DESC_OBJS_MODULE = createManagedFromKey(T_OBJ, IMG_OBJS_MODULE);
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/RubyElementImageProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/RubyElementImageProvider.java 2007-02-23 15:23:45 UTC (rev 2012)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/RubyElementImageProvider.java 2007-02-23 16:01:27 UTC (rev 2013)
@@ -26,6 +26,7 @@
import org.rubypeople.rdt.core.IMethod;
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.ISourceFolderRoot;
import org.rubypeople.rdt.core.IType;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
@@ -209,6 +210,15 @@
case IRubyElement.SOURCE_FOLDER:
return RubyPluginImages.DESC_OBJS_SOURCE_FOLDER;
+
+ case IRubyElement.SOURCE_FOLDER_ROOT:
+ ISourceFolderRoot root= (ISourceFolderRoot) element;
+ if (root.isExternal()) {
+ return RubyPluginImages.DESC_OBJS_LIBRARY;
+ } else {
+ return RubyPluginImages.DESC_OBJS_SOURCE_FOLDER_ROOT;
+ }
+
case IRubyElement.RUBY_PROJECT:
IRubyProject jp = (IRubyProject) element;
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/ISharedImages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/ISharedImages.java 2007-02-23 15:23:45 UTC (rev 2012)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/ISharedImages.java 2007-02-23 16:01:27 UTC (rev 2013)
@@ -11,12 +11,6 @@
*/
public static final String IMG_OBJS_LIBRARY= RubyPluginImages.IMG_OBJS_LIBRARY;
- /**
- * Key to access the shared image or image descriptor for external archives with source.
- * @since 0.9.0
- */
- public static final String IMG_OBJS_EXTERNAL_ARCHIVE= RubyPluginImages.IMG_OBJS_EXTJAR_WSRC;
-
Image getImage(String key);
ImageDescriptor getImageDescriptor(String key);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-02-23 15:23:46
|
Revision: 2012
http://svn.sourceforge.net/rubyeclipse/?rev=2012&view=rev
Author: cawilliams
Date: 2007-02-23 07:23:45 -0800 (Fri, 23 Feb 2007)
Log Message:
-----------
fix broken test
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/search/TC_RubySearchTreeContentProvider.java
Modified: trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/search/TC_RubySearchTreeContentProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/search/TC_RubySearchTreeContentProvider.java 2007-02-23 15:11:19 UTC (rev 2011)
+++ trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/search/TC_RubySearchTreeContentProvider.java 2007-02-23 15:23:45 UTC (rev 2012)
@@ -34,7 +34,7 @@
}
- public void testGroupByFIle() {
+ public void testGroupByPath() {
// could be a MockSearchResult instead
RubySearchResult rubyUISearchResult = new RubySearchResult(null);
// call initialize before the search starts
@@ -47,7 +47,7 @@
rubyUISearchResult.addMatch(new Match(searchResult, Match.UNIT_CHARACTER, 0, 0));
rubySearchTreeContentProvider.elementsChanged(new Object[]{searchResult}) ;
- Assert.assertTrue(mockTreeViewer.isParentAdded(file)) ;
+ Assert.assertTrue(mockTreeViewer.isParentAdded(searchResult.getLocation().getSourceFile().getFullPath())) ;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-02-23 15:11:21
|
Revision: 2011
http://svn.sourceforge.net/rubyeclipse/?rev=2011&view=rev
Author: cawilliams
Date: 2007-02-23 07:11:19 -0800 (Fri, 23 Feb 2007)
Log Message:
-----------
start fixing the broken test...
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/search/MockTreeViewer.java
Modified: trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/search/MockTreeViewer.java
===================================================================
--- trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/search/MockTreeViewer.java 2007-02-23 14:40:49 UTC (rev 2010)
+++ trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/search/MockTreeViewer.java 2007-02-23 15:11:19 UTC (rev 2011)
@@ -46,8 +46,7 @@
}
protected Item[] getChildren(Widget widget) {
- // TODO Auto-generated method stub
- return null;
+ return new Item[0];
}
protected boolean getExpanded(Item item) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-02-23 14:40:50
|
Revision: 2010
http://svn.sourceforge.net/rubyeclipse/?rev=2010&view=rev
Author: cawilliams
Date: 2007-02-23 06:40:49 -0800 (Fri, 23 Feb 2007)
Log Message:
-----------
make abstract (since it's a base class)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/AbstractRubyModelTest.java
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/AbstractRubyModelTest.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/AbstractRubyModelTest.java 2007-02-23 14:40:23 UTC (rev 2009)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/AbstractRubyModelTest.java 2007-02-23 14:40:49 UTC (rev 2010)
@@ -37,7 +37,7 @@
import org.rubypeople.rdt.internal.core.util.CharOperation;
import org.rubypeople.rdt.internal.core.util.Util;
-public class AbstractRubyModelTest extends TestCase {
+public abstract class AbstractRubyModelTest extends TestCase {
protected IRubyProject currentProject;
protected String endChar = ",";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-02-23 14:40:25
|
Revision: 2009
http://svn.sourceforge.net/rubyeclipse/?rev=2009&view=rev
Author: cawilliams
Date: 2007-02-23 06:40:23 -0800 (Fri, 23 Feb 2007)
Log Message:
-----------
make abstract (since it's a base class)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/ModifyingResourceTest.java
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/ModifyingResourceTest.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/ModifyingResourceTest.java 2007-02-23 14:37:40 UTC (rev 2008)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/ModifyingResourceTest.java 2007-02-23 14:40:23 UTC (rev 2009)
@@ -10,7 +10,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
-public class ModifyingResourceTest extends AbstractRubyModelTest {
+public abstract class ModifyingResourceTest extends AbstractRubyModelTest {
public ModifyingResourceTest(String name) {
super(name);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-02-23 14:37:43
|
Revision: 2008
http://svn.sourceforge.net/rubyeclipse/?rev=2008&view=rev
Author: cawilliams
Date: 2007-02-23 06:37:40 -0800 (Fri, 23 Feb 2007)
Log Message:
-----------
fix broken test (the ugly way - I made a class public to test it. We may want to see if there's anyway to test this from the APIU of a RubyEditor)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditor.java
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/rubyeditor/TC_TabConverter.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditor.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditor.java 2007-02-23 11:33:06 UTC (rev 2007)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditor.java 2007-02-23 14:37:40 UTC (rev 2008)
@@ -1518,7 +1518,7 @@
void customizeDocumentCommand(IDocument document, DocumentCommand command);
}
- static class TabConverter implements ITextConverter {
+ public static class TabConverter implements ITextConverter {
private int fTabRatio;
private ILineTracker fLineTracker;
Modified: trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/rubyeditor/TC_TabConverter.java
===================================================================
--- trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/rubyeditor/TC_TabConverter.java 2007-02-23 11:33:06 UTC (rev 2007)
+++ trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/rubyeditor/TC_TabConverter.java 2007-02-23 14:37:40 UTC (rev 2008)
@@ -2,6 +2,7 @@
import junit.framework.TestCase;
+import org.eclipse.jface.text.DefaultLineTracker;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.DocumentCommand;
import org.rubypeople.rdt.internal.ui.rubyeditor.RubyEditor.TabConverter;
@@ -55,11 +56,16 @@
TestDocumentCommand command = new TestDocumentCommand(currentOffset);
command.text = "\t";
Document document = new Document(TEST_TEXT);
+ DefaultLineTracker tracker = new DefaultLineTracker();
+ converter.setLineTracker(tracker);
converter.customizeDocumentCommand(document, command);
String message = "Offset = "+currentOffset + "; tabWidth = "+spacesPerTab;
- assertEquals(message, " ".substring(0,expectedCountOfTabs), command.text);
+ if (spacesPerTab == 0)
+ assertEquals(message, "", command.text);
+ else
+ assertEquals(message, " ".substring(0,expectedCountOfTabs), command.text);
// assertEquals("Full indent (" + spacesPerTab + ")", " ".substring(0,spacesPerTab), expander.getFullIndent());
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cal...@us...> - 2007-02-23 11:33:10
|
Revision: 2007
http://svn.sourceforge.net/rubyeclipse/?rev=2007&view=rev
Author: callandor1983
Date: 2007-02-23 03:33:06 -0800 (Fri, 23 Feb 2007)
Log Message:
-----------
Rename refactorings enhanced.
Renames will only be launched if the name of the Item to rename is selected (class or method body doesn't count any more)
method to decide which rename refactoring will be launched no uses the condition checkers of the rename refactorings.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/NodeProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/RefactoringConditionChecker.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/converttemptofield/TempToFieldConverter.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/extractmethod/ExtractedMethodHelper.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinetemp/InlineTempConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movemethod/InsertMethodEditProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movemethod/MethodMover.java
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/RenameConfig.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/renamefield/RenameFieldConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/LocalVariableRenamer.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/LocalVariablesEditProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/RenameLocalVariableRefactoring.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemethod/RenameMethodConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/nodewrapper/CallArgsNodeWrapper.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/nodewrapper/FieldNodeWrapper.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/nodewrapper/LocalNodeWrapper.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/nodewrapper/MethodCallNodeWrapper.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/nodewrapper/PartialClassNodeWrapper.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/nodewrapper/VisibilityNodeWrapper.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/util/NodeUtil.java
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/rename/rename_test_2.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/rename/rename_test_7.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamefield/conditionchecks/rename_field_checker_test_3.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemethod/conditioncheck/rename_method_checker_test_1.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemethod/conditioncheck/rename_method_checker_test_3.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemethod/conditioncheck/rename_method_checker_test_4.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemethod/rename_method_test_1.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemethod/rename_method_test_5.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemethod/rename_method_test_6.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/TC_NodeProvider.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/renamelocalvariable/TS_RenameLocalVariable.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamelocalvariable/conditionchecks/TS_RenameLocalCondition.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/RenameLocalConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/RenameLocalConfig.java
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamefield/conditionchecks/rename_field_checker_test_4.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamefield/conditionchecks/rename_field_checker_test_4.test_source
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemethod/conditioncheck/rename_method_checker_test_6.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/renamemethod/conditioncheck/rename_method_checker_test_6.test_source
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamelocalvariable/RenameLocalTester.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamelocalvariable/conditionchecks/RenameLocalConditionTester.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/RenameConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/RenameConfig.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamelocalvariable/RenameTester.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/renamelocalvariable/conditionchecks/RenameLocalConditionChecker.java
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/NodeProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/NodeProvider.java 2007-02-22 20:46:57 UTC (rev 2006)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/NodeProvider.java 2007-02-23 11:33:06 UTC (rev 2007)
@@ -166,10 +166,10 @@
}
private static void addAccessorNodes(Collection<AttrAccessorNodeWrapper> accessorNodes, FCallNode callNode) {
- if (nodeAssignableFrom(callNode.getArgsNode(), ArrayNode.class)) {
+ if (NodeUtil.nodeAssignableFrom(callNode.getArgsNode(), ArrayNode.class)) {
for (Object o : callNode.getArgsNode().childNodes()) {
Node aktNode = (Node) o;
- if (nodeAssignableFrom(aktNode, SymbolNode.class)) {
+ if (NodeUtil.nodeAssignableFrom(aktNode, SymbolNode.class)) {
SymbolNode symbolNode = ((SymbolNode) aktNode);
accessorNodes.add(new AttrAccessorNodeWrapper(callNode, symbolNode));
}
@@ -181,11 +181,11 @@
if (!hasAccessorName(fCallNode)) {
return false;
}
- if (NodeProvider.nodeAssignableFrom(fCallNode.getArgsNode(), ArrayNode.class)) {
+ if (NodeUtil.nodeAssignableFrom(fCallNode.getArgsNode(), ArrayNode.class)) {
ArrayNode arrayNode = (ArrayNode) fCallNode.getArgsNode();
for (Object o : arrayNode.childNodes()) {
Node aktNode = (Node) o;
- if (!NodeProvider.nodeAssignableFrom(aktNode, SymbolNode.class)) {
+ if (!NodeUtil.nodeAssignableFrom(aktNode, SymbolNode.class)) {
return false;
}
}
@@ -356,7 +356,7 @@
public static Collection<Node> gatherNodesOfTypeInAktScopeNode(Node baseNode, Class... klasses) {
ArrayList<Node> candidates = new ArrayList<Node>();
- if (nodeAssignableFrom(baseNode, klasses)) {
+ if (NodeUtil.nodeAssignableFrom(baseNode, klasses)) {
candidates.add(baseNode);
}
if (baseNode != null && !NodeUtil.hasScope(baseNode)) {
@@ -373,7 +373,7 @@
Collection<Node> allNodes = getAllNodes(baseNode);
Collection<Node> resultNodes = new ArrayList<Node>();
for (Node aktNode : allNodes) {
- if (nodeAssignableFrom(aktNode, klasses)) {
+ if (NodeUtil.nodeAssignableFrom(aktNode, klasses)) {
resultNodes.add(aktNode);
}
}
@@ -384,18 +384,6 @@
return !getSubNodes(baseNode, klasses).isEmpty();
}
- public static boolean nodeAssignableFrom(Node n, Class<?>... klasses) {
- if(n == null) {
- return false;
- }
- for (Class<?> klass : klasses) {
- if (klass.isAssignableFrom(n.getClass())) {
- return true;
- }
- }
- return false;
- }
-
public static Node getEnclosingNodeOfType(Node baseNode, Node enclosedNode, Class<? extends Object>... klasses) {
return SelectionNodeProvider.getSelectedNodeOfType(baseNode, enclosedNode.getPosition().getStartOffset(), klasses);
}
@@ -421,7 +409,7 @@
if(node == null) {
return true;
}
- if(!nodeAssignableFrom(node, EMPTY_NODES)) {
+ if(!NodeUtil.nodeAssignableFrom(node, EMPTY_NODES)) {
return false;
}
for(Object o : node.childNodes()) {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/RefactoringConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/RefactoringConditionChecker.java 2007-02-22 20:46:57 UTC (rev 2006)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/RefactoringConditionChecker.java 2007-02-23 11:33:06 UTC (rev 2007)
@@ -131,6 +131,10 @@
protected void addWarning(String message) {
messages.get(IRefactoringConditionChecker.WARNING).add(message);
}
+
+ protected boolean hasErrors() {
+ return !messages.get(IRefactoringConditionChecker.ERRORS).isEmpty();
+ }
protected abstract void checkInitialConditions();
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-02-22 20:46:57 UTC (rev 2006)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/SelectionNodeProvider.java 2007-02-23 11:33:06 UTC (rev 2007)
@@ -60,7 +60,10 @@
import org.rubypeople.rdt.refactoring.exception.NoClassNodeException;
import org.rubypeople.rdt.refactoring.nodewrapper.AttrAccessorNodeWrapper;
import org.rubypeople.rdt.refactoring.nodewrapper.ClassNodeWrapper;
+import org.rubypeople.rdt.refactoring.nodewrapper.FieldNodeWrapper;
+import org.rubypeople.rdt.refactoring.nodewrapper.INodeWrapper;
import org.rubypeople.rdt.refactoring.nodewrapper.PartialClassNodeWrapper;
+import org.rubypeople.rdt.refactoring.util.NodeUtil;
public class SelectionNodeProvider {
@@ -165,16 +168,16 @@
Class[] classes = { LocalAsgnNode.class, LocalVarNode.class, DAsgnNode.class, DVarNode.class, InstAsgnNode.class, InstVarNode.class,
ClassVarAsgnNode.class, ClassVarNode.class, GlobalAsgnNode.class, GlobalVarNode.class};
boolean sameStart = firstNode.getPosition().getStartOffset() == secondNode.getPosition().getStartOffset();
- boolean isFirstNodeVarNode = NodeProvider.nodeAssignableFrom(firstNode, classes);
- boolean isSecondNodeVarNode = NodeProvider.nodeAssignableFrom(secondNode, classes);
+ boolean isFirstNodeVarNode = NodeUtil.nodeAssignableFrom(firstNode, classes);
+ boolean isSecondNodeVarNode = NodeUtil.nodeAssignableFrom(secondNode, classes);
return sameStart && isFirstNodeVarNode && isSecondNodeVarNode;
}
private static boolean hasSamePosAndIsSelfAsignment(Node probablyCallNode, Node probablyAsgnNode) {
boolean sameStart = probablyCallNode.getPosition().getStartOffset() == probablyAsgnNode.getPosition().getStartOffset();
boolean sameEnd = probablyCallNode.getPosition().getEndOffset() == probablyAsgnNode.getPosition().getEndOffset();
- boolean isAsgnNode = NodeProvider.nodeAssignableFrom(probablyAsgnNode, LocalAsgnNode.class, DAsgnNode.class, InstAsgnNode.class, ClassVarAsgnNode.class);
- boolean isCallNode = NodeProvider.nodeAssignableFrom(probablyCallNode, CallNode.class, AttrAssignNode.class);
+ boolean isAsgnNode = NodeUtil.nodeAssignableFrom(probablyAsgnNode, LocalAsgnNode.class, DAsgnNode.class, InstAsgnNode.class, ClassVarAsgnNode.class);
+ boolean isCallNode = NodeUtil.nodeAssignableFrom(probablyCallNode, CallNode.class, AttrAssignNode.class);
return sameStart && sameEnd && isCallNode && isAsgnNode;
}
@@ -219,7 +222,7 @@
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) && NodeProvider.nodeAssignableFrom(n, klasses)) {
+ if (nodeContainsPosition(n, position) && !(n instanceof NewlineNode) && NodeUtil.nodeAssignableFrom(n, klasses)) {
candidates.add(n);
}
}
@@ -290,4 +293,24 @@
}
return selectedAccessor;
}
+
+ public static <T extends INodeWrapper> T getSelectedWrappedNode(Collection<T> candidates, int caretPosition) {
+ T selected = null;
+ for(T aktNode : candidates) {
+ if(nodeContainsPosition(aktNode.getWrappedNode(), caretPosition)) {
+ selected = getBestCandidate(selected, aktNode);
+ }
+ }
+ return selected;
+ }
+
+ private static <T extends INodeWrapper> T getBestCandidate(T oldNode, T newNode) {
+ if(oldNode == null) {
+ return newNode;
+ }
+ if(nodeEnclosesNode(newNode.getWrappedNode(), oldNode.getWrappedNode())) {
+ return oldNode;
+ }
+ return newNode;
+ }
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/TempToFieldConverter.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/TempToFieldConverter.java 2007-02-22 20:46:57 UTC (rev 2006)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/TempToFieldConverter.java 2007-02-23 11:33:06 UTC (rev 2007)
@@ -45,7 +45,6 @@
import org.jruby.ast.Node;
import org.jruby.ast.StrNode;
import org.jruby.ast.VCallNode;
-import org.rubypeople.rdt.refactoring.core.NodeProvider;
import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
import org.rubypeople.rdt.refactoring.editprovider.DeleteEditProvider;
import org.rubypeople.rdt.refactoring.editprovider.EditProvider;
@@ -97,10 +96,10 @@
for (Object o : baseNode.childNodes()) {
Node n = (Node) o;
- if (NodeProvider.nodeAssignableFrom(n, LocalNodeWrapper.getLocalNodeClasses())) {
+ if (NodeUtil.nodeAssignableFrom(n, LocalNodeWrapper.LOCAL_NODES_CLASSES)) {
candidates.add(n);
}
- if (!NodeProvider.nodeAssignableFrom(n, DAsgnNode.class, LocalAsgnNode.class)) {
+ if (!NodeUtil.nodeAssignableFrom(n, DAsgnNode.class, LocalAsgnNode.class)) {
candidates.addAll(gatherLocalNodes(n));
}
}
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-02-22 20:46:57 UTC (rev 2006)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractMethodConditionChecker.java 2007-02-23 11:33:06 UTC (rev 2007)
@@ -91,10 +91,10 @@
Node selectedNode = SelectionNodeProvider.getSelectedNodes(rootNode, config.getSelection());
//If selected node is an WhenNode, take the enclosing CaseNode as selectedNode.
- if (NodeProvider.nodeAssignableFrom(selectedNode, WhenNode.class)) {
+ if (NodeUtil.nodeAssignableFrom(selectedNode, WhenNode.class)) {
selectedNode = SelectionNodeProvider.getEnclosingNode(rootNode, config.getSelection(), CaseNode.class);
}
- if(NodeProvider.nodeAssignableFrom(selectedNode, ArrayNode.class)) {
+ if(NodeUtil.nodeAssignableFrom(selectedNode, ArrayNode.class)) {
WhenNode enclosingWhen = (WhenNode) SelectionNodeProvider.getEnclosingNode(rootNode, config.getSelection(), WhenNode.class);
if(enclosingWhen != null && SelectionNodeProvider.nodeEnclosesNode(enclosingWhen.getExpressionNodes(), selectedNode)) {
selectedNode = SelectionNodeProvider.getEnclosingNode(rootNode, config.getSelection(), CaseNode.class);
@@ -108,7 +108,7 @@
}
//Check if the selected Node is an argumentNode
- if(NodeProvider.nodeAssignableFrom(selectedNode, ArgumentNode.class)) {
+ if(NodeUtil.nodeAssignableFrom(selectedNode, ArgumentNode.class)) {
selectedNode = config.getEnclosingMethodNode();
}
@@ -122,7 +122,7 @@
//Check if enclosingArrayNode is the argsNode of a MethodCallNode.
Node enclosingMethodCallNode = SelectionNodeProvider.getEnclosingNode(rootNode, config.getSelection(), MethodCallNodeWrapper.METHOD_CALL_NODE_CLASSES());
MethodCallNodeWrapper enclosingMethodCall = new MethodCallNodeWrapper(enclosingMethodCallNode);
- if(NodeProvider.nodeAssignableFrom(enclosingMethodCall.getArgsNode(), ArrayNode.class)) {
+ if(NodeUtil.nodeAssignableFrom(enclosingMethodCall.getArgsNode(), ArrayNode.class)) {
ArrayNode enclosingMethodCallArgs = (ArrayNode) enclosingMethodCall.getArgsNode();
if(enclosingArrayNode == enclosingMethodCallArgs)
return enclosingMethodCallNode;
@@ -130,7 +130,7 @@
//Check if enclosingArrayNode is the receiver node of a multiAsgnNode
MultipleAsgnNode asgnNode = (MultipleAsgnNode) SelectionNodeProvider.getEnclosingNode(rootNode, config.getSelection(), MultipleAsgnNode.class);
- if(asgnNode != null && NodeProvider.nodeAssignableFrom(asgnNode.getHeadNode(), ArrayNode.class)) {
+ if(asgnNode != null && NodeUtil.nodeAssignableFrom(asgnNode.getHeadNode(), ArrayNode.class)) {
// ArrayNode multiAsgnHeadNode = (ArrayNode) asgnNode.getHeadNode();
// if(enclosingArrayNode == multiAsgnHeadNode) {
// return asgnNode;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractedMethodHelper.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractedMethodHelper.java 2007-02-22 20:46:57 UTC (rev 2006)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractedMethodHelper.java 2007-02-23 11:33:06 UTC (rev 2007)
@@ -131,7 +131,7 @@
}
private boolean isLocalNodeOfEnclosingScope(boolean isWrongScopeNode, Node aktNode) {
- return !isWrongScopeNode && (NodeProvider.nodeAssignableFrom(aktNode, LocalNodeWrapper.getLocalNodeClasses()));
+ return !isWrongScopeNode && (NodeUtil.nodeAssignableFrom(aktNode, LocalNodeWrapper.LOCAL_NODES_CLASSES));
}
private void initNeededLocalNodes() {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinetemp/InlineTempConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinetemp/InlineTempConditionChecker.java 2007-02-22 20:46:57 UTC (rev 2006)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinetemp/InlineTempConditionChecker.java 2007-02-23 11:33:06 UTC (rev 2007)
@@ -64,7 +64,7 @@
config.setEnclosingScopeNode(SelectionNodeProvider.getEnclosingScope(rootNode, caretPosition));
- Node locVarNode = SelectionNodeProvider.getSelectedNodeOfType(rootNode, caretPosition, LocalNodeWrapper.getLocalNodeClasses());
+ Node locVarNode = SelectionNodeProvider.getSelectedNodeOfType(rootNode, caretPosition, LocalNodeWrapper.LOCAL_NODES_CLASSES);
if (locVarNode == null) {
return;
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movemethod/InsertMethodEditProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movemethod/InsertMethodEditProvider.java 2007-02-22 20:46:57 UTC (rev 2006)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movemethod/InsertMethodEditProvider.java 2007-02-23 11:33:06 UTC (rev 2007)
@@ -55,6 +55,7 @@
import org.rubypeople.rdt.refactoring.nodewrapper.VisibilityNodeWrapper.METHOD_VISIBILITY;
import org.rubypeople.rdt.refactoring.offsetprovider.AfterLastMethodInClassOffsetProvider;
import org.rubypeople.rdt.refactoring.offsetprovider.IOffsetProvider;
+import org.rubypeople.rdt.refactoring.util.NodeUtil;
public class InsertMethodEditProvider extends InsertEditProvider {
@@ -147,7 +148,7 @@
String insertText = config.getFieldInDestinationClassOfTypeSourceClass() + ".";
if (aktCallNode.isCallNode()) {
Node receiverNode = aktCallNode.getReceiverNode();
- if (NodeProvider.nodeAssignableFrom(receiverNode, SelfNode.class) && !isCallToMovingMethod(aktCallNode.getName())) {
+ if (NodeUtil.nodeAssignableFrom(receiverNode, SelfNode.class) && !isCallToMovingMethod(aktCallNode.getName())) {
int length = receiverNode.getPosition().getEndOffset() - insertPos;
multiEdit.addChild(new ReplaceEdit(insertPos, length, config.getFieldInDestinationClassOfTypeSourceClass()));
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movemethod/MethodMover.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movemethod/MethodMover.java 2007-02-22 20:46:57 UTC (rev 2006)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movemethod/MethodMover.java 2007-02-23 11:33:06 UTC (rev 2007)
@@ -60,6 +60,7 @@
import org.rubypeople.rdt.refactoring.nodewrapper.VisibilityNodeWrapper;
import org.rubypeople.rdt.refactoring.nodewrapper.VisibilityNodeWrapper.METHOD_VISIBILITY;
import org.rubypeople.rdt.refactoring.util.NameHelper;
+import org.rubypeople.rdt.refactoring.util.NodeUtil;
public class MethodMover implements IMultiFileEditProvider, Observer {
@@ -125,7 +126,7 @@
if(callNode.isCallToClassMethod()) {
return false;
}
- boolean isReceiverSelf = callNode.isCallNode() && NodeProvider.nodeAssignableFrom(callNode.getReceiverNode(), SelfNode.class);
+ boolean isReceiverSelf = callNode.isCallNode() && NodeUtil.nodeAssignableFrom(callNode.getReceiverNode(), SelfNode.class);
boolean isNotCallNode = !callNode.isCallNode();
boolean hasExistingMethodName = config.getSourceClassNode().containsMethod(callNode.getName());
return (isReceiverSelf || isNotCallNode) && hasExistingMethodName;
@@ -330,7 +331,7 @@
boolean sameName = methodCall.getName().equals(selectedMethodName);
boolean notInMovingMethod = !SelectionNodeProvider.isNodeContainedInNode(methodCall.getWrappedNode(), config.getMethodNode().getWrappedNode());
boolean isNotCallNode = !methodCall.isCallNode();
- boolean isSelfNode = methodCall.isCallNode() && NodeProvider.nodeAssignableFrom(methodCall.getReceiverNode(), SelfNode.class);
+ boolean isSelfNode = methodCall.isCallNode() && NodeUtil.nodeAssignableFrom(methodCall.getReceiverNode(), SelfNode.class);
boolean sameType = config.getMethodNode().isClassMethod() == methodCall.isCallToClassMethod();
return sameName && sameType && notInMovingMethod && (isNotCallNode || isSelfNode || methodCall.isCallToClassMethod());
}
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-02-22 20:46:57 UTC (rev 2006)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/rename/RenameConditionChecker.java 2007-02-23 11:33:06 UTC (rev 2007)
@@ -1,121 +1,98 @@
package org.rubypeople.rdt.refactoring.core.rename;
-import org.jruby.ast.ArgsNode;
-import org.jruby.ast.ArgumentNode;
-import org.jruby.ast.ClassNode;
-import org.jruby.ast.ConstNode;
-import org.jruby.ast.InstAsgnNode;
-import org.jruby.ast.InstVarNode;
-import org.jruby.ast.MethodDefNode;
-import org.jruby.ast.Node;
-import org.jruby.ast.SymbolNode;
+import org.rubypeople.rdt.refactoring.core.IRefactoringConditionChecker;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
-import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
-import org.rubypeople.rdt.refactoring.exception.NoClassNodeException;
-import org.rubypeople.rdt.refactoring.nodewrapper.ClassNodeWrapper;
-import org.rubypeople.rdt.refactoring.nodewrapper.LocalNodeWrapper;
+import org.rubypeople.rdt.refactoring.core.renameclass.RenameClassConditionChecker;
+import org.rubypeople.rdt.refactoring.core.renameclass.RenameClassConfig;
+import org.rubypeople.rdt.refactoring.core.renamefield.RenameFieldConditionChecker;
+import org.rubypeople.rdt.refactoring.core.renamefield.RenameFieldConfig;
+import org.rubypeople.rdt.refactoring.core.renamelocalvariable.RenameLocalConditionChecker;
+import org.rubypeople.rdt.refactoring.core.renamelocalvariable.RenameLocalConfig;
+import org.rubypeople.rdt.refactoring.core.renamemethod.RenameMethodConditionChecker;
+import org.rubypeople.rdt.refactoring.core.renamemethod.RenameMethodConfig;
+import org.rubypeople.rdt.refactoring.documentprovider.DocumentProvider;
public class RenameConditionChecker extends RefactoringConditionChecker {
- private ClassNode selectedClassNode;
- private Node selectedMethodNode;
- private Node selectedFieldNode;
- private Node selectedLocalNode;
- private Node preferedNode;
- private Node rootNode;
- private int offset;
+ private enum RenameType {
+ INVALID, LOCAL, FIELD, METHOD, CLASS
+ };
+ private RenameType selectedType;
+
+ private RenameLocalConditionChecker localConditionChecker;
+
+ private RefactoringConditionChecker fieldConditionChecker;
+
+ private RefactoringConditionChecker methodConditionChecker;
+
+ private RefactoringConditionChecker classConditionChecker;
+
public RenameConditionChecker(RenameConfig config) {
super(config.getDocumentProvider(), config);
}
@Override
protected void checkInitialConditions() {
- if(preferedNode == null) {
- addError("Nothing selected to rename.");
+ if (selectedType == RenameType.INVALID) {
+ addErrorMessage();
}
}
- @Override
- protected void init(Object configObj) {
- RenameConfig config = (RenameConfig) configObj;
- rootNode = config.getDocumentProvider().getRootNode();
- offset = config.getOffset();
- selectedClassNode = (ClassNode) SelectionNodeProvider.getSelectedNodeOfType(rootNode, offset, ClassNode.class);
- selectedMethodNode = SelectionNodeProvider.getSelectedNodeOfType(rootNode, offset, MethodDefNode.class);
- selectedFieldNode = SelectionNodeProvider.getSelectedNodeOfType(rootNode, offset, InstAsgnNode.class, InstVarNode.class);
- selectedLocalNode = SelectionNodeProvider.getSelectedNodeOfType(rootNode, offset, LocalNodeWrapper.getLocalNodeClasses());
- ConstNode selectedConstNode = (ConstNode) SelectionNodeProvider.getSelectedNodeOfType(rootNode, offset, ConstNode.class);
- SymbolNode selectedSymbolNode = (SymbolNode) SelectionNodeProvider.getSelectedNodeOfType(rootNode, offset, SymbolNode.class);
- ArgsNode argsNode = (ArgsNode) SelectionNodeProvider.getSelectedNodeOfType(rootNode, offset, ArgsNode.class);
- if(selectedLocalNode == null && argsNode != null) {
- selectedLocalNode = SelectionNodeProvider.getSelectedNodeOfType(argsNode, offset, ArgumentNode.class);
- }
- initPreferedNode(selectedConstNode, selectedSymbolNode);
- }
+ private void addErrorMessage() {
+ addErrorIfNotDefaultError(localConditionChecker, RenameLocalConditionChecker.DEFAULT_ERROR);
+ addErrorIfNotDefaultError(fieldConditionChecker, RenameFieldConditionChecker.DEFAULT_ERROR);
+ addErrorIfNotDefaultError(methodConditionChecker, RenameMethodConditionChecker.DEFAULT_ERROR);
+ addErrorIfNotDefaultError(classConditionChecker, RenameClassConditionChecker.DEFAULT_ERROR);
+ if (!hasErrors()) {
- private void initPreferedNode(ConstNode selectedConstNode, SymbolNode selectedSymbolNode) {
- if(selectedLocalNode != null) {
- if(selectedFieldNode != null) {
- preferedNode = (SelectionNodeProvider.isNodeContainedInNode(selectedFieldNode, selectedLocalNode)) ? selectedFieldNode : selectedLocalNode;
- } else {
- preferedNode = selectedLocalNode;
- }
- } else if(selectedFieldNode != null) {
- preferedNode = selectedFieldNode;
- } else if(selectedMethodNode != null) {
- preferedNode = selectedMethodNode;
- } else if(selectedClassNode != null) {
- preferedNode = selectedClassNode;
- if(selectedConstNode != null) {
- considerConstNode(selectedConstNode.getName());
- }
- if(selectedSymbolNode != null) {
- considerSymbolNode(selectedSymbolNode);
- }
+ addError("Nothing selected to rename.");
+
}
}
- private void considerSymbolNode(SymbolNode selectedSymbolNode) {
- try {
- ClassNodeWrapper classNode = SelectionNodeProvider.getSelectedClassNode(rootNode, offset);
- String symbolName = selectedSymbolNode.getName();
- if(classNode.containsField(symbolName)) {
- selectedFieldNode = selectedSymbolNode;
- preferedNode = selectedFieldNode;
- } else if(classNode.containsMethod(symbolName)) {
- selectedMethodNode = selectedSymbolNode;
- preferedNode = selectedSymbolNode;
+ private void addErrorIfNotDefaultError(RefactoringConditionChecker checker, String defaultError) {
+ String firstError = checker.getInitialMessages().get(IRefactoringConditionChecker.ERRORS).toArray(new String[0])[0];
+ if (!firstError.equals(defaultError)) {
+ addError(firstError);
}
- } catch (NoClassNodeException e) {/*do nothing*/}
}
- private void considerConstNode(String constName) {
- if(selectedClassNode != null && constName.equals(selectedClassNode.getCPath().getName())) {
- preferedNode = selectedClassNode;
+ @Override
+ protected void init(Object configObj) {
+ RenameConfig config = (RenameConfig) configObj;
+ int offset = config.getOffset();
+ DocumentProvider 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));
+ if (localConditionChecker.shouldPerform()) {
+ selectedType = RenameType.LOCAL;
+ } else if (fieldConditionChecker.shouldPerform()) {
+ selectedType = RenameType.FIELD;
+ } else if (methodConditionChecker.shouldPerform()) {
+ selectedType = RenameType.METHOD;
+ } else if (classConditionChecker.shouldPerform()) {
+ selectedType = RenameType.CLASS;
+ } else {
+ selectedType = RenameType.INVALID;
}
}
public boolean shouldRenameLocal() {
- return testShould(selectedLocalNode);
+ return selectedType == RenameType.LOCAL;
}
-
- private boolean testShould(Node nodeToTest) {
- if(preferedNode == null) {
- return false;
- }
- return preferedNode.equals(nodeToTest);
- }
public boolean shouldRenameField() {
- return testShould(selectedFieldNode);
+ return selectedType == RenameType.FIELD;
}
-
+
public boolean shouldRenameMethod() {
- return testShould(selectedMethodNode);
+ return selectedType == RenameType.METHOD;
}
-
+
public boolean shouldRenameClass() {
- return testShould(selectedClassNode);
+ return selectedType == RenameType.CLASS;
}
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/rename/RenameConfig.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/rename/RenameConfig.java 2007-02-22 20:46:57 UTC (rev 2006)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/rename/RenameConfig.java 2007-02-23 11:33:06 UTC (rev 2007)
@@ -1,18 +1,18 @@
package org.rubypeople.rdt.refactoring.core.rename;
-import org.rubypeople.rdt.refactoring.documentprovider.IDocumentProvider;
+import org.rubypeople.rdt.refactoring.documentprovider.DocumentProvider;
public class RenameConfig {
- private IDocumentProvider documentProvider;
+ private DocumentProvider documentProvider;
private int offset;
- public RenameConfig(IDocumentProvider documentProvider, int offset) {
+ public RenameConfig(DocumentProvider documentProvider, int offset) {
this.documentProvider = documentProvider;
this.offset = offset;
}
- public IDocumentProvider getDocumentProvider() {
+ public DocumentProvider getDocumentProvider() {
return documentProvider;
}
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-02-22 20:46:57 UTC (rev 2006)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassConditionChecker.java 2007-02-23 11:33:06 UTC (rev 2007)
@@ -37,6 +37,7 @@
public class RenameClassConditionChecker extends RefactoringConditionChecker {
+ public static final String DEFAULT_ERROR = "Please select the name of a class declaration.";
private RenameClassConfig config;
public RenameClassConditionChecker(RenameClassConfig config) {
@@ -64,7 +65,7 @@
@Override
protected void checkInitialConditions() {
if (config.getSelectedNode() == null) {
- addError("Please select the name of a class declaration.");
+ addError(DEFAULT_ERROR);
}
}
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/RenameFieldConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/RenameFieldConditionChecker.java 2007-02-22 20:46:57 UTC (rev 2006)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/RenameFieldConditionChecker.java 2007-02-23 11:33:06 UTC (rev 2007)
@@ -45,77 +45,79 @@
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.nodewrapper.FieldNodeWrapper;
+import org.rubypeople.rdt.refactoring.nodewrapper.PartialClassNodeWrapper;
public class RenameFieldConditionChecker extends RefactoringConditionChecker {
-
+
+ public static final String DEFAULT_ERROR = "There is no field at the caret position.";
+
private RenameFieldConfig config;
public RenameFieldConditionChecker(RenameFieldConfig config) {
super(config.getDocProvider(), config);
}
-
+
public void init(Object configObj) {
this.config = (RenameFieldConfig) configObj;
-
+
config.setDocProvider(new DocumentWithIncluding(config.getDocProvider()));
Node rootNode = config.getDocProvider().getRootNode();
-
+
try {
ClassNodeWrapper enclosingClassNode = SelectionNodeProvider.getSelectedClassNode(rootNode, config.getCaretPosition());
ClassNodeProvider classNodeProvider = new IncludedClassesProvider(config.getDocProvider());
config.setWholeClassNode(classNodeProvider.getClassNode(enclosingClassNode.getName()));
config.setFieldProvider(new FieldProvider(config.getWholeClassNode(), config.getDocProvider()));
- config.setSelectedItem(config.getFieldProvider().getNameAtPosition(config.getCaretPosition(), config.getDocProvider().getActiveFileName()));
- if(config.hasSelectedItem()){
+ config.setSelectedItem(config.getFieldProvider()
+ .getNameAtPosition(config.getCaretPosition(), config.getDocProvider().getActiveFileName()));
+ if (config.hasSelectedItem()) {
config.setSelectedName(config.getSelectedItem().getFieldName());
}
-
} catch (NoClassNodeException e) {
- /*don't care*/
- }
+ /* don't care */
+ }
- if(config.hasSelectedName()){
+ if (config.hasSelectedName()) {
setSelection();
}
}
- private void setSelection() {
+ private void setSelection() {
String fieldName = config.getSelectedName();
boolean concernsClassField = config.concernsClassField();
Collection<FieldItem> selectedItems = config.getFieldProvider().getFieldItems(fieldName, concernsClassField);
config.setSelectedCalls(selectedItems);
-
+
Collection<FieldItem> possibleItems = new ArrayList<FieldItem>();
possibleItems.addAll(selectedItems);
-
- if(!concernsClassField){
+
+ if (!concernsClassField) {
possibleItems.addAll(getInstVarAccesses());
}
-
+
config.setPossibleCalls(possibleItems);
}
private Collection<FieldItem> getInstVarAccesses() {
ArrayList<FieldItem> fieldCallNodes = new ArrayList<FieldItem>();
-
Collection<Node> allNodes = config.getDocProvider().getAllNodes();
- for(Node currentNode : allNodes){
- if(isPossibleCall(currentNode)){
- fieldCallNodes.add(new FieldCallItem((CallNode)currentNode));
+ for (Node currentNode : allNodes) {
+ if (isPossibleCall(currentNode)) {
+ fieldCallNodes.add(new FieldCallItem((CallNode) currentNode));
}
}
-
+
return fieldCallNodes;
}
+ private boolean isPossibleCall(Node candidateNode) {
+ if ((candidateNode instanceof CallNode)) {
- private boolean isPossibleCall(Node candidateNode) {
- if((candidateNode instanceof CallNode)){
-
CallNode callNode = (CallNode) candidateNode;
- if(callNode.getName().replaceAll("=", "").equals(config.getSelectedName())){
+ if (callNode.getName().replaceAll("=", "").equals(config.getSelectedName())) {
String fileName = callNode.getPosition().getFile();
Node rootNode = NodeProvider.getRootNode(fileName, config.getDocProvider().getFileContent(fileName));
try {
@@ -127,32 +129,41 @@
}
return false;
}
-
@Override
protected void checkFinalConditions() {
String newName = config.getNewName();
String selectedName = config.getSelectedName();
-
- if(newName == null || selectedName.equals(newName)){
+
+ if (newName == null || selectedName.equals(newName)) {
addError("The name has to be changed to perform the refactoring.");
return;
}
-
- for ( String currentName : config.getFieldNames()){
- if(currentName.equals(newName)){
+
+ for (String currentName : config.getFieldNames()) {
+ if (currentName.equals(newName)) {
addError("Field name already exists.");
return;
}
- }
+ }
}
@Override
protected void checkInitialConditions() {
- if(!config.hasSelectedName()){
- addError("There is no field at the caret position.");
- } else if(!config.hasWholeClassNode()) {
- addError("The selected field is not inside of a class.");
+ Collection<FieldNodeWrapper> fields = PartialClassNodeWrapper.getFieldsFromNode(config.getDocProvider().getRootNode());
+ FieldNodeWrapper selectedFieldNode = SelectionNodeProvider.getSelectedWrappedNode(fields, config.getCaretPosition());
+ if (config.getWholeClassNode() == null) {
+ if (selectedFieldNode != null) {
+ addError("Cannot rename the selected field. There was no surrounding class found.");
+ return;
+ }
}
+ if (!config.hasSelectedName() || !isSelectionInFieldName(selectedFieldNode)) {
+ addError(DEFAULT_ERROR);
+ }
}
+
+ private boolean isSelectionInFieldName(FieldNodeWrapper node) {
+ return config.getCaretPosition() <= node.getPosition().getStartOffset() + node.getName().length();
+ }
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/LocalVariableRenamer.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/LocalVariableRenamer.java 2007-02-22 20:46:57 UTC (rev 2006)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/LocalVariableRenamer.java 2007-02-23 11:33:06 UTC (rev 2007)
@@ -47,8 +47,8 @@
}
public TextEdit getEdit() {
- RenameConfig config = new RenameConfig(doc, 0);
- new RenameConditionChecker(config);
+ RenameLocalConfig config = new RenameLocalConfig(doc, 0);
+ new RenameLocalConditionChecker(config);
LocalVariablesEditProvider editProvider = new LocalVariablesEditProvider(config);
editProvider.setSelectedVariableName(from);
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/LocalVariablesEditProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/LocalVariablesEditProvider.java 2007-02-22 20:46:57 UTC (rev 2006)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/LocalVariablesEditProvider.java 2007-02-23 11:33:06 UTC (rev 2007)
@@ -65,7 +65,7 @@
private final Node selectedNode;
- public LocalVariablesEditProvider(RenameConfig config) {
+ public LocalVariablesEditProvider(RenameLocalConfig config) {
rootNode = config.getSelectedMethod();
selectedNode = config.getSelectedNode();
localNames = config.getLocalNames();
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/RenameConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/RenameConditionChecker.java 2007-02-22 20:46:57 UTC (rev 2006)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/RenameConditionChecker.java 2007-02-23 11:33:06 UTC (rev 2007)
@@ -1,122 +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.renamelocalvariable;
-
-import java.util.Collection;
-
-import org.jruby.ast.ArgumentNode;
-import org.jruby.ast.AssignableNode;
-import org.jruby.ast.BlockArgNode;
-import org.jruby.ast.DAsgnNode;
-import org.jruby.ast.DVarNode;
-import org.jruby.ast.LocalAsgnNode;
-import org.jruby.ast.LocalVarNode;
-import org.jruby.ast.MethodDefNode;
-import org.jruby.ast.Node;
-import org.jruby.ast.RootNode;
-import org.jruby.ast.types.INameNode;
-import org.rubypeople.rdt.refactoring.core.NodeProvider;
-import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
-import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
-import org.rubypeople.rdt.refactoring.util.NameValidator;
-import org.rubypeople.rdt.refactoring.util.NodeUtil;
-
-public class RenameConditionChecker extends RefactoringConditionChecker {
-
- private static final String ALREADY_EXISTS = "The chosen variable name already exists! Please go back and change it.";
-
- private static final String INVALID_NAME = "Please enter a valid name for the variable.";
-
- private static final String NO_VARIABLE_SELECTED = "No variable selected. Please select the variable you want to rename.";
-
- private static final String NO_LOCAL_VARIABLES = "There are no local variables at the current carret position.";
-
- private static final Class[] SELECTED_NODE_TYPES = {LocalVarNode.class, LocalAsgnNode.class, ArgumentNode.class,
- BlockArgNode.class, DVarNode.class, DAsgnNode.class};
-
- private RenameConfig config;
-
- public RenameConditionChecker(RenameConfig config) {
- super(config.getDocumentProvider(), config);
- }
-
- public void init(Object configObj) {
- config = (RenameConfig) configObj;
- RootNode rootNode = config.getDocumentProvider().getRootNode();
- Node selectedNode = SelectionNodeProvider.getSelectedNodeOfType(rootNode, config.getCaretPosition(), SELECTED_NODE_TYPES);
- if(selectedNode instanceof AssignableNode) {
- int start = selectedNode.getPosition().getStartOffset();
- int end = start + ((INameNode) selectedNode).getName().length();
- if(config.getCaretPosition() < start || config.getCaretPosition() > end) {
- return;
- }
- }
-
- config.setSelectedNode(selectedNode);
- if(selectedNode == null) {
- config.setLocalNames(NodeUtil.getScope(rootNode).getVariables());
- Collection<MethodDefNode> methodNodes = NodeProvider.getMethodNodes(config.getDocumentProvider().getRootNode());
- config.setSelectedMethod(SelectionNodeProvider.getSelectedNodeOfType(methodNodes, config.getCaretPosition(), MethodDefNode.class));
- return;
- }
- config.setSelectedMethod(SelectionNodeProvider.getEnclosingScope(rootNode, selectedNode));
- config.setLocalNames(NodeUtil.getScope(config.getSelectedMethod()).getVariables());
- }
-
- @Override
- protected void checkInitialConditions() {
- if ((!config.hasSelectedMethod() || !config.hasLocalNames())
- && !NodeProvider.nodeAssignableFrom(config.getSelectedNode(), DVarNode.class, DAsgnNode.class)) {
- addError(NO_LOCAL_VARIABLES);
- }
- }
-
- @Override
- protected void checkFinalConditions() {
- LocalVariablesEditProvider editProvider = config.getRenameEditProvider();
- if (editProvider.getSelectedVariableName().equals("") && editProvider.getNewVariableName().equals("")) {
- addError(NO_VARIABLE_SELECTED);
- }
-
- if (!NameValidator.isValidLocalVariableName(editProvider.getNewVariableName())) {
- addError(INVALID_NAME);
- }
-
- if (editProvider.getSelectedVariableName().equals(editProvider.getNewVariableName())) {
- addError("You didn't choose a different name.");
- }
-
- for (String s : config.getLocalNames()) {
- if (editProvider.getNewVariableName().equals(s)) {
- addError(ALREADY_EXISTS);
- }
- }
- }
-
-}
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/RenameConfig.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/RenameConfig.java 2007-02-22 20:46:57 UTC (rev 2006)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/RenameConfig.java 2007-02-23 11:33:06 UTC (rev 2007)
@@ -1,104 +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.renamelocalvariable;
-
-import org.jruby.ast.Node;
-import org.jruby.ast.types.INameNode;
-import org.rubypeople.rdt.refactoring.documentprovider.DocumentProvider;
-
-public class RenameConfig implements IRenameConfig {
-
- private DocumentProvider docProvider;
- private int caretPosition;
- private Node selectedNode;
- private Node selectedMethod;
- private String[] localNames;
- private LocalVariablesEditProvider editProvider;
-
- public RenameConfig(DocumentProvider docProvider, int caretPosition) {
- this.docProvider = docProvider;
- this.caretPosition = caretPosition;
- }
-
- public String getSelectedNodeName() {
- if (selectedNode instanceof INameNode) {
- return ((INameNode) selectedNode).getName();
- }
- return "";
- }
-
- public DocumentProvider getDocumentProvider() {
- return docProvider;
- }
-
- public int getCaretPosition() {
- return caretPosition;
- }
-
- public boolean hasSelectedMethod() {
- return selectedMethod != null;
- }
-
- public boolean hasLocalNames() {
- return localNames.length > 2;
- }
-
- public Node getSelectedNode() {
- return selectedNode;
- }
-
- public Node getSelectedMethod() {
- return selectedMethod;
- }
-
- public String[] getLocalNames() {
- return localNames.clone();
- }
-
- public void setLocalVariablesEditProvider(LocalVariablesEditProvider editProvider) {
- this.editProvider = editProvider;
- }
-
- public LocalVariablesEditProvider getRenameEditProvider() {
- return editProvider;
- }
-
- public void setSelectedNode(Node selectedNode) {
- this.selectedNode = selectedNode;
- }
-
- public void setSelectedMethod(Node selectedMethod) {
- this.selectedMethod = selectedMethod;
- }
-
- public void setLocalNames(String[] localNames) {
- this.localNames = localNames.clone();
- }
-
-}
Copied: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/RenameLocalConditionChecker.java (from rev 1993, trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/RenameConditionChecker.java)
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/RenameLocalConditionChecker.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/RenameLocalConditionChecker.java 2007-02-23 11:33:06 UTC (rev 2007)
@@ -0,0 +1,136 @@
+/***** 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.renamelocalvariable;
+
+import java.util.Collection;
+
+import org.jruby.ast.ArgumentNode;
+import org.jruby.ast.AssignableNode;
+import org.jruby.ast.BlockArgNode;
+import org.jruby.ast.DAsgnNode;
+import org.jruby.ast.DVarNode;
+import org.jruby.ast.LocalAsgnNode;
+import org.jruby.ast.LocalVarNode;
+import org.jruby.ast.MethodDefNode;
+import org.jruby.ast.Node;
+import org.jruby.ast.RootNode;
+import org.jruby.ast.types.INameNode;
+import org.rubypeople.rdt.refactoring.core.NodeProvider;
+import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
+import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.LocalNodeWrapper;
+import org.rubypeople.rdt.refactoring.util.NameValidator;
+import org.rubypeople.rdt.refactoring.util.NodeUtil;
+
+public class RenameLocalConditionChecker extends RefactoringConditionChecker {
+
+ private static final String ALREADY_EXISTS = "The chosen variable name already exists! Please go back and change it.";
+
+ private static final String INVALID_NAME = "Please enter a valid name for the variable.";
+
+ private static final String NO_VARIABLE_SELECTED = "No variable selected. Please select the variable you want to rename.";
+
+ private static final String NO_LOCAL_VARIABLES = "There are no local variables at the current carret position.";
+
+ private static final Class[] SELECTED_NODE_TYPES = {LocalVarNode.class, LocalAsgnNode.class, ArgumentNode.class,
+ BlockArgNode.class, DVarNode.class, DAsgnNode.class};
+
+ public static final String DEFAULT_ERROR = NO_LOCAL_VARIABLES;
+
+ private RenameLocalConfig config;
+
+ public RenameLocalConditionChecker(RenameLocalConfig config) {
+ super(config.getDocumentProvider(), config);
+ }
+
+ public void init(Object configObj) {
+ config = (RenameLocalConfig) configObj;
+ RootNode rootNode = config.getDocumentProvider().getRootNode();
+ Node selectedNode = SelectionNodeProvider.getSelectedNodeOfType(rootNode, config.getCaretPosition(), SELECTED_NODE_TYPES);
+ if(selectedNode instanceof AssignableNode) {
+ int start = selectedNode.getPosition().getStartOffset();
+ int end = start + ((INameNode) selectedNode).getName().length();
+ if(config.getCaretPosition() < start || config.getCaretPosition() > end) {
+ return;
+ }
+ }
+
+ config.setSelectedNode(selectedNode);
+ if(selectedNode == null) {
+ config.setLocalNames(NodeUtil.getScope(rootNode).getVariables());
+ Collection<MethodDefNode> methodNodes = NodeProvider.getMethodNodes(rootNode);
+ config.setSelectedMethod(SelectionNodeProvider.getSelectedNodeOfType(methodNodes, config.getCaretPosition(), MethodDefNode.class));
+ return;
+ }
+ config.setSelectedMethod(SelectionNodeProvider.getEnclosingScope(rootNode, selectedNode));
+ config.setLocalNames(NodeUtil.getScope(config.getSelectedMethod()).getVariables());
+ }
+
+ @Override
+ protected void checkInitialConditions() {
+ if (!config.hasSelectedNode() || !isSelectedNodeLocalVar()) {
+ addError(NO_LOCAL_VARIABLES);
+ }
+ }
+
+ private boolean isSelectedNodeLocalVar() {
+ Node selected = config.getSelectedNode();
+ if(NodeUtil.nodeAssignableFrom(selected, LocalNodeWrapper.LOCAL_NODES_CLASSES)){
+ return true;
+ }
+ if(NodeUtil.nodeAssignableFrom(selected, ArgumentNode.class, BlockArgNode.class) && NodeUtil.nodeAssignableFrom(config.getSelectedMethod(), MethodDefNode.class)) {
+ MethodDefNode methodNode = (MethodDefNode) config.getSelectedMethod();
+ return methodNode.getNameNode() != selected;
+ }
+ return false;
+ }
+
+ @Override
+ protected void checkFinalConditions() {
+ LocalVariablesEditProvider editProvider = config.getRenameEditProvider();
+ if (editProvider.getSelectedVariableName().equals("") && editProvider.getNewVariableName().equals("")) {
+ addError(NO_VARIABLE_SELECTED);
+ }
+
+ if (!NameValidator.isValidLocalVariableName(editProvider.getNewVariableName())) {
+ addError(INVALID_NAME);
+ }
+
+ if (editProvider.getSelectedVariableName().equals(editProvider.getNewVariableName())) {
+ addError("You didn't choose a different name.");
+ }
+
+ for (String s : config.getLocalNames()) {
+ if (editProvider.getNewVariableName().equals(s)) {
+ addError(ALREADY_EXISTS);
+ }
+ }
+ }
+
+}
Copied: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/RenameLocalConfig.java (from rev 1993, trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/RenameConfig.java)
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/RenameLocalConfig.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocalvariable/RenameLocalConfig.java 2007-02-23 11:33:06 UTC (rev 2007)
@@ -0,0 +1,108 @@
+/***** 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 t...
[truncated message content] |
|
From: <caw...@us...> - 2007-02-22 20:47:02
|
Revision: 2006
http://svn.sourceforge.net/rubyeclipse/?rev=2006&view=rev
Author: cawilliams
Date: 2007-02-22 12:46:57 -0800 (Thu, 22 Feb 2007)
Log Message:
-----------
chnage the infrastructure for generating errors/warnings. Much easier to add a new type of AST code analyzer now...
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java 2007-02-22 20:46:57 UTC (rev 2006)
@@ -0,0 +1,51 @@
+package org.rubypeople.rdt.internal.core.parser.warnings;
+
+import org.jruby.ast.Node;
+import org.jruby.ast.visitor.AbstractVisitor;
+import org.jruby.evaluator.Instruction;
+import org.jruby.lexer.yacc.ISourcePosition;
+import org.rubypeople.rdt.core.IProblemRequestor;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.core.parser.IProblem;
+import org.rubypeople.rdt.internal.core.parser.Error;
+import org.rubypeople.rdt.internal.core.parser.NodeUtil;
+import org.rubypeople.rdt.internal.core.parser.Warning;
+
+public abstract class RubyLintVisitor extends AbstractVisitor {
+
+ private IProblemRequestor problemRequestor;
+ private String contents;
+
+ public RubyLintVisitor(String contents, IProblemRequestor problemRequestor) {
+ this.problemRequestor = problemRequestor;
+ this.contents = contents;
+ }
+
+ protected String getSource(Node node) {
+ return NodeUtil.getSource(contents, node);
+ }
+
+ protected void createProblem(ISourcePosition position, String message) {
+ String value = RubyCore.getOption(getOptionKey());
+ if (value != null && value.equals(RubyCore.IGNORE))
+ return;
+ IProblem problem;
+ if (value != null && value.equals(RubyCore.ERROR))
+ problem = new Error(position, message);
+ else
+ problem = new Warning(position, message);
+ problemRequestor.acceptProblem(problem);
+ }
+
+ @Override
+ protected Instruction visitNode(Node iVisited) {
+ return null;
+ }
+
+ /**
+ * The key used to store the error/warning severity option.
+ * @return a String key
+ */
+ abstract protected String getOptionKey();
+
+}
Property changes on: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-02-22 20:46:27
|
Revision: 2005
http://svn.sourceforge.net/rubyeclipse/?rev=2005&view=rev
Author: cawilliams
Date: 2007-02-22 12:46:25 -0800 (Thu, 22 Feb 2007)
Log Message:
-----------
chnage the infrastructure for generating errors/warnings. Much easier to add a new type of AST code analyzer now...
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/ConstantReassignmentVisitor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/DelegatingVisitor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/EmptyStatementVisitor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/StaticConditionalVisitor.java
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/ConstantReassignmentVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/ConstantReassignmentVisitor.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/ConstantReassignmentVisitor.java 2007-02-22 20:46:25 UTC (rev 2005)
@@ -0,0 +1,34 @@
+package org.rubypeople.rdt.internal.core.parser.warnings;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jruby.ast.ConstDeclNode;
+import org.jruby.evaluator.Instruction;
+import org.rubypeople.rdt.core.IProblemRequestor;
+
+public class ConstantReassignmentVisitor extends RubyLintVisitor {
+
+ private Set<String> assignedConstants;
+
+ public ConstantReassignmentVisitor(String contents, IProblemRequestor problemRequestor) {
+ super(contents, problemRequestor);
+ assignedConstants = new HashSet<String>();
+ }
+
+ @Override
+ protected String getOptionKey() {
+ // FIXME Set up a compiler option for this!
+ return null;
+ }
+
+ public Instruction visitConstDeclNode(ConstDeclNode iVisited) {
+ String name = iVisited.getName();
+ if (assignedConstants.contains(name)) {
+ createProblem(iVisited.getPosition(), "Reassignment of a constant");
+ } else
+ assignedConstants.add(name);
+ return super.visitConstDeclNode(iVisited);
+ }
+
+}
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/DelegatingVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/DelegatingVisitor.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/DelegatingVisitor.java 2007-02-22 20:46:25 UTC (rev 2005)
@@ -0,0 +1,886 @@
+package org.rubypeople.rdt.internal.core.parser.warnings;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jruby.ast.AliasNode;
+import org.jruby.ast.AndNode;
+import org.jruby.ast.ArgsCatNode;
+import org.jruby.ast.ArgsNode;
+import org.jruby.ast.ArgsPushNode;
+import org.jruby.ast.ArrayNode;
+import org.jruby.ast.AttrAssignNode;
+import org.jruby.ast.BackRefNode;
+import org.jruby.ast.BeginNode;
+import org.jruby.ast.BignumNode;
+import org.jruby.ast.BlockArgNode;
+import org.jruby.ast.BlockNode;
+import org.jruby.ast.BlockPassNode;
+import org.jruby.ast.BreakNode;
+import org.jruby.ast.CallNode;
+import org.jruby.ast.CaseNode;
+import org.jruby.ast.ClassNode;
+import org.jruby.ast.ClassVarAsgnNode;
+import org.jruby.ast.ClassVarDeclNode;
+import org.jruby.ast.ClassVarNode;
+import org.jruby.ast.Colon2Node;
+import org.jruby.ast.Colon3Node;
+import org.jruby.ast.ConstDeclNode;
+import org.jruby.ast.ConstNode;
+import org.jruby.ast.DAsgnNode;
+import org.jruby.ast.DRegexpNode;
+import org.jruby.ast.DStrNode;
+import org.jruby.ast.DSymbolNode;
+import org.jruby.ast.DVarNode;
+import org.jruby.ast.DXStrNode;
+import org.jruby.ast.DefinedNode;
+import org.jruby.ast.DefnNode;
+import org.jruby.ast.DefsNode;
+import org.jruby.ast.DotNode;
+import org.jruby.ast.EnsureNode;
+import org.jruby.ast.EvStrNode;
+import org.jruby.ast.FCallNode;
+import org.jruby.ast.FalseNode;
+import org.jruby.ast.FixnumNode;
+import org.jruby.ast.FlipNode;
+import org.jruby.ast.FloatNode;
+import org.jruby.ast.ForNode;
+import org.jruby.ast.GlobalAsgnNode;
+import org.jruby.ast.GlobalVarNode;
+import org.jruby.ast.HashNode;
+import org.jruby.ast.IfNode;
+import org.jruby.ast.InstAsgnNode;
+import org.jruby.ast.InstVarNode;
+import org.jruby.ast.IterNode;
+import org.jruby.ast.LocalAsgnNode;
+import org.jruby.ast.LocalVarNode;
+import org.jruby.ast.Match2Node;
+import org.jruby.ast.Match3Node;
+import org.jruby.ast.MatchNode;
+import org.jruby.ast.ModuleNode;
+import org.jruby.ast.MultipleAsgnNode;
+import org.jruby.ast.NewlineNode;
+import org.jruby.ast.NextNode;
+import org.jruby.ast.NilNode;
+import org.jruby.ast.NotNode;
+import org.jruby.ast.NthRefNode;
+import org.jruby.ast.OpAsgnAndNode;
+import org.jruby.ast.OpAsgnNode;
+import org.jruby.ast.OpAsgnOrNode;
+import org.jruby.ast.OpElementAsgnNode;
+import org.jruby.ast.OptNNode;
+import org.jruby.ast.OrNode;
+import org.jruby.ast.PostExeNode;
+import org.jruby.ast.RedoNode;
+import org.jruby.ast.RegexpNode;
+import org.jruby.ast.RescueBodyNode;
+import org.jruby.ast.RescueNode;
+import org.jruby.ast.RetryNode;
+import org.jruby.ast.ReturnNode;
+import org.jruby.ast.RootNode;
+import org.jruby.ast.SClassNode;
+import org.jruby.ast.SValueNode;
+import org.jruby.ast.SelfNode;
+import org.jruby.ast.SplatNode;
+import org.jruby.ast.StrNode;
+import org.jruby.ast.SuperNode;
+import org.jruby.ast.SymbolNode;
+import org.jruby.ast.ToAryNode;
+import org.jruby.ast.TrueNode;
+import org.jruby.ast.UndefNode;
+import org.jruby.ast.UntilNode;
+import org.jruby.ast.VAliasNode;
+import org.jruby.ast.VCallNode;
+import org.jruby.ast.WhenNode;
+import org.jruby.ast.WhileNode;
+import org.jruby.ast.XStrNode;
+import org.jruby.ast.YieldNode;
+import org.jruby.ast.ZArrayNode;
+import org.jruby.ast.ZSuperNode;
+import org.jruby.evaluator.Instruction;
+import org.rubypeople.rdt.core.IProblemRequestor;
+import org.rubypeople.rdt.internal.core.parser.InOrderVisitor;
+
+/**
+ * <p>DelegatingVisitor takes a list of visitors, traverse the AST in order, and at
+ * each node calls the correct visitXXXNode method on every visitor. This allows
+ * us to traverse the AST only once while having X number of visitors operate on
+ * it.</p>
+ *
+ * <p>Right now it is customized to RubyLintVisitors, which is the abstract
+ * base class for all visitors that do coce analysis for Error/Warning markers.</p>
+ *
+ * @author Christopher Williams
+ *
+ */
+public class DelegatingVisitor extends InOrderVisitor {
+
+ private List<RubyLintVisitor> visitors;
+
+ public static List<RubyLintVisitor> createVisitors(String contents, IProblemRequestor requestor) {
+ List<RubyLintVisitor> visitors = new ArrayList<RubyLintVisitor>();
+ // FIXME Run through a map of keys to classes and add instances of
+ // classes whose key is not set to ignore
+ visitors.add(new EmptyStatementVisitor(contents, requestor));
+ visitors.add(new StaticConditionalVisitor(contents, requestor));
+ visitors.add(new ConstantReassignmentVisitor(contents, requestor));
+ return visitors;
+ }
+
+ public DelegatingVisitor(List<RubyLintVisitor> visitors) {
+ this.visitors = visitors;
+ }
+
+ @Override
+ public Instruction visitAliasNode(AliasNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitAliasNode(iVisited);
+ }
+ return super.visitAliasNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitAndNode(AndNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitAndNode(iVisited);
+ }
+ return super.visitAndNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitArgsCatNode(ArgsCatNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitArgsCatNode(iVisited);
+ }
+ return super.visitArgsCatNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitArgsNode(ArgsNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitArgsNode(iVisited);
+ }
+ return super.visitArgsNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitArgsPushNode(ArgsPushNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitArgsPushNode(iVisited);
+ }
+ return super.visitArgsPushNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitArrayNode(ArrayNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitArrayNode(iVisited);
+ }
+ return super.visitArrayNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitAttrAssignNode(AttrAssignNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitAttrAssignNode(iVisited);
+ }
+ return super.visitAttrAssignNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitBackRefNode(BackRefNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitBackRefNode(iVisited);
+ }
+ return super.visitBackRefNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitBeginNode(BeginNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitBeginNode(iVisited);
+ }
+ return super.visitBeginNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitBignumNode(BignumNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitBignumNode(iVisited);
+ }
+ return super.visitBignumNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitBlockArgNode(BlockArgNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitBlockArgNode(iVisited);
+ }
+ return super.visitBlockArgNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitBlockNode(BlockNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitBlockNode(iVisited);
+ }
+ return super.visitBlockNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitBlockPassNode(BlockPassNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitBlockPassNode(iVisited);
+ }
+ return super.visitBlockPassNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitBreakNode(BreakNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitBreakNode(iVisited);
+ }
+ return super.visitBreakNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitCallNode(CallNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitCallNode(iVisited);
+ }
+ return super.visitCallNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitCaseNode(CaseNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitCaseNode(iVisited);
+ }
+ return super.visitCaseNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitClassNode(ClassNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitClassNode(iVisited);
+ }
+ return super.visitClassNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitClassVarAsgnNode(ClassVarAsgnNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitClassVarAsgnNode(iVisited);
+ }
+ return super.visitClassVarAsgnNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitClassVarDeclNode(ClassVarDeclNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitClassVarDeclNode(iVisited);
+ }
+ return super.visitClassVarDeclNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitClassVarNode(ClassVarNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitClassVarNode(iVisited);
+ }
+ return super.visitClassVarNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitColon2Node(Colon2Node iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitColon2Node(iVisited);
+ }
+ return super.visitColon2Node(iVisited);
+ }
+
+ @Override
+ public Instruction visitColon3Node(Colon3Node iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitColon3Node(iVisited);
+ }
+ return super.visitColon3Node(iVisited);
+ }
+
+ @Override
+ public Instruction visitConstDeclNode(ConstDeclNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitConstDeclNode(iVisited);
+ }
+ return super.visitConstDeclNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitConstNode(ConstNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitConstNode(iVisited);
+ }
+ return super.visitConstNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitDAsgnNode(DAsgnNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitDAsgnNode(iVisited);
+ }
+ return super.visitDAsgnNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitDefinedNode(DefinedNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitDefinedNode(iVisited);
+ }
+ return super.visitDefinedNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitDefnNode(DefnNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitDefnNode(iVisited);
+ }
+ return super.visitDefnNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitDefsNode(DefsNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitDefsNode(iVisited);
+ }
+ return super.visitDefsNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitDotNode(DotNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitDotNode(iVisited);
+ }
+ return super.visitDotNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitDRegxNode(DRegexpNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitDRegxNode(iVisited);
+ }
+ return super.visitDRegxNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitDStrNode(DStrNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitDStrNode(iVisited);
+ }
+ return super.visitDStrNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitDSymbolNode(DSymbolNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitDSymbolNode(iVisited);
+ }
+ return super.visitDSymbolNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitDVarNode(DVarNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitDVarNode(iVisited);
+ }
+ return super.visitDVarNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitDXStrNode(DXStrNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitDXStrNode(iVisited);
+ }
+ return super.visitDXStrNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitEnsureNode(EnsureNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitEnsureNode(iVisited);
+ }
+ return super.visitEnsureNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitEvStrNode(EvStrNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitEvStrNode(iVisited);
+ }
+ return super.visitEvStrNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitFalseNode(FalseNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitFalseNode(iVisited);
+ }
+ return super.visitFalseNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitFCallNode(FCallNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitFCallNode(iVisited);
+ }
+ return super.visitFCallNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitFixnumNode(FixnumNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitFixnumNode(iVisited);
+ }
+ return super.visitFixnumNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitFlipNode(FlipNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitFlipNode(iVisited);
+ }
+ return super.visitFlipNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitFloatNode(FloatNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitFloatNode(iVisited);
+ }
+ return super.visitFloatNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitForNode(ForNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitForNode(iVisited);
+ }
+ return super.visitForNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitGlobalAsgnNode(GlobalAsgnNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitGlobalAsgnNode(iVisited);
+ }
+ return super.visitGlobalAsgnNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitGlobalVarNode(GlobalVarNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitGlobalVarNode(iVisited);
+ }
+ return super.visitGlobalVarNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitHashNode(HashNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitHashNode(iVisited);
+ }
+ return super.visitHashNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitIfNode(IfNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitIfNode(iVisited);
+ }
+ return super.visitIfNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitInstAsgnNode(InstAsgnNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitInstAsgnNode(iVisited);
+ }
+ return super.visitInstAsgnNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitInstVarNode(InstVarNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitInstVarNode(iVisited);
+ }
+ return super.visitInstVarNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitIterNode(IterNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitIterNode(iVisited);
+ }
+ return super.visitIterNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitLocalAsgnNode(LocalAsgnNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitLocalAsgnNode(iVisited);
+ }
+ return super.visitLocalAsgnNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitLocalVarNode(LocalVarNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitLocalVarNode(iVisited);
+ }
+ return super.visitLocalVarNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitMatch2Node(Match2Node iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitMatch2Node(iVisited);
+ }
+ return super.visitMatch2Node(iVisited);
+ }
+
+ @Override
+ public Instruction visitMatch3Node(Match3Node iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitMatch3Node(iVisited);
+ }
+ return super.visitMatch3Node(iVisited);
+ }
+
+ @Override
+ public Instruction visitMatchNode(MatchNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitMatchNode(iVisited);
+ }
+ return super.visitMatchNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitModuleNode(ModuleNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitModuleNode(iVisited);
+ }
+ return super.visitModuleNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitMultipleAsgnNode(MultipleAsgnNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitMultipleAsgnNode(iVisited);
+ }
+ return super.visitMultipleAsgnNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitNewlineNode(NewlineNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitNewlineNode(iVisited);
+ }
+ return super.visitNewlineNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitNextNode(NextNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitNextNode(iVisited);
+ }
+ return super.visitNextNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitNilNode(NilNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitNilNode(iVisited);
+ }
+ return super.visitNilNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitNotNode(NotNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitNotNode(iVisited);
+ }
+ return super.visitNotNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitNthRefNode(NthRefNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitNthRefNode(iVisited);
+ }
+ return super.visitNthRefNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitOpAsgnAndNode(OpAsgnAndNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitOpAsgnAndNode(iVisited);
+ }
+ return super.visitOpAsgnAndNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitOpAsgnNode(OpAsgnNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitOpAsgnNode(iVisited);
+ }
+ return super.visitOpAsgnNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitOpAsgnOrNode(OpAsgnOrNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitOpAsgnOrNode(iVisited);
+ }
+ return super.visitOpAsgnOrNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitOpElementAsgnNode(OpElementAsgnNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitOpElementAsgnNode(iVisited);
+ }
+ return super.visitOpElementAsgnNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitOptNNode(OptNNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitOptNNode(iVisited);
+ }
+ return super.visitOptNNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitOrNode(OrNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitOrNode(iVisited);
+ }
+ return super.visitOrNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitPostExeNode(PostExeNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitPostExeNode(iVisited);
+ }
+ return super.visitPostExeNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitRedoNode(RedoNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitRedoNode(iVisited);
+ }
+ return super.visitRedoNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitRegexpNode(RegexpNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitRegexpNode(iVisited);
+ }
+ return super.visitRegexpNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitRescueBodyNode(RescueBodyNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitRescueBodyNode(iVisited);
+ }
+ return super.visitRescueBodyNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitRescueNode(RescueNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitRescueNode(iVisited);
+ }
+ return super.visitRescueNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitRetryNode(RetryNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitRetryNode(iVisited);
+ }
+ return super.visitRetryNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitReturnNode(ReturnNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitReturnNode(iVisited);
+ }
+ return super.visitReturnNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitRootNode(RootNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitRootNode(iVisited);
+ }
+ return super.visitRootNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitSClassNode(SClassNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitSClassNode(iVisited);
+ }
+ return super.visitSClassNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitSelfNode(SelfNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitSelfNode(iVisited);
+ }
+ return super.visitSelfNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitSplatNode(SplatNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitSplatNode(iVisited);
+ }
+ return super.visitSplatNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitStrNode(StrNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitStrNode(iVisited);
+ }
+ return super.visitStrNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitSuperNode(SuperNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitSuperNode(iVisited);
+ }
+ return super.visitSuperNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitSValueNode(SValueNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitSValueNode(iVisited);
+ }
+ return super.visitSValueNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitSymbolNode(SymbolNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitSymbolNode(iVisited);
+ }
+ return super.visitSymbolNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitToAryNode(ToAryNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitToAryNode(iVisited);
+ }
+ return super.visitToAryNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitTrueNode(TrueNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitTrueNode(iVisited);
+ }
+ return super.visitTrueNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitUndefNode(UndefNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitUndefNode(iVisited);
+ }
+ return super.visitUndefNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitUntilNode(UntilNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitUntilNode(iVisited);
+ }
+ return super.visitUntilNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitVAliasNode(VAliasNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitVAliasNode(iVisited);
+ }
+ return super.visitVAliasNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitVCallNode(VCallNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitVCallNode(iVisited);
+ }
+ return super.visitVCallNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitWhenNode(WhenNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitWhenNode(iVisited);
+ }
+ return super.visitWhenNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitWhileNode(WhileNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitWhileNode(iVisited);
+ }
+ return super.visitWhileNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitXStrNode(XStrNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitXStrNode(iVisited);
+ }
+ return super.visitXStrNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitYieldNode(YieldNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitYieldNode(iVisited);
+ }
+ return super.visitYieldNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitZArrayNode(ZArrayNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitZArrayNode(iVisited);
+ }
+ return super.visitZArrayNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitZSuperNode(ZSuperNode iVisited) {
+ for (RubyLintVisitor visitor : visitors) {
+ visitor.visitZSuperNode(iVisited);
+ }
+ return super.visitZSuperNode(iVisited);
+ }
+
+}
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/EmptyStatementVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/EmptyStatementVisitor.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/EmptyStatementVisitor.java 2007-02-22 20:46:25 UTC (rev 2005)
@@ -0,0 +1,59 @@
+package org.rubypeople.rdt.internal.core.parser.warnings;
+
+import org.jruby.ast.DefnNode;
+import org.jruby.ast.DefsNode;
+import org.jruby.ast.IfNode;
+import org.jruby.ast.IterNode;
+import org.jruby.ast.WhenNode;
+import org.jruby.evaluator.Instruction;
+import org.rubypeople.rdt.core.IProblemRequestor;
+import org.rubypeople.rdt.core.RubyCore;
+
+public class EmptyStatementVisitor extends RubyLintVisitor {
+
+ public EmptyStatementVisitor(String contents, IProblemRequestor problemRequestor) {
+ super(contents, problemRequestor);
+ }
+
+ @Override
+ protected String getOptionKey() {
+ return RubyCore.COMPILER_PB_EMPTY_STATEMENT;
+ }
+
+ public Instruction visitIfNode(IfNode iVisited) {
+ String source = getSource(iVisited);
+ if (iVisited.getThenBody() == null && source.indexOf("unless") == -1) {
+ createProblem(iVisited.getPosition(), "Empty Conditional Body");
+ }
+ return super.visitIfNode(iVisited);
+ }
+
+ public Instruction visitDefnNode(DefnNode iVisited) {
+ if (iVisited.getBodyNode() == null) {
+ createProblem(iVisited.getPosition(), "Empty Method Definition");
+ }
+ return super.visitDefnNode(iVisited);
+ }
+
+ public Instruction visitDefsNode(DefsNode iVisited) {
+ if (iVisited.getBodyNode() == null) {
+ createProblem(iVisited.getPosition(), "Empty Method Definition");
+ }
+ return super.visitDefsNode(iVisited);
+ }
+
+ public Instruction visitWhenNode(WhenNode iVisited) {
+ if (iVisited.getBodyNode() == null) {
+ createProblem(iVisited.getPosition(), "Empty When Body");
+ }
+ return super.visitWhenNode(iVisited);
+ }
+
+ public Instruction visitIterNode(IterNode iVisited) {
+ if (iVisited.getBodyNode() == null) {
+ createProblem(iVisited.getPosition(), "Empty Block");
+ }
+ return super.visitIterNode(iVisited);
+ }
+
+}
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/StaticConditionalVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/StaticConditionalVisitor.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/StaticConditionalVisitor.java 2007-02-22 20:46:25 UTC (rev 2005)
@@ -0,0 +1,33 @@
+package org.rubypeople.rdt.internal.core.parser.warnings;
+
+import org.jruby.ast.FalseNode;
+import org.jruby.ast.IfNode;
+import org.jruby.ast.NilNode;
+import org.jruby.ast.Node;
+import org.jruby.ast.TrueNode;
+import org.jruby.evaluator.Instruction;
+import org.rubypeople.rdt.core.IProblemRequestor;
+
+public class StaticConditionalVisitor extends RubyLintVisitor {
+
+ public StaticConditionalVisitor(String contents, IProblemRequestor problemRequestor) {
+ super(contents, problemRequestor);
+ }
+
+ @Override
+ protected String getOptionKey() {
+// FIXME Set up a compiler option for this!
+ return null;
+ }
+
+ public Instruction visitIfNode(IfNode iVisited) {
+ Node condition = iVisited.getCondition();
+ if (condition instanceof TrueNode) {
+ createProblem(iVisited.getPosition(), "Condition is always true");
+ } else if ((condition instanceof FalseNode) || (condition instanceof NilNode)) {
+ createProblem(iVisited.getPosition(), "Condition is always false");
+ }
+ return super.visitIfNode(iVisited);
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-02-22 20:45:44
|
Revision: 2004
http://svn.sourceforge.net/rubyeclipse/?rev=2004&view=rev
Author: cawilliams
Date: 2007-02-22 12:45:36 -0800 (Thu, 22 Feb 2007)
Log Message:
-----------
chnage the infrastructure for generating errors/warnings. Much easier to add a new type of AST code analyzer now...
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptProblemFinder.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_RubyLintVisitor.java
Modified: trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF 2007-02-22 20:44:36 UTC (rev 2003)
+++ trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF 2007-02-22 20:45:36 UTC (rev 2004)
@@ -15,6 +15,7 @@
org.rubypeople.rdt.internal.core.buffer,
org.rubypeople.rdt.internal.core.builder,
org.rubypeople.rdt.internal.core.parser,
+ org.rubypeople.rdt.internal.core.parser.warnings,
org.rubypeople.rdt.internal.core.symbols,
org.rubypeople.rdt.internal.core.util,
org.rubypeople.rdt.internal.formatter,
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptProblemFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptProblemFinder.java 2007-02-22 20:44:36 UTC (rev 2003)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptProblemFinder.java 2007-02-22 20:45:36 UTC (rev 2004)
@@ -11,15 +11,18 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
import org.jruby.ast.Node;
+import org.jruby.ast.visitor.NodeVisitor;
import org.jruby.lexer.yacc.SyntaxException;
import org.rubypeople.rdt.core.IProblemRequestor;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.parser.IProblem;
+import org.rubypeople.rdt.internal.core.builder.ProblemRequestorMarkerManager;
import org.rubypeople.rdt.internal.core.parser.Error;
import org.rubypeople.rdt.internal.core.parser.RdtWarnings;
-import org.rubypeople.rdt.internal.core.parser.RubyLintVisitor;
import org.rubypeople.rdt.internal.core.parser.RubyParser;
import org.rubypeople.rdt.internal.core.parser.TaskParser;
+import org.rubypeople.rdt.internal.core.parser.warnings.DelegatingVisitor;
+import org.rubypeople.rdt.internal.core.parser.warnings.RubyLintVisitor;
/**
* @author Chris
@@ -52,7 +55,8 @@
try {
Node node = parser.parse((IFile) script.getUnderlyingResource(), new StringReader(contents));
if (node == null) return;
- RubyLintVisitor visitor = new RubyLintVisitor(contents, problemRequestor);
+ List<RubyLintVisitor> visitors = DelegatingVisitor.createVisitors(contents, problemRequestor);
+ NodeVisitor visitor = new DelegatingVisitor(visitors);
node.accept(visitor);
} catch (SyntaxException e) {
// Eat the exception
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java 2007-02-22 20:44:36 UTC (rev 2003)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java 2007-02-22 20:45:36 UTC (rev 2004)
@@ -17,15 +17,18 @@
import java.io.Reader;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
+import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.jruby.ast.Node;
+import org.jruby.ast.visitor.NodeVisitor;
import org.jruby.lexer.yacc.SyntaxException;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.internal.core.parser.ImmediateWarnings;
-import org.rubypeople.rdt.internal.core.parser.RubyLintVisitor;
import org.rubypeople.rdt.internal.core.parser.RubyParser;
+import org.rubypeople.rdt.internal.core.parser.warnings.DelegatingVisitor;
+import org.rubypeople.rdt.internal.core.parser.warnings.RubyLintVisitor;
public final class RubyCodeAnalyzer implements SingleFileCompiler {
private final IMarkerManager markerManager;
@@ -54,8 +57,9 @@
markerManager.removeProblemsAndTasksFor(file);
try {
Node rootNode = parser.parse(file, new StringReader(contents));
- if (rootNode == null) return;
- RubyLintVisitor visitor = new RubyLintVisitor(contents, new ProblemRequestorMarkerManager(file, markerManager));
+ if (rootNode == null) return;
+ List<RubyLintVisitor> visitors = DelegatingVisitor.createVisitors(contents, new ProblemRequestorMarkerManager(file, markerManager));
+ NodeVisitor visitor = new DelegatingVisitor(visitors);
rootNode.accept(visitor);
indexUpdater.update(file, rootNode, true);
} catch (SyntaxException e) {
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_RubyLintVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_RubyLintVisitor.java 2007-02-22 20:44:36 UTC (rev 2003)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_RubyLintVisitor.java 2007-02-22 20:45:36 UTC (rev 2004)
@@ -7,11 +7,13 @@
import junit.framework.TestCase;
import org.jruby.ast.Node;
+import org.jruby.ast.visitor.NodeVisitor;
import org.rubypeople.eclipse.shams.resources.ShamFile;
import org.rubypeople.rdt.core.IProblemRequestor;
import org.rubypeople.rdt.core.parser.IProblem;
-import org.rubypeople.rdt.internal.core.parser.RubyLintVisitor;
import org.rubypeople.rdt.internal.core.parser.RubyParser;
+import org.rubypeople.rdt.internal.core.parser.warnings.DelegatingVisitor;
+import org.rubypeople.rdt.internal.core.parser.warnings.RubyLintVisitor;
public class TC_RubyLintVisitor extends TestCase {
@@ -47,7 +49,6 @@
public void testUnlessConditionalDoesntCreateEmptyConditionalWarning() throws Exception {
runLint("unless @blah\n @var = 3\nend");
- System.out.println(problemRequestor.problems.get(0));
assertEquals(0, problemRequestor.problems.size());
}
@@ -55,8 +56,8 @@
RubyParser parser = new RubyParser();
Node rootNode = parser.parse(new ShamFile("fake/path.rb"), new StringReader(contents));
problemRequestor = new MockProblemRequestor();
- RubyLintVisitor visitor = new RubyLintVisitor(contents,
- problemRequestor);
+ List<RubyLintVisitor> visitors = DelegatingVisitor.createVisitors(contents, problemRequestor);
+ NodeVisitor visitor = new DelegatingVisitor(visitors);
rootNode.accept(visitor);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-02-22 20:44:50
|
Revision: 2003
http://svn.sourceforge.net/rubyeclipse/?rev=2003&view=rev
Author: cawilliams
Date: 2007-02-22 12:44:36 -0800 (Thu, 22 Feb 2007)
Log Message:
-----------
chnage the infrastructure for generating errors/warnings. Much easier to add a new type of AST code analyzer now...
Removed Paths:
-------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/RubyLintVisitor.java
Deleted: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/RubyLintVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/RubyLintVisitor.java 2007-02-22 19:36:48 UTC (rev 2002)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/RubyLintVisitor.java 2007-02-22 20:44:36 UTC (rev 2003)
@@ -1,127 +0,0 @@
-package org.rubypeople.rdt.internal.core.parser;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jruby.ast.BlockNode;
-import org.jruby.ast.CallNode;
-import org.jruby.ast.ConstDeclNode;
-import org.jruby.ast.DefnNode;
-import org.jruby.ast.DefsNode;
-import org.jruby.ast.FCallNode;
-import org.jruby.ast.FalseNode;
-import org.jruby.ast.IfNode;
-import org.jruby.ast.IterNode;
-import org.jruby.ast.NilNode;
-import org.jruby.ast.Node;
-import org.jruby.ast.TrueNode;
-import org.jruby.ast.WhenNode;
-import org.jruby.evaluator.Instruction;
-import org.jruby.lexer.yacc.ISourcePosition;
-import org.rubypeople.rdt.core.IProblemRequestor;
-import org.rubypeople.rdt.core.RubyCore;
-import org.rubypeople.rdt.core.parser.IProblem;
-
-public class RubyLintVisitor extends InOrderVisitor {
-
- private IProblemRequestor problemRequestor;
- private Set assignedConstants;
- private Set methodsCalled;
- private String contents;
-
- public RubyLintVisitor(String contents, IProblemRequestor problemRequestor) {
- this.problemRequestor = problemRequestor;
- assignedConstants = new HashSet();
- methodsCalled = new HashSet();
- this.contents = contents;
- }
-
- public Instruction visitFCallNode(FCallNode iVisited) {
- methodsCalled.add(iVisited.getName());
- return super.visitFCallNode(iVisited);
- }
-
- public Instruction visitCallNode(CallNode iVisited) {
- methodsCalled.add(iVisited.getName());
- return super.visitCallNode(iVisited);
- }
-
- public Instruction visitIfNode(IfNode iVisited) {
- Node condition = iVisited.getCondition();
- if (condition instanceof TrueNode) {
- problemRequestor.acceptProblem(new Warning(iVisited.getPosition(), "Condition is always true"));
- } else if ((condition instanceof FalseNode) || (condition instanceof NilNode)) {
- problemRequestor.acceptProblem(new Warning(iVisited.getPosition(), "Condition is always false"));
- }
-
- String source = NodeUtil.getSource(contents, iVisited);
- if (iVisited.getThenBody() == null && source.indexOf("unless") == -1) {
- IProblem problem = createProblem(RubyCore.COMPILER_PB_EMPTY_STATEMENT, iVisited.getPosition(), "Empty Conditional Body");
- if (problem != null)
- problemRequestor.acceptProblem(problem);
- }
- return super.visitIfNode(iVisited);
- }
-
- public Instruction visitWhenNode(WhenNode iVisited) {
- if (iVisited.getBodyNode() == null) {
- IProblem problem = createProblem(RubyCore.COMPILER_PB_EMPTY_STATEMENT, iVisited.getPosition(), "Empty When Body");
- if (problem != null)
- problemRequestor.acceptProblem(problem);
- }
- return super.visitWhenNode(iVisited);
- }
-
- public Instruction visitBlockNode(BlockNode iVisited) {
- return super.visitBlockNode(iVisited);
- }
-
- public Instruction visitIterNode(IterNode iVisited) {
- if (iVisited.getBodyNode() == null) {
- IProblem problem = createProblem(RubyCore.COMPILER_PB_EMPTY_STATEMENT, iVisited.getPosition(), "Empty Block");
- if (problem != null)
- problemRequestor.acceptProblem(problem);
- }
- return super.visitIterNode(iVisited);
- }
-
- public Instruction visitDefnNode(DefnNode iVisited) {
- // TODO Analyze method visibility. Create warning for uncalled private
- // methods
- if (iVisited.getBodyNode() == null) {
- IProblem problem = createProblem(RubyCore.COMPILER_PB_EMPTY_STATEMENT, iVisited.getPosition(), "Empty Method Definition");
- if (problem != null)
- problemRequestor.acceptProblem(problem);
- }
- return super.visitDefnNode(iVisited);
- }
-
- public Instruction visitDefsNode(DefsNode iVisited) {
- if (iVisited.getBodyNode() == null) {
- IProblem problem = createProblem(RubyCore.COMPILER_PB_EMPTY_STATEMENT, iVisited.getPosition(), "Empty Method Definition");
- if (problem != null)
- problemRequestor.acceptProblem(problem);
- }
- return super.visitDefsNode(iVisited);
- }
-
- public Instruction visitConstDeclNode(ConstDeclNode iVisited) {
- String name = iVisited.getName();
-
- if (assignedConstants.contains(name)) {
- problemRequestor.acceptProblem(new Warning(iVisited.getPosition(), "Reassignment of a constant"));
- } else
- assignedConstants.add(name);
- return super.visitConstDeclNode(iVisited);
- }
-
- private IProblem createProblem(String compilerOption, ISourcePosition position, String message) {
- String value = RubyCore.getOption(compilerOption);
- if (value != null && value.equals(RubyCore.ERROR))
- return new Error(position, message);
- if (value != null && value.equals(RubyCore.IGNORE))
- return null;
- return new Warning(position, message);
- }
-
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-02-22 19:36:54
|
Revision: 2002
http://svn.sourceforge.net/rubyeclipse/?rev=2002&view=rev
Author: cawilliams
Date: 2007-02-22 11:36:48 -0800 (Thu, 22 Feb 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java 2007-02-22 19:35:43 UTC (rev 2001)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java 2007-02-22 19:36:48 UTC (rev 2002)
@@ -46,7 +46,6 @@
start);
if (selected instanceof Colon2Node) {
-// FIXME What if we have a constant with multiple parts (i.e. TMail::Mail)?
String simpleName = ((Colon2Node)selected).getName();
String fullyQualifiedName = ASTUtil.getFullyQualifiedName((Colon2Node) selected);
IRubyElement element = findChild(simpleName, IRubyElement.TYPE, script);
@@ -65,6 +64,7 @@
ConstNode constNode = (ConstNode) selected;
String name = constNode.getName();
// Try to find a matching constant in this script
+ // TODO Use convention of all caps versus camelcase to decided which to search for first?
IRubyElement element = findChild(name, IRubyElement.CONSTANT, script);
if (element != null) {
return new IRubyElement[] { element };
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-02-22 19:35:45
|
Revision: 2001
http://svn.sourceforge.net/rubyeclipse/?rev=2001&view=rev
Author: cawilliams
Date: 2007-02-22 11:35:43 -0800 (Thu, 22 Feb 2007)
Log Message:
-----------
when a user selects a Colon2Node - which is a scoped constant (i.e. TMail::Mail), we check for types with that scope (so we search for all mail types, then filter to those with declaring types named TMail).
So go to declaration on the Mail part of TMail::Mail.new will send you to TMail::Mail, while selecting TMail on TMail::Mail will send you to the TMail module definition. Sweet!
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/ASTUtil.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java 2007-02-22 18:59:17 UTC (rev 2000)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java 2007-02-22 19:35:43 UTC (rev 2001)
@@ -10,6 +10,7 @@
import org.jruby.ast.ClassVarAsgnNode;
import org.jruby.ast.ClassVarDeclNode;
import org.jruby.ast.ClassVarNode;
+import org.jruby.ast.Colon2Node;
import org.jruby.ast.ConstNode;
import org.jruby.ast.FCallNode;
import org.jruby.ast.InstAsgnNode;
@@ -26,6 +27,8 @@
import org.rubypeople.rdt.core.IType;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.internal.core.parser.RubyParser;
+import org.rubypeople.rdt.internal.core.util.ASTUtil;
+import org.rubypeople.rdt.internal.core.util.Util;
import org.rubypeople.rdt.internal.ti.DefaultTypeInferrer;
import org.rubypeople.rdt.internal.ti.ITypeGuess;
import org.rubypeople.rdt.internal.ti.ITypeInferrer;
@@ -42,7 +45,23 @@
Node selected = OffsetNodeLocator.Instance().getNodeAtOffset(root,
start);
- if (selected instanceof ConstNode) {
+ if (selected instanceof Colon2Node) {
+// FIXME What if we have a constant with multiple parts (i.e. TMail::Mail)?
+ String simpleName = ((Colon2Node)selected).getName();
+ String fullyQualifiedName = ASTUtil.getFullyQualifiedName((Colon2Node) selected);
+ IRubyElement element = findChild(simpleName, IRubyElement.TYPE, script);
+ if (element != null && parentsMatch((IType)element, fullyQualifiedName)) {
+ return new IRubyElement[] { element };
+ }
+ RubyElementRequestor completer = new RubyElementRequestor(script);
+ IType[] types = completer.findType(simpleName);
+ List<IType> matches = new ArrayList<IType>();
+ for (int i = 0; i < types.length; i++) {
+ if (parentsMatch(types[i], fullyQualifiedName)) matches.add(types[i]);
+ }
+ return matches.toArray(new IType[matches.size()]);
+ }
+ if (selected instanceof ConstNode) {
ConstNode constNode = (ConstNode) selected;
String name = constNode.getName();
// Try to find a matching constant in this script
@@ -101,6 +120,22 @@
return new IRubyElement[0];
}
+ private boolean parentsMatch(IType type, String fullyQualifiedName) {
+ String[] names = getTrimmedSimpleNames(fullyQualifiedName);
+ for (int i = names.length - 2; i >= 0; i--) { // Start at second last name piece, go all the way to first
+ IType parent = type.getDeclaringType();
+ if (parent == null || !names[i].equals(parent.getElementName())) {
+ return false;
+ }
+ type = parent;
+ }
+ return true;
+ }
+
+ private String[] getTrimmedSimpleNames(String fullyQualifiedName) {
+ return fullyQualifiedName.split("::");
+ }
+
private IRubyElement findChild(String name, int type,
IParent parent) {
try {
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-02-22 18:59:17 UTC (rev 2000)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/ASTUtil.java 2007-02-22 19:35:43 UTC (rev 2001)
@@ -7,6 +7,7 @@
import org.jruby.ast.ArgsNode;
import org.jruby.ast.ArgumentNode;
+import org.jruby.ast.Colon2Node;
import org.jruby.ast.ConstNode;
import org.jruby.ast.DStrNode;
import org.jruby.ast.FalseNode;
@@ -14,7 +15,6 @@
import org.jruby.ast.HashNode;
import org.jruby.ast.ListNode;
import org.jruby.ast.LocalAsgnNode;
-import org.jruby.ast.LocalVarNode;
import org.jruby.ast.NilNode;
import org.jruby.ast.Node;
import org.jruby.ast.SelfNode;
@@ -154,4 +154,17 @@
}
}
+ public static String getFullyQualifiedName(Colon2Node node) {
+ StringBuffer name = new StringBuffer();
+ Node left = node.getLeftNode();
+ if (left instanceof Colon2Node) {
+ name.append(getFullyQualifiedName((Colon2Node)left));
+ } else if (left instanceof ConstNode) {
+ name.append(((ConstNode)left).getName());
+ }
+ name.append("::");
+ name.append(node.getName());
+ return name.toString();
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-02-22 18:59:22
|
Revision: 2000
http://svn.sourceforge.net/rubyeclipse/?rev=2000&view=rev
Author: cawilliams
Date: 2007-02-22 10:59:17 -0800 (Thu, 22 Feb 2007)
Log Message:
-----------
fix dialog to choose a module when multiple matches are available (post qualify with script location)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/OpenActionUtil.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyElementLabels.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/OpenActionUtil.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/OpenActionUtil.java 2007-02-22 15:46:44 UTC (rev 1999)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/OpenActionUtil.java 2007-02-22 18:59:17 UTC (rev 2000)
@@ -36,7 +36,7 @@
return elements[0];
int flags= RubyElementLabelProvider.SHOW_DEFAULT
- | RubyElementLabelProvider.SHOW_QUALIFIED
+ | RubyElementLabelProvider.SHOW_POST_QUALIFIED
| RubyElementLabelProvider.SHOW_ROOT;
ElementListSelectionDialog dialog= new ElementListSelectionDialog(shell, new RubyElementLabelProvider(flags));
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyElementLabels.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyElementLabels.java 2007-02-22 15:46:44 UTC (rev 1999)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyElementLabels.java 2007-02-22 18:59:17 UTC (rev 2000)
@@ -330,22 +330,20 @@
getTypeLabel((IType) element, flags, buf);
break;
case IRubyElement.SCRIPT:
- getCompilationUnitLabel((IRubyScript) element, flags, buf);
+ getRubyScriptLabel((IRubyScript) element, flags, buf);
break;
case IRubyElement.IMPORT_CONTAINER:
case IRubyElement.IMPORT_DECLARATION:
getDeclarationLabel(element, flags, buf);
break;
case IRubyElement.SOURCE_FOLDER:
- getPackageFragmentLabel((ISourceFolder) element, flags, buf);
+ getSourceFolderLabel((ISourceFolder) element, flags, buf);
break;
case IRubyElement.SOURCE_FOLDER_ROOT:
- getPackageFragmentRootLabel((ISourceFolderRoot) element, flags, buf);
+ getSourceFolderRootLabel((ISourceFolderRoot) element, flags, buf);
break;
case IRubyElement.RUBY_PROJECT:
case IRubyElement.RUBY_MODEL:
- buf.append(element.getElementName());
- break;
default:
buf.append(element.getElementName());
}
@@ -500,17 +498,19 @@
*/
public static void getTypeLabel(IType type, long flags, StringBuffer buf) {
if (getFlag(flags, T_FULLY_QUALIFIED)) {
- ISourceFolder pack = type.getSourceFolder();
- if (!pack.isDefaultPackage()) {
- getPackageFragmentLabel(pack, (flags & QUALIFIER_FLAGS), buf);
- buf.append('.');
+ ISourceFolder folder = type.getSourceFolder();
+ if (!folder.isDefaultPackage()) {
+ getSourceFolderLabel(folder, (flags & QUALIFIER_FLAGS), buf);
+ buf.append('/');
}
+ getRubyScriptLabel(type.getRubyScript(), (flags & QUALIFIER_FLAGS), buf);
+ buf.append(':');
}
if (getFlag(flags, T_FULLY_QUALIFIED | T_CONTAINER_QUALIFIED)) {
IType declaringType = type.getDeclaringType();
if (declaringType != null) {
getTypeLabel(declaringType, T_CONTAINER_QUALIFIED | (flags & QUALIFIER_FLAGS), buf);
- buf.append('.');
+ buf.append("::");
}
int parentType = type.getParent().getElementType();
if (parentType == IRubyElement.METHOD || parentType == IRubyElement.FIELD) { // anonymous
@@ -569,7 +569,11 @@
getElementLabel(type.getParent(), 0, buf);
}
} else {
- getPackageFragmentLabel(type.getSourceFolder(), flags & QUALIFIER_FLAGS, buf);
+ ISourceFolder folder = type.getSourceFolder();
+ if (!folder.isDefaultPackage()) {
+ getSourceFolderLabel(type.getSourceFolder(), flags & QUALIFIER_FLAGS, buf);
+ }
+ getRubyScriptLabel(type.getRubyScript(), (flags & QUALIFIER_FLAGS), buf);
}
}
}
@@ -623,11 +627,11 @@
* @param buf
* The buffer to append the resulting label to.
*/
- public static void getCompilationUnitLabel(IRubyScript cu, long flags, StringBuffer buf) {
+ public static void getRubyScriptLabel(IRubyScript cu, long flags, StringBuffer buf) {
if (getFlag(flags, CU_QUALIFIED)) {
ISourceFolder pack = (ISourceFolder) cu.getParent();
if (!pack.isDefaultPackage()) {
- getPackageFragmentLabel(pack, (flags & QUALIFIER_FLAGS), buf);
+ getSourceFolderLabel(pack, (flags & QUALIFIER_FLAGS), buf);
buf.append('.');
}
}
@@ -635,7 +639,7 @@
if (getFlag(flags, CU_POST_QUALIFIED)) {
buf.append(CONCAT_STRING);
- getPackageFragmentLabel((ISourceFolder) cu.getParent(), flags & QUALIFIER_FLAGS, buf);
+ getSourceFolderLabel((ISourceFolder) cu.getParent(), flags & QUALIFIER_FLAGS, buf);
}
}
@@ -645,9 +649,9 @@
* @param flags The rendering flags. Flags with names starting with P_' are considered.
* @param buf The buffer to append the resulting label to.
*/
- public static void getPackageFragmentLabel(ISourceFolder pack, long flags, StringBuffer buf) {
+ public static void getSourceFolderLabel(ISourceFolder pack, long flags, StringBuffer buf) {
if (getFlag(flags, P_QUALIFIED)) {
- getPackageFragmentRootLabel((ISourceFolderRoot) pack.getParent(), ROOT_QUALIFIED, buf);
+ getSourceFolderRootLabel((ISourceFolderRoot) pack.getParent(), ROOT_QUALIFIED, buf);
buf.append('/');
}
refreshPackageNamePattern();
@@ -674,7 +678,7 @@
}
if (getFlag(flags, P_POST_QUALIFIED)) {
buf.append(CONCAT_STRING);
- getPackageFragmentRootLabel((ISourceFolderRoot) pack.getParent(), ROOT_QUALIFIED, buf);
+ getSourceFolderRootLabel((ISourceFolderRoot) pack.getParent(), ROOT_QUALIFIED, buf);
}
}
@@ -723,7 +727,7 @@
* @param flags The rendering flags. Flags with names starting with ROOT_' are considered.
* @param buf The buffer to append the resulting label to.
*/
- public static void getPackageFragmentRootLabel(ISourceFolderRoot root, long flags, StringBuffer buf) {
+ public static void getSourceFolderRootLabel(ISourceFolderRoot root, long flags, StringBuffer buf) {
// TODO Uncomment to handle archives
// if (root.isArchive())
// getArchiveLabel(root, flags, buf);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
Revision: 1999
http://svn.sourceforge.net/rubyeclipse/?rev=1999&view=rev
Author: cawilliams
Date: 2007-02-22 07:46:44 -0800 (Thu, 22 Feb 2007)
Log Message:
-----------
fix tests
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyApplicationShortcut.java
Modified: trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyApplicationShortcut.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyApplicationShortcut.java 2007-02-22 15:09:10 UTC (rev 1998)
+++ trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyApplicationShortcut.java 2007-02-22 15:46:44 UTC (rev 1999)
@@ -7,6 +7,7 @@
import junit.framework.Assert;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -32,8 +33,6 @@
public class TC_RubyApplicationShortcut extends ModifyingResourceTest {
- private static final String VM_ID = "vm_id";
-
private static final String VM_TYPE_ID = "org.rubypeople.rdt.launching.StandardVMType";
protected ShamRubyApplicationShortcut shortcut;
@@ -67,15 +66,16 @@
}
private IVMInstallType vmType;
+ private IVMInstall vm;
protected void setUp() throws Exception {
+ super.setUp();
shortcut = new ShamRubyApplicationShortcut();
-// createProject("project1");
- createRubyProject("project1");
- createFolder("project1/folderOne");
- nonRubyFile = createFile("project1/folderOne/myFile.java", "");
- rubyFile = createFile("project1/folderOne/myFile.rb", "");
+ createRubyProject("/project1");
+ createFolder("/project1/folderOne");
+ nonRubyFile = createFile("/project1/folderOne/myFile.java", "");
+ rubyFile = createFile("/project1/folderOne/myFile.rb", "");
ILaunchConfiguration[] configs = this.getLaunchConfigurations();
for (int i = 0; i < configs.length; i++) {
@@ -85,30 +85,36 @@
ShamApplicationLaunchConfigurationDelegate.resetLaunches();
+ // TODO Refcator out this common code which is in a few tests now - setting up a fake default vm install
vmType = RubyRuntime.getVMInstallType(VM_TYPE_ID);
- VMStandin standin = new VMStandin(vmType, VM_ID);
- standin.setInstallLocation(new File("C:/RubyInstallRootOne"));
+ VMStandin standin = new VMStandin(vmType, "fake");
+ IFolder location = createFolder("/project1/interpreterOne");
+ createFolder("/project1/interpreterOne/lib");
+ createFolder("/project1/interpreterOne/bin");
+ createFile("/project1/interpreterOne/bin/ruby", "");
+ standin.setInstallLocation(location.getLocation().toFile());
standin.setName("InterpreterOne");
- IVMInstall vm = standin.convertToRealVM();
+ vm = standin.convertToRealVM();
RubyRuntime.setDefaultVMInstall(vm, null, true);
- super.setUp();
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
- deleteProject("project1");
+ vmType.disposeVMInstall(vm.getId());
+ deleteProject("/project1");
configurations.clear();
}
public void testNoInterpreterInstalled() throws Exception {
- vmType.disposeVMInstall(VM_ID);
+ vmType.disposeVMInstall(vm.getId());
+ RubyRuntime.setDefaultVMInstall(null, null, true);
ISelection selection = new StructuredSelection(rubyFile);
shortcut.launch(selection, ILaunchManager.RUN_MODE);
- assertTrue("A dialog has been shown.", shortcut.didShowDialog);
+ assertTrue("The 'no interpreter selected' dialog should have been shown.", shortcut.didShowDialog);
}
public void testLaunchWithSelectedRubyFile() throws Exception {
@@ -116,8 +122,8 @@
shortcut.launch(selection, ILaunchManager.RUN_MODE);
- assertEquals("A configuration has been created", 1, getLaunchConfigurations().length);
- assertEquals("A launch took place.", 1, shortcut.launchCount());
+ assertEquals("One configuration should have been created.", 1, getLaunchConfigurations().length);
+ assertEquals("One launch should have taken place.", 1, shortcut.launchCount());
assertTrue("The shortcut should not log a message when asked to launch the correct file type.", !shortcut.didLog());
}
@@ -261,6 +267,7 @@
return DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(SHAM_LAUNCH_CONFIG_TYPE);
}
+
protected void showNoInterpreterDialog() {
didShowDialog = true ;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-02-22 15:09:12
|
Revision: 1998
http://svn.sourceforge.net/rubyeclipse/?rev=1998&view=rev
Author: cawilliams
Date: 2007-02-22 07:09:10 -0800 (Thu, 22 Feb 2007)
Log Message:
-----------
fix test up a little (though it is still broken)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMType.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/RubyRuntime.java
trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RunnerLaunching.java
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMType.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMType.java 2007-02-22 14:31:48 UTC (rev 1997)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMType.java 2007-02-22 15:09:10 UTC (rev 1998)
@@ -52,7 +52,12 @@
public IPath[] getDefaultLibraryLocations(File installLocation) {
File rubyExecutable = findRubyExecutable(installLocation);
- LibraryInfo info = getLibraryInfo(installLocation, rubyExecutable);
+ LibraryInfo info;
+ if (rubyExecutable == null) {
+ info = getDefaultLibraryInfo(installLocation);
+ } else {
+ info = getLibraryInfo(installLocation, rubyExecutable);
+ }
String[] loadpath = info.getBootpath();
IPath[] paths = new IPath[loadpath.length];
for (int i = 0; i < loadpath.length; i++) {
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/RubyRuntime.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/RubyRuntime.java 2007-02-22 14:31:48 UTC (rev 1997)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/RubyRuntime.java 2007-02-22 15:09:10 UTC (rev 1998)
@@ -759,8 +759,8 @@
* @since 0.9.0
*/
public static IVMInstall computeVMInstall(ILaunchConfiguration configuration) throws CoreException {
- String jreAttr = configuration.getAttribute(IRubyLaunchConfigurationConstants.ATTR_RUBY_CONTAINER_PATH, (String)null);
- if (jreAttr == null) {
+ String rubyVmAttr = configuration.getAttribute(IRubyLaunchConfigurationConstants.ATTR_RUBY_CONTAINER_PATH, (String)null);
+ if (rubyVmAttr == null) {
String type = configuration.getAttribute(IRubyLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, (String)null);
if (type == null) {
IRubyProject proj = getRubyProject(configuration);
@@ -775,13 +775,13 @@
return resolveVM(type, name, configuration);
}
} else {
- IPath jrePath = Path.fromPortableString(jreAttr);
- ILoadpathEntry entry = RubyCore.newContainerEntry(jrePath);
- IRuntimeLoadpathEntryResolver2 resolver = getVariableResolver(jrePath.segment(0));
+ IPath rubyVmPath = Path.fromPortableString(rubyVmAttr);
+ ILoadpathEntry entry = RubyCore.newContainerEntry(rubyVmPath);
+ IRuntimeLoadpathEntryResolver2 resolver = getVariableResolver(rubyVmPath.segment(0));
if (resolver != null) {
return resolver.resolveVMInstall(entry);
} else {
- resolver = getContainerResolver(jrePath.segment(0));
+ resolver = getContainerResolver(rubyVmPath.segment(0));
if (resolver != null) {
return resolver.resolveVMInstall(entry);
}
Modified: trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RunnerLaunching.java
===================================================================
--- trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RunnerLaunching.java 2007-02-22 14:31:48 UTC (rev 1997)
+++ trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RunnerLaunching.java 2007-02-22 15:09:10 UTC (rev 1998)
@@ -7,6 +7,7 @@
import java.util.Map;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -23,6 +24,7 @@
import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.tests.ModifyingResourceTest;
+import org.rubypeople.rdt.launching.IRubyLaunchConfigurationConstants;
import org.rubypeople.rdt.launching.IVMInstall;
import org.rubypeople.rdt.launching.IVMInstallType;
import org.rubypeople.rdt.launching.RubyRuntime;
@@ -39,8 +41,11 @@
private static final String VM_TYPE_ID = "org.rubypeople.rdt.launching.StandardVMType";
private IVMInstallType vmType;
+ private IVMInstall interpreter;
private IRubyProject project;
+ // XXX This test class desperately needs to be rewritten...
+
public TC_RunnerLaunching(String name) {
super(name);
}
@@ -48,19 +53,25 @@
@Override
protected void setUp() throws Exception {
super.setUp();
+ project = createRubyProject('/' + PROJECT_NAME);
+ IFolder location = createFolder('/' + PROJECT_NAME + "/interpreterOne");
+ createFolder('/' + PROJECT_NAME +"/interpreterOne/lib");
+ createFolder('/' + PROJECT_NAME +"/interpreterOne/bin");
+ createFile('/' + PROJECT_NAME +"/interpreterOne/bin/ruby", "");
+
vmType = RubyRuntime.getVMInstallType(VM_TYPE_ID);
VMStandin standin = new VMStandin(vmType, "fake");
standin.setName("fake");
- standin.setInstallLocation(new File("C:\ruby"));
- IVMInstall real = standin.convertToRealVM();
- RubyRuntime.setDefaultVMInstall(real, null, true);
- project = createRubyProject(PROJECT_NAME);
+ standin.setInstallLocation(location.getLocation().toFile());
+ interpreter = standin.convertToRealVM();
+ RubyRuntime.setDefaultVMInstall(interpreter, null, true);
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
- deleteProject(PROJECT_NAME);
+ deleteProject('/' + PROJECT_NAME);
+ vmType.disposeVMInstall(interpreter.getId());
}
protected ILaunchManager getLaunchManager() {
@@ -109,8 +120,6 @@
}
public void launch(boolean debug) throws Exception {
- IVMInstall interpreter = new VMStandin(vmType, "");
-
ILaunchConfiguration configuration = new ShamLaunchConfiguration();
ILaunch launch = new Launch(configuration, debug ? ILaunchManager.DEBUG_MODE : ILaunchManager.RUN_MODE, null);
ILaunchConfigurationType launchConfigurationType =
@@ -162,19 +171,19 @@
}
public boolean getAttribute(String attributeName, boolean defaultValue) throws CoreException {
- return false;
+ return defaultValue;
}
public int getAttribute(String attributeName, int defaultValue) throws CoreException {
- return 0;
+ return defaultValue;
}
public List getAttribute(String attributeName, List defaultValue) throws CoreException {
- return null;
+ return defaultValue;
}
public Map getAttribute(String attributeName, Map defaultValue) throws CoreException {
- return null;
+ return defaultValue;
}
public String getAttribute(String attributeName, String defaultValue) throws CoreException {
@@ -183,14 +192,16 @@
} else if (attributeName.equals(RubyLaunchConfigurationAttribute.FILE_NAME)) {
return RUBY_LIB_DIR + File.separator + RUBY_FILE_NAME;
} else if (attributeName.equals(RubyLaunchConfigurationAttribute.WORKING_DIRECTORY)) {
- return "C:\\Working Dir";
+ return '/' + PROJECT_NAME;
} else if (attributeName.equals(RubyLaunchConfigurationAttribute.INTERPRETER_ARGUMENTS)) {
return INTERPRETER_ARGUMENTS;
} else if (attributeName.equals(RubyLaunchConfigurationAttribute.PROGRAM_ARGUMENTS)) {
return PROGRAM_ARGUMENTS;
+ } else if (attributeName.equals(IRubyLaunchConfigurationConstants.ATTR_VM_ARGUMENTS)) {
+ return "";
}
- return null;
+ return defaultValue;
}
public IFile getFile() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|