Skip to content

Commit e492623

Browse files
authored
Merge pull request #4005 from a-lavis/fix-semantic-default-library-modifier
Fix semantic token `defaultLibrary` modifier casing
2 parents afa0fc4 + bca1913 commit e492623

4 files changed

Lines changed: 14 additions & 5 deletions

File tree

jekyll/semantic-highlighting.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ contained in the default list.
4343
| Method calls with any syntax | method | |
4444
| Constant references (including classes and modules) | namespace | We don't yet differentiate between module and class references |
4545
| Method definition | method.declaration | |
46-
| self | variable.default_library | |
46+
| self | variable.defaultLibrary | |
4747
| Method, block and lambda arguments | parameter | |
4848
| Class declaration | class.declaration | |
4949
| Module declaration | class.declaration | |

lib/ruby_lsp/listeners/semantic_highlighting.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def on_rest_parameter_node_enter(node)
162162

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

168168
#: (Prism::LocalVariableWriteNode node) -> void

lib/ruby_lsp/response_builders/semantic_highlighting.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class UndefinedTokenType < StandardError; end
4343
async: 6,
4444
modification: 7,
4545
documentation: 8,
46-
default_library: 9,
46+
defaultLibrary: 9,
4747
}.freeze #: Hash[Symbol, Integer]
4848

4949
#: ((^(Integer arg0) -> Integer | Prism::CodeUnitsCache) code_units_cache) -> void
@@ -184,8 +184,8 @@ def compute_delta(token)
184184
end
185185

186186
# Encode an array of modifiers to positions onto a bit flag
187-
# For example, [:default_library] will be encoded as
188-
# 0b1000000000, as :default_library is the 10th bit according
187+
# For example, [:defaultLibrary] will be encoded as
188+
# 0b1000000000, as :defaultLibrary is the 10th bit according
189189
# to the token modifiers index map.
190190
#: (Array[Integer] modifiers) -> Integer
191191
def encode_modifiers(modifiers)

test/requests/semantic_highlighting_expectations_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ class Post
8282
end
8383
end
8484

85+
def test_provider_uses_lsp_default_library_modifier_casing
86+
token_modifiers = JSON.parse(
87+
RubyLsp::Requests::SemanticHighlighting.provider.to_json,
88+
).dig("legend", "tokenModifiers")
89+
90+
assert_includes(token_modifiers, "defaultLibrary")
91+
refute_includes(token_modifiers, "default_library")
92+
end
93+
8594
private
8695

8796
def create_semantic_highlighting_addon

0 commit comments

Comments
 (0)