Class: RubyLsp::ResponseBuilders::SemanticHighlighting::SemanticToken

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_lsp/response_builders/semantic_highlighting.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_line:, start_code_unit_column:, length:, type:, modifier:) ⇒ SemanticToken

: (start_line: Integer, start_code_unit_column: Integer, length: Integer, type: Integer, modifier: Array) -> void



109
110
111
112
113
114
115
# File 'lib/ruby_lsp/response_builders/semantic_highlighting.rb', line 109

def initialize(start_line:, start_code_unit_column:, length:, type:, modifier:)
  @start_line = start_line
  @start_code_unit_column = start_code_unit_column
  @length = length
  @type = type
  @modifier = modifier
end

Instance Attribute Details

#lengthObject (readonly)

: Integer



100
101
102
# File 'lib/ruby_lsp/response_builders/semantic_highlighting.rb', line 100

def length
  @length
end

#modifierObject (readonly)

: Array



106
107
108
# File 'lib/ruby_lsp/response_builders/semantic_highlighting.rb', line 106

def modifier
  @modifier
end

#start_code_unit_columnObject (readonly)

: Integer



97
98
99
# File 'lib/ruby_lsp/response_builders/semantic_highlighting.rb', line 97

def start_code_unit_column
  @start_code_unit_column
end

#start_lineObject (readonly)

: Integer



94
95
96
# File 'lib/ruby_lsp/response_builders/semantic_highlighting.rb', line 94

def start_line
  @start_line
end

#typeObject (readonly)

: Integer



103
104
105
# File 'lib/ruby_lsp/response_builders/semantic_highlighting.rb', line 103

def type
  @type
end

Instance Method Details

#replace_modifier(modifier_symbols) ⇒ Object

: (Array modifier_symbols) -> void



126
127
128
129
130
131
132
133
# File 'lib/ruby_lsp/response_builders/semantic_highlighting.rb', line 126

def replace_modifier(modifier_symbols)
  @modifier = modifier_symbols.filter_map do |modifier_symbol|
    modifier_index = TOKEN_MODIFIERS[modifier_symbol]
    raise UndefinedTokenType, "Undefined token modifier: #{modifier_symbol}" unless modifier_index

    modifier_index
  end
end

#replace_type(type_symbol) ⇒ Object

: (Symbol type_symbol) -> void

Raises:



118
119
120
121
122
123
# File 'lib/ruby_lsp/response_builders/semantic_highlighting.rb', line 118

def replace_type(type_symbol)
  type_int = TOKEN_TYPES[type_symbol]
  raise UndefinedTokenType, "Undefined token type: #{type_symbol}" unless type_int

  @type = type_int
end