ruby-lsp 0.23.11 → 0.23.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/VERSION +1 -1
  4. data/exe/ruby-lsp-launcher +20 -11
  5. data/lib/rubocop/cop/ruby_lsp/use_language_server_aliases.rb +1 -1
  6. data/lib/rubocop/cop/ruby_lsp/use_register_with_handler_method.rb +3 -5
  7. data/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +82 -116
  8. data/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb +123 -169
  9. data/lib/ruby_indexer/lib/ruby_indexer/enhancement.rb +9 -7
  10. data/lib/ruby_indexer/lib/ruby_indexer/entry.rb +92 -202
  11. data/lib/ruby_indexer/lib/ruby_indexer/index.rb +116 -222
  12. data/lib/ruby_indexer/lib/ruby_indexer/location.rb +4 -27
  13. data/lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb +18 -19
  14. data/lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb +22 -45
  15. data/lib/ruby_indexer/lib/ruby_indexer/reference_finder.rb +47 -61
  16. data/lib/ruby_indexer/lib/ruby_indexer/uri.rb +17 -19
  17. data/lib/ruby_indexer/lib/ruby_indexer/visibility_scope.rb +5 -9
  18. data/lib/ruby_indexer/test/class_variables_test.rb +14 -14
  19. data/lib/ruby_indexer/test/classes_and_modules_test.rb +65 -40
  20. data/lib/ruby_indexer/test/configuration_test.rb +48 -7
  21. data/lib/ruby_indexer/test/constant_test.rb +34 -34
  22. data/lib/ruby_indexer/test/enhancements_test.rb +1 -1
  23. data/lib/ruby_indexer/test/index_test.rb +139 -135
  24. data/lib/ruby_indexer/test/instance_variables_test.rb +37 -37
  25. data/lib/ruby_indexer/test/method_test.rb +143 -117
  26. data/lib/ruby_indexer/test/prefix_tree_test.rb +13 -13
  27. data/lib/ruby_indexer/test/rbs_indexer_test.rb +65 -71
  28. data/lib/ruby_indexer/test/test_case.rb +2 -2
  29. data/lib/ruby_indexer/test/uri_test.rb +15 -2
  30. data/lib/ruby_lsp/addon.rb +44 -71
  31. data/lib/ruby_lsp/base_server.rb +29 -32
  32. data/lib/ruby_lsp/client_capabilities.rb +10 -12
  33. data/lib/ruby_lsp/document.rb +39 -45
  34. data/lib/ruby_lsp/erb_document.rb +36 -40
  35. data/lib/ruby_lsp/global_state.rb +52 -57
  36. data/lib/ruby_lsp/internal.rb +2 -0
  37. data/lib/ruby_lsp/listeners/code_lens.rb +82 -89
  38. data/lib/ruby_lsp/listeners/completion.rb +60 -66
  39. data/lib/ruby_lsp/listeners/definition.rb +38 -52
  40. data/lib/ruby_lsp/listeners/document_highlight.rb +123 -150
  41. data/lib/ruby_lsp/listeners/document_link.rb +46 -63
  42. data/lib/ruby_lsp/listeners/document_symbol.rb +38 -52
  43. data/lib/ruby_lsp/listeners/folding_ranges.rb +40 -43
  44. data/lib/ruby_lsp/listeners/hover.rb +83 -102
  45. data/lib/ruby_lsp/listeners/inlay_hints.rb +4 -11
  46. data/lib/ruby_lsp/listeners/semantic_highlighting.rb +54 -56
  47. data/lib/ruby_lsp/listeners/signature_help.rb +11 -26
  48. data/lib/ruby_lsp/listeners/spec_style.rb +155 -0
  49. data/lib/ruby_lsp/listeners/test_discovery.rb +89 -0
  50. data/lib/ruby_lsp/listeners/test_style.rb +160 -88
  51. data/lib/ruby_lsp/node_context.rb +12 -39
  52. data/lib/ruby_lsp/rbs_document.rb +8 -6
  53. data/lib/ruby_lsp/requests/code_action_resolve.rb +24 -25
  54. data/lib/ruby_lsp/requests/code_actions.rb +14 -26
  55. data/lib/ruby_lsp/requests/code_lens.rb +6 -17
  56. data/lib/ruby_lsp/requests/completion.rb +7 -20
  57. data/lib/ruby_lsp/requests/completion_resolve.rb +6 -6
  58. data/lib/ruby_lsp/requests/definition.rb +8 -17
  59. data/lib/ruby_lsp/requests/diagnostics.rb +8 -11
  60. data/lib/ruby_lsp/requests/discover_tests.rb +18 -5
  61. data/lib/ruby_lsp/requests/document_highlight.rb +5 -15
  62. data/lib/ruby_lsp/requests/document_link.rb +6 -17
  63. data/lib/ruby_lsp/requests/document_symbol.rb +5 -8
  64. data/lib/ruby_lsp/requests/folding_ranges.rb +7 -15
  65. data/lib/ruby_lsp/requests/formatting.rb +6 -9
  66. data/lib/ruby_lsp/requests/go_to_relevant_file.rb +87 -0
  67. data/lib/ruby_lsp/requests/hover.rb +10 -20
  68. data/lib/ruby_lsp/requests/inlay_hints.rb +6 -17
  69. data/lib/ruby_lsp/requests/on_type_formatting.rb +32 -40
  70. data/lib/ruby_lsp/requests/prepare_rename.rb +4 -9
  71. data/lib/ruby_lsp/requests/prepare_type_hierarchy.rb +5 -15
  72. data/lib/ruby_lsp/requests/range_formatting.rb +5 -6
  73. data/lib/ruby_lsp/requests/references.rb +8 -37
  74. data/lib/ruby_lsp/requests/rename.rb +19 -42
  75. data/lib/ruby_lsp/requests/request.rb +7 -19
  76. data/lib/ruby_lsp/requests/selection_ranges.rb +6 -6
  77. data/lib/ruby_lsp/requests/semantic_highlighting.rb +16 -35
  78. data/lib/ruby_lsp/requests/show_syntax_tree.rb +7 -8
  79. data/lib/ruby_lsp/requests/signature_help.rb +8 -26
  80. data/lib/ruby_lsp/requests/support/annotation.rb +4 -10
  81. data/lib/ruby_lsp/requests/support/common.rb +16 -51
  82. data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +27 -35
  83. data/lib/ruby_lsp/requests/support/rubocop_formatter.rb +11 -14
  84. data/lib/ruby_lsp/requests/support/rubocop_runner.rb +22 -34
  85. data/lib/ruby_lsp/requests/support/selection_range.rb +1 -3
  86. data/lib/ruby_lsp/requests/support/sorbet.rb +29 -38
  87. data/lib/ruby_lsp/requests/support/source_uri.rb +20 -32
  88. data/lib/ruby_lsp/requests/support/syntax_tree_formatter.rb +12 -19
  89. data/lib/ruby_lsp/requests/support/test_item.rb +10 -14
  90. data/lib/ruby_lsp/requests/type_hierarchy_supertypes.rb +5 -6
  91. data/lib/ruby_lsp/requests/workspace_symbol.rb +4 -4
  92. data/lib/ruby_lsp/response_builders/collection_response_builder.rb +5 -5
  93. data/lib/ruby_lsp/response_builders/document_symbol.rb +13 -18
  94. data/lib/ruby_lsp/response_builders/hover.rb +11 -14
  95. data/lib/ruby_lsp/response_builders/response_builder.rb +1 -1
  96. data/lib/ruby_lsp/response_builders/semantic_highlighting.rb +60 -88
  97. data/lib/ruby_lsp/response_builders/signature_help.rb +5 -6
  98. data/lib/ruby_lsp/response_builders/test_collection.rb +6 -10
  99. data/lib/ruby_lsp/ruby_document.rb +24 -62
  100. data/lib/ruby_lsp/scope.rb +7 -11
  101. data/lib/ruby_lsp/scripts/compose_bundle.rb +6 -4
  102. data/lib/ruby_lsp/server.rb +147 -79
  103. data/lib/ruby_lsp/setup_bundler.rb +65 -60
  104. data/lib/ruby_lsp/static_docs.rb +11 -7
  105. data/lib/ruby_lsp/store.rb +24 -42
  106. data/lib/ruby_lsp/test_helper.rb +2 -12
  107. data/lib/ruby_lsp/test_reporters/lsp_reporter.rb +164 -0
  108. data/lib/ruby_lsp/test_reporters/minitest_reporter.rb +105 -0
  109. data/lib/ruby_lsp/test_reporters/test_unit_reporter.rb +94 -0
  110. data/lib/ruby_lsp/type_inferrer.rb +13 -14
  111. data/lib/ruby_lsp/utils.rb +49 -83
  112. metadata +9 -3
@@ -0,0 +1,105 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ begin
5
+ require "minitest"
6
+ rescue LoadError
7
+ return
8
+ end
9
+
10
+ require_relative "lsp_reporter"
11
+ require "ruby_indexer/lib/ruby_indexer/uri"
12
+
13
+ module RubyLsp
14
+ # An override of the default progress reporter in Minitest to add color to the output
15
+ class ProgressReporterWithColor < Minitest::ProgressReporter
16
+ #: (Minitest::Result) -> void
17
+ def record(result)
18
+ color = if result.error?
19
+ "\e[31m" # red
20
+ elsif result.passed?
21
+ "\e[32m" # green
22
+ elsif result.skipped?
23
+ "\e[33m" # yellow
24
+ elsif result.failure
25
+ "\e[31m" # red
26
+ else
27
+ "\e[0m" # no color
28
+ end
29
+
30
+ io.print("#{color}#{result.result_code}\e[0m") # Reset color after printing
31
+ end
32
+ end
33
+
34
+ class MinitestReporter < Minitest::AbstractReporter
35
+ class << self
36
+ #: (Hash[untyped, untyped]) -> void
37
+ def minitest_plugin_init(_options)
38
+ # Remove the original progress reporter, so that we replace it with our own. We only do this if no other
39
+ # reporters were included by the application itself to avoid double reporting
40
+ reporters = Minitest.reporter.reporters
41
+
42
+ if reporters.all? { |r| r.is_a?(Minitest::ProgressReporter) || r.is_a?(Minitest::SummaryReporter) }
43
+ reporters.delete_if { |r| r.is_a?(Minitest::ProgressReporter) }
44
+ reporters << ProgressReporterWithColor.new
45
+ end
46
+
47
+ # Add the JSON RPC reporter
48
+ reporters << MinitestReporter.new
49
+ end
50
+ end
51
+
52
+ #: (singleton(Minitest::Test) test_class, String method_name) -> void
53
+ def prerecord(test_class, method_name)
54
+ uri = uri_from_test_class(test_class, method_name)
55
+ return unless uri
56
+
57
+ LspReporter.instance.start_test(id: "#{test_class.name}##{method_name}", uri: uri)
58
+ end
59
+
60
+ #: (Minitest::Result result) -> void
61
+ def record(result)
62
+ id = "#{result.klass}##{result.name}"
63
+ uri = uri_from_result(result)
64
+
65
+ if result.error?
66
+ message = result.failures.first.message
67
+ LspReporter.instance.record_error(id: id, uri: uri, message: message)
68
+ elsif result.passed?
69
+ LspReporter.instance.record_pass(id: id, uri: uri)
70
+ elsif result.skipped?
71
+ LspReporter.instance.record_skip(id: id, uri: uri)
72
+ elsif result.failure
73
+ message = result.failure.message
74
+ LspReporter.instance.record_fail(id: id, uri: uri, message: message)
75
+ end
76
+ end
77
+
78
+ #: -> void
79
+ def report
80
+ LspReporter.instance.shutdown
81
+ end
82
+
83
+ private
84
+
85
+ #: (Minitest::Result result) -> URI::Generic
86
+ def uri_from_result(result)
87
+ file = result.source_location[0]
88
+ absolute_path = File.expand_path(file, Dir.pwd)
89
+ URI::Generic.from_path(path: absolute_path)
90
+ end
91
+
92
+ #: (singleton(Minitest::Test) test_class, String method_name) -> URI::Generic?
93
+ def uri_from_test_class(test_class, method_name)
94
+ file, _line = test_class.instance_method(method_name).source_location
95
+ return unless file
96
+
97
+ return if file.start_with?("(eval at ") # test is dynamically defined
98
+
99
+ absolute_path = File.expand_path(file, Dir.pwd)
100
+ URI::Generic.from_path(path: absolute_path)
101
+ end
102
+ end
103
+ end
104
+
105
+ Minitest.extensions << RubyLsp::MinitestReporter
@@ -0,0 +1,94 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ begin
5
+ require "test/unit"
6
+ require "test/unit/ui/testrunner"
7
+ require "test/unit/ui/console/testrunner"
8
+ rescue LoadError
9
+ return
10
+ end
11
+
12
+ require_relative "lsp_reporter"
13
+ require "ruby_indexer/lib/ruby_indexer/uri"
14
+
15
+ module RubyLsp
16
+ class TestUnitReporter < Test::Unit::UI::Console::TestRunner
17
+ def initialize(suite, options = {})
18
+ super
19
+ @current_uri = nil #: URI::Generic?
20
+ @current_test_id = nil #: String?
21
+ end
22
+
23
+ private
24
+
25
+ #: (::Test::Unit::TestCase test) -> void
26
+ def test_started(test)
27
+ super
28
+
29
+ current_test = test
30
+ @current_uri = uri_for_test(current_test)
31
+ return unless @current_uri
32
+
33
+ @current_test_id = "#{current_test.class.name}##{current_test.method_name}"
34
+ LspReporter.instance.start_test(id: @current_test_id, uri: @current_uri)
35
+ end
36
+
37
+ #: (::Test::Unit::TestCase test) -> void
38
+ def test_finished(test)
39
+ super
40
+ return unless test.passed? && @current_uri && @current_test_id
41
+
42
+ LspReporter.instance.record_pass(id: @current_test_id, uri: @current_uri)
43
+ end
44
+
45
+ #: (::Test::Unit::Failure | ::Test::Unit::Error | ::Test::Unit::Pending result) -> void
46
+ def add_fault(result)
47
+ super
48
+ return unless @current_uri && @current_test_id
49
+
50
+ case result
51
+ when ::Test::Unit::Failure
52
+ LspReporter.instance.record_fail(id: @current_test_id, message: result.message, uri: @current_uri)
53
+ when ::Test::Unit::Error
54
+ LspReporter.instance.record_error(id: @current_test_id, message: result.message, uri: @current_uri)
55
+ when ::Test::Unit::Pending
56
+ LspReporter.instance.record_skip(id: @current_test_id, uri: @current_uri)
57
+ end
58
+ end
59
+
60
+ #: (Float) -> void
61
+ def finished(elapsed_time)
62
+ LspReporter.instance.shutdown
63
+ end
64
+
65
+ #: (::Test::Unit::TestCase test) -> URI::Generic?
66
+ def uri_for_test(test)
67
+ location = test.method(test.method_name).source_location
68
+ return unless location
69
+
70
+ file, _line = location
71
+ return if file.start_with?("(eval at ")
72
+
73
+ absolute_path = File.expand_path(file, Dir.pwd)
74
+ URI::Generic.from_path(path: absolute_path)
75
+ end
76
+
77
+ #: -> void
78
+ def attach_to_mediator
79
+ # Events we care about
80
+ @mediator.add_listener(Test::Unit::TestResult::FAULT, &method(:add_fault))
81
+ @mediator.add_listener(Test::Unit::TestCase::STARTED_OBJECT, &method(:test_started))
82
+ @mediator.add_listener(Test::Unit::TestCase::FINISHED_OBJECT, &method(:test_finished))
83
+ @mediator.add_listener(Test::Unit::UI::TestRunnerMediator::FINISHED, &method(:finished))
84
+
85
+ # Other events needed for the console test runner to print
86
+ @mediator.add_listener(Test::Unit::UI::TestRunnerMediator::STARTED, &method(:started))
87
+ @mediator.add_listener(Test::Unit::TestSuite::STARTED_OBJECT, &method(:test_suite_started))
88
+ @mediator.add_listener(Test::Unit::TestSuite::FINISHED_OBJECT, &method(:test_suite_finished))
89
+ end
90
+ end
91
+ end
92
+
93
+ Test::Unit::AutoRunner.register_runner(:ruby_lsp) { |_auto_runner| RubyLsp::TestUnitReporter }
94
+ Test::Unit::AutoRunner.default_runner = :ruby_lsp
@@ -5,14 +5,12 @@ module RubyLsp
5
5
  # A minimalistic type checker to try to resolve types that can be inferred without requiring a type system or
6
6
  # annotations
7
7
  class TypeInferrer
8
- extend T::Sig
9
-
10
- sig { params(index: RubyIndexer::Index).void }
8
+ #: (RubyIndexer::Index index) -> void
11
9
  def initialize(index)
12
10
  @index = index
13
11
  end
14
12
 
15
- sig { params(node_context: NodeContext).returns(T.nilable(Type)) }
13
+ #: (NodeContext node_context) -> Type?
16
14
  def infer_receiver_type(node_context)
17
15
  node = node_context.node
18
16
 
@@ -31,7 +29,7 @@ module RubyLsp
31
29
 
32
30
  private
33
31
 
34
- sig { params(node: Prism::CallNode, node_context: NodeContext).returns(T.nilable(Type)) }
32
+ #: (Prism::CallNode node, NodeContext node_context) -> Type?
35
33
  def infer_receiver_for_call_node(node, node_context)
36
34
  receiver = node.receiver
37
35
 
@@ -114,7 +112,7 @@ module RubyLsp
114
112
  end
115
113
  end
116
114
 
117
- sig { params(raw_receiver: String, nesting: T::Array[String]).returns(T.nilable(GuessedType)) }
115
+ #: (String raw_receiver, Array[String] nesting) -> GuessedType?
118
116
  def guess_type(raw_receiver, nesting)
119
117
  guessed_name = raw_receiver
120
118
  .delete_prefix("@")
@@ -130,7 +128,7 @@ module RubyLsp
130
128
  GuessedType.new(name)
131
129
  end
132
130
 
133
- sig { params(node_context: NodeContext).returns(Type) }
131
+ #: (NodeContext node_context) -> Type
134
132
  def self_receiver_handling(node_context)
135
133
  nesting = node_context.nesting
136
134
  # If we're at the top level, then the invocation is happening on `<main>`, which is a special singleton that
@@ -147,7 +145,7 @@ module RubyLsp
147
145
  Type.new("#{parts.join("::")}::<Class:#{parts.last}>")
148
146
  end
149
147
 
150
- sig { params(node_context: NodeContext).returns(T.nilable(Type)) }
148
+ #: (NodeContext node_context) -> Type?
151
149
  def infer_receiver_for_class_variables(node_context)
152
150
  nesting_parts = node_context.nesting.dup
153
151
 
@@ -168,20 +166,21 @@ module RubyLsp
168
166
 
169
167
  # A known type
170
168
  class Type
171
- extend T::Sig
172
-
173
- sig { returns(String) }
169
+ #: String
174
170
  attr_reader :name
175
171
 
176
- sig { params(name: String).void }
172
+ #: (String name) -> void
177
173
  def initialize(name)
178
174
  @name = name
179
175
  end
180
176
 
181
177
  # Returns the attached version of this type by removing the `<Class:...>` part from its name
182
- sig { returns(Type) }
178
+ #: -> Type
183
179
  def attached
184
- Type.new(T.must(@name.split("::")[..-2]).join("::"))
180
+ Type.new(
181
+ @name.split("::")[..-2] #: as !nil
182
+ .join("::"),
183
+ )
185
184
  end
186
185
  end
187
186
 
@@ -9,22 +9,16 @@ module RubyLsp
9
9
  # rubocop:enable RubyLsp/UseLanguageServerAliases
10
10
 
11
11
  # Used to indicate that a request shouldn't return a response
12
- BUNDLE_PATH = T.let(
13
- begin
14
- Bundler.bundle_path.to_s
15
- rescue Bundler::GemfileNotFound
16
- nil
17
- end,
18
- T.nilable(String),
19
- )
20
- GEMFILE_NAME = T.let(
21
- begin
22
- Bundler.with_original_env { Bundler.default_gemfile.basename.to_s }
23
- rescue Bundler::GemfileNotFound
24
- "Gemfile"
25
- end,
26
- String,
27
- )
12
+ BUNDLE_PATH = begin
13
+ Bundler.bundle_path.to_s
14
+ rescue Bundler::GemfileNotFound
15
+ nil
16
+ end #: String?
17
+ GEMFILE_NAME = begin
18
+ Bundler.with_original_env { Bundler.default_gemfile.basename.to_s }
19
+ rescue Bundler::GemfileNotFound
20
+ "Gemfile"
21
+ end #: String
28
22
  GUESSED_TYPES_URL = "https://shopify.github.io/ruby-lsp/#guessed-types"
29
23
 
30
24
  # Request delegation for embedded languages is not yet standardized into the language server specification. Here we
@@ -44,15 +38,15 @@ module RubyLsp
44
38
  extend T::Sig
45
39
  extend T::Helpers
46
40
 
47
- sig { returns(String) }
41
+ #: String
48
42
  attr_reader :method
49
43
 
50
- sig { returns(Object) }
44
+ #: Object
51
45
  attr_reader :params
52
46
 
53
47
  abstract!
54
48
 
55
- sig { params(method: String, params: Object).void }
49
+ #: (method: String, params: Object) -> void
56
50
  def initialize(method:, params:)
57
51
  @method = method
58
52
  @params = params
@@ -64,9 +58,7 @@ module RubyLsp
64
58
 
65
59
  class Notification < Message
66
60
  class << self
67
- extend T::Sig
68
-
69
- sig { params(message: String, type: Integer).returns(Notification) }
61
+ #: (String message, ?type: Integer) -> Notification
70
62
  def window_show_message(message, type: Constant::MessageType::INFO)
71
63
  new(
72
64
  method: "window/showMessage",
@@ -74,7 +66,7 @@ module RubyLsp
74
66
  )
75
67
  end
76
68
 
77
- sig { params(message: String, type: Integer).returns(Notification) }
69
+ #: (String message, ?type: Integer) -> Notification
78
70
  def window_log_message(message, type: Constant::MessageType::LOG)
79
71
  new(
80
72
  method: "window/logMessage",
@@ -82,7 +74,7 @@ module RubyLsp
82
74
  )
83
75
  end
84
76
 
85
- sig { params(data: T::Hash[Symbol, T.untyped]).returns(Notification) }
77
+ #: (Hash[Symbol, untyped] data) -> Notification
86
78
  def telemetry(data)
87
79
  new(
88
80
  method: "telemetry/event",
@@ -90,14 +82,7 @@ module RubyLsp
90
82
  )
91
83
  end
92
84
 
93
- sig do
94
- params(
95
- id: String,
96
- title: String,
97
- percentage: T.nilable(Integer),
98
- message: T.nilable(String),
99
- ).returns(Notification)
100
- end
85
+ #: (String id, String title, ?percentage: Integer?, ?message: String?) -> Notification
101
86
  def progress_begin(id, title, percentage: nil, message: nil)
102
87
  new(
103
88
  method: "$/progress",
@@ -113,13 +98,7 @@ module RubyLsp
113
98
  )
114
99
  end
115
100
 
116
- sig do
117
- params(
118
- id: String,
119
- percentage: T.nilable(Integer),
120
- message: T.nilable(String),
121
- ).returns(Notification)
122
- end
101
+ #: (String id, ?percentage: Integer?, ?message: String?) -> Notification
123
102
  def progress_report(id, percentage: nil, message: nil)
124
103
  new(
125
104
  method: "$/progress",
@@ -134,7 +113,7 @@ module RubyLsp
134
113
  )
135
114
  end
136
115
 
137
- sig { params(id: String).returns(Notification) }
116
+ #: (String id) -> Notification
138
117
  def progress_end(id)
139
118
  Notification.new(
140
119
  method: "$/progress",
@@ -145,13 +124,7 @@ module RubyLsp
145
124
  )
146
125
  end
147
126
 
148
- sig do
149
- params(
150
- uri: String,
151
- diagnostics: T::Array[Interface::Diagnostic],
152
- version: T.nilable(Integer),
153
- ).returns(Notification)
154
- end
127
+ #: (String uri, Array[Interface::Diagnostic] diagnostics, ?version: Integer?) -> Notification
155
128
  def publish_diagnostics(uri, diagnostics, version: nil)
156
129
  new(
157
130
  method: "textDocument/publishDiagnostics",
@@ -160,30 +133,23 @@ module RubyLsp
160
133
  end
161
134
  end
162
135
 
163
- extend T::Sig
164
-
165
- sig { override.returns(T::Hash[Symbol, T.untyped]) }
136
+ # @override
137
+ #: -> Hash[Symbol, untyped]
166
138
  def to_hash
167
139
  hash = { method: @method }
168
- hash[:params] = T.unsafe(@params).to_hash if @params
140
+
141
+ if @params
142
+ hash[:params] = @params #: as untyped
143
+ .to_hash
144
+ end
145
+
169
146
  hash
170
147
  end
171
148
  end
172
149
 
173
150
  class Request < Message
174
- extend T::Sig
175
-
176
151
  class << self
177
- extend T::Sig
178
-
179
- sig do
180
- params(
181
- id: Integer,
182
- pattern: T.any(Interface::RelativePattern, String),
183
- kind: Integer,
184
- registration_id: T.nilable(String),
185
- ).returns(Request)
186
- end
152
+ #: (Integer id, (Interface::RelativePattern | String) pattern, ?kind: Integer, ?registration_id: String?) -> Request
187
153
  def register_watched_files(
188
154
  id,
189
155
  pattern,
@@ -210,30 +176,34 @@ module RubyLsp
210
176
  end
211
177
  end
212
178
 
213
- sig { params(id: T.any(Integer, String), method: String, params: Object).void }
179
+ #: (id: (Integer | String), method: String, params: Object) -> void
214
180
  def initialize(id:, method:, params:)
215
181
  @id = id
216
182
  super(method: method, params: params)
217
183
  end
218
184
 
219
- sig { override.returns(T::Hash[Symbol, T.untyped]) }
185
+ # @override
186
+ #: -> Hash[Symbol, untyped]
220
187
  def to_hash
221
188
  hash = { id: @id, method: @method }
222
- hash[:params] = T.unsafe(@params).to_hash if @params
189
+
190
+ if @params
191
+ hash[:params] = @params #: as untyped
192
+ .to_hash
193
+ end
194
+
223
195
  hash
224
196
  end
225
197
  end
226
198
 
227
199
  class Error
228
- extend T::Sig
229
-
230
- sig { returns(String) }
200
+ #: String
231
201
  attr_reader :message
232
202
 
233
- sig { returns(Integer) }
203
+ #: Integer
234
204
  attr_reader :code
235
205
 
236
- sig { params(id: Integer, code: Integer, message: String, data: T.nilable(T::Hash[Symbol, T.untyped])).void }
206
+ #: (id: Integer, code: Integer, message: String, ?data: Hash[Symbol, untyped]?) -> void
237
207
  def initialize(id:, code:, message:, data: nil)
238
208
  @id = id
239
209
  @code = code
@@ -241,7 +211,7 @@ module RubyLsp
241
211
  @data = data
242
212
  end
243
213
 
244
- sig { returns(T::Hash[Symbol, T.untyped]) }
214
+ #: -> Hash[Symbol, untyped]
245
215
  def to_hash
246
216
  {
247
217
  id: @id,
@@ -256,21 +226,19 @@ module RubyLsp
256
226
 
257
227
  # The final result of running a request before its IO is finalized
258
228
  class Result
259
- extend T::Sig
260
-
261
- sig { returns(T.untyped) }
229
+ #: untyped
262
230
  attr_reader :response
263
231
 
264
- sig { returns(Integer) }
232
+ #: Integer
265
233
  attr_reader :id
266
234
 
267
- sig { params(id: Integer, response: T.untyped).void }
235
+ #: (id: Integer, response: untyped) -> void
268
236
  def initialize(id:, response:)
269
237
  @id = id
270
238
  @response = response
271
239
  end
272
240
 
273
- sig { returns(T::Hash[Symbol, T.untyped]) }
241
+ #: -> Hash[Symbol, untyped]
274
242
  def to_hash
275
243
  { id: @id, result: @response }
276
244
  end
@@ -278,17 +246,15 @@ module RubyLsp
278
246
 
279
247
  # A request configuration, to turn on/off features
280
248
  class RequestConfig
281
- extend T::Sig
282
-
283
- sig { returns(T::Hash[Symbol, T::Boolean]) }
249
+ #: Hash[Symbol, bool]
284
250
  attr_accessor :configuration
285
251
 
286
- sig { params(configuration: T::Hash[Symbol, T::Boolean]).void }
252
+ #: (Hash[Symbol, bool] configuration) -> void
287
253
  def initialize(configuration)
288
254
  @configuration = configuration
289
255
  end
290
256
 
291
- sig { params(feature: Symbol).returns(T.nilable(T::Boolean)) }
257
+ #: (Symbol feature) -> bool?
292
258
  def enabled?(feature)
293
259
  @configuration[:enableAll] || @configuration[feature]
294
260
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lsp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.11
4
+ version: 0.23.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-02-14 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: language_server-protocol
@@ -140,6 +140,8 @@ files:
140
140
  - lib/ruby_lsp/listeners/inlay_hints.rb
141
141
  - lib/ruby_lsp/listeners/semantic_highlighting.rb
142
142
  - lib/ruby_lsp/listeners/signature_help.rb
143
+ - lib/ruby_lsp/listeners/spec_style.rb
144
+ - lib/ruby_lsp/listeners/test_discovery.rb
143
145
  - lib/ruby_lsp/listeners/test_style.rb
144
146
  - lib/ruby_lsp/load_sorbet.rb
145
147
  - lib/ruby_lsp/node_context.rb
@@ -157,6 +159,7 @@ files:
157
159
  - lib/ruby_lsp/requests/document_symbol.rb
158
160
  - lib/ruby_lsp/requests/folding_ranges.rb
159
161
  - lib/ruby_lsp/requests/formatting.rb
162
+ - lib/ruby_lsp/requests/go_to_relevant_file.rb
160
163
  - lib/ruby_lsp/requests/hover.rb
161
164
  - lib/ruby_lsp/requests/inlay_hints.rb
162
165
  - lib/ruby_lsp/requests/on_type_formatting.rb
@@ -199,6 +202,9 @@ files:
199
202
  - lib/ruby_lsp/static_docs.rb
200
203
  - lib/ruby_lsp/store.rb
201
204
  - lib/ruby_lsp/test_helper.rb
205
+ - lib/ruby_lsp/test_reporters/lsp_reporter.rb
206
+ - lib/ruby_lsp/test_reporters/minitest_reporter.rb
207
+ - lib/ruby_lsp/test_reporters/test_unit_reporter.rb
202
208
  - lib/ruby_lsp/type_inferrer.rb
203
209
  - lib/ruby_lsp/utils.rb
204
210
  - static_docs/yield.md
@@ -222,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
228
  - !ruby/object:Gem::Version
223
229
  version: '0'
224
230
  requirements: []
225
- rubygems_version: 3.6.3
231
+ rubygems_version: 3.6.8
226
232
  specification_version: 4
227
233
  summary: An opinionated language server for Ruby
228
234
  test_files: []