ruby-lsp 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '08f4db46a392926873115c77175be859ecdfc4c5093e003f913eec7288f05fac'
4
- data.tar.gz: 2f34acc2fc69ab4dd6ad5fc9961a86c020d550284ed18aefd3221b0525af2628
3
+ metadata.gz: edcd6c49e7546a82b2e64a023c04be808dac40695a2e5667f915f17b4f9fc08a
4
+ data.tar.gz: d8751bfd61a98e1a42d596b03d0dca55bd3441d3ec206b7ab36c6bf38f3afdcd
5
5
  SHA512:
6
- metadata.gz: 99a9e243c0dd2f763532a5a1c52241ac86c9a7ba2ccb0814932d8e08b17add78143566ac26ad609b59ff8d96e1d2844b53995b85b473cb736c5f87e2a30c5a26
7
- data.tar.gz: 2a1669be7a054a5d19b0b7eff113347571928cb601e1b432c6f49bc3f349a530b6d0df45c7ea5dfa46add7b69fd347713ec33f95fdca9baa896855f958814209
6
+ metadata.gz: d71efe1d5848a42076452ddc0b714926bd2fed03730ffc5d509df1dbed67524484af607cb473fb03c9bee2867eb64654afa64ca8c349a39cde09e321cb6550b8
7
+ data.tar.gz: a87eedc485b3280982c25d45c455d1a5420582ad30739cdb4268068b766b707104f37d9eba82875494f5e5eb5bb0bb6592ad2e42bfcb65cf20f65a8636d57210
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.1
1
+ 0.9.2
@@ -134,7 +134,7 @@ module RubyIndexer
134
134
 
135
135
  sig { returns(Regexp) }
136
136
  def magic_comment_regex
137
- /^\s*#\s*#{@excluded_magic_comments.join("|")}/
137
+ @magic_comment_regex ||= T.let(/^\s*#\s*#{@excluded_magic_comments.join("|")}/, T.nilable(Regexp))
138
138
  end
139
139
 
140
140
  private
@@ -204,8 +204,6 @@ module RubyLsp
204
204
 
205
205
  sig { void }
206
206
  def perform_initial_indexing
207
- return unless @store.experimental_features
208
-
209
207
  # The begin progress invocation happens during `initialize`, so that the notification is sent before we are
210
208
  # stuck indexing files
211
209
  RubyIndexer.configuration.load_config
@@ -581,7 +579,7 @@ module RubyLsp
581
579
  Interface::DocumentSymbolClientCapabilities.new(
582
580
  hierarchical_document_symbol_support: true,
583
581
  symbol_kind: {
584
- value_set: Requests::DocumentSymbol::SYMBOL_KIND.values,
582
+ value_set: (Constant::SymbolKind::FILE..Constant::SymbolKind::TYPE_PARAMETER).to_a,
585
583
  },
586
584
  )
587
585
  end
@@ -643,37 +641,35 @@ module RubyLsp
643
641
  )
644
642
  end
645
643
 
646
- if @store.experimental_features
647
- # Dynamically registered capabilities
648
- file_watching_caps = options.dig(:capabilities, :workspace, :didChangeWatchedFiles)
649
-
650
- # Not every client supports dynamic registration or file watching
651
- if file_watching_caps&.dig(:dynamicRegistration) && file_watching_caps&.dig(:relativePatternSupport)
652
- @message_queue << Request.new(
653
- message: "client/registerCapability",
654
- params: Interface::RegistrationParams.new(
655
- registrations: [
656
- # Register watching Ruby files
657
- Interface::Registration.new(
658
- id: "workspace/didChangeWatchedFiles",
659
- method: "workspace/didChangeWatchedFiles",
660
- register_options: Interface::DidChangeWatchedFilesRegistrationOptions.new(
661
- watchers: [
662
- Interface::FileSystemWatcher.new(
663
- glob_pattern: "**/*.rb",
664
- kind: Constant::WatchKind::CREATE | Constant::WatchKind::CHANGE | Constant::WatchKind::DELETE,
665
- ),
666
- ],
667
- ),
644
+ # Dynamically registered capabilities
645
+ file_watching_caps = options.dig(:capabilities, :workspace, :didChangeWatchedFiles)
646
+
647
+ # Not every client supports dynamic registration or file watching
648
+ if file_watching_caps&.dig(:dynamicRegistration) && file_watching_caps&.dig(:relativePatternSupport)
649
+ @message_queue << Request.new(
650
+ message: "client/registerCapability",
651
+ params: Interface::RegistrationParams.new(
652
+ registrations: [
653
+ # Register watching Ruby files
654
+ Interface::Registration.new(
655
+ id: "workspace/didChangeWatchedFiles",
656
+ method: "workspace/didChangeWatchedFiles",
657
+ register_options: Interface::DidChangeWatchedFilesRegistrationOptions.new(
658
+ watchers: [
659
+ Interface::FileSystemWatcher.new(
660
+ glob_pattern: "**/*.rb",
661
+ kind: Constant::WatchKind::CREATE | Constant::WatchKind::CHANGE | Constant::WatchKind::DELETE,
662
+ ),
663
+ ],
668
664
  ),
669
- ],
670
- ),
671
- )
672
- end
673
-
674
- begin_progress("indexing-progress", "Ruby LSP: indexing files")
665
+ ),
666
+ ],
667
+ ),
668
+ )
675
669
  end
676
670
 
671
+ begin_progress("indexing-progress", "Ruby LSP: indexing files")
672
+
677
673
  Interface::InitializeResult.new(
678
674
  capabilities: Interface::ServerCapabilities.new(
679
675
  text_document_sync: Interface::TextDocumentSyncOptions.new(
@@ -65,7 +65,7 @@ module RubyLsp
65
65
  class_name = node.constant.constant.value
66
66
  @class_stack.push(class_name)
67
67
 
68
- if class_name.end_with?("Test")
68
+ if @path && class_name.end_with?("Test")
69
69
  add_test_code_lens(
70
70
  node,
71
71
  name: class_name,
@@ -89,7 +89,7 @@ module RubyLsp
89
89
  visibility, _ = @visibility_stack.last
90
90
  if visibility == "public"
91
91
  method_name = node.name.value
92
- if method_name.start_with?("test_")
92
+ if @path && method_name.start_with?("test_")
93
93
  add_test_code_lens(
94
94
  node,
95
95
  name: method_name,
@@ -32,38 +32,6 @@ module RubyLsp
32
32
 
33
33
  ResponseType = type_member { { fixed: T::Array[Interface::DocumentSymbol] } }
34
34
 
35
- SYMBOL_KIND = T.let(
36
- {
37
- file: 1,
38
- module: 2,
39
- namespace: 3,
40
- package: 4,
41
- class: 5,
42
- method: 6,
43
- property: 7,
44
- field: 8,
45
- constructor: 9,
46
- enum: 10,
47
- interface: 11,
48
- function: 12,
49
- variable: 13,
50
- constant: 14,
51
- string: 15,
52
- number: 16,
53
- boolean: 17,
54
- array: 18,
55
- object: 19,
56
- key: 20,
57
- null: 21,
58
- enummember: 22,
59
- struct: 23,
60
- event: 24,
61
- operator: 25,
62
- typeparameter: 26,
63
- }.freeze,
64
- T::Hash[Symbol, Integer],
65
- )
66
-
67
35
  ATTR_ACCESSORS = T.let(["attr_reader", "attr_writer", "attr_accessor"].freeze, T::Array[String])
68
36
 
69
37
  class SymbolHierarchyRoot
@@ -111,7 +79,7 @@ module RubyLsp
111
79
  def on_class(node)
112
80
  @stack << create_document_symbol(
113
81
  name: full_constant_name(node.constant),
114
- kind: :class,
82
+ kind: Constant::SymbolKind::CLASS,
115
83
  range_node: node,
116
84
  selection_range_node: node.constant,
117
85
  )
@@ -131,7 +99,7 @@ module RubyLsp
131
99
 
132
100
  create_document_symbol(
133
101
  name: argument.value.value,
134
- kind: :field,
102
+ kind: Constant::SymbolKind::FIELD,
135
103
  range_node: argument,
136
104
  selection_range_node: argument.value,
137
105
  )
@@ -142,7 +110,7 @@ module RubyLsp
142
110
  def on_const_path_field(node)
143
111
  create_document_symbol(
144
112
  name: node.constant.value,
145
- kind: :constant,
113
+ kind: Constant::SymbolKind::CONSTANT,
146
114
  range_node: node,
147
115
  selection_range_node: node.constant,
148
116
  )
@@ -154,10 +122,10 @@ module RubyLsp
154
122
 
155
123
  if target.is_a?(SyntaxTree::VarRef) && target.value.is_a?(SyntaxTree::Kw) && target.value.value == "self"
156
124
  name = "self.#{node.name.value}"
157
- kind = :method
125
+ kind = Constant::SymbolKind::METHOD
158
126
  else
159
127
  name = node.name.value
160
- kind = name == "initialize" ? :constructor : :method
128
+ kind = name == "initialize" ? Constant::SymbolKind::CONSTRUCTOR : Constant::SymbolKind::METHOD
161
129
  end
162
130
 
163
131
  symbol = create_document_symbol(
@@ -179,7 +147,7 @@ module RubyLsp
179
147
  def on_module(node)
180
148
  @stack << create_document_symbol(
181
149
  name: full_constant_name(node.constant),
182
- kind: :module,
150
+ kind: Constant::SymbolKind::MODULE,
183
151
  range_node: node,
184
152
  selection_range_node: node.constant,
185
153
  )
@@ -194,7 +162,7 @@ module RubyLsp
194
162
  def on_top_const_field(node)
195
163
  create_document_symbol(
196
164
  name: node.constant.value,
197
- kind: :constant,
165
+ kind: Constant::SymbolKind::CONSTANT,
198
166
  range_node: node,
199
167
  selection_range_node: node.constant,
200
168
  )
@@ -205,9 +173,9 @@ module RubyLsp
205
173
  value = node.value
206
174
  kind = case value
207
175
  when SyntaxTree::Const
208
- :constant
176
+ Constant::SymbolKind::CONSTANT
209
177
  when SyntaxTree::CVar, SyntaxTree::IVar
210
- :variable
178
+ Constant::SymbolKind::VARIABLE
211
179
  else
212
180
  return
213
181
  end
@@ -225,7 +193,7 @@ module RubyLsp
225
193
  sig do
226
194
  params(
227
195
  name: String,
228
- kind: Symbol,
196
+ kind: Integer,
229
197
  range_node: SyntaxTree::Node,
230
198
  selection_range_node: SyntaxTree::Node,
231
199
  ).returns(Interface::DocumentSymbol)
@@ -233,7 +201,7 @@ module RubyLsp
233
201
  def create_document_symbol(name:, kind:, range_node:, selection_range_node:)
234
202
  symbol = Interface::DocumentSymbol.new(
235
203
  name: name,
236
- kind: SYMBOL_KIND[kind],
204
+ kind: kind,
237
205
  range: range_from_syntax_tree_node(range_node),
238
206
  selection_range: range_from_syntax_tree_node(selection_range_node),
239
207
  children: [],
@@ -112,11 +112,12 @@ module RubyLsp
112
112
  next_line = @lines[@position[:line] + 1]
113
113
 
114
114
  if current_line.nil? || current_line.strip.empty?
115
- add_edit_with_text(" \n#{indents}end")
115
+ add_edit_with_text("\n")
116
+ add_edit_with_text("#{indents}end")
116
117
  move_cursor_to(@position[:line], @indentation + 2)
117
118
  elsif next_line.nil? || next_line.strip.empty?
118
- add_edit_with_text("#{indents}end", { line: @position[:line] + 1, character: @position[:character] })
119
- move_cursor_to(@position[:line], @indentation + 3)
119
+ add_edit_with_text("#{indents}end\n", { line: @position[:line] + 1, character: @position[:character] })
120
+ move_cursor_to(@position[:line] - 1, @indentation + @previous_line.size + 1)
120
121
  end
121
122
  end
122
123
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lsp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-28 00:00:00.000000000 Z
11
+ date: 2023-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: language_server-protocol