Module: NREPL::DefinitionFixer

Defined in:
lib/nrepl-lazuli/server.rb

Constant Summary collapse

@@definitions =
{}

Instance Method Summary collapse

Instance Method Details

#__lazuli_source_location(method) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/nrepl-lazuli/server.rb', line 117

def __lazuli_source_location(method)
  final_loc = nil
  loc = ancestors.each do |klass|
    loc = (klass.instance_variable_get(:@__lazuli_methods) || {})[method]
    if loc
      final_loc = loc
      break
    end
  end
  p [:LAZ, final_loc]
  p self

  if(final_loc && File.exist?(final_loc[0]))
    final_loc
  else
    instance_method(method).source_location
  end
end

#method_added(method_name) ⇒ Object



136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/nrepl-lazuli/server.rb', line 136

def method_added(method_name)
  return if method_name == :__lazuli_source_location
  path = caller.reject { |x| x =~ /gems.*gems/ }[0]
  if path
    (file, row) = path.split(/:/)

    known = instance_variable_get(:@__lazuli_methods)
    if !known
      known = {}
      instance_variable_set(:@__lazuli_methods, known)
    end
    known[method_name] = [file, row.to_i]
  end
end