[ruby/irb] Detect the variable class to show doc
https://github.com/ruby/irb/commit/33b9bec954
This commit is contained in:
parent
f734590f8e
commit
4e40b7ddb0
@ -314,13 +314,20 @@ module IRB
|
|||||||
select_message(receiver, message, candidates)
|
select_message(receiver, message, candidates)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
if doc_namespace
|
||||||
|
vars = eval("local_variables | instance_variables", bind).collect{|m| m.to_s}
|
||||||
|
perfect_match_var = vars.find{|m| m.to_s == input}
|
||||||
|
if perfect_match_var
|
||||||
|
eval("#{perfect_match_var}.class.name", bind)
|
||||||
else
|
else
|
||||||
candidates = eval("methods | private_methods | local_variables | instance_variables | self.class.constants", bind).collect{|m| m.to_s}
|
candidates = eval("methods | private_methods | local_variables | instance_variables | self.class.constants", bind).collect{|m| m.to_s}
|
||||||
candidates |= ReservedWords
|
candidates |= ReservedWords
|
||||||
|
|
||||||
if doc_namespace
|
|
||||||
candidates.find{ |i| i == input }
|
candidates.find{ |i| i == input }
|
||||||
|
end
|
||||||
else
|
else
|
||||||
|
candidates = eval("methods | private_methods | local_variables | instance_variables | self.class.constants", bind).collect{|m| m.to_s}
|
||||||
|
candidates |= ReservedWords
|
||||||
candidates.grep(/^#{Regexp.quote(input)}/)
|
candidates.grep(/^#{Regexp.quote(input)}/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -83,5 +83,11 @@ module TestIRB
|
|||||||
assert_include candidates, word
|
assert_include candidates, word
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_complete_variable
|
||||||
|
str_example = ''
|
||||||
|
assert_include(IRB::InputCompletor.retrieve_completion_data("str_examp", bind: binding), "str_example")
|
||||||
|
assert_equal(IRB::InputCompletor.retrieve_completion_data("str_example", bind: binding, doc_namespace: true), "String")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user