2015-12-16 00:07:31 -05:00
|
|
|
# frozen_string_literal: false
|
2001-04-30 14:25:04 -04:00
|
|
|
#
|
2018-07-28 06:00:29 -04:00
|
|
|
# irb/completion.rb -
|
2002-07-09 07:17:17 -04:00
|
|
|
# $Release Version: 0.9$
|
2001-04-30 14:25:04 -04:00
|
|
|
# $Revision$
|
|
|
|
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
|
|
|
|
# From Original Idea of shugo@ruby-lang.org
|
|
|
|
#
|
2000-05-12 05:07:57 -04:00
|
|
|
|
2021-03-24 01:55:05 -04:00
|
|
|
require_relative 'ruby-lex'
|
|
|
|
|
2000-05-12 05:07:57 -04:00
|
|
|
module IRB
|
2012-12-21 00:45:50 -05:00
|
|
|
module InputCompletor # :nodoc:
|
2019-04-23 08:55:29 -04:00
|
|
|
|
|
|
|
|
2012-12-21 00:45:50 -05:00
|
|
|
# Set of reserved words used by Ruby, you should not use these for
|
|
|
|
# constants or variables
|
2013-06-04 10:17:17 -04:00
|
|
|
ReservedWords = %w[
|
2020-02-12 05:16:12 -05:00
|
|
|
__ENCODING__ __LINE__ __FILE__
|
2013-06-04 10:17:17 -04:00
|
|
|
BEGIN END
|
|
|
|
alias and
|
|
|
|
begin break
|
|
|
|
case class
|
2020-02-12 05:16:12 -05:00
|
|
|
def defined? do
|
2013-06-04 10:17:17 -04:00
|
|
|
else elsif end ensure
|
|
|
|
false for
|
|
|
|
if in
|
|
|
|
module
|
|
|
|
next nil not
|
|
|
|
or
|
|
|
|
redo rescue retry return
|
|
|
|
self super
|
|
|
|
then true
|
|
|
|
undef unless until
|
|
|
|
when while
|
|
|
|
yield
|
2000-05-12 05:07:57 -04:00
|
|
|
]
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2019-04-27 17:37:39 -04:00
|
|
|
BASIC_WORD_BREAK_CHARACTERS = " \t\n`><=;|&{("
|
|
|
|
|
2021-03-24 02:33:07 -04:00
|
|
|
def self.retrieve_files_to_require_from_load_path
|
|
|
|
@@files_from_load_path ||= $LOAD_PATH.flat_map { |path|
|
|
|
|
begin
|
|
|
|
Dir.glob("**/*.{rb,#{RbConfig::CONFIG['DLEXT']}}", base: path)
|
|
|
|
rescue Errno::ENOENT
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
}.uniq.map { |path|
|
|
|
|
path.sub(/\.(rb|#{RbConfig::CONFIG['DLEXT']})\z/, '')
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.retrieve_files_to_require_relative_from_current_dir
|
|
|
|
@@files_from_current_dir ||= Dir.glob("**/*.{rb,#{RbConfig::CONFIG['DLEXT']}}", base: '.').map { |path|
|
|
|
|
path.sub(/\.(rb|#{RbConfig::CONFIG['DLEXT']})\z/, '')
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2021-03-24 01:55:05 -04:00
|
|
|
CompletionRequireProc = lambda { |target, preposing = nil, postposing = nil|
|
|
|
|
if target =~ /\A(['"])([^'"]+)\Z/
|
|
|
|
quote = $1
|
|
|
|
actual_target = $2
|
|
|
|
else
|
|
|
|
return nil # It's not String literal
|
|
|
|
end
|
|
|
|
tokens = RubyLex.ripper_lex_without_warning(preposing.gsub(/\s*\z/, ''))
|
|
|
|
tok = nil
|
|
|
|
tokens.reverse_each do |t|
|
|
|
|
unless [:on_lparen, :on_sp, :on_ignored_sp, :on_nl, :on_ignored_nl, :on_comment].include?(t.event)
|
|
|
|
tok = t
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
2021-03-24 02:33:07 -04:00
|
|
|
result = []
|
2021-03-24 01:55:05 -04:00
|
|
|
if tok && tok.event == :on_ident && tok.state == Ripper::EXPR_CMDARG
|
|
|
|
case tok.tok
|
|
|
|
when 'require'
|
2021-03-24 02:33:07 -04:00
|
|
|
result = retrieve_files_to_require_from_load_path.select { |path|
|
2021-03-24 01:55:05 -04:00
|
|
|
path.start_with?(actual_target)
|
|
|
|
}.map { |path|
|
|
|
|
quote + path
|
|
|
|
}
|
|
|
|
when 'require_relative'
|
2021-03-24 02:33:07 -04:00
|
|
|
result = retrieve_files_to_require_relative_from_current_dir.select { |path|
|
2021-03-24 01:55:05 -04:00
|
|
|
path.start_with?(actual_target)
|
|
|
|
}.map { |path|
|
|
|
|
quote + path
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
result
|
|
|
|
}
|
|
|
|
|
|
|
|
CompletionProc = lambda { |target, preposing = nil, postposing = nil|
|
|
|
|
if preposing && postposing
|
|
|
|
result = CompletionRequireProc.(target, preposing, postposing)
|
|
|
|
unless result
|
|
|
|
result = retrieve_completion_data(target).compact.map{ |i| i.encode(Encoding.default_external) }
|
|
|
|
end
|
|
|
|
result
|
|
|
|
else
|
|
|
|
retrieve_completion_data(target).compact.map{ |i| i.encode(Encoding.default_external) }
|
|
|
|
end
|
2019-05-26 12:24:03 -04:00
|
|
|
}
|
|
|
|
|
2019-11-28 01:15:41 -05:00
|
|
|
def self.retrieve_completion_data(input, bind: IRB.conf[:MAIN_CONTEXT].workspace.binding, doc_namespace: false)
|
2000-05-12 05:07:57 -04:00
|
|
|
case input
|
2011-06-29 11:08:41 -04:00
|
|
|
when /^((["'`]).*\2)\.([^.]*)$/
|
2014-08-08 21:36:49 -04:00
|
|
|
# String
|
|
|
|
receiver = $1
|
2021-01-06 05:05:46 -05:00
|
|
|
message = $3
|
2011-06-29 11:08:41 -04:00
|
|
|
|
2014-08-08 21:36:49 -04:00
|
|
|
candidates = String.instance_methods.collect{|m| m.to_s}
|
2019-05-26 12:24:03 -04:00
|
|
|
if doc_namespace
|
|
|
|
"String.#{message}"
|
|
|
|
else
|
|
|
|
select_message(receiver, message, candidates)
|
|
|
|
end
|
2011-06-29 11:08:41 -04:00
|
|
|
|
2001-04-30 14:25:04 -04:00
|
|
|
when /^(\/[^\/]*\/)\.([^.]*)$/
|
2014-08-08 21:36:49 -04:00
|
|
|
# Regexp
|
|
|
|
receiver = $1
|
2021-01-06 05:05:46 -05:00
|
|
|
message = $2
|
2001-04-30 14:25:04 -04:00
|
|
|
|
2014-08-08 21:36:49 -04:00
|
|
|
candidates = Regexp.instance_methods.collect{|m| m.to_s}
|
2019-05-26 12:24:03 -04:00
|
|
|
if doc_namespace
|
|
|
|
"Regexp.#{message}"
|
|
|
|
else
|
|
|
|
select_message(receiver, message, candidates)
|
|
|
|
end
|
2001-04-30 14:25:04 -04:00
|
|
|
|
|
|
|
when /^([^\]]*\])\.([^.]*)$/
|
2014-08-08 21:36:49 -04:00
|
|
|
# Array
|
|
|
|
receiver = $1
|
2021-01-06 05:05:46 -05:00
|
|
|
message = $2
|
2001-04-30 14:25:04 -04:00
|
|
|
|
2014-08-08 21:36:49 -04:00
|
|
|
candidates = Array.instance_methods.collect{|m| m.to_s}
|
2019-05-26 12:24:03 -04:00
|
|
|
if doc_namespace
|
|
|
|
"Array.#{message}"
|
|
|
|
else
|
|
|
|
select_message(receiver, message, candidates)
|
|
|
|
end
|
2001-04-30 14:25:04 -04:00
|
|
|
|
|
|
|
when /^([^\}]*\})\.([^.]*)$/
|
2014-08-08 21:36:49 -04:00
|
|
|
# Proc or Hash
|
|
|
|
receiver = $1
|
2021-01-06 05:05:46 -05:00
|
|
|
message = $2
|
2001-04-30 14:25:04 -04:00
|
|
|
|
2019-05-26 12:24:03 -04:00
|
|
|
proc_candidates = Proc.instance_methods.collect{|m| m.to_s}
|
|
|
|
hash_candidates = Hash.instance_methods.collect{|m| m.to_s}
|
|
|
|
if doc_namespace
|
|
|
|
["Proc.#{message}", "Hash.#{message}"]
|
|
|
|
else
|
|
|
|
select_message(receiver, message, proc_candidates | hash_candidates)
|
|
|
|
end
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2002-07-09 07:17:17 -04:00
|
|
|
when /^(:[^:.]*)$/
|
2014-08-08 21:36:49 -04:00
|
|
|
# Symbol
|
2019-05-26 12:24:03 -04:00
|
|
|
return nil if doc_namespace
|
2020-07-24 10:48:32 -04:00
|
|
|
sym = $1
|
|
|
|
candidates = Symbol.all_symbols.collect do |s|
|
|
|
|
":" + s.id2name.encode(Encoding.default_external)
|
|
|
|
rescue Encoding::UndefinedConversionError
|
|
|
|
# ignore
|
2014-08-08 21:36:49 -04:00
|
|
|
end
|
2020-07-24 10:48:32 -04:00
|
|
|
candidates.grep(/^#{Regexp.quote(sym)}/)
|
2001-04-30 14:25:04 -04:00
|
|
|
|
|
|
|
when /^::([A-Z][^:\.\(]*)$/
|
2014-08-08 21:36:49 -04:00
|
|
|
# Absolute Constant or class methods
|
|
|
|
receiver = $1
|
|
|
|
candidates = Object.constants.collect{|m| m.to_s}
|
2019-05-26 12:24:03 -04:00
|
|
|
if doc_namespace
|
|
|
|
candidates.find { |i| i == receiver }
|
|
|
|
else
|
|
|
|
candidates.grep(/^#{receiver}/).collect{|e| "::" + e}
|
|
|
|
end
|
2001-04-30 14:25:04 -04:00
|
|
|
|
2010-04-13 01:01:10 -04:00
|
|
|
when /^([A-Z].*)::([^:.]*)$/
|
2014-08-08 21:36:49 -04:00
|
|
|
# Constant or class methods
|
|
|
|
receiver = $1
|
2021-01-06 05:05:46 -05:00
|
|
|
message = $2
|
2014-08-08 21:36:49 -04:00
|
|
|
begin
|
|
|
|
candidates = eval("#{receiver}.constants.collect{|m| m.to_s}", bind)
|
|
|
|
candidates |= eval("#{receiver}.methods.collect{|m| m.to_s}", bind)
|
|
|
|
rescue Exception
|
|
|
|
candidates = []
|
|
|
|
end
|
2019-05-26 12:24:03 -04:00
|
|
|
if doc_namespace
|
|
|
|
"#{receiver}::#{message}"
|
|
|
|
else
|
|
|
|
select_message(receiver, message, candidates, "::")
|
|
|
|
end
|
2001-04-30 14:25:04 -04:00
|
|
|
|
2011-01-18 04:34:10 -05:00
|
|
|
when /^(:[^:.]+)(\.|::)([^.]*)$/
|
2014-08-08 21:36:49 -04:00
|
|
|
# Symbol
|
|
|
|
receiver = $1
|
|
|
|
sep = $2
|
2021-01-06 05:05:46 -05:00
|
|
|
message = $3
|
2001-04-30 14:25:04 -04:00
|
|
|
|
2014-08-08 21:36:49 -04:00
|
|
|
candidates = Symbol.instance_methods.collect{|m| m.to_s}
|
2019-05-26 12:24:03 -04:00
|
|
|
if doc_namespace
|
|
|
|
"Symbol.#{message}"
|
|
|
|
else
|
|
|
|
select_message(receiver, message, candidates, sep)
|
|
|
|
end
|
2001-04-30 14:25:04 -04:00
|
|
|
|
2020-01-29 22:08:37 -05:00
|
|
|
when /^(?<num>-?(?:0[dbo])?[0-9_]+(?:\.[0-9_]+)?(?:(?:[eE][+-]?[0-9]+)?i?|r)?)(?<sep>\.|::)(?<mes>[^.]*)$/
|
2014-08-08 21:36:49 -04:00
|
|
|
# Numeric
|
2019-05-26 12:24:03 -04:00
|
|
|
receiver = $~[:num]
|
|
|
|
sep = $~[:sep]
|
2021-01-06 05:05:46 -05:00
|
|
|
message = $~[:mes]
|
2014-08-08 21:36:49 -04:00
|
|
|
|
|
|
|
begin
|
2019-05-26 12:24:03 -04:00
|
|
|
instance = eval(receiver, bind)
|
|
|
|
if doc_namespace
|
|
|
|
"#{instance.class.name}.#{message}"
|
|
|
|
else
|
|
|
|
candidates = instance.methods.collect{|m| m.to_s}
|
|
|
|
select_message(receiver, message, candidates, sep)
|
|
|
|
end
|
2014-08-08 21:36:49 -04:00
|
|
|
rescue Exception
|
2019-05-26 12:24:03 -04:00
|
|
|
if doc_namespace
|
|
|
|
nil
|
|
|
|
else
|
|
|
|
candidates = []
|
|
|
|
end
|
2014-08-08 21:36:49 -04:00
|
|
|
end
|
2006-07-19 10:18:20 -04:00
|
|
|
|
2011-01-18 04:34:10 -05:00
|
|
|
when /^(-?0x[0-9a-fA-F_]+)(\.|::)([^.]*)$/
|
2014-08-08 21:36:49 -04:00
|
|
|
# Numeric(0xFFFF)
|
|
|
|
receiver = $1
|
|
|
|
sep = $2
|
2021-01-06 05:05:46 -05:00
|
|
|
message = $3
|
2014-08-08 21:36:49 -04:00
|
|
|
|
|
|
|
begin
|
2019-05-26 12:24:03 -04:00
|
|
|
instance = eval(receiver, bind)
|
|
|
|
if doc_namespace
|
|
|
|
"#{instance.class.name}.#{message}"
|
|
|
|
else
|
|
|
|
candidates = instance.methods.collect{|m| m.to_s}
|
|
|
|
select_message(receiver, message, candidates, sep)
|
|
|
|
end
|
2014-08-08 21:36:49 -04:00
|
|
|
rescue Exception
|
2019-05-26 12:24:03 -04:00
|
|
|
if doc_namespace
|
|
|
|
nil
|
|
|
|
else
|
|
|
|
candidates = []
|
|
|
|
end
|
2014-08-08 21:36:49 -04:00
|
|
|
end
|
2001-04-30 14:25:04 -04:00
|
|
|
|
2002-07-09 07:17:17 -04:00
|
|
|
when /^(\$[^.]*)$/
|
2014-08-08 21:36:49 -04:00
|
|
|
# global var
|
2019-05-26 12:24:03 -04:00
|
|
|
gvar = $1
|
|
|
|
all_gvars = global_variables.collect{|m| m.to_s}
|
|
|
|
if doc_namespace
|
|
|
|
all_gvars.find{ |i| i == gvar }
|
|
|
|
else
|
|
|
|
all_gvars.grep(Regexp.new(Regexp.quote(gvar)))
|
|
|
|
end
|
2002-07-09 07:17:17 -04:00
|
|
|
|
2011-01-18 04:34:10 -05:00
|
|
|
when /^([^."].*)(\.|::)([^.]*)$/
|
2014-08-08 21:36:49 -04:00
|
|
|
# variable.func or func.func
|
|
|
|
receiver = $1
|
|
|
|
sep = $2
|
2021-01-06 05:05:46 -05:00
|
|
|
message = $3
|
2014-08-08 21:36:49 -04:00
|
|
|
|
2020-01-17 13:30:28 -05:00
|
|
|
gv = eval("global_variables", bind).collect{|m| m.to_s}.push("true", "false", "nil")
|
2014-08-08 21:36:49 -04:00
|
|
|
lv = eval("local_variables", bind).collect{|m| m.to_s}
|
|
|
|
iv = eval("instance_variables", bind).collect{|m| m.to_s}
|
|
|
|
cv = eval("self.class.constants", bind).collect{|m| m.to_s}
|
|
|
|
|
|
|
|
if (gv | lv | iv | cv).include?(receiver) or /^[A-Z]/ =~ receiver && /\./ !~ receiver
|
|
|
|
# foo.func and foo is var. OR
|
|
|
|
# foo::func and foo is var. OR
|
|
|
|
# foo::Const and foo is var. OR
|
|
|
|
# Foo::Bar.func
|
|
|
|
begin
|
|
|
|
candidates = []
|
|
|
|
rec = eval(receiver, bind)
|
|
|
|
if sep == "::" and rec.kind_of?(Module)
|
|
|
|
candidates = rec.constants.collect{|m| m.to_s}
|
|
|
|
end
|
|
|
|
candidates |= rec.methods.collect{|m| m.to_s}
|
|
|
|
rescue Exception
|
|
|
|
candidates = []
|
|
|
|
end
|
|
|
|
else
|
|
|
|
# func1.func2
|
|
|
|
candidates = []
|
2018-03-12 21:28:27 -04:00
|
|
|
to_ignore = ignored_modules
|
2014-08-08 21:36:49 -04:00
|
|
|
ObjectSpace.each_object(Module){|m|
|
2018-03-12 21:28:27 -04:00
|
|
|
next if (to_ignore.include?(m) rescue true)
|
2014-08-08 21:36:49 -04:00
|
|
|
candidates.concat m.instance_methods(false).collect{|x| x.to_s}
|
|
|
|
}
|
|
|
|
candidates.sort!
|
|
|
|
candidates.uniq!
|
|
|
|
end
|
2019-05-26 12:24:03 -04:00
|
|
|
if doc_namespace
|
2019-07-18 19:23:37 -04:00
|
|
|
"#{rec.class.name}#{sep}#{candidates.find{ |i| i == message }}"
|
2019-05-26 12:24:03 -04:00
|
|
|
else
|
|
|
|
select_message(receiver, message, candidates, sep)
|
|
|
|
end
|
2001-04-30 14:25:04 -04:00
|
|
|
|
|
|
|
when /^\.([^.]*)$/
|
2014-08-08 21:36:49 -04:00
|
|
|
# unknown(maybe String)
|
2001-04-30 14:25:04 -04:00
|
|
|
|
2014-08-08 21:36:49 -04:00
|
|
|
receiver = ""
|
2021-01-06 05:05:46 -05:00
|
|
|
message = $1
|
2001-04-30 14:25:04 -04:00
|
|
|
|
2014-08-08 21:36:49 -04:00
|
|
|
candidates = String.instance_methods(true).collect{|m| m.to_s}
|
2019-05-26 12:24:03 -04:00
|
|
|
if doc_namespace
|
|
|
|
"String.#{candidates.find{ |i| i == message }}"
|
|
|
|
else
|
|
|
|
select_message(receiver, message, candidates)
|
|
|
|
end
|
2001-04-30 14:25:04 -04:00
|
|
|
|
2000-05-12 05:07:57 -04:00
|
|
|
else
|
2014-08-08 21:36:49 -04:00
|
|
|
candidates = eval("methods | private_methods | local_variables | instance_variables | self.class.constants", bind).collect{|m| m.to_s}
|
2020-02-12 05:16:12 -05:00
|
|
|
candidates |= ReservedWords
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2019-05-26 12:24:03 -04:00
|
|
|
if doc_namespace
|
|
|
|
candidates.find{ |i| i == input }
|
|
|
|
else
|
|
|
|
candidates.grep(/^#{Regexp.quote(input)}/)
|
|
|
|
end
|
2000-05-12 05:07:57 -04:00
|
|
|
end
|
2019-05-26 12:24:03 -04:00
|
|
|
end
|
2001-04-30 14:25:04 -04:00
|
|
|
|
2020-02-10 09:22:24 -05:00
|
|
|
PerfectMatchedProc = ->(matched, bind: IRB.conf[:MAIN_CONTEXT].workspace.binding) {
|
2021-03-29 13:11:10 -04:00
|
|
|
begin
|
|
|
|
require 'rdoc'
|
|
|
|
rescue LoadError
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2019-06-10 08:07:24 -04:00
|
|
|
RDocRIDriver ||= RDoc::RI::Driver.new
|
2021-03-29 13:11:10 -04:00
|
|
|
|
2019-05-28 17:11:24 -04:00
|
|
|
if matched =~ /\A(?:::)?RubyVM/ and not ENV['RUBY_YES_I_AM_NOT_A_NORMAL_USER']
|
2020-11-05 06:54:34 -05:00
|
|
|
IRB.__send__(:easter_egg)
|
2019-05-28 17:08:25 -04:00
|
|
|
return
|
|
|
|
end
|
2021-03-29 13:11:10 -04:00
|
|
|
|
2020-02-10 09:22:24 -05:00
|
|
|
namespace = retrieve_completion_data(matched, bind: bind, doc_namespace: true)
|
|
|
|
return unless namespace
|
2021-03-29 13:11:10 -04:00
|
|
|
|
2019-05-26 12:24:03 -04:00
|
|
|
if namespace.is_a?(Array)
|
|
|
|
out = RDoc::Markup::Document.new
|
|
|
|
namespace.each do |m|
|
|
|
|
begin
|
|
|
|
RDocRIDriver.add_method(out, m)
|
|
|
|
rescue RDoc::RI::Driver::NotFoundError
|
|
|
|
end
|
|
|
|
end
|
|
|
|
RDocRIDriver.display(out)
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
RDocRIDriver.display_names([namespace])
|
|
|
|
rescue RDoc::RI::Driver::NotFoundError
|
|
|
|
end
|
2019-04-27 18:47:33 -04:00
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2012-12-21 00:45:50 -05:00
|
|
|
# Set of available operators in Ruby
|
2013-06-04 10:17:17 -04:00
|
|
|
Operators = %w[% & * ** + - / < << <= <=> == === =~ > >= >> [] []= ^ ! != !~]
|
2001-04-30 14:25:04 -04:00
|
|
|
|
2011-01-18 04:34:10 -05:00
|
|
|
def self.select_message(receiver, message, candidates, sep = ".")
|
2021-01-06 05:05:46 -05:00
|
|
|
candidates.grep(/^#{Regexp.quote(message)}/).collect do |e|
|
2014-08-08 21:36:49 -04:00
|
|
|
case e
|
|
|
|
when /^[a-zA-Z_]/
|
|
|
|
receiver + sep + e
|
|
|
|
when /^[0-9]/
|
|
|
|
when *Operators
|
|
|
|
#receiver + " " + e
|
|
|
|
end
|
2001-04-30 14:25:04 -04:00
|
|
|
end
|
|
|
|
end
|
2018-03-12 21:28:27 -04:00
|
|
|
|
|
|
|
def self.ignored_modules
|
|
|
|
# We could cache the result, but this is very fast already.
|
|
|
|
# By using this approach, we avoid Module#name calls, which are
|
|
|
|
# relatively slow when there are a lot of anonymous modules defined.
|
2018-03-12 21:28:28 -04:00
|
|
|
s = {}
|
2018-03-12 21:28:27 -04:00
|
|
|
|
|
|
|
scanner = lambda do |m|
|
|
|
|
next if s.include?(m) # IRB::ExtendCommandBundle::EXCB recurses.
|
2018-03-12 21:28:28 -04:00
|
|
|
s[m] = true
|
2018-03-12 21:28:27 -04:00
|
|
|
m.constants(false).each do |c|
|
|
|
|
value = m.const_get(c)
|
|
|
|
scanner.call(value) if value.is_a?(Module)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-11-27 18:26:10 -05:00
|
|
|
%i(IRB RubyLex).each do |sym|
|
2018-03-12 21:28:27 -04:00
|
|
|
next unless Object.const_defined?(sym)
|
|
|
|
scanner.call(Object.const_get(sym))
|
|
|
|
end
|
|
|
|
|
|
|
|
s.delete(IRB::Context) if defined?(IRB::Context)
|
|
|
|
|
|
|
|
s
|
|
|
|
end
|
2000-05-12 05:07:57 -04:00
|
|
|
end
|
|
|
|
end
|