|
From: <caw...@us...> - 2007-06-07 21:15:56
|
Revision: 2589
http://svn.sourceforge.net/rubyeclipse/?rev=2589&view=rev
Author: cawilliams
Date: 2007-06-07 14:15:54 -0700 (Thu, 07 Jun 2007)
Log Message:
-----------
properly detect if we're referring to a variable 9so the read/write images are used when we do a search for occurrences in file of identifier)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/ASTUtil.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/OccurrencesFinder.java
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-06-07 20:57:17 UTC (rev 2588)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/ASTUtil.java 2007-06-07 21:15:54 UTC (rev 2589)
@@ -10,14 +10,19 @@
import org.jruby.ast.AttrAssignNode;
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.ConstDeclNode;
import org.jruby.ast.ConstNode;
import org.jruby.ast.DStrNode;
import org.jruby.ast.FalseNode;
import org.jruby.ast.FixnumNode;
import org.jruby.ast.GlobalAsgnNode;
+import org.jruby.ast.GlobalVarNode;
import org.jruby.ast.HashNode;
import org.jruby.ast.InstAsgnNode;
+import org.jruby.ast.InstVarNode;
import org.jruby.ast.ListNode;
import org.jruby.ast.LocalAsgnNode;
import org.jruby.ast.ModuleNode;
@@ -193,4 +198,12 @@
return contents.substring(pos.getStartOffset(), pos.getEndOffset());
}
+ public static boolean isVariable(Node node) {
+ return (node instanceof GlobalAsgnNode) || (node instanceof GlobalVarNode)
+ || (node instanceof InstAsgnNode) || (node instanceof InstVarNode)
+ || (node instanceof ConstDeclNode) || (node instanceof ConstNode)
+ || (node instanceof ClassVarAsgnNode) || (node instanceof ClassVarDeclNode)
+ || (node instanceof ClassVarNode);
+ }
+
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/OccurrencesFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/OccurrencesFinder.java 2007-06-07 20:57:17 UTC (rev 2588)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/OccurrencesFinder.java 2007-06-07 21:15:54 UTC (rev 2589)
@@ -96,7 +96,7 @@
if (groupKey == null) {
IRegion region= document.getLineInformation(line);
String lineContents= document.get(region.getOffset(), region.getLength()).trim();
- groupKey= new OccurrencesGroupKey(element, line, lineContents, isWriteAccess, isVariable(element));
+ groupKey= new OccurrencesGroupKey(element, line, lineContents, isWriteAccess, isVariable(fSelectedNode));
lineToGroup.put(lineInteger, groupKey);
} else if (isWriteAccess) {
// a line with read an write access is considered as write access:
@@ -110,8 +110,8 @@
}
}
- private boolean isVariable(IRubyElement element) {
- return element.isType(IRubyElement.INSTANCE_VAR) || element.isType(IRubyElement.GLOBAL) || element.isType(IRubyElement.CLASS_VAR) || element.isType(IRubyElement.LOCAL_VARIABLE) || element.isType(IRubyElement.DYNAMIC_VAR);
+ private boolean isVariable(Node node) {
+ return ASTUtil.isVariable(node);
}
public String initialize(Node root, int offset, int length) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|