Permalink
Browse files

support line for Sexp :massign

  • Loading branch information...
1 parent dde0466 commit d8acfebff01398c293d4877546b7bbe9407d90e7 @flyerhzm committed Sep 17, 2012
Showing with 11 additions and 1 deletion.
  1. +4 −1 lib/code_analyzer/sexp.rb
  2. +7 −0 spec/code_analyzer/sexp_spec.rb
@@ -17,14 +17,17 @@ def line
case sexp_type
when :def, :defs, :command, :command_call, :call, :fcall, :method_add_arg, :method_add_block,
:var_ref, :vcall, :const_ref, :const_path_ref, :class, :module, :if, :unless, :elsif, :ifop, :binary,
- :alias, :symbol_literal, :symbol, :aref, :hash, :assoc_new, :string_literal
+ :alias, :symbol_literal, :symbol, :aref, :hash, :assoc_new, :string_literal,
+ :massign
self[1].line
when :assoclist_from_args, :bare_assoc_hash
self[1][0].line
when :string_add
self[2].line
when :array
array_values.first.line
+ when :mlhs_add
+ self.last.line
else
self.last.first if self.last.is_a? Array
end
@@ -10,6 +10,9 @@ def test
end
alias :test_new :test
CONST = { foo: :bar }
+ def massign
+ a, b = 10, 20
+ end
end
EOF
@node = parse_content(content)
@@ -38,6 +41,10 @@ def test
it "should return hash line" do
@node.grep_node(sexp_type: :hash).line.should == 6
end
+
+ it "should return massign line" do
+ @node.grep_node(sexp_type: :massign).line.should == 8
+ end
end
describe "grep_nodes" do

0 comments on commit d8acfeb

Please sign in to comment.