Class: RubyLsp::RubyLspSlim::SlimScanner
- Inherits:
-
Object
- Object
- RubyLsp::RubyLspSlim::SlimScanner
- Defined in:
- lib/ruby_lsp/ruby_lsp_slim/slim_scanner.rb
Overview
Scanner that extracts Ruby code from Slim templates while preserving byte positions.
Produces two same-length strings: @ruby contains Ruby code (with spaces where host language is)
and @host_language contains Slim markup (with spaces where Ruby code is).
Instance Attribute Summary collapse
-
#host_language ⇒ Object
readonly
Returns the value of attribute host_language.
-
#ruby ⇒ Object
readonly
Returns the value of attribute ruby.
Instance Method Summary collapse
-
#initialize(source) ⇒ SlimScanner
constructor
A new instance of SlimScanner.
- #scan ⇒ Object
Constructor Details
#initialize(source) ⇒ SlimScanner
Returns a new instance of SlimScanner.
11 12 13 14 15 16 17 18 19 |
# File 'lib/ruby_lsp/ruby_lsp_slim/slim_scanner.rb', line 11 def initialize(source) @source = source @ruby = +"" # Ruby code with spaces for non-Ruby portions @host_language = +"" # Host language with spaces for Ruby portions @current_pos = 0 @line_start = true @in_ruby_filter = false @ruby_filter_indent = 0 end |
Instance Attribute Details
#host_language ⇒ Object (readonly)
Returns the value of attribute host_language.
9 10 11 |
# File 'lib/ruby_lsp/ruby_lsp_slim/slim_scanner.rb', line 9 def host_language @host_language end |
#ruby ⇒ Object (readonly)
Returns the value of attribute ruby.
9 10 11 |
# File 'lib/ruby_lsp/ruby_lsp_slim/slim_scanner.rb', line 9 def ruby @ruby end |
Instance Method Details
#scan ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/ruby_lsp/ruby_lsp_slim/slim_scanner.rb', line 21 def scan while @current_pos < @source.length if @line_start scan_line_start else scan_inline end end end |