RubyModule#discoverInstanceVariables() for the working version
Visitor to search AST nodes for instance variables. Certain nodes are
ignored during walking since they always create a new context with a new
self.
Example usage:
Node node = getNodeFromSomewhere();
InstanceVariableFinder finder = new InstanceVariableFinder();
node.accept(finder);
System.out.println("found: " + finder.getFoundVariables);
<init>()Walk a node and its children looking for instance variables using a new InstanceVariableFinder. Return an array of the variable names found.
| name | type | description |
|---|---|---|
| node | org.jruby.ast.Node | the node to walk |
Returns: an array of instance variable names found
Return the Set of all instance variables found during walking.
Returns: a Set of all instance variable names found
visitClassNode(org.jruby.ast.ClassNode iVisited)ClassNode creates a new scope and self, so do not search for ivars.
Returns: null
visitInstAsgnNode(org.jruby.ast.InstAsgnNode iVisited)Add the name of the instance variable being assigned to our set of instance variable names and continue to walk child nodes.
Returns: null
visitInstVarNode(org.jruby.ast.InstVarNode iVisited)Add the name of the instance variable being retrieved to our set of instance variable names and continue to walk child nodes.
Returns: null
visitModuleNode(org.jruby.ast.ModuleNode iVisited)ModuleNode creates a new scope and self, so do not search for ivars.
Returns: null
visitNilRestArgNode(org.jruby.ast.NilRestArgNode iVisited)visitPostExeNode(org.jruby.ast.PostExeNode iVisited)PostExeNode can't appear in methods, so do not search for ivars.
Returns: null
visitPreExeNode(org.jruby.ast.PreExeNode iVisited)PreExeNode can't appear in methods, so do not search for ivars.
Returns: null
visitArgsPushNode(org.jruby.ast.ArgsPushNode node)visitArgumentNode(org.jruby.ast.ArgumentNode node)visitArrayPatternNode(org.jruby.ast.ArrayPatternNode node)visitAttrAssignNode(org.jruby.ast.AttrAssignNode node)visitBlockArgNode(org.jruby.ast.BlockArgNode node)visitBlockPassNode(org.jruby.ast.BlockPassNode node)visitClassVarAsgnNode(org.jruby.ast.ClassVarAsgnNode node)visitClassVarNode(org.jruby.ast.ClassVarNode node)visitConstDeclNode(org.jruby.ast.ConstDeclNode node)visitEncodingNode(org.jruby.ast.EncodingNode node)visitFindPatternNode(org.jruby.ast.FindPatternNode node)visitGlobalAsgnNode(org.jruby.ast.GlobalAsgnNode node)visitGlobalVarNode(org.jruby.ast.GlobalVarNode node)visitHashPatternNode(org.jruby.ast.HashPatternNode node)visitKeywordArgNode(org.jruby.ast.KeywordArgNode node)visitKeywordRestArgNode(org.jruby.ast.KeywordRestArgNode node)visitLocalAsgnNode(org.jruby.ast.LocalAsgnNode node)visitLocalVarNode(org.jruby.ast.LocalVarNode node)visitMultipleAsgnNode(org.jruby.ast.MultipleAsgnNode node)visitOpAsgnAndNode(org.jruby.ast.OpAsgnAndNode node)visitOpAsgnConstDeclNode(org.jruby.ast.OpAsgnConstDeclNode node)visitOpAsgnOrNode(org.jruby.ast.OpAsgnOrNode node)visitOpElementAsgnNode(org.jruby.ast.OpElementAsgnNode node)visitOperatorCallNode(org.jruby.ast.visitor.OperatorCallNode node)visitPatternCaseNode(org.jruby.ast.PatternCaseNode node)visitRationalNode(org.jruby.ast.RationalNode node)visitRequiredKeywordArgumentValueNode(org.jruby.ast.RequiredKeywordArgumentValueNode node)visitRescueBodyNode(org.jruby.ast.RescueBodyNode node)