20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/ruby_language_server/line_context.rb', line 20
def self.for(line, position)
line_end = line[position..-1]
return nil if line_end.nil?
match = line_end.partition(/^(@{0,2}\w+)/)[1]
RubyLanguageServer.logger.debug("match: #{match}")
line_start = line[0..(position + match.length - 1)]
RubyLanguageServer.logger.debug("line_start: #{line_start}")
end_match = line_start.partition(/(@{0,2}[:&\.\w]+)$/)[1]
matches = end_match.split('&.', -1)
matches = matches.map { |m| m.length.positive? ? m.split('.', -1) : m }.flatten
matches = matches.map { |m| m.length.positive? ? m.split('::', -1) : m }.flatten
RubyLanguageServer.logger.debug("matches: #{matches}")
matches
end
|