Class: RubyLsp::Document::Scanner Abstract
- Inherits:
-
Object
- Object
- RubyLsp::Document::Scanner
- Defined in:
- lib/ruby_lsp/document.rb
Overview
Parent class for all position scanners. Scanners are used to translate a position given by the editor into a string index that we can use to find the right place in the document source. The logic for finding the correct index depends on the encoding negotiated with the editor, so we have different subclasses for each encoding. See microsoft.github.io/language-server-protocol/specification/#positionEncodingKind for more information
Direct Known Subclasses
Constant Summary collapse
- LINE_BREAK =
: Integer
0x0A- SURROGATE_PAIR_START =
After character 0xFFFF, UTF-16 considers characters to have length 2 and we have to account for that
0xFFFF
Instance Method Summary collapse
-
#find_char_position(position) ⇒ Object
abstract
Finds the character index inside the source string for a given line and column.
-
#initialize ⇒ Scanner
constructor
: -> void.
Constructor Details
#initialize ⇒ Scanner
: -> void
188 189 190 191 |
# File 'lib/ruby_lsp/document.rb', line 188 def initialize @current_line = 0 #: Integer @pos = 0 #: Integer end |
Instance Method Details
#find_char_position(position) ⇒ Object
Finds the character index inside the source string for a given line and column. This method always returns the character index regardless of whether we are searching positions based on bytes, code units, or codepoints. : (Hash[Symbol, untyped] position) -> Integer
197 198 199 |
# File 'lib/ruby_lsp/document.rb', line 197 def find_char_position(position) raise AbstractMethodInvokedError end |