|
From: <caw...@us...> - 2007-06-12 03:12:24
|
Revision: 2601
http://svn.sourceforge.net/rubyeclipse/?rev=2601&view=rev
Author: cawilliams
Date: 2007-06-11 20:12:21 -0700 (Mon, 11 Jun 2007)
Log Message:
-----------
include dynamic variables as part of model. Make their image same as local variable.
this allows us to resolve a dynamic variable to its assignment.
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/compiler/ISourceElementRequestor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyDynamicVar.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceElementParser.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/RubyElementImageProvider.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-06-12 03:11:17 UTC (rev 2600)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java 2007-06-12 03:12:21 UTC (rev 2601)
@@ -18,6 +18,8 @@
import org.jruby.ast.Colon2Node;
import org.jruby.ast.ConstDeclNode;
import org.jruby.ast.ConstNode;
+import org.jruby.ast.DAsgnNode;
+import org.jruby.ast.DVarNode;
import org.jruby.ast.DefnNode;
import org.jruby.ast.DefsNode;
import org.jruby.ast.FCallNode;
@@ -53,6 +55,7 @@
import org.rubypeople.rdt.internal.ti.ITypeGuess;
import org.rubypeople.rdt.internal.ti.ITypeInferrer;
import org.rubypeople.rdt.internal.ti.util.ClosestSpanningNodeLocator;
+import org.rubypeople.rdt.internal.ti.util.FirstPrecursorNodeLocator;
import org.rubypeople.rdt.internal.ti.util.INodeAcceptor;
import org.rubypeople.rdt.internal.ti.util.OffsetNodeLocator;
@@ -82,6 +85,18 @@
RubyElementRequestor completer = new RubyElementRequestor(script);
return completer.findType(fullyQualifiedName);
}
+ if (selected instanceof DVarNode) {
+ final String name = ((DVarNode) selected).getName();
+ Node assignment = FirstPrecursorNodeLocator.Instance().findFirstPrecursor(root, start, new INodeAcceptor() {
+
+ public boolean doesAccept(Node node) {
+ // TODO Auto-generated method stub
+ return (node instanceof DAsgnNode) && ((DAsgnNode) node).getName().equals(name);
+ }
+
+ });
+ return new IRubyElement[] { script.getElementAt(assignment.getPosition().getStartOffset()) };
+ }
if (selected instanceof ConstNode) {
ConstNode constNode = (ConstNode) selected;
String name = constNode.getName();
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/ISourceElementRequestor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/ISourceElementRequestor.java 2007-06-12 03:11:17 UTC (rev 2600)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/ISourceElementRequestor.java 2007-06-12 03:12:21 UTC (rev 2601)
@@ -30,6 +30,7 @@
public int declarationStart;
// public String type; TODO Pre populate our guesses at type?
public String name;
+ public boolean isDynamic;
public int nameSourceStart;
public int nameSourceEnd;
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyDynamicVar.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyDynamicVar.java 2007-06-12 03:11:17 UTC (rev 2600)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyDynamicVar.java 2007-06-12 03:12:21 UTC (rev 2601)
@@ -31,13 +31,13 @@
* RubyDynamicVar is a dynamic variable which is scoped to an iterator or loop
*
*/
-public class RubyDynamicVar extends RubyField {
+public class RubyDynamicVar extends LocalVariable {
/**
* @param name
*/
- public RubyDynamicVar(RubyElement parent, String name) {
- super(parent, name);
+ public RubyDynamicVar(RubyElement parent, String name, int start, int end) {
+ super(parent, name, start, end);
}
/* (non-Javadoc)
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-06-12 03:11:17 UTC (rev 2600)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java 2007-06-12 03:12:21 UTC (rev 2601)
@@ -202,13 +202,17 @@
} else {
int start = field.declarationStart - field.name.length() + 1;
int end = start + field.name.length();
- handle = new LocalVariable(modelStack.peek(), field.name, start, end);
+ if (field.isDynamic) {
+ handle = new RubyDynamicVar(modelStack.peek(), field.name, start, end);
+ } else {
+ handle = new LocalVariable(modelStack.peek(), field.name, start, end);
+ }
}
modelStack.push(handle);
// Add to enclosing type
RubyElementInfo parentInfo;
- if (handle instanceof LocalVariable) {
+ if (handle instanceof LocalVariable || handle instanceof RubyDynamicVar) {
parentInfo = infoStack.peek();
} else if (handle instanceof RubyGlobal){
parentInfo = scriptInfo; // FIXME Grab the project info?
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceElementParser.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceElementParser.java 2007-06-12 03:11:17 UTC (rev 2600)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceElementParser.java 2007-06-12 03:12:21 UTC (rev 2601)
@@ -365,6 +365,11 @@
@Override
public Instruction visitDAsgnNode(DAsgnNode iVisited) {
// RubyDynamicVar var = new RubyDynamicVar(modelStack.peek(), iVisited.getName()); FIXME Notify like a normal local var?
+ FieldInfo field = createFieldInfo(iVisited);
+ field.name = iVisited.getName();
+ field.isDynamic = true;
+ requestor.enterField(field);
+ exitField(iVisited);
return super.visitDAsgnNode(iVisited);
}
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-06-12 03:11:17 UTC (rev 2600)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/RubyElementImageProvider.java 2007-06-12 03:12:21 UTC (rev 2601)
@@ -186,6 +186,7 @@
return RubyPluginImages.DESC_OBJS_CONSTANT;
case IRubyElement.LOCAL_VARIABLE:
+ case IRubyElement.DYNAMIC_VAR: // FIXME Make dynamic var have it's own image?
return RubyPluginImages.DESC_OBJS_LOCAL_VAR;
case IRubyElement.INSTANCE_VAR:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|