diff --git a/lib/ruby_lsp/listeners/semantic_highlighting.rb b/lib/ruby_lsp/listeners/semantic_highlighting.rb index 51e51bde5..317b80881 100644 --- a/lib/ruby_lsp/listeners/semantic_highlighting.rb +++ b/lib/ruby_lsp/listeners/semantic_highlighting.rb @@ -14,7 +14,7 @@ class SemanticHighlighting Kernel.methods(false), Bundler::Dsl.instance_methods(false), Module.private_instance_methods(false), - ].flatten.map(&:to_s), + ].flatten.map(&:to_s).freeze, T::Array[String], ) @@ -50,13 +50,6 @@ def initialize(dispatcher, response_builder) :on_optional_parameter_node_enter, :on_required_parameter_node_enter, :on_rest_parameter_node_enter, - :on_constant_read_node_enter, - :on_constant_write_node_enter, - :on_constant_and_write_node_enter, - :on_constant_operator_write_node_enter, - :on_constant_or_write_node_enter, - :on_constant_target_node_enter, - :on_constant_path_node_enter, :on_local_variable_and_write_node_enter, :on_local_variable_operator_write_node_enter, :on_local_variable_or_write_node_enter, @@ -82,8 +75,14 @@ def on_call_node_enter(node) return if message == "=~" return if special_method?(message) - type = Requests::Support::Sorbet.annotation?(node) ? :type : :method - @response_builder.add_token(T.must(node.message_loc), type) + if Requests::Support::Sorbet.annotation?(node) + @response_builder.add_token(T.must(node.message_loc), :type) + elsif !node.receiver && !node.opening_loc + # If the node has a receiver, then the syntax is not ambiguous and semantic highlighting is not necessary to + # determine that the token is a method call. The only ambiguous case is method calls with implicit self + # receiver and no parenthesis, which may be confused with local variables + @response_builder.add_token(T.must(node.message_loc), :method) + end end sig { params(node: Prism::MatchWriteNode).void } @@ -101,42 +100,9 @@ def on_match_write_node_leave(node) @inside_regex_capture = true if node.call.message == "=~" end - sig { params(node: Prism::ConstantReadNode).void } - def on_constant_read_node_enter(node) - return if @inside_implicit_node - - @response_builder.add_token(node.location, :namespace) - end - - sig { params(node: Prism::ConstantWriteNode).void } - def on_constant_write_node_enter(node) - @response_builder.add_token(node.name_loc, :namespace) - end - - sig { params(node: Prism::ConstantAndWriteNode).void } - def on_constant_and_write_node_enter(node) - @response_builder.add_token(node.name_loc, :namespace) - end - - sig { params(node: Prism::ConstantOperatorWriteNode).void } - def on_constant_operator_write_node_enter(node) - @response_builder.add_token(node.name_loc, :namespace) - end - - sig { params(node: Prism::ConstantOrWriteNode).void } - def on_constant_or_write_node_enter(node) - @response_builder.add_token(node.name_loc, :namespace) - end - - sig { params(node: Prism::ConstantTargetNode).void } - def on_constant_target_node_enter(node) - @response_builder.add_token(node.location, :namespace) - end - sig { params(node: Prism::DefNode).void } def on_def_node_enter(node) @current_scope = ParameterScope.new(@current_scope) - @response_builder.add_token(node.name_loc, :method, [:declaration]) end sig { params(node: Prism::DefNode).void } @@ -168,49 +134,33 @@ def on_block_parameter_node_enter(node) sig { params(node: Prism::RequiredKeywordParameterNode).void } def on_required_keyword_parameter_node_enter(node) @current_scope << node.name - - location = node.name_loc - @response_builder.add_token(location.copy(length: location.length - 1), :parameter) end sig { params(node: Prism::OptionalKeywordParameterNode).void } def on_optional_keyword_parameter_node_enter(node) @current_scope << node.name - - location = node.name_loc - @response_builder.add_token(location.copy(length: location.length - 1), :parameter) end sig { params(node: Prism::KeywordRestParameterNode).void } def on_keyword_rest_parameter_node_enter(node) name = node.name - - if name - @current_scope << name.to_sym - @response_builder.add_token(T.must(node.name_loc), :parameter) - end + @current_scope << name.to_sym if name end sig { params(node: Prism::OptionalParameterNode).void } def on_optional_parameter_node_enter(node) @current_scope << node.name - @response_builder.add_token(node.name_loc, :parameter) end sig { params(node: Prism::RequiredParameterNode).void } def on_required_parameter_node_enter(node) @current_scope << node.name - @response_builder.add_token(node.location, :parameter) end sig { params(node: Prism::RestParameterNode).void } def on_rest_parameter_node_enter(node) name = node.name - - if name - @current_scope << name.to_sym - @response_builder.add_token(T.must(node.name_loc), :parameter) - end + @current_scope << name.to_sym if name end sig { params(node: Prism::SelfNode).void } @@ -332,13 +282,6 @@ def on_implicit_node_leave(node) @inside_implicit_node = false end - sig { params(node: Prism::ConstantPathNode).void } - def on_constant_path_node_enter(node) - return if @inside_implicit_node - - @response_builder.add_token(node.name_loc, :namespace) - end - private # Textmate provides highlighting for a subset of these special Ruby-specific methods. We want to utilize that diff --git a/lib/ruby_lsp/requests/semantic_highlighting.rb b/lib/ruby_lsp/requests/semantic_highlighting.rb index 9e1a639d7..eca1f0a91 100644 --- a/lib/ruby_lsp/requests/semantic_highlighting.rb +++ b/lib/ruby_lsp/requests/semantic_highlighting.rb @@ -19,6 +19,16 @@ module Requests # some_invocation # --> semantic highlighting: method invocation # var # --> semantic highlighting: local variable # end + # + # # Strategy + # + # To maximize editor performance, the Ruby LSP will return the minimum number of semantic tokens, since applying + # them is an expensive operation for the client. This means that the server only returns tokens for ambiguous pieces + # of syntax, such as method invocations with no receivers or parenthesis (which can be confused with local + # variables). + # + # Offloading as much handling as possible to Text Mate grammars or equivalent will guarantee responsiveness in the + # editor and allow for a much smoother experience. # ``` class SemanticHighlighting < Request extend T::Sig diff --git a/test/expectations/semantic_highlighting/aref_field.exp.json b/test/expectations/semantic_highlighting/aref_field.exp.json index fd2462914..a781fd87d 100644 --- a/test/expectations/semantic_highlighting/aref_field.exp.json +++ b/test/expectations/semantic_highlighting/aref_field.exp.json @@ -1,12 +1,5 @@ { "result": [ - { - "delta_line": 0, - "delta_start_char": 4, - "length": 9, - "token_type": 13, - "token_modifiers": 1 - }, { "delta_line": 1, "delta_start_char": 2, diff --git a/test/expectations/semantic_highlighting/aref_variable.exp.json b/test/expectations/semantic_highlighting/aref_variable.exp.json index fd2462914..a781fd87d 100644 --- a/test/expectations/semantic_highlighting/aref_variable.exp.json +++ b/test/expectations/semantic_highlighting/aref_variable.exp.json @@ -1,12 +1,5 @@ { "result": [ - { - "delta_line": 0, - "delta_start_char": 4, - "length": 9, - "token_type": 13, - "token_modifiers": 1 - }, { "delta_line": 1, "delta_start_char": 2, diff --git a/test/expectations/semantic_highlighting/block_locals.exp.json b/test/expectations/semantic_highlighting/block_locals.exp.json index 6c7f1fcad..e11eaedb5 100644 --- a/test/expectations/semantic_highlighting/block_locals.exp.json +++ b/test/expectations/semantic_highlighting/block_locals.exp.json @@ -1,23 +1,8 @@ { - "params": [], "result": [ { "delta_line": 0, - "delta_start_char": 3, - "length": 4, - "token_type": 13, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 9, - "length": 1, - "token_type": 7, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 3, + "delta_start_char": 15, "length": 11, "token_type": 8, "token_modifiers": 0 diff --git a/test/expectations/semantic_highlighting/call_invocation.exp.json b/test/expectations/semantic_highlighting/call_invocation.exp.json deleted file mode 100644 index 37904018e..000000000 --- a/test/expectations/semantic_highlighting/call_invocation.exp.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "result": [ - { - "delta_line": 0, - "delta_start_char": 8, - "length": 6, - "token_type": 13, - "token_modifiers": 0 - } - ] -} diff --git a/test/expectations/semantic_highlighting/call_invocation_with_variable_receiver.exp.json b/test/expectations/semantic_highlighting/call_invocation_with_variable_receiver.exp.json index a9af1e79c..2750011fd 100644 --- a/test/expectations/semantic_highlighting/call_invocation_with_variable_receiver.exp.json +++ b/test/expectations/semantic_highlighting/call_invocation_with_variable_receiver.exp.json @@ -1,12 +1,5 @@ { "result": [ - { - "delta_line": 0, - "delta_start_char": 4, - "length": 11, - "token_type": 13, - "token_modifiers": 1 - }, { "delta_line": 1, "delta_start_char": 2, @@ -20,13 +13,6 @@ "length": 3, "token_type": 8, "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 4, - "length": 6, - "token_type": 13, - "token_modifiers": 0 } ] } diff --git a/test/expectations/semantic_highlighting/call_invocation_with_variable_receiver_and_arguments.exp.json b/test/expectations/semantic_highlighting/call_invocation_with_variable_receiver_and_arguments.exp.json index ad4f2ba4c..09975ac74 100644 --- a/test/expectations/semantic_highlighting/call_invocation_with_variable_receiver_and_arguments.exp.json +++ b/test/expectations/semantic_highlighting/call_invocation_with_variable_receiver_and_arguments.exp.json @@ -1,12 +1,5 @@ { "result": [ - { - "delta_line": 0, - "delta_start_char": 4, - "length": 11, - "token_type": 13, - "token_modifiers": 1 - }, { "delta_line": 1, "delta_start_char": 2, @@ -30,14 +23,7 @@ }, { "delta_line": 0, - "delta_start_char": 4, - "length": 6, - "token_type": 13, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 7, + "delta_start_char": 11, "length": 3, "token_type": 8, "token_modifiers": 0 diff --git a/test/expectations/semantic_highlighting/class_declaration_with_superclass.exp.json b/test/expectations/semantic_highlighting/class_declaration_with_superclass.exp.json index 4ebe8ce88..b26a6cacd 100644 --- a/test/expectations/semantic_highlighting/class_declaration_with_superclass.exp.json +++ b/test/expectations/semantic_highlighting/class_declaration_with_superclass.exp.json @@ -7,26 +7,12 @@ "token_type": 2, "token_modifiers": 1 }, - { - "delta_line": 0, - "delta_start_char": 0, - "length": 3, - "token_type": 0, - "token_modifiers": 0 - }, { "delta_line": 0, "delta_start_char": 6, "length": 10, "token_type": 2, "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 0, - "length": 10, - "token_type": 0, - "token_modifiers": 0 } ] } diff --git a/test/expectations/semantic_highlighting/command_call.exp.json b/test/expectations/semantic_highlighting/command_call.exp.json index b925f698f..79b019ad1 100644 --- a/test/expectations/semantic_highlighting/command_call.exp.json +++ b/test/expectations/semantic_highlighting/command_call.exp.json @@ -16,14 +16,7 @@ }, { "delta_line": 0, - "delta_start_char": 7, - "length": 10, - "token_type": 13, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 11, + "delta_start_char": 18, "length": 3, "token_type": 8, "token_modifiers": 0 diff --git a/test/expectations/semantic_highlighting/const.exp.json b/test/expectations/semantic_highlighting/const.exp.json index 1b1cc1215..5bafdfc60 100644 --- a/test/expectations/semantic_highlighting/const.exp.json +++ b/test/expectations/semantic_highlighting/const.exp.json @@ -1,243 +1,12 @@ { "result": [ { - "delta_line": 0, - "delta_start_char": 0, - "length": 2, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 1, - "delta_start_char": 2, - "length": 2, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 1, - "delta_start_char": 0, - "length": 3, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 5, - "length": 2, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 1, - "delta_start_char": 2, - "length": 3, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 5, - "length": 2, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 1, - "delta_start_char": 0, - "length": 2, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 1, - "delta_start_char": 2, - "length": 2, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 1, - "delta_start_char": 0, - "length": 3, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 5, - "length": 2, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 1, - "delta_start_char": 2, - "length": 3, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 5, - "length": 2, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 2, - "delta_start_char": 0, - "length": 1, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 1, - "delta_start_char": 2, - "length": 1, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 1, - "delta_start_char": 0, - "length": 1, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 3, - "length": 1, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 1, - "delta_start_char": 2, - "length": 1, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 3, - "length": 1, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 2, - "delta_start_char": 0, - "length": 1, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 1, - "delta_start_char": 2, - "length": 1, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 1, - "delta_start_char": 0, - "length": 1, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 3, - "length": 1, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 1, - "delta_start_char": 2, - "length": 1, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 3, - "length": 1, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 2, - "delta_start_char": 0, - "length": 1, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 1, - "delta_start_char": 2, - "length": 1, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 1, - "delta_start_char": 0, - "length": 1, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 3, - "length": 1, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 1, - "delta_start_char": 2, - "length": 1, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 3, - "length": 1, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 2, - "delta_start_char": 0, - "length": 1, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 10, - "length": 1, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 1, + "delta_line": 25, "delta_start_char": 0, "length": 4, "token_type": 8, "token_modifiers": 512 }, - { - "delta_line": 0, - "delta_start_char": 6, - "length": 1, - "token_type": 0, - "token_modifiers": 0 - }, { "delta_line": 1, "delta_start_char": 0, @@ -254,13 +23,6 @@ }, { "delta_line": 1, - "delta_start_char": 0, - "length": 1, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 0, "delta_start_char": 3, "length": 3, "token_type": 8, diff --git a/test/expectations/semantic_highlighting/def_endless.exp.json b/test/expectations/semantic_highlighting/def_endless.exp.json deleted file mode 100644 index 1f8de64e1..000000000 --- a/test/expectations/semantic_highlighting/def_endless.exp.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "result": [ - { - "delta_line": 0, - "delta_start_char": 4, - "length": 3, - "token_type": 13, - "token_modifiers": 1 - } - ] -} diff --git a/test/expectations/semantic_highlighting/defs.exp.json b/test/expectations/semantic_highlighting/defs.exp.json index b4e75a55c..7052f6711 100644 --- a/test/expectations/semantic_highlighting/defs.exp.json +++ b/test/expectations/semantic_highlighting/defs.exp.json @@ -7,13 +7,6 @@ "token_type": 8, "token_modifiers": 512 }, - { - "delta_line": 0, - "delta_start_char": 5, - "length": 3, - "token_type": 13, - "token_modifiers": 1 - }, { "delta_line": 1, "delta_start_char": 2, diff --git a/test/expectations/semantic_highlighting/destructured_splat_block_arg.exp.json b/test/expectations/semantic_highlighting/destructured_splat_block_arg.exp.json deleted file mode 100644 index 686ac1dea..000000000 --- a/test/expectations/semantic_highlighting/destructured_splat_block_arg.exp.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "result": [ - { - "delta_line": 0, - "delta_start_char": 3, - "length": 4, - "token_type": 13, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 10, - "length": 1, - "token_type": 7, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 4, - "length": 4, - "token_type": 7, - "token_modifiers": 0 - } - ] -} diff --git a/test/expectations/semantic_highlighting/fcall_invocation.exp.json b/test/expectations/semantic_highlighting/fcall_invocation.exp.json deleted file mode 100644 index e16a7f103..000000000 --- a/test/expectations/semantic_highlighting/fcall_invocation.exp.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "result": [ - { - "delta_line": 0, - "delta_start_char": 4, - "length": 11, - "token_type": 13, - "token_modifiers": 1 - }, - { - "delta_line": 1, - "delta_start_char": 2, - "length": 10, - "token_type": 13, - "token_modifiers": 0 - } - ] -} diff --git a/test/expectations/semantic_highlighting/fcall_invocation_variable_arguments.exp.json b/test/expectations/semantic_highlighting/fcall_invocation_variable_arguments.exp.json index 45ccbfff7..601b65e67 100644 --- a/test/expectations/semantic_highlighting/fcall_invocation_variable_arguments.exp.json +++ b/test/expectations/semantic_highlighting/fcall_invocation_variable_arguments.exp.json @@ -1,12 +1,5 @@ { "result": [ - { - "delta_line": 0, - "delta_start_char": 4, - "length": 11, - "token_type": 13, - "token_modifiers": 1 - }, { "delta_line": 1, "delta_start_char": 2, @@ -16,14 +9,7 @@ }, { "delta_line": 1, - "delta_start_char": 2, - "length": 10, - "token_type": 13, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 11, + "delta_start_char": 13, "length": 3, "token_type": 8, "token_modifiers": 0 diff --git a/test/expectations/semantic_highlighting/field_assignment.exp.json b/test/expectations/semantic_highlighting/field_assignment.exp.json index ae2d8ff7a..4047c8462 100644 --- a/test/expectations/semantic_highlighting/field_assignment.exp.json +++ b/test/expectations/semantic_highlighting/field_assignment.exp.json @@ -6,13 +6,6 @@ "length": 6, "token_type": 13, "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 7, - "length": 3, - "token_type": 13, - "token_modifiers": 0 } ] } diff --git a/test/expectations/semantic_highlighting/implicit_node.exp.json b/test/expectations/semantic_highlighting/implicit_node.exp.json index 5a560df89..ad8ae1873 100644 --- a/test/expectations/semantic_highlighting/implicit_node.exp.json +++ b/test/expectations/semantic_highlighting/implicit_node.exp.json @@ -13,14 +13,6 @@ "length": 4, "token_type": 8, "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 6, - "length": 5, - "token_type": 0, - "token_modifiers": 0 } - ], - "params": [] + ] } diff --git a/test/expectations/semantic_highlighting/lambda_locals.exp.json b/test/expectations/semantic_highlighting/lambda_locals.exp.json index b356a81b9..591a90777 100644 --- a/test/expectations/semantic_highlighting/lambda_locals.exp.json +++ b/test/expectations/semantic_highlighting/lambda_locals.exp.json @@ -1,16 +1,8 @@ { - "params": [], "result": [ { "delta_line": 0, - "delta_start_char": 3, - "length": 1, - "token_type": 7, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 3, + "delta_start_char": 6, "length": 12, "token_type": 8, "token_modifiers": 0 diff --git a/test/expectations/semantic_highlighting/lambdas.exp.json b/test/expectations/semantic_highlighting/lambdas.exp.json index 698959c6e..bdaa28ef5 100644 --- a/test/expectations/semantic_highlighting/lambdas.exp.json +++ b/test/expectations/semantic_highlighting/lambdas.exp.json @@ -1,12 +1,5 @@ { "result": [ - { - "delta_line": 0, - "delta_start_char": 10, - "length": 4, - "token_type": 7, - "token_modifiers": 0 - }, { "delta_line": 1, "delta_start_char": 7, diff --git a/test/expectations/semantic_highlighting/local_variables.exp.json b/test/expectations/semantic_highlighting/local_variables.exp.json index ea8471c26..2750011fd 100644 --- a/test/expectations/semantic_highlighting/local_variables.exp.json +++ b/test/expectations/semantic_highlighting/local_variables.exp.json @@ -1,12 +1,5 @@ { "result": [ - { - "delta_line": 0, - "delta_start_char": 4, - "length": 9, - "token_type": 13, - "token_modifiers": 1 - }, { "delta_line": 1, "delta_start_char": 2, diff --git a/test/expectations/semantic_highlighting/local_vars_and_params.exp.json b/test/expectations/semantic_highlighting/local_vars_and_params.exp.json index e25dbd0b6..db9119657 100644 --- a/test/expectations/semantic_highlighting/local_vars_and_params.exp.json +++ b/test/expectations/semantic_highlighting/local_vars_and_params.exp.json @@ -1,19 +1,5 @@ { "result": [ - { - "delta_line": 0, - "delta_start_char": 4, - "length": 3, - "token_type": 13, - "token_modifiers": 1 - }, - { - "delta_line": 0, - "delta_start_char": 4, - "length": 1, - "token_type": 7, - "token_modifiers": 0 - }, { "delta_line": 1, "delta_start_char": 2, @@ -34,13 +20,6 @@ "length": 5, "token_type": 7, "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 6, - "length": 4, - "token_type": 13, - "token_modifiers": 0 } ] } diff --git a/test/expectations/semantic_highlighting/method_params.exp.json b/test/expectations/semantic_highlighting/method_params.exp.json index 05ffcf886..959b4ee8c 100644 --- a/test/expectations/semantic_highlighting/method_params.exp.json +++ b/test/expectations/semantic_highlighting/method_params.exp.json @@ -1,54 +1,5 @@ { "result": [ - { - "delta_line": 0, - "delta_start_char": 4, - "length": 3, - "token_type": 13, - "token_modifiers": 1 - }, - { - "delta_line": 0, - "delta_start_char": 4, - "length": 1, - "token_type": 7, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 3, - "length": 1, - "token_type": 7, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 8, - "length": 1, - "token_type": 7, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 3, - "length": 1, - "token_type": 7, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 3, - "length": 1, - "token_type": 7, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 8, - "length": 1, - "token_type": 7, - "token_modifiers": 0 - }, { "delta_line": 1, "delta_start_char": 7, diff --git a/test/expectations/semantic_highlighting/module_and_reference.exp.json b/test/expectations/semantic_highlighting/module_and_reference.exp.json index 2f39a4010..e748d89fd 100644 --- a/test/expectations/semantic_highlighting/module_and_reference.exp.json +++ b/test/expectations/semantic_highlighting/module_and_reference.exp.json @@ -1,5 +1,4 @@ { - "params": [], "result": [ { "delta_line": 0, @@ -7,20 +6,6 @@ "length": 3, "token_type": 0, "token_modifiers": 1 - }, - { - "delta_line": 0, - "delta_start_char": 0, - "length": 3, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 3, - "delta_start_char": 0, - "length": 3, - "token_type": 0, - "token_modifiers": 0 } ] } diff --git a/test/expectations/semantic_highlighting/multi_assignment.exp.json b/test/expectations/semantic_highlighting/multi_assignment.exp.json index 2f9af3c42..7875729a9 100644 --- a/test/expectations/semantic_highlighting/multi_assignment.exp.json +++ b/test/expectations/semantic_highlighting/multi_assignment.exp.json @@ -1,12 +1,5 @@ { "result": [ - { - "delta_line": 0, - "delta_start_char": 4, - "length": 9, - "token_type": 13, - "token_modifiers": 1 - }, { "delta_line": 1, "delta_start_char": 2, diff --git a/test/expectations/semantic_highlighting/multibyte_characters.exp.json b/test/expectations/semantic_highlighting/multibyte_characters.exp.json index 7a594dc4d..f20cf0a18 100644 --- a/test/expectations/semantic_highlighting/multibyte_characters.exp.json +++ b/test/expectations/semantic_highlighting/multibyte_characters.exp.json @@ -7,13 +7,6 @@ "token_type": 0, "token_modifiers": 1 }, - { - "delta_line": 0, - "delta_start_char": 0, - "length": 3, - "token_type": 0, - "token_modifiers": 0 - }, { "delta_line": 1, "delta_start_char": 8, @@ -22,21 +15,7 @@ "token_modifiers": 1 }, { - "delta_line": 0, - "delta_start_char": 0, - "length": 3, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 1, - "delta_start_char": 8, - "length": 1, - "token_type": 13, - "token_modifiers": 1 - }, - { - "delta_line": 1, + "delta_line": 2, "delta_start_char": 6, "length": 2, "token_type": 8, @@ -56,13 +35,6 @@ "token_type": 8, "token_modifiers": 0 }, - { - "delta_line": 0, - "delta_start_char": 3, - "length": 6, - "token_type": 13, - "token_modifiers": 0 - }, { "delta_line": 1, "delta_start_char": 11, diff --git a/test/expectations/semantic_highlighting/pinned_variable.exp.json b/test/expectations/semantic_highlighting/pinned_variable.exp.json index b84ba009a..83c9193ab 100644 --- a/test/expectations/semantic_highlighting/pinned_variable.exp.json +++ b/test/expectations/semantic_highlighting/pinned_variable.exp.json @@ -1,12 +1,5 @@ { "result": [ - { - "delta_line": 0, - "delta_start_char": 4, - "length": 3, - "token_type": 13, - "token_modifiers": 1 - }, { "delta_line": 1, "delta_start_char": 2, diff --git a/test/expectations/semantic_highlighting/sclass.exp.json b/test/expectations/semantic_highlighting/sclass.exp.json index cd887c9b8..c4c1b4952 100644 --- a/test/expectations/semantic_highlighting/sclass.exp.json +++ b/test/expectations/semantic_highlighting/sclass.exp.json @@ -7,13 +7,6 @@ "token_type": 2, "token_modifiers": 1 }, - { - "delta_line": 0, - "delta_start_char": 0, - "length": 3, - "token_type": 0, - "token_modifiers": 0 - }, { "delta_line": 1, "delta_start_char": 11, diff --git a/test/expectations/semantic_highlighting/shadowed_block_arg.exp.json b/test/expectations/semantic_highlighting/shadowed_block_arg.exp.json index 2bd00e8a5..e6a4067a2 100644 --- a/test/expectations/semantic_highlighting/shadowed_block_arg.exp.json +++ b/test/expectations/semantic_highlighting/shadowed_block_arg.exp.json @@ -8,21 +8,7 @@ "token_modifiers": 0 }, { - "delta_line": 2, - "delta_start_char": 3, - "length": 4, - "token_type": 13, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 9, - "length": 3, - "token_type": 7, - "token_modifiers": 0 - }, - { - "delta_line": 1, + "delta_line": 3, "delta_start_char": 7, "length": 3, "token_type": 7, diff --git a/test/expectations/semantic_highlighting/single_line_lambda.exp.json b/test/expectations/semantic_highlighting/single_line_lambda.exp.json index 47dc6724d..7a626a664 100644 --- a/test/expectations/semantic_highlighting/single_line_lambda.exp.json +++ b/test/expectations/semantic_highlighting/single_line_lambda.exp.json @@ -2,14 +2,7 @@ "result": [ { "delta_line": 0, - "delta_start_char": 4, - "length": 3, - "token_type": 7, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 12, + "delta_start_char": 16, "length": 3, "token_type": 7, "token_modifiers": 0 diff --git a/test/expectations/semantic_highlighting/special_ruby_methods.exp.json b/test/expectations/semantic_highlighting/special_ruby_methods.exp.json index f1b5e926c..392cea0bf 100644 --- a/test/expectations/semantic_highlighting/special_ruby_methods.exp.json +++ b/test/expectations/semantic_highlighting/special_ruby_methods.exp.json @@ -8,49 +8,7 @@ "token_modifiers": 1 }, { - "delta_line": 0, - "delta_start_char": 0, - "length": 3, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 1, - "delta_start_char": 10, - "length": 3, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 4, - "delta_start_char": 9, - "length": 3, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 4, - "delta_start_char": 6, - "length": 3, - "token_type": 13, - "token_modifiers": 1 - }, - { - "delta_line": 1, - "delta_start_char": 4, - "length": 3, - "token_type": 0, - "token_modifiers": 0 - }, - { - "delta_line": 0, - "delta_start_char": 4, - "length": 3, - "token_type": 13, - "token_modifiers": 0 - }, - { - "delta_line": 1, + "delta_line": 11, "delta_start_char": 4, "length": 11, "token_type": 13, diff --git a/test/expectations/semantic_highlighting/var_aref_variable.exp.json b/test/expectations/semantic_highlighting/var_aref_variable.exp.json index 88009e0b0..8949a1b55 100644 --- a/test/expectations/semantic_highlighting/var_aref_variable.exp.json +++ b/test/expectations/semantic_highlighting/var_aref_variable.exp.json @@ -1,25 +1,11 @@ { "result": [ - { - "delta_line": 0, - "delta_start_char": 4, - "length": 9, - "token_type": 13, - "token_modifiers": 1 - }, { "delta_line": 1, "delta_start_char": 2, "length": 1, "token_type": 8, "token_modifiers": 0 - }, - { - "delta_line": 5, - "delta_start_char": 0, - "length": 3, - "token_type": 0, - "token_modifiers": 0 } ] } diff --git a/test/expectations/semantic_highlighting/var_field_variable.exp.json b/test/expectations/semantic_highlighting/var_field_variable.exp.json index 611f07d44..2692e3fe1 100644 --- a/test/expectations/semantic_highlighting/var_field_variable.exp.json +++ b/test/expectations/semantic_highlighting/var_field_variable.exp.json @@ -1,12 +1,5 @@ { "result": [ - { - "delta_line": 0, - "delta_start_char": 4, - "length": 9, - "token_type": 13, - "token_modifiers": 1 - }, { "delta_line": 1, "delta_start_char": 2, @@ -14,13 +7,6 @@ "token_type": 8, "token_modifiers": 0 }, - { - "delta_line": 0, - "delta_start_char": 4, - "length": 3, - "token_type": 0, - "token_modifiers": 0 - }, { "delta_line": 1, "delta_start_char": 2, diff --git a/test/expectations/semantic_highlighting/vcall_invocation.exp.json b/test/expectations/semantic_highlighting/vcall_invocation.exp.json index e16a7f103..df439c06a 100644 --- a/test/expectations/semantic_highlighting/vcall_invocation.exp.json +++ b/test/expectations/semantic_highlighting/vcall_invocation.exp.json @@ -1,12 +1,5 @@ { "result": [ - { - "delta_line": 0, - "delta_start_char": 4, - "length": 11, - "token_type": 13, - "token_modifiers": 1 - }, { "delta_line": 1, "delta_start_char": 2, diff --git a/test/fixtures/call_invocation.rb b/test/fixtures/call_invocation.rb deleted file mode 100644 index a64427b33..000000000 --- a/test/fixtures/call_invocation.rb +++ /dev/null @@ -1 +0,0 @@ -"Hello".upcase diff --git a/test/fixtures/fcall_invocation.rb b/test/fixtures/fcall_invocation.rb deleted file mode 100644 index 01d1a25a2..000000000 --- a/test/fixtures/fcall_invocation.rb +++ /dev/null @@ -1,3 +0,0 @@ -def some_method - invocation(1, 2, 3) -end diff --git a/test/requests/semantic_highlighting_expectations_test.rb b/test/requests/semantic_highlighting_expectations_test.rb index 6909c4bd0..ea575c021 100644 --- a/test/requests/semantic_highlighting_expectations_test.rb +++ b/test/requests/semantic_highlighting_expectations_test.rb @@ -63,18 +63,14 @@ class Post { delta_line: 0, delta_start_char: 6, length: 4, token_type: 2, token_modifiers: 1 }, decoded_response[0], ) - assert_equal( - { delta_line: 0, delta_start_char: 0, length: 4, token_type: 0, token_modifiers: 0 }, - decoded_response[1], - ) assert_equal( { delta_line: 1, delta_start_char: 2, length: 13, token_type: 13, token_modifiers: 0 }, - decoded_response[2], + decoded_response[1], ) # This is the token modified by the addon assert_equal( { delta_line: 1, delta_start_char: 2, length: 13, token_type: 15, token_modifiers: 1 }, - decoded_response[3], + decoded_response[2], ) end ensure