class RubyLsp::ResponseBuilders::SemanticHighlighting
: [ResponseType = Interface::SemanticTokens]
def add_token(location, type, modifiers = [])
def add_token(location, type, modifiers = []) end_code_unit = location.cached_end_code_units_offset(@code_units_cache) length = end_code_unit - location.cached_start_code_units_offset(@code_units_cache) modifiers_indices = modifiers.filter_map { |modifier| TOKEN_MODIFIERS[modifier] } @stack.push( SemanticToken.new( start_line: location.start_line, start_code_unit_column: location.cached_start_code_units_column(@code_units_cache), length: length, type: TOKEN_TYPES[type], #: as !nil modifier: modifiers_indices, ), ) end
def initialize(code_units_cache)
def initialize(code_units_cache) super() @code_units_cache = code_units_cache @stack = [] #: Array[SemanticToken] end
def last
def last @stack.last end
def last_token_matches?(location)
def last_token_matches?(location) token = @stack.last return false unless token token.start_line == location.start_line && token.start_code_unit_column == location.cached_start_code_units_column(@code_units_cache) end
def response
@override
def response @stack end