Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jekyll/semantic-highlighting.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ contained in the default list.
| Method calls with any syntax | method | |
| Constant references (including classes and modules) | namespace | We don't yet differentiate between module and class references |
| Method definition | method.declaration | |
| self | variable.default_library | |
| self | variable.defaultLibrary | |
| Method, block and lambda arguments | parameter | |
| Class declaration | class.declaration | |
| Module declaration | class.declaration | |
2 changes: 1 addition & 1 deletion lib/ruby_lsp/listeners/semantic_highlighting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def on_rest_parameter_node_enter(node)

#: (Prism::SelfNode node) -> void
def on_self_node_enter(node)
@response_builder.add_token(node.location, :variable, [:default_library])
@response_builder.add_token(node.location, :variable, [:defaultLibrary])
end

#: (Prism::LocalVariableWriteNode node) -> void
Expand Down
6 changes: 3 additions & 3 deletions lib/ruby_lsp/response_builders/semantic_highlighting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class UndefinedTokenType < StandardError; end
async: 6,
modification: 7,
documentation: 8,
default_library: 9,
defaultLibrary: 9,
}.freeze #: Hash[Symbol, Integer]

#: ((^(Integer arg0) -> Integer | Prism::CodeUnitsCache) code_units_cache) -> void
Expand Down Expand Up @@ -184,8 +184,8 @@ def compute_delta(token)
end

# Encode an array of modifiers to positions onto a bit flag
# For example, [:default_library] will be encoded as
# 0b1000000000, as :default_library is the 10th bit according
# For example, [:defaultLibrary] will be encoded as
# 0b1000000000, as :defaultLibrary is the 10th bit according
# to the token modifiers index map.
#: (Array[Integer] modifiers) -> Integer
def encode_modifiers(modifiers)
Expand Down
9 changes: 9 additions & 0 deletions test/requests/semantic_highlighting_expectations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ class Post
end
end

def test_provider_uses_lsp_default_library_modifier_casing
token_modifiers = JSON.parse(
RubyLsp::Requests::SemanticHighlighting.provider.to_json,
).dig("legend", "tokenModifiers")

assert_includes(token_modifiers, "defaultLibrary")
refute_includes(token_modifiers, "default_library")
end

private

def create_semantic_highlighting_addon
Expand Down
Loading