Class: RubyLsp::Document::Scanner
- Inherits:
-
Object
- Object
- RubyLsp::Document::Scanner
- Extended by:
- T::Sig
- Defined in:
- lib/ruby_lsp/document.rb
Instance Method Summary collapse
- #find_position(position) ⇒ Object
-
#initialize(source) ⇒ Scanner
constructor
A new instance of Scanner.
Constructor Details
#initialize(source) ⇒ Scanner
Returns a new instance of Scanner.
95 96 97 98 99 |
# File 'lib/ruby_lsp/document.rb', line 95 def initialize(source) @current_line = T.let(0, Integer) @pos = T.let(0, Integer) @source = source end |
Instance Method Details
#find_position(position) ⇒ Object
102 103 104 105 106 107 108 109 110 |
# File 'lib/ruby_lsp/document.rb', line 102 def find_position(position) until @current_line == position[:line] @pos += 1 until /\R/.match?(@source[@pos]) @pos += 1 @current_line += 1 end @pos + position[:character] end |