ruby-lsp 0.23.12 → 0.23.13

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 (88) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/rubocop/cop/ruby_lsp/use_language_server_aliases.rb +1 -1
  4. data/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +31 -40
  5. data/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb +56 -22
  6. data/lib/ruby_indexer/lib/ruby_indexer/enhancement.rb +1 -1
  7. data/lib/ruby_indexer/lib/ruby_indexer/entry.rb +15 -18
  8. data/lib/ruby_indexer/lib/ruby_indexer/index.rb +8 -11
  9. data/lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb +2 -2
  10. data/lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb +1 -1
  11. data/lib/ruby_indexer/lib/ruby_indexer/reference_finder.rb +2 -2
  12. data/lib/ruby_indexer/test/configuration_test.rb +10 -1
  13. data/lib/ruby_indexer/test/method_test.rb +26 -0
  14. data/lib/ruby_indexer/test/rbs_indexer_test.rb +1 -1
  15. data/lib/ruby_lsp/addon.rb +12 -4
  16. data/lib/ruby_lsp/base_server.rb +19 -22
  17. data/lib/ruby_lsp/client_capabilities.rb +6 -6
  18. data/lib/ruby_lsp/document.rb +13 -13
  19. data/lib/ruby_lsp/erb_document.rb +7 -9
  20. data/lib/ruby_lsp/global_state.rb +21 -24
  21. data/lib/ruby_lsp/listeners/code_lens.rb +59 -48
  22. data/lib/ruby_lsp/listeners/completion.rb +2 -2
  23. data/lib/ruby_lsp/listeners/definition.rb +2 -2
  24. data/lib/ruby_lsp/listeners/document_highlight.rb +62 -80
  25. data/lib/ruby_lsp/listeners/document_link.rb +34 -43
  26. data/lib/ruby_lsp/listeners/document_symbol.rb +1 -1
  27. data/lib/ruby_lsp/listeners/folding_ranges.rb +1 -1
  28. data/lib/ruby_lsp/listeners/hover.rb +43 -52
  29. data/lib/ruby_lsp/listeners/inlay_hints.rb +1 -1
  30. data/lib/ruby_lsp/listeners/semantic_highlighting.rb +11 -14
  31. data/lib/ruby_lsp/listeners/signature_help.rb +2 -2
  32. data/lib/ruby_lsp/listeners/spec_style.rb +15 -59
  33. data/lib/ruby_lsp/listeners/test_discovery.rb +89 -0
  34. data/lib/ruby_lsp/listeners/test_style.rb +47 -81
  35. data/lib/ruby_lsp/node_context.rb +4 -4
  36. data/lib/ruby_lsp/rbs_document.rb +1 -1
  37. data/lib/ruby_lsp/requests/code_actions.rb +9 -12
  38. data/lib/ruby_lsp/requests/code_lens.rb +2 -4
  39. data/lib/ruby_lsp/requests/completion.rb +3 -5
  40. data/lib/ruby_lsp/requests/completion_resolve.rb +1 -1
  41. data/lib/ruby_lsp/requests/definition.rb +4 -5
  42. data/lib/ruby_lsp/requests/diagnostics.rb +2 -2
  43. data/lib/ruby_lsp/requests/discover_tests.rb +3 -2
  44. data/lib/ruby_lsp/requests/document_highlight.rb +2 -4
  45. data/lib/ruby_lsp/requests/document_link.rb +2 -4
  46. data/lib/ruby_lsp/requests/document_symbol.rb +1 -1
  47. data/lib/ruby_lsp/requests/folding_ranges.rb +3 -8
  48. data/lib/ruby_lsp/requests/formatting.rb +2 -2
  49. data/lib/ruby_lsp/requests/go_to_relevant_file.rb +3 -3
  50. data/lib/ruby_lsp/requests/hover.rb +2 -2
  51. data/lib/ruby_lsp/requests/inlay_hints.rb +2 -4
  52. data/lib/ruby_lsp/requests/on_type_formatting.rb +10 -13
  53. data/lib/ruby_lsp/requests/prepare_rename.rb +1 -1
  54. data/lib/ruby_lsp/requests/range_formatting.rb +2 -2
  55. data/lib/ruby_lsp/requests/references.rb +1 -1
  56. data/lib/ruby_lsp/requests/rename.rb +2 -2
  57. data/lib/ruby_lsp/requests/request.rb +2 -2
  58. data/lib/ruby_lsp/requests/selection_ranges.rb +2 -2
  59. data/lib/ruby_lsp/requests/semantic_highlighting.rb +5 -7
  60. data/lib/ruby_lsp/requests/show_syntax_tree.rb +1 -1
  61. data/lib/ruby_lsp/requests/signature_help.rb +2 -2
  62. data/lib/ruby_lsp/requests/support/common.rb +1 -1
  63. data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +15 -21
  64. data/lib/ruby_lsp/requests/support/rubocop_formatter.rb +2 -2
  65. data/lib/ruby_lsp/requests/support/rubocop_runner.rb +12 -18
  66. data/lib/ruby_lsp/requests/support/sorbet.rb +28 -31
  67. data/lib/ruby_lsp/requests/support/source_uri.rb +11 -14
  68. data/lib/ruby_lsp/requests/support/syntax_tree_formatter.rb +5 -9
  69. data/lib/ruby_lsp/requests/support/test_item.rb +4 -9
  70. data/lib/ruby_lsp/requests/type_hierarchy_supertypes.rb +1 -1
  71. data/lib/ruby_lsp/requests/workspace_symbol.rb +1 -1
  72. data/lib/ruby_lsp/response_builders/collection_response_builder.rb +1 -1
  73. data/lib/ruby_lsp/response_builders/document_symbol.rb +2 -5
  74. data/lib/ruby_lsp/response_builders/hover.rb +5 -8
  75. data/lib/ruby_lsp/response_builders/semantic_highlighting.rb +41 -47
  76. data/lib/ruby_lsp/response_builders/signature_help.rb +1 -1
  77. data/lib/ruby_lsp/response_builders/test_collection.rb +1 -1
  78. data/lib/ruby_lsp/ruby_document.rb +7 -20
  79. data/lib/ruby_lsp/ruby_lsp_reporter_plugin.rb +7 -4
  80. data/lib/ruby_lsp/scope.rb +1 -1
  81. data/lib/ruby_lsp/server.rb +9 -1
  82. data/lib/ruby_lsp/setup_bundler.rb +36 -42
  83. data/lib/ruby_lsp/static_docs.rb +4 -7
  84. data/lib/ruby_lsp/store.rb +9 -12
  85. data/lib/ruby_lsp/test_reporter.rb +140 -4
  86. data/lib/ruby_lsp/test_unit_test_runner.rb +10 -8
  87. data/lib/ruby_lsp/utils.rb +10 -16
  88. metadata +3 -2
@@ -14,17 +14,14 @@ module RubyLsp
14
14
  CREATE_ATTRIBUTE_WRITER = "Create Attribute Writer"
15
15
  CREATE_ATTRIBUTE_ACCESSOR = "Create Attribute Accessor"
16
16
 
17
- INSTANCE_VARIABLE_NODES = T.let(
18
- [
19
- Prism::InstanceVariableAndWriteNode,
20
- Prism::InstanceVariableOperatorWriteNode,
21
- Prism::InstanceVariableOrWriteNode,
22
- Prism::InstanceVariableReadNode,
23
- Prism::InstanceVariableTargetNode,
24
- Prism::InstanceVariableWriteNode,
25
- ],
26
- T::Array[T.class_of(Prism::Node)],
27
- )
17
+ INSTANCE_VARIABLE_NODES = [
18
+ Prism::InstanceVariableAndWriteNode,
19
+ Prism::InstanceVariableOperatorWriteNode,
20
+ Prism::InstanceVariableOrWriteNode,
21
+ Prism::InstanceVariableReadNode,
22
+ Prism::InstanceVariableTargetNode,
23
+ Prism::InstanceVariableWriteNode,
24
+ ] #: Array[singleton(Prism::Node)]
28
25
 
29
26
  class << self
30
27
  #: -> Interface::CodeActionRegistrationOptions
@@ -40,7 +37,7 @@ module RubyLsp
40
37
  def initialize(document, range, context)
41
38
  super()
42
39
  @document = document
43
- @uri = T.let(document.uri, URI::Generic)
40
+ @uri = document.uri #: URI::Generic
44
41
  @range = range
45
42
  @context = context
46
43
  end
@@ -20,10 +20,8 @@ module RubyLsp
20
20
 
21
21
  #: (GlobalState global_state, URI::Generic uri, Prism::Dispatcher dispatcher) -> void
22
22
  def initialize(global_state, uri, dispatcher)
23
- @response_builder = T.let(
24
- ResponseBuilders::CollectionResponseBuilder[Interface::CodeLens].new,
25
- ResponseBuilders::CollectionResponseBuilder[Interface::CodeLens],
26
- )
23
+ @response_builder = ResponseBuilders::CollectionResponseBuilder[Interface::CodeLens]
24
+ .new #: ResponseBuilders::CollectionResponseBuilder[Interface::CodeLens]
27
25
  super()
28
26
  Listeners::CodeLens.new(@response_builder, global_state, uri, dispatcher)
29
27
 
@@ -24,7 +24,7 @@ module RubyLsp
24
24
  #: ((RubyDocument | ERBDocument) document, GlobalState global_state, Hash[Symbol, untyped] params, RubyDocument::SorbetLevel sorbet_level, Prism::Dispatcher dispatcher) -> void
25
25
  def initialize(document, global_state, params, sorbet_level, dispatcher)
26
26
  super()
27
- @target = T.let(nil, T.nilable(Prism::Node))
27
+ @target = nil #: Prism::Node?
28
28
  @dispatcher = dispatcher
29
29
  # Completion always receives the position immediately after the character that was just typed. Here we adjust it
30
30
  # back by 1, so that we find the right node
@@ -60,10 +60,8 @@ module RubyLsp
60
60
  ],
61
61
  code_units_cache: document.code_units_cache,
62
62
  )
63
- @response_builder = T.let(
64
- ResponseBuilders::CollectionResponseBuilder[Interface::CompletionItem].new,
65
- ResponseBuilders::CollectionResponseBuilder[Interface::CompletionItem],
66
- )
63
+ @response_builder = ResponseBuilders::CollectionResponseBuilder[Interface::CompletionItem]
64
+ .new #: ResponseBuilders::CollectionResponseBuilder[Interface::CompletionItem]
67
65
 
68
66
  Listeners::Completion.new(
69
67
  @response_builder,
@@ -23,7 +23,7 @@ module RubyLsp
23
23
  #: (GlobalState global_state, Hash[Symbol, untyped] item) -> void
24
24
  def initialize(global_state, item)
25
25
  super()
26
- @index = T.let(global_state.index, RubyIndexer::Index)
26
+ @index = global_state.index #: RubyIndexer::Index
27
27
  @item = item
28
28
  end
29
29
 
@@ -14,10 +14,9 @@ module RubyLsp
14
14
  #: ((RubyDocument | ERBDocument) document, GlobalState global_state, Hash[Symbol, untyped] position, Prism::Dispatcher dispatcher, RubyDocument::SorbetLevel sorbet_level) -> void
15
15
  def initialize(document, global_state, position, dispatcher, sorbet_level)
16
16
  super()
17
- @response_builder = T.let(
18
- ResponseBuilders::CollectionResponseBuilder[T.any(Interface::Location, Interface::LocationLink)].new,
19
- ResponseBuilders::CollectionResponseBuilder[T.any(Interface::Location, Interface::LocationLink)],
20
- )
17
+ @response_builder = ResponseBuilders::CollectionResponseBuilder[
18
+ T.any(Interface::Location, Interface::LocationLink)
19
+ ].new #: ResponseBuilders::CollectionResponseBuilder[(Interface::Location | Interface::LocationLink)]
21
20
  @dispatcher = dispatcher
22
21
 
23
22
  char_position, _ = document.find_index_by_position(position)
@@ -91,7 +90,7 @@ module RubyLsp
91
90
  end
92
91
  end
93
92
 
94
- @target = T.let(target, T.nilable(Prism::Node))
93
+ @target = target #: Prism::Node?
95
94
  end
96
95
 
97
96
  # @override
@@ -21,9 +21,9 @@ module RubyLsp
21
21
  #: (GlobalState global_state, RubyDocument document) -> void
22
22
  def initialize(global_state, document)
23
23
  super()
24
- @active_linters = T.let(global_state.active_linters, T::Array[Support::Formatter])
24
+ @active_linters = global_state.active_linters #: Array[Support::Formatter]
25
25
  @document = document
26
- @uri = T.let(document.uri, URI::Generic)
26
+ @uri = document.uri #: URI::Generic
27
27
  end
28
28
 
29
29
  # @override
@@ -1,6 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
+ require "ruby_lsp/listeners/test_discovery"
4
5
  require "ruby_lsp/listeners/test_style"
5
6
  require "ruby_lsp/listeners/spec_style"
6
7
 
@@ -17,8 +18,8 @@ module RubyLsp
17
18
  @global_state = global_state
18
19
  @document = document
19
20
  @dispatcher = dispatcher
20
- @response_builder = T.let(ResponseBuilders::TestCollection.new, ResponseBuilders::TestCollection)
21
- @index = T.let(global_state.index, RubyIndexer::Index)
21
+ @response_builder = ResponseBuilders::TestCollection.new #: ResponseBuilders::TestCollection
22
+ @index = global_state.index #: RubyIndexer::Index
22
23
  end
23
24
 
24
25
  # @override
@@ -25,10 +25,8 @@ module RubyLsp
25
25
  code_units_cache: document.code_units_cache,
26
26
  )
27
27
 
28
- @response_builder = T.let(
29
- ResponseBuilders::CollectionResponseBuilder[Interface::DocumentHighlight].new,
30
- ResponseBuilders::CollectionResponseBuilder[Interface::DocumentHighlight],
31
- )
28
+ @response_builder = ResponseBuilders::CollectionResponseBuilder[Interface::DocumentHighlight]
29
+ .new #: ResponseBuilders::CollectionResponseBuilder[Interface::DocumentHighlight]
32
30
  Listeners::DocumentHighlight.new(
33
31
  @response_builder,
34
32
  node_context.node,
@@ -19,10 +19,8 @@ module RubyLsp
19
19
  #: (URI::Generic uri, Array[Prism::Comment] comments, Prism::Dispatcher dispatcher) -> void
20
20
  def initialize(uri, comments, dispatcher)
21
21
  super()
22
- @response_builder = T.let(
23
- ResponseBuilders::CollectionResponseBuilder[Interface::DocumentLink].new,
24
- ResponseBuilders::CollectionResponseBuilder[Interface::DocumentLink],
25
- )
22
+ @response_builder = ResponseBuilders::CollectionResponseBuilder[Interface::DocumentLink]
23
+ .new #: ResponseBuilders::CollectionResponseBuilder[Interface::DocumentLink]
26
24
  Listeners::DocumentLink.new(@response_builder, uri, comments, dispatcher)
27
25
  end
28
26
 
@@ -23,7 +23,7 @@ module RubyLsp
23
23
  #: (URI::Generic uri, Prism::Dispatcher dispatcher) -> void
24
24
  def initialize(uri, dispatcher)
25
25
  super()
26
- @response_builder = T.let(ResponseBuilders::DocumentSymbol.new, ResponseBuilders::DocumentSymbol)
26
+ @response_builder = ResponseBuilders::DocumentSymbol.new #: ResponseBuilders::DocumentSymbol
27
27
  Listeners::DocumentSymbol.new(@response_builder, uri, dispatcher)
28
28
 
29
29
  Addon.addons.each do |addon|
@@ -18,14 +18,9 @@ module RubyLsp
18
18
  #: (Array[Prism::Comment] comments, Prism::Dispatcher dispatcher) -> void
19
19
  def initialize(comments, dispatcher)
20
20
  super()
21
- @response_builder = T.let(
22
- ResponseBuilders::CollectionResponseBuilder[Interface::FoldingRange].new,
23
- ResponseBuilders::CollectionResponseBuilder[Interface::FoldingRange],
24
- )
25
- @listener = T.let(
26
- Listeners::FoldingRanges.new(@response_builder, comments, dispatcher),
27
- Listeners::FoldingRanges,
28
- )
21
+ @response_builder = ResponseBuilders::CollectionResponseBuilder[Interface::FoldingRange]
22
+ .new #: ResponseBuilders::CollectionResponseBuilder[Interface::FoldingRange]
23
+ @listener = Listeners::FoldingRanges.new(@response_builder, comments, dispatcher) #: Listeners::FoldingRanges
29
24
  end
30
25
 
31
26
  # @override
@@ -20,8 +20,8 @@ module RubyLsp
20
20
  def initialize(global_state, document)
21
21
  super()
22
22
  @document = document
23
- @active_formatter = T.let(global_state.active_formatter, T.nilable(Support::Formatter))
24
- @uri = T.let(document.uri, URI::Generic)
23
+ @active_formatter = global_state.active_formatter #: Support::Formatter?
24
+ @uri = document.uri #: URI::Generic
25
25
  end
26
26
 
27
27
  # @override
@@ -16,15 +16,15 @@ module RubyLsp
16
16
  TEST_SUFFIX_PATTERN = /(_#{TEST_KEYWORDS.join("|_")})$/
17
17
  TEST_PATTERN = /#{TEST_PREFIX_PATTERN}|#{TEST_SUFFIX_PATTERN}/
18
18
 
19
- TEST_PREFIX_GLOB = T.let("#{TEST_KEYWORDS.join("_,")}_", String)
20
- TEST_SUFFIX_GLOB = T.let("_#{TEST_KEYWORDS.join(",_")}", String)
19
+ TEST_PREFIX_GLOB = "#{TEST_KEYWORDS.join("_,")}_" #: String
20
+ TEST_SUFFIX_GLOB = "_#{TEST_KEYWORDS.join(",_")}" #: String
21
21
 
22
22
  #: (String path, String workspace_path) -> void
23
23
  def initialize(path, workspace_path)
24
24
  super()
25
25
 
26
26
  @workspace_path = workspace_path
27
- @path = T.let(path.delete_prefix(workspace_path), String)
27
+ @path = path.delete_prefix(workspace_path) #: String
28
28
  end
29
29
 
30
30
  # @override
@@ -48,9 +48,9 @@ module RubyLsp
48
48
  # Don't need to instantiate any listeners if there's no target
49
49
  return unless target
50
50
 
51
- @target = T.let(target, T.nilable(Prism::Node))
51
+ @target = target #: Prism::Node?
52
52
  uri = document.uri
53
- @response_builder = T.let(ResponseBuilders::Hover.new, ResponseBuilders::Hover)
53
+ @response_builder = ResponseBuilders::Hover.new #: ResponseBuilders::Hover
54
54
  Listeners::Hover.new(@response_builder, global_state, uri, node_context, dispatcher, sorbet_level)
55
55
  Addon.addons.each do |addon|
56
56
  addon.create_hover_listener(@response_builder, node_context, dispatcher)
@@ -20,10 +20,8 @@ module RubyLsp
20
20
  def initialize(document, hints_configuration, dispatcher)
21
21
  super()
22
22
 
23
- @response_builder = T.let(
24
- ResponseBuilders::CollectionResponseBuilder[Interface::InlayHint].new,
25
- ResponseBuilders::CollectionResponseBuilder[Interface::InlayHint],
26
- )
23
+ @response_builder = ResponseBuilders::CollectionResponseBuilder[Interface::InlayHint]
24
+ .new #: ResponseBuilders::CollectionResponseBuilder[Interface::InlayHint]
27
25
  Listeners::InlayHints.new(@response_builder, hints_configuration, dispatcher)
28
26
  end
29
27
 
@@ -17,26 +17,23 @@ module RubyLsp
17
17
  end
18
18
  end
19
19
 
20
- END_REGEXES = T.let(
21
- [
22
- /\b(if|unless|for|while|until)\b($|\s|\()/,
23
- /\b(class|module|def|case)\b($|\s)/,
24
- /.*\s\bdo\b($|\s)/,
25
- ],
26
- T::Array[Regexp],
27
- )
20
+ END_REGEXES = [
21
+ /\b(if|unless|for|while|until)\b($|\s|\()/,
22
+ /\b(class|module|def|case)\b($|\s)/,
23
+ /.*\s\bdo\b($|\s)/,
24
+ ] #: Array[Regexp]
28
25
 
29
26
  #: (RubyDocument document, Hash[Symbol, untyped] position, String trigger_character, String client_name) -> void
30
27
  def initialize(document, position, trigger_character, client_name)
31
28
  super()
32
29
  @document = document
33
- @lines = T.let(@document.source.lines, T::Array[String])
30
+ @lines = @document.source.lines #: Array[String]
34
31
  line = @lines[[position[:line] - 1, 0].max]
35
32
 
36
- @indentation = T.let(line ? find_indentation(line) : 0, Integer)
37
- @previous_line = T.let(line ? line.strip.chomp : "", String)
33
+ @indentation = line ? find_indentation(line) : 0 #: Integer
34
+ @previous_line = line ? line.strip.chomp : "" #: String
38
35
  @position = position
39
- @edits = T.let([], T::Array[Interface::TextEdit])
36
+ @edits = [] #: Array[Interface::TextEdit]
40
37
  @trigger_character = trigger_character
41
38
  @client_name = client_name
42
39
  end
@@ -163,7 +160,7 @@ module RubyLsp
163
160
 
164
161
  #: (Integer line, Integer character) -> void
165
162
  def move_cursor_to(line, character)
166
- return unless /Visual Studio Code|Cursor/.match?(@client_name)
163
+ return unless /Visual Studio Code|Cursor|VSCodium/.match?(@client_name)
167
164
 
168
165
  position = Interface::Position.new(
169
166
  line: line,
@@ -13,7 +13,7 @@ module RubyLsp
13
13
  def initialize(document, position)
14
14
  super()
15
15
  @document = document
16
- @position = T.let(position, T::Hash[Symbol, Integer])
16
+ @position = position #: Hash[Symbol, Integer]
17
17
  end
18
18
 
19
19
  # @override
@@ -10,9 +10,9 @@ module RubyLsp
10
10
  def initialize(global_state, document, params)
11
11
  super()
12
12
  @document = document
13
- @uri = T.let(document.uri, URI::Generic)
13
+ @uri = document.uri #: URI::Generic
14
14
  @params = params
15
- @active_formatter = T.let(global_state.active_formatter, T.nilable(Support::Formatter))
15
+ @active_formatter = global_state.active_formatter #: Support::Formatter?
16
16
  end
17
17
 
18
18
  # @override
@@ -16,7 +16,7 @@ module RubyLsp
16
16
  @store = store
17
17
  @document = document
18
18
  @params = params
19
- @locations = T.let([], T::Array[Interface::Location])
19
+ @locations = [] #: Array[Interface::Location]
20
20
  end
21
21
 
22
22
  # @override
@@ -24,8 +24,8 @@ module RubyLsp
24
24
  @global_state = global_state
25
25
  @store = store
26
26
  @document = document
27
- @position = T.let(params[:position], T::Hash[Symbol, Integer])
28
- @new_name = T.let(params[:newName], String)
27
+ @position = params[:position] #: Hash[Symbol, Integer]
28
+ @new_name = params[:newName] #: String
29
29
  end
30
30
 
31
31
  # @override
@@ -59,8 +59,8 @@ module RubyLsp
59
59
  def determine_target(target, parent, position)
60
60
  return target unless parent.is_a?(Prism::ConstantPathNode)
61
61
 
62
- target = T.let(parent, Prism::Node)
63
- parent = T.let(T.cast(target, Prism::ConstantPathNode).parent, T.nilable(Prism::Node))
62
+ target = parent #: Prism::Node
63
+ parent = T.cast(target, Prism::ConstantPathNode).parent #: Prism::Node?
64
64
 
65
65
  while parent && cover?(parent.location, position)
66
66
  target = parent
@@ -17,8 +17,8 @@ module RubyLsp
17
17
  def initialize(document)
18
18
  super()
19
19
  @document = document
20
- @ranges = T.let([], T::Array[Support::SelectionRange])
21
- @stack = T.let([], T::Array[Support::SelectionRange])
20
+ @ranges = [] #: Array[Support::SelectionRange]
21
+ @stack = [] #: Array[Support::SelectionRange]
22
22
  end
23
23
 
24
24
  # @override
@@ -71,8 +71,8 @@ module RubyLsp
71
71
  end
72
72
  end
73
73
 
74
- @result_id = T.let(0, Integer)
75
- @mutex = T.let(Mutex.new, Mutex)
74
+ @result_id = 0 #: Integer
75
+ @mutex = Mutex.new #: Mutex
76
76
 
77
77
  #: (GlobalState global_state, Prism::Dispatcher dispatcher, (RubyDocument | ERBDocument) document, String? previous_result_id, ?range: T::Range[Integer]?) -> void
78
78
  def initialize(global_state, dispatcher, document, previous_result_id, range: nil)
@@ -81,11 +81,9 @@ module RubyLsp
81
81
  @document = document
82
82
  @previous_result_id = previous_result_id
83
83
  @range = range
84
- @result_id = T.let(SemanticHighlighting.next_result_id.to_s, String)
85
- @response_builder = T.let(
86
- ResponseBuilders::SemanticHighlighting.new(document.code_units_cache),
87
- ResponseBuilders::SemanticHighlighting,
88
- )
84
+ @result_id = SemanticHighlighting.next_result_id.to_s #: String
85
+ @response_builder = ResponseBuilders::SemanticHighlighting
86
+ .new(document.code_units_cache) #: ResponseBuilders::SemanticHighlighting
89
87
  Listeners::SemanticHighlighting.new(dispatcher, @response_builder)
90
88
 
91
89
  Addon.addons.each do |addon|
@@ -12,7 +12,7 @@ module RubyLsp
12
12
  super()
13
13
  @document = document
14
14
  @range = range
15
- @tree = T.let(document.parse_result.value, Prism::ProgramNode)
15
+ @tree = document.parse_result.value #: Prism::ProgramNode
16
16
  end
17
17
 
18
18
  # @override
@@ -35,9 +35,9 @@ module RubyLsp
35
35
 
36
36
  target = adjust_for_nested_target(node_context.node, node_context.parent, position)
37
37
 
38
- @target = T.let(target, T.nilable(Prism::Node))
38
+ @target = target #: Prism::Node?
39
39
  @dispatcher = dispatcher
40
- @response_builder = T.let(ResponseBuilders::SignatureHelp.new, ResponseBuilders::SignatureHelp)
40
+ @response_builder = ResponseBuilders::SignatureHelp.new #: ResponseBuilders::SignatureHelp
41
41
  Listeners::SignatureHelp.new(@response_builder, global_state, node_context, dispatcher, sorbet_level)
42
42
  end
43
43
 
@@ -132,7 +132,7 @@ module RubyLsp
132
132
  # `Baz`.
133
133
  #: (Prism::Node node) { (Prism::Node part) -> void } -> void
134
134
  def each_constant_path_part(node, &block)
135
- current = T.let(node, T.nilable(Prism::Node))
135
+ current = node #: Prism::Node?
136
136
 
137
137
  while current.is_a?(Prism::ConstantPathNode)
138
138
  block.call(current)
@@ -5,27 +5,21 @@ module RubyLsp
5
5
  module Requests
6
6
  module Support
7
7
  class RuboCopDiagnostic
8
- RUBOCOP_TO_LSP_SEVERITY = T.let(
9
- {
10
- info: Constant::DiagnosticSeverity::HINT,
11
- refactor: Constant::DiagnosticSeverity::INFORMATION,
12
- convention: Constant::DiagnosticSeverity::INFORMATION,
13
- warning: Constant::DiagnosticSeverity::WARNING,
14
- error: Constant::DiagnosticSeverity::ERROR,
15
- fatal: Constant::DiagnosticSeverity::ERROR,
16
- }.freeze,
17
- T::Hash[Symbol, Integer],
18
- )
19
-
20
- ENHANCED_DOC_URL = T.let(
21
- begin
22
- gem("rubocop", ">= 1.64.0")
23
- true
24
- rescue LoadError
25
- false
26
- end,
27
- T::Boolean,
28
- )
8
+ RUBOCOP_TO_LSP_SEVERITY = {
9
+ info: Constant::DiagnosticSeverity::HINT,
10
+ refactor: Constant::DiagnosticSeverity::INFORMATION,
11
+ convention: Constant::DiagnosticSeverity::INFORMATION,
12
+ warning: Constant::DiagnosticSeverity::WARNING,
13
+ error: Constant::DiagnosticSeverity::ERROR,
14
+ fatal: Constant::DiagnosticSeverity::ERROR,
15
+ }.freeze #: Hash[Symbol, Integer]
16
+
17
+ ENHANCED_DOC_URL = begin
18
+ gem("rubocop", ">= 1.64.0")
19
+ true
20
+ rescue LoadError
21
+ false
22
+ end #: bool
29
23
 
30
24
  # TODO: avoid passing document once we have alternative ways to get at
31
25
  # encoding and file source
@@ -13,9 +13,9 @@ module RubyLsp
13
13
 
14
14
  #: -> void
15
15
  def initialize
16
- @diagnostic_runner = T.let(RuboCopRunner.new, RuboCopRunner)
16
+ @diagnostic_runner = RuboCopRunner.new #: RuboCopRunner
17
17
  # -a is for "--auto-correct" (or "--autocorrect" on newer versions of RuboCop)
18
- @format_runner = T.let(RuboCopRunner.new("-a"), RuboCopRunner)
18
+ @format_runner = RuboCopRunner.new("-a") #: RuboCopRunner
19
19
  end
20
20
 
21
21
  # @override
@@ -54,15 +54,12 @@ module RubyLsp
54
54
  class RuboCopRunner < ::RuboCop::Runner
55
55
  class ConfigurationError < StandardError; end
56
56
 
57
- DEFAULT_ARGS = T.let(
58
- [
59
- "--stderr", # Print any output to stderr so that our stdout does not get polluted
60
- "--force-exclusion",
61
- "--format",
62
- "RuboCop::Formatter::BaseFormatter", # Suppress any output by using the base formatter
63
- ],
64
- T::Array[String],
65
- )
57
+ DEFAULT_ARGS = [
58
+ "--stderr", # Print any output to stderr so that our stdout does not get polluted
59
+ "--force-exclusion",
60
+ "--format",
61
+ "RuboCop::Formatter::BaseFormatter", # Suppress any output by using the base formatter
62
+ ] #: Array[String]
66
63
 
67
64
  #: Array[::RuboCop::Cop::Offense]
68
65
  attr_reader :offenses
@@ -80,17 +77,17 @@ module RubyLsp
80
77
 
81
78
  #: (*String args) -> void
82
79
  def initialize(*args)
83
- @options = T.let({}, T::Hash[Symbol, T.untyped])
84
- @offenses = T.let([], T::Array[::RuboCop::Cop::Offense])
85
- @errors = T.let([], T::Array[String])
86
- @warnings = T.let([], T::Array[String])
80
+ @options = {} #: Hash[Symbol, untyped]
81
+ @offenses = [] #: Array[::RuboCop::Cop::Offense]
82
+ @errors = [] #: Array[String]
83
+ @warnings = [] #: Array[String]
87
84
 
88
85
  args += DEFAULT_ARGS
89
86
  rubocop_options = ::RuboCop::Options.new.parse(args).first
90
87
 
91
88
  config_store = ::RuboCop::ConfigStore.new
92
89
  config_store.options_config = rubocop_options[:config] if rubocop_options[:config]
93
- @config_for_working_directory = T.let(config_store.for_pwd, ::RuboCop::Config)
90
+ @config_for_working_directory = config_store.for_pwd #: ::RuboCop::Config
94
91
 
95
92
  super(rubocop_options, config_store)
96
93
  end
@@ -132,10 +129,7 @@ module RubyLsp
132
129
 
133
130
  #: -> Hash[String, [singleton(::RuboCop::Cop::Base)]]
134
131
  def cop_registry
135
- @cop_registry ||= T.let(
136
- ::RuboCop::Cop::Registry.global.to_h,
137
- T.nilable(T::Hash[String, [T.class_of(::RuboCop::Cop::Base)]]),
138
- )
132
+ @cop_registry ||= ::RuboCop::Cop::Registry.global.to_h #: Hash[String, [singleton(::RuboCop::Cop::Base)]]?
139
133
  end
140
134
  end
141
135
 
@@ -6,37 +6,34 @@ module RubyLsp
6
6
  module Support
7
7
  class Sorbet
8
8
  class << self
9
- ANNOTATIONS = T.let(
10
- {
11
- abstract!: Annotation.new(arity: 0),
12
- absurd: Annotation.new(arity: 1, receiver: true),
13
- all: Annotation.new(arity: (2..), receiver: true),
14
- any: Annotation.new(arity: (2..), receiver: true),
15
- assert_type!: Annotation.new(arity: 2, receiver: true),
16
- attached_class: Annotation.new(arity: 0, receiver: true),
17
- bind: Annotation.new(arity: 2, receiver: true),
18
- cast: Annotation.new(arity: 2, receiver: true),
19
- class_of: Annotation.new(arity: 1, receiver: true),
20
- enums: Annotation.new(arity: 0),
21
- interface!: Annotation.new(arity: 0),
22
- let: Annotation.new(arity: 2, receiver: true),
23
- mixes_in_class_methods: Annotation.new(arity: 1),
24
- must: Annotation.new(arity: 1, receiver: true),
25
- must_because: Annotation.new(arity: 1, receiver: true),
26
- nilable: Annotation.new(arity: 1, receiver: true),
27
- noreturn: Annotation.new(arity: 0, receiver: true),
28
- requires_ancestor: Annotation.new(arity: 0),
29
- reveal_type: Annotation.new(arity: 1, receiver: true),
30
- sealed!: Annotation.new(arity: 0),
31
- self_type: Annotation.new(arity: 0, receiver: true),
32
- sig: Annotation.new(arity: 0),
33
- type_member: Annotation.new(arity: (0..1)),
34
- type_template: Annotation.new(arity: 0),
35
- unsafe: Annotation.new(arity: 1),
36
- untyped: Annotation.new(arity: 0, receiver: true),
37
- },
38
- T::Hash[Symbol, Annotation],
39
- )
9
+ ANNOTATIONS = {
10
+ abstract!: Annotation.new(arity: 0),
11
+ absurd: Annotation.new(arity: 1, receiver: true),
12
+ all: Annotation.new(arity: (2..), receiver: true),
13
+ any: Annotation.new(arity: (2..), receiver: true),
14
+ assert_type!: Annotation.new(arity: 2, receiver: true),
15
+ attached_class: Annotation.new(arity: 0, receiver: true),
16
+ bind: Annotation.new(arity: 2, receiver: true),
17
+ cast: Annotation.new(arity: 2, receiver: true),
18
+ class_of: Annotation.new(arity: 1, receiver: true),
19
+ enums: Annotation.new(arity: 0),
20
+ interface!: Annotation.new(arity: 0),
21
+ let: Annotation.new(arity: 2, receiver: true),
22
+ mixes_in_class_methods: Annotation.new(arity: 1),
23
+ must: Annotation.new(arity: 1, receiver: true),
24
+ must_because: Annotation.new(arity: 1, receiver: true),
25
+ nilable: Annotation.new(arity: 1, receiver: true),
26
+ noreturn: Annotation.new(arity: 0, receiver: true),
27
+ requires_ancestor: Annotation.new(arity: 0),
28
+ reveal_type: Annotation.new(arity: 1, receiver: true),
29
+ sealed!: Annotation.new(arity: 0),
30
+ self_type: Annotation.new(arity: 0, receiver: true),
31
+ sig: Annotation.new(arity: 0),
32
+ type_member: Annotation.new(arity: (0..1)),
33
+ type_template: Annotation.new(arity: 0),
34
+ unsafe: Annotation.new(arity: 1),
35
+ untyped: Annotation.new(arity: 0, receiver: true),
36
+ } #: Hash[Symbol, Annotation]
40
37
 
41
38
  #: (Prism::CallNode node) -> bool
42
39
  def annotation?(node)