Class: DidYouMean::Experimental::IvarNameChecker
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/did_you_mean/experimental/ivar_name_correction.rb |
Constant Summary
-
REPLS =
# File 'lib/did_you_mean/experimental/ivar_name_correction.rb', line 20{ "(irb)" => -> { Readline::HISTORY.to_a.last } }
-
TRACE =
# File 'lib/did_you_mean/experimental/ivar_name_correction.rb', line 24TracePoint.trace(:raise) do |tp| e = tp.raised_exception if SPELL_CHECKERS.include?(e.class.to_s) && !e.instance_variable_defined?(:@frame_binding) e.instance_variable_set(:@frame_binding, tp.binding) end end
Class Method Summary
Instance Attribute Summary
- #original_checker readonly
Instance Method Summary
- #corrections
- #ivar_name_corrections
- #line(abs_path, lineno) private
- #receiver_name private
Constructor Details
.new(no_method_error, original_checker:) ⇒ IvarNameChecker
# File 'lib/did_you_mean/experimental/ivar_name_correction.rb', line 34
def initialize(no_method_error, original_checker: ) @original_checker = original_checker.new(no_method_error) @location = no_method_error.backtrace_locations.first @ivar_names = no_method_error.frame_binding.receiver.instance_variables end
Instance Attribute Details
#original_checker (readonly)
[ GitHub ]# File 'lib/did_you_mean/experimental/ivar_name_correction.rb', line 32
attr_reader :original_checker
Instance Method Details
#corrections
[ GitHub ]# File 'lib/did_you_mean/experimental/ivar_name_correction.rb', line 41
def corrections original_checker.corrections + ivar_name_corrections end
#ivar_name_corrections
[ GitHub ]# File 'lib/did_you_mean/experimental/ivar_name_correction.rb', line 45
def ivar_name_corrections @ivar_name_corrections ||= SpellChecker.new(dictionary: @ivar_names).correct(receiver_name.to_s) end
#line(abs_path, lineno) (private)
[ GitHub ]#receiver_name (private)
[ GitHub ]# File 'lib/did_you_mean/experimental/ivar_name_correction.rb', line 51
def receiver_name return unless @original_checker.receiver.nil? abs_path = @location.absolute_path lineno = @location.lineno /@(\w+)*\.#{@original_checker.method_name}/ =~ line(abs_path, lineno).to_s && $1 end