steep 0.51.0 → 0.52.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 502d495f9b623c5d90a041a1e0bb7854be76251a8ac0f3567c1c91911eb641ee
4
- data.tar.gz: 7845d6d26f38ceae87407d507f3f67b8d35bae18ecdd5f4ee9fdb841d434a4ad
3
+ metadata.gz: f6846cc048d7515ef655b81cf7f399e5852a96c390d90c7f859c07cc6a5c0f94
4
+ data.tar.gz: fecb8b0b0be4e338f3ccf0375064f39167693c0b25b68e3b4ea2f103f117260f
5
5
  SHA512:
6
- metadata.gz: e2e61987da5ef5d78381affeb2f4fbb8b84dd2a6fede0baa60c68f54a3464e3cb7eea0e2822f22a66d62f1de3b9f8b223cd6399dceb927397a3dab0bed3fea5d
7
- data.tar.gz: ee91ba6b1a4d8f35ec1fbc157efd2fb54f27b11e398af09a7ef3d4f403ae0ae2fab3258404316c6ded646f688b61ff38b47a514fec83cd9fe1b4fcf136fdc441
6
+ metadata.gz: 9c08fa692eda8915ef4ce4fe725aecb2a9823c2da188900a3811fdf1d02c6b0369dae8755aed83fe9cc80a376c3309df29efcf849681cd2a9a249559ff6c3ae2
7
+ data.tar.gz: 77953f34eb6ab001dfee4f03e0ec1250f1128fedae9e5b427e0037b97b6b809c5bb8ae4c94d9d93f3af3a702de7dd33a182399fe2b7a81ba8ac0d2708c422579
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.52.0 (2022-04-05)
6
+
7
+ * Add `steep binstub` command ([\#527](https://github.com/soutaro/steep/pull/527))
8
+ * Let hover and completion work in heredoc ([\#528](https://github.com/soutaro/steep/pull/528))
9
+ * Better constant typing ([\#529](https://github.com/soutaro/steep/pull/529))
10
+
5
11
  ## 0.51.0 (2022-04-01)
6
12
 
7
13
  * Completion for constant ([\#524](https://github.com/soutaro/steep/pull/524))
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- steep (0.51.0)
4
+ steep (0.52.0)
5
5
  activesupport (>= 5.1)
6
6
  language_server-protocol (>= 3.15, < 4.0)
7
7
  listen (~> 3.0)
@@ -51,7 +51,7 @@ GEM
51
51
  rb-fsevent (0.11.1)
52
52
  rb-inotify (0.10.1)
53
53
  ffi (~> 1.0)
54
- rbs (2.3.0)
54
+ rbs (2.3.1)
55
55
  stackprof (0.2.19)
56
56
  terminal-table (3.0.2)
57
57
  unicode-display_width (>= 1.1.1, < 3)
data/lib/steep/cli.rb CHANGED
@@ -18,7 +18,7 @@ module Steep
18
18
  end
19
19
 
20
20
  def self.available_commands
21
- [:init, :check, :validate, :annotations, :version, :project, :watch, :langserver, :stats]
21
+ [:init, :check, :validate, :annotations, :version, :project, :watch, :langserver, :stats, :binstub]
22
22
  end
23
23
 
24
24
  def process_global_options
@@ -208,6 +208,75 @@ module Steep
208
208
  end.run
209
209
  end
210
210
 
211
+ def process_binstub
212
+ path = Pathname("bin/steep")
213
+ force = false
214
+
215
+ OptionParser.new do |opts|
216
+ opts.banner = <<BANNER
217
+ Usage: steep binstub [options]
218
+
219
+ Generate a binstub to execute Steep with setting up Bundler and rbenv/rvm.
220
+ Use the executable for LSP integration setup.
221
+
222
+ Options:
223
+ BANNER
224
+ handle_logging_options opts
225
+
226
+ opts.on("-o PATH", "--output=PATH", "The path of the executable file (defaults to `bin/steep`)") do |v|
227
+ path = Pathname(v)
228
+ end
229
+
230
+ opts.on("--[no-]force", "Overwrite file (defaults to false)") do
231
+ force = true
232
+ end
233
+ end.parse!(argv)
234
+
235
+ path.parent.mkpath
236
+
237
+ gemfile_path =
238
+ if defined?(Bundler)
239
+ Bundler.default_gemfile.relative_path_from(Pathname.pwd + path.parent)
240
+ else
241
+ Pathname("../Gemfile")
242
+ end
243
+
244
+ if path.file?
245
+ if force
246
+ stdout.puts Rainbow("#{path} already exists. Overwriting...").yellow
247
+ else
248
+ stdout.puts Rainbow(''"⚠️ #{path} already exists. Bye! 👋").red
249
+ return 0
250
+ end
251
+ end
252
+
253
+ template = <<TEMPLATE
254
+ #!/usr/bin/env bash
255
+
256
+ BINSTUB_DIR=$(cd $(dirname $0); pwd)
257
+ GEMFILE=${BINSTUB_DIR}/#{gemfile_path}
258
+
259
+ STEEP="bundle exec --gemfile=${GEMFILE} steep"
260
+
261
+ if type "rbenv" > /dev/null 2>&1; then
262
+ STEEP="rbenv exec ${STEEP}"
263
+ else
264
+ if type "rvm" > /dev/null 2>&1; then
265
+ STEEP="rvm ${REPO_ROOT} do ${STEEP}"
266
+ fi
267
+ fi
268
+
269
+ exec $STEEP $@
270
+ TEMPLATE
271
+
272
+ path.write(template)
273
+ path.chmod(0755)
274
+
275
+ stdout.puts Rainbow("Successfully generated executable #{path} 🎉").blue
276
+
277
+ 0
278
+ end
279
+
211
280
  def process_version
212
281
  stdout.puts Steep::VERSION
213
282
  0
data/lib/steep/source.rb CHANGED
@@ -301,13 +301,42 @@ module Steep
301
301
  end
302
302
  end
303
303
 
304
- def find_nodes(line:, column:, node: self.node, position: nil, parents: [])
305
- return [] unless node
304
+ def each_heredoc_node(node = self.node, parents = [], &block)
305
+ if block
306
+ case node.type
307
+ when :dstr, :str
308
+ if node.location.is_a?(Parser::Source::Map::Heredoc)
309
+ yield [node, *parents]
310
+ end
311
+ end
306
312
 
307
- position ||= (line-1).times.sum do |i|
308
- node.location.expression.source_buffer.source_line(i+1).size + 1
309
- end + column
313
+ parents.unshift(node)
314
+ Source.each_child_node(node) do |child|
315
+ each_heredoc_node(child, parents, &block)
316
+ end
317
+ parents.shift()
318
+ else
319
+ enum_for :each_heredoc_node, node
320
+ end
321
+ end
310
322
 
323
+ def find_heredoc_nodes(line, column, position)
324
+ each_heredoc_node() do |nodes|
325
+ node = nodes[0]
326
+
327
+ range = node.location.heredoc_body&.yield_self do |r|
328
+ r.begin_pos..r.end_pos
329
+ end
330
+
331
+ if range && (range === position)
332
+ return nodes
333
+ end
334
+ end
335
+
336
+ nil
337
+ end
338
+
339
+ def find_nodes_loc(node, position, parents)
311
340
  range = node.location.expression&.yield_self do |r|
312
341
  r.begin_pos..r.end_pos
313
342
  end
@@ -317,7 +346,7 @@ module Steep
317
346
  parents.unshift node
318
347
 
319
348
  Source.each_child_node(node) do |child|
320
- ns = find_nodes(line: line, column: column, node: child, position: position, parents: parents) and return ns
349
+ ns = find_nodes_loc(child, position, parents) and return ns
321
350
  end
322
351
 
323
352
  parents
@@ -325,6 +354,24 @@ module Steep
325
354
  end
326
355
  end
327
356
 
357
+ def find_nodes(line:, column:)
358
+ return [] unless node
359
+
360
+ position = (line-1).times.sum do |i|
361
+ node.location.expression.source_buffer.source_line(i+1).size + 1
362
+ end + column
363
+
364
+ if nodes = find_heredoc_nodes(line, column, position)
365
+ Source.each_child_node(nodes[0]) do |child|
366
+ find_nodes_loc(child, position, nodes) and break
367
+ end
368
+
369
+ nodes
370
+ else
371
+ find_nodes_loc(node, position, [])
372
+ end
373
+ end
374
+
328
375
  def self.delete_defs(node, allow_list)
329
376
  case node.type
330
377
  when :def
@@ -2731,6 +2731,14 @@ module Steep
2731
2731
 
2732
2732
  return [type, constr, name]
2733
2733
  end
2734
+ when AST::Types::Any
2735
+ # Couldn't detect the type of the parent constant
2736
+ # Skip reporting error for this node.
2737
+ if node
2738
+ _, constr = add_typing(node, type: parent_type)
2739
+ end
2740
+
2741
+ return [parent_type, constr, nil]
2734
2742
  end
2735
2743
  end
2736
2744
 
@@ -2744,6 +2752,10 @@ module Steep
2744
2752
  end
2745
2753
  end
2746
2754
 
2755
+ if node
2756
+ _, constr = add_typing(node, type: AST::Builtin.any_type)
2757
+ end
2758
+
2747
2759
  [AST::Builtin.any_type, constr, nil]
2748
2760
  end
2749
2761
  end
data/lib/steep/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Steep
2
- VERSION = "0.51.0"
2
+ VERSION = "0.52.0"
3
3
  end
@@ -557,16 +557,6 @@
557
557
  severity: ERROR
558
558
  message: 'Cannot find the declaration of constant: `FOO`'
559
559
  code: Ruby::UnknownConstant
560
- - range:
561
- start:
562
- line: 4
563
- character: 7
564
- end:
565
- line: 4
566
- character: 10
567
- severity: ERROR
568
- message: 'Cannot find the declaration of constant: `BAR`'
569
- code: Ruby::UnknownConstant
570
560
  - range:
571
561
  start:
572
562
  line: 6
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: steep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.51.0
4
+ version: 0.52.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-01 00:00:00.000000000 Z
11
+ date: 2022-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser