[ruby/irb] support more body argument for oneliner method definition
https://github.com/ruby/irb/commit/2ff1295533
This commit is contained in:
parent
7c879cbb3f
commit
5218f17737
@ -317,14 +317,12 @@ class RubyLex
|
|||||||
if t[2] == '='
|
if t[2] == '='
|
||||||
in_oneliner_def = :BODY
|
in_oneliner_def = :BODY
|
||||||
end
|
end
|
||||||
elsif t[3].allbits?(Ripper::EXPR_END)
|
else
|
||||||
if in_oneliner_def == :BODY
|
if in_oneliner_def == :BODY
|
||||||
# one-liner method definition
|
# one-liner method definition
|
||||||
indent -= 1
|
indent -= 1
|
||||||
end
|
end
|
||||||
in_oneliner_def = nil
|
in_oneliner_def = nil
|
||||||
else
|
|
||||||
in_oneliner_def = nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -376,14 +374,12 @@ class RubyLex
|
|||||||
if t[2] == '='
|
if t[2] == '='
|
||||||
in_oneliner_def = :BODY
|
in_oneliner_def = :BODY
|
||||||
end
|
end
|
||||||
elsif t[3].allbits?(Ripper::EXPR_END)
|
else
|
||||||
if in_oneliner_def == :BODY
|
if in_oneliner_def == :BODY
|
||||||
# one[-liner method definition
|
# one[-liner method definition
|
||||||
depth_difference -= 1
|
depth_difference -= 1
|
||||||
end
|
end
|
||||||
in_oneliner_def = nil
|
in_oneliner_def = nil
|
||||||
else
|
|
||||||
in_oneliner_def = nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -451,7 +447,7 @@ class RubyLex
|
|||||||
if t[2] == '='
|
if t[2] == '='
|
||||||
in_oneliner_def = :BODY
|
in_oneliner_def = :BODY
|
||||||
end
|
end
|
||||||
elsif t[3].allbits?(Ripper::EXPR_END)
|
else
|
||||||
if in_oneliner_def == :BODY
|
if in_oneliner_def == :BODY
|
||||||
# one-liner method definition
|
# one-liner method definition
|
||||||
if is_first_printable_of_line
|
if is_first_printable_of_line
|
||||||
@ -462,8 +458,6 @@ class RubyLex
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
in_oneliner_def = nil
|
in_oneliner_def = nil
|
||||||
else
|
|
||||||
in_oneliner_def = nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -233,6 +233,8 @@ module TestIRB
|
|||||||
Row.new(%q( def bar0() = 3), nil, 2),
|
Row.new(%q( def bar0() = 3), nil, 2),
|
||||||
Row.new(%q( def bar1(a) = a), nil, 2),
|
Row.new(%q( def bar1(a) = a), nil, 2),
|
||||||
Row.new(%q( def bar2(a, b) = a + b), nil, 2),
|
Row.new(%q( def bar2(a, b) = a + b), nil, 2),
|
||||||
|
Row.new(%q( def bar3() = :s), nil, 2),
|
||||||
|
Row.new(%q( def bar4() = Time.now), nil, 2),
|
||||||
Row.new(%q(end), 0, 0),
|
Row.new(%q(end), 0, 0),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user