solargraph 0.38.6 → 0.39.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/SPONSORS.md +9 -0
  3. data/lib/solargraph.rb +1 -0
  4. data/lib/solargraph/api_map.rb +24 -13
  5. data/lib/solargraph/api_map/bundler_methods.rb +3 -0
  6. data/lib/solargraph/api_map/source_to_yard.rb +1 -6
  7. data/lib/solargraph/api_map/store.rb +19 -3
  8. data/lib/solargraph/complex_type/type_methods.rb +4 -4
  9. data/lib/solargraph/convention/base.rb +0 -5
  10. data/lib/solargraph/core_fills.rb +28 -2
  11. data/lib/solargraph/diagnostics/base.rb +1 -0
  12. data/lib/solargraph/diagnostics/type_check.rb +13 -13
  13. data/lib/solargraph/language_server/host.rb +11 -2
  14. data/lib/solargraph/language_server/host/sources.rb +20 -11
  15. data/lib/solargraph/language_server/message/text_document/formatting.rb +16 -11
  16. data/lib/solargraph/language_server/transport/data_reader.rb +2 -0
  17. data/lib/solargraph/library.rb +3 -3
  18. data/lib/solargraph/parser.rb +26 -0
  19. data/lib/solargraph/parser/comment_ripper.rb +52 -0
  20. data/lib/solargraph/parser/legacy.rb +12 -0
  21. data/lib/solargraph/parser/legacy/class_methods.rb +105 -0
  22. data/lib/solargraph/parser/legacy/flawed_builder.rb +16 -0
  23. data/lib/solargraph/parser/legacy/node_chainer.rb +115 -0
  24. data/lib/solargraph/parser/legacy/node_methods.rb +289 -0
  25. data/lib/solargraph/parser/legacy/node_processors.rb +54 -0
  26. data/lib/solargraph/parser/legacy/node_processors/alias_node.rb +23 -0
  27. data/lib/solargraph/parser/legacy/node_processors/args_node.rb +35 -0
  28. data/lib/solargraph/parser/legacy/node_processors/begin_node.rb +15 -0
  29. data/lib/solargraph/parser/legacy/node_processors/block_node.rb +22 -0
  30. data/lib/solargraph/parser/legacy/node_processors/casgn_node.rb +25 -0
  31. data/lib/solargraph/parser/legacy/node_processors/cvasgn_node.rb +23 -0
  32. data/lib/solargraph/parser/legacy/node_processors/def_node.rb +63 -0
  33. data/lib/solargraph/parser/legacy/node_processors/defs_node.rb +36 -0
  34. data/lib/solargraph/parser/legacy/node_processors/gvasgn_node.rb +23 -0
  35. data/lib/solargraph/parser/legacy/node_processors/ivasgn_node.rb +38 -0
  36. data/lib/solargraph/parser/legacy/node_processors/lvasgn_node.rb +28 -0
  37. data/lib/solargraph/parser/legacy/node_processors/namespace_node.rb +39 -0
  38. data/lib/solargraph/parser/legacy/node_processors/orasgn_node.rb +16 -0
  39. data/lib/solargraph/parser/legacy/node_processors/resbody_node.rb +36 -0
  40. data/lib/solargraph/parser/legacy/node_processors/sclass_node.rb +21 -0
  41. data/lib/solargraph/parser/legacy/node_processors/send_node.rb +232 -0
  42. data/lib/solargraph/parser/legacy/node_processors/sym_node.rb +18 -0
  43. data/lib/solargraph/parser/node_methods.rb +43 -0
  44. data/lib/solargraph/parser/node_processor.rb +43 -0
  45. data/lib/solargraph/parser/node_processor/base.rb +77 -0
  46. data/lib/solargraph/{source_map → parser}/region.rb +11 -6
  47. data/lib/solargraph/parser/rubyvm.rb +40 -0
  48. data/lib/solargraph/parser/rubyvm/class_methods.rb +146 -0
  49. data/lib/solargraph/parser/rubyvm/node_chainer.rb +133 -0
  50. data/lib/solargraph/parser/rubyvm/node_methods.rb +279 -0
  51. data/lib/solargraph/parser/rubyvm/node_processors.rb +60 -0
  52. data/lib/solargraph/parser/rubyvm/node_processors/alias_node.rb +23 -0
  53. data/lib/solargraph/parser/rubyvm/node_processors/args_node.rb +62 -0
  54. data/lib/solargraph/parser/rubyvm/node_processors/begin_node.rb +15 -0
  55. data/lib/solargraph/parser/rubyvm/node_processors/block_node.rb +22 -0
  56. data/lib/solargraph/parser/rubyvm/node_processors/casgn_node.rb +22 -0
  57. data/lib/solargraph/parser/rubyvm/node_processors/cvasgn_node.rb +23 -0
  58. data/lib/solargraph/parser/rubyvm/node_processors/def_node.rb +64 -0
  59. data/lib/solargraph/parser/rubyvm/node_processors/defs_node.rb +57 -0
  60. data/lib/solargraph/parser/rubyvm/node_processors/gvasgn_node.rb +23 -0
  61. data/lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb +38 -0
  62. data/lib/solargraph/parser/rubyvm/node_processors/kw_arg_node.rb +34 -0
  63. data/lib/solargraph/parser/rubyvm/node_processors/lit_node.rb +20 -0
  64. data/lib/solargraph/parser/rubyvm/node_processors/lvasgn_node.rb +27 -0
  65. data/lib/solargraph/parser/rubyvm/node_processors/namespace_node.rb +39 -0
  66. data/lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb +26 -0
  67. data/lib/solargraph/parser/rubyvm/node_processors/orasgn_node.rb +15 -0
  68. data/lib/solargraph/parser/rubyvm/node_processors/resbody_node.rb +45 -0
  69. data/lib/solargraph/parser/rubyvm/node_processors/sclass_node.rb +21 -0
  70. data/lib/solargraph/parser/rubyvm/node_processors/scope_node.rb +15 -0
  71. data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +292 -0
  72. data/lib/solargraph/parser/rubyvm/node_processors/sym_node.rb +18 -0
  73. data/lib/solargraph/parser/snippet.rb +13 -0
  74. data/lib/solargraph/pin/attribute.rb +8 -0
  75. data/lib/solargraph/pin/base.rb +1 -1
  76. data/lib/solargraph/pin/base_method.rb +26 -4
  77. data/lib/solargraph/pin/base_variable.rb +7 -8
  78. data/lib/solargraph/pin/block.rb +1 -1
  79. data/lib/solargraph/pin/constant.rb +16 -0
  80. data/lib/solargraph/pin/conversions.rb +2 -2
  81. data/lib/solargraph/pin/method.rb +26 -14
  82. data/lib/solargraph/pin/parameter.rb +56 -2
  83. data/lib/solargraph/pin/reference.rb +1 -0
  84. data/lib/solargraph/pin/reference/override.rb +2 -0
  85. data/lib/solargraph/pin/reference/prepend.rb +10 -0
  86. data/lib/solargraph/pin/yard_pin/constant.rb +2 -4
  87. data/lib/solargraph/pin/yard_pin/method.rb +34 -18
  88. data/lib/solargraph/pin/yard_pin/namespace.rb +3 -11
  89. data/lib/solargraph/pin/yard_pin/yard_mixin.rb +3 -12
  90. data/lib/solargraph/range.rb +8 -2
  91. data/lib/solargraph/shell.rb +17 -11
  92. data/lib/solargraph/source.rb +114 -135
  93. data/lib/solargraph/source/chain.rb +11 -3
  94. data/lib/solargraph/source/chain/call.rb +1 -2
  95. data/lib/solargraph/source/chain/constant.rb +44 -8
  96. data/lib/solargraph/source/chain/link.rb +1 -0
  97. data/lib/solargraph/source/cursor.rb +2 -28
  98. data/lib/solargraph/source/source_chainer.rb +12 -6
  99. data/lib/solargraph/source/updater.rb +2 -0
  100. data/lib/solargraph/source_map.rb +0 -2
  101. data/lib/solargraph/source_map/clip.rb +24 -17
  102. data/lib/solargraph/source_map/mapper.rb +34 -29
  103. data/lib/solargraph/type_checker.rb +367 -275
  104. data/lib/solargraph/type_checker/checks.rb +95 -0
  105. data/lib/solargraph/type_checker/param_def.rb +2 -17
  106. data/lib/solargraph/type_checker/rules.rb +53 -0
  107. data/lib/solargraph/version.rb +1 -1
  108. data/lib/solargraph/views/environment.erb +5 -3
  109. data/lib/solargraph/workspace.rb +17 -2
  110. data/lib/solargraph/workspace/config.rb +15 -7
  111. data/lib/solargraph/yard_map.rb +89 -49
  112. data/lib/solargraph/yard_map/core_docs.rb +1 -1
  113. data/solargraph.gemspec +2 -1
  114. metadata +88 -32
  115. data/OVERVIEW.md +0 -37
  116. data/lib/solargraph/source/flawed_builder.rb +0 -15
  117. data/lib/solargraph/source/node_chainer.rb +0 -111
  118. data/lib/solargraph/source/node_methods.rb +0 -240
  119. data/lib/solargraph/source_map/node_processor.rb +0 -85
  120. data/lib/solargraph/source_map/node_processor/alias_node.rb +0 -21
  121. data/lib/solargraph/source_map/node_processor/args_node.rb +0 -24
  122. data/lib/solargraph/source_map/node_processor/base.rb +0 -103
  123. data/lib/solargraph/source_map/node_processor/begin_node.rb +0 -13
  124. data/lib/solargraph/source_map/node_processor/block_node.rb +0 -21
  125. data/lib/solargraph/source_map/node_processor/casgn_node.rb +0 -21
  126. data/lib/solargraph/source_map/node_processor/cvasgn_node.rb +0 -21
  127. data/lib/solargraph/source_map/node_processor/def_node.rb +0 -62
  128. data/lib/solargraph/source_map/node_processor/defs_node.rb +0 -33
  129. data/lib/solargraph/source_map/node_processor/gvasgn_node.rb +0 -21
  130. data/lib/solargraph/source_map/node_processor/ivasgn_node.rb +0 -34
  131. data/lib/solargraph/source_map/node_processor/lvasgn_node.rb +0 -24
  132. data/lib/solargraph/source_map/node_processor/namespace_node.rb +0 -35
  133. data/lib/solargraph/source_map/node_processor/orasgn_node.rb +0 -14
  134. data/lib/solargraph/source_map/node_processor/resbody_node.rb +0 -32
  135. data/lib/solargraph/source_map/node_processor/sclass_node.rb +0 -19
  136. data/lib/solargraph/source_map/node_processor/send_node.rb +0 -217
  137. data/lib/solargraph/source_map/node_processor/sym_node.rb +0 -16
@@ -30,8 +30,8 @@ module Solargraph
30
30
  #
31
31
  # @return [void]
32
32
  def require_minimum
33
+ FileUtils.mkdir_p File.join(cache_dir, 'gems')
33
34
  return unless best_match.nil?
34
- FileUtils.mkdir_p cache_dir
35
35
  FileUtils.cp File.join(Solargraph::YARDOC_PATH, "#{DEFAULT}.tar.gz"), cache_dir
36
36
  install_archive File.join(cache_dir, "#{DEFAULT}.tar.gz")
37
37
  end
@@ -31,9 +31,10 @@ Gem::Specification.new do |s|
31
31
  s.add_runtime_dependency 'rubocop', '~> 0.52'
32
32
  s.add_runtime_dependency 'thor', '~> 1.0'
33
33
  s.add_runtime_dependency 'tilt', '~> 2.0'
34
- s.add_runtime_dependency 'yard', '~> 0.9'
34
+ s.add_runtime_dependency 'yard', '~> 0.9', '>= 0.9.24'
35
35
 
36
36
  s.add_development_dependency 'pry', '~> 0.11.3'
37
+ s.add_development_dependency 'public_suffix', '~> 3.1'
37
38
  s.add_development_dependency 'rspec', '~> 3.5', '>= 3.5.0'
38
39
  s.add_development_dependency 'simplecov', '~> 0.14'
39
40
  s.add_development_dependency 'webmock', '~> 3.6'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solargraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.38.6
4
+ version: 0.39.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-22 00:00:00.000000000 Z
11
+ date: 2020-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backport
@@ -203,6 +203,9 @@ dependencies:
203
203
  - - "~>"
204
204
  - !ruby/object:Gem::Version
205
205
  version: '0.9'
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: 0.9.24
206
209
  type: :runtime
207
210
  prerelease: false
208
211
  version_requirements: !ruby/object:Gem::Requirement
@@ -210,6 +213,9 @@ dependencies:
210
213
  - - "~>"
211
214
  - !ruby/object:Gem::Version
212
215
  version: '0.9'
216
+ - - ">="
217
+ - !ruby/object:Gem::Version
218
+ version: 0.9.24
213
219
  - !ruby/object:Gem::Dependency
214
220
  name: pry
215
221
  requirement: !ruby/object:Gem::Requirement
@@ -225,25 +231,39 @@ dependencies:
225
231
  - !ruby/object:Gem::Version
226
232
  version: 0.11.3
227
233
  - !ruby/object:Gem::Dependency
228
- name: rspec
234
+ name: public_suffix
229
235
  requirement: !ruby/object:Gem::Requirement
230
236
  requirements:
231
- - - ">="
232
- - !ruby/object:Gem::Version
233
- version: 3.5.0
234
237
  - - "~>"
235
238
  - !ruby/object:Gem::Version
236
- version: '3.5'
239
+ version: '3.1'
237
240
  type: :development
238
241
  prerelease: false
239
242
  version_requirements: !ruby/object:Gem::Requirement
240
243
  requirements:
244
+ - - "~>"
245
+ - !ruby/object:Gem::Version
246
+ version: '3.1'
247
+ - !ruby/object:Gem::Dependency
248
+ name: rspec
249
+ requirement: !ruby/object:Gem::Requirement
250
+ requirements:
251
+ - - "~>"
252
+ - !ruby/object:Gem::Version
253
+ version: '3.5'
241
254
  - - ">="
242
255
  - !ruby/object:Gem::Version
243
256
  version: 3.5.0
257
+ type: :development
258
+ prerelease: false
259
+ version_requirements: !ruby/object:Gem::Requirement
260
+ requirements:
244
261
  - - "~>"
245
262
  - !ruby/object:Gem::Version
246
263
  version: '3.5'
264
+ - - ">="
265
+ - !ruby/object:Gem::Version
266
+ version: 3.5.0
247
267
  - !ruby/object:Gem::Dependency
248
268
  name: simplecov
249
269
  requirement: !ruby/object:Gem::Requirement
@@ -286,9 +306,9 @@ files:
286
306
  - ".yardopts"
287
307
  - Gemfile
288
308
  - LICENSE
289
- - OVERVIEW.md
290
309
  - README.md
291
310
  - Rakefile
311
+ - SPONSORS.md
292
312
  - bin/solargraph
293
313
  - lib/solargraph.rb
294
314
  - lib/solargraph/api_map.rb
@@ -382,6 +402,62 @@ files:
382
402
  - lib/solargraph/location.rb
383
403
  - lib/solargraph/logging.rb
384
404
  - lib/solargraph/page.rb
405
+ - lib/solargraph/parser.rb
406
+ - lib/solargraph/parser/comment_ripper.rb
407
+ - lib/solargraph/parser/legacy.rb
408
+ - lib/solargraph/parser/legacy/class_methods.rb
409
+ - lib/solargraph/parser/legacy/flawed_builder.rb
410
+ - lib/solargraph/parser/legacy/node_chainer.rb
411
+ - lib/solargraph/parser/legacy/node_methods.rb
412
+ - lib/solargraph/parser/legacy/node_processors.rb
413
+ - lib/solargraph/parser/legacy/node_processors/alias_node.rb
414
+ - lib/solargraph/parser/legacy/node_processors/args_node.rb
415
+ - lib/solargraph/parser/legacy/node_processors/begin_node.rb
416
+ - lib/solargraph/parser/legacy/node_processors/block_node.rb
417
+ - lib/solargraph/parser/legacy/node_processors/casgn_node.rb
418
+ - lib/solargraph/parser/legacy/node_processors/cvasgn_node.rb
419
+ - lib/solargraph/parser/legacy/node_processors/def_node.rb
420
+ - lib/solargraph/parser/legacy/node_processors/defs_node.rb
421
+ - lib/solargraph/parser/legacy/node_processors/gvasgn_node.rb
422
+ - lib/solargraph/parser/legacy/node_processors/ivasgn_node.rb
423
+ - lib/solargraph/parser/legacy/node_processors/lvasgn_node.rb
424
+ - lib/solargraph/parser/legacy/node_processors/namespace_node.rb
425
+ - lib/solargraph/parser/legacy/node_processors/orasgn_node.rb
426
+ - lib/solargraph/parser/legacy/node_processors/resbody_node.rb
427
+ - lib/solargraph/parser/legacy/node_processors/sclass_node.rb
428
+ - lib/solargraph/parser/legacy/node_processors/send_node.rb
429
+ - lib/solargraph/parser/legacy/node_processors/sym_node.rb
430
+ - lib/solargraph/parser/node_methods.rb
431
+ - lib/solargraph/parser/node_processor.rb
432
+ - lib/solargraph/parser/node_processor/base.rb
433
+ - lib/solargraph/parser/region.rb
434
+ - lib/solargraph/parser/rubyvm.rb
435
+ - lib/solargraph/parser/rubyvm/class_methods.rb
436
+ - lib/solargraph/parser/rubyvm/node_chainer.rb
437
+ - lib/solargraph/parser/rubyvm/node_methods.rb
438
+ - lib/solargraph/parser/rubyvm/node_processors.rb
439
+ - lib/solargraph/parser/rubyvm/node_processors/alias_node.rb
440
+ - lib/solargraph/parser/rubyvm/node_processors/args_node.rb
441
+ - lib/solargraph/parser/rubyvm/node_processors/begin_node.rb
442
+ - lib/solargraph/parser/rubyvm/node_processors/block_node.rb
443
+ - lib/solargraph/parser/rubyvm/node_processors/casgn_node.rb
444
+ - lib/solargraph/parser/rubyvm/node_processors/cvasgn_node.rb
445
+ - lib/solargraph/parser/rubyvm/node_processors/def_node.rb
446
+ - lib/solargraph/parser/rubyvm/node_processors/defs_node.rb
447
+ - lib/solargraph/parser/rubyvm/node_processors/gvasgn_node.rb
448
+ - lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb
449
+ - lib/solargraph/parser/rubyvm/node_processors/kw_arg_node.rb
450
+ - lib/solargraph/parser/rubyvm/node_processors/lit_node.rb
451
+ - lib/solargraph/parser/rubyvm/node_processors/lvasgn_node.rb
452
+ - lib/solargraph/parser/rubyvm/node_processors/namespace_node.rb
453
+ - lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb
454
+ - lib/solargraph/parser/rubyvm/node_processors/orasgn_node.rb
455
+ - lib/solargraph/parser/rubyvm/node_processors/resbody_node.rb
456
+ - lib/solargraph/parser/rubyvm/node_processors/sclass_node.rb
457
+ - lib/solargraph/parser/rubyvm/node_processors/scope_node.rb
458
+ - lib/solargraph/parser/rubyvm/node_processors/send_node.rb
459
+ - lib/solargraph/parser/rubyvm/node_processors/sym_node.rb
460
+ - lib/solargraph/parser/snippet.rb
385
461
  - lib/solargraph/pin.rb
386
462
  - lib/solargraph/pin/attribute.rb
387
463
  - lib/solargraph/pin/base.rb
@@ -410,6 +486,7 @@ files:
410
486
  - lib/solargraph/pin/reference/extend.rb
411
487
  - lib/solargraph/pin/reference/include.rb
412
488
  - lib/solargraph/pin/reference/override.rb
489
+ - lib/solargraph/pin/reference/prepend.rb
413
490
  - lib/solargraph/pin/reference/require.rb
414
491
  - lib/solargraph/pin/reference/superclass.rb
415
492
  - lib/solargraph/pin/singleton.rb
@@ -439,39 +516,18 @@ files:
439
516
  - lib/solargraph/source/change.rb
440
517
  - lib/solargraph/source/cursor.rb
441
518
  - lib/solargraph/source/encoding_fixes.rb
442
- - lib/solargraph/source/flawed_builder.rb
443
- - lib/solargraph/source/node_chainer.rb
444
- - lib/solargraph/source/node_methods.rb
445
519
  - lib/solargraph/source/source_chainer.rb
446
520
  - lib/solargraph/source/updater.rb
447
521
  - lib/solargraph/source_map.rb
448
522
  - lib/solargraph/source_map/clip.rb
449
523
  - lib/solargraph/source_map/completion.rb
450
524
  - lib/solargraph/source_map/mapper.rb
451
- - lib/solargraph/source_map/node_processor.rb
452
- - lib/solargraph/source_map/node_processor/alias_node.rb
453
- - lib/solargraph/source_map/node_processor/args_node.rb
454
- - lib/solargraph/source_map/node_processor/base.rb
455
- - lib/solargraph/source_map/node_processor/begin_node.rb
456
- - lib/solargraph/source_map/node_processor/block_node.rb
457
- - lib/solargraph/source_map/node_processor/casgn_node.rb
458
- - lib/solargraph/source_map/node_processor/cvasgn_node.rb
459
- - lib/solargraph/source_map/node_processor/def_node.rb
460
- - lib/solargraph/source_map/node_processor/defs_node.rb
461
- - lib/solargraph/source_map/node_processor/gvasgn_node.rb
462
- - lib/solargraph/source_map/node_processor/ivasgn_node.rb
463
- - lib/solargraph/source_map/node_processor/lvasgn_node.rb
464
- - lib/solargraph/source_map/node_processor/namespace_node.rb
465
- - lib/solargraph/source_map/node_processor/orasgn_node.rb
466
- - lib/solargraph/source_map/node_processor/resbody_node.rb
467
- - lib/solargraph/source_map/node_processor/sclass_node.rb
468
- - lib/solargraph/source_map/node_processor/send_node.rb
469
- - lib/solargraph/source_map/node_processor/sym_node.rb
470
- - lib/solargraph/source_map/region.rb
471
525
  - lib/solargraph/stdlib_fills.rb
472
526
  - lib/solargraph/type_checker.rb
527
+ - lib/solargraph/type_checker/checks.rb
473
528
  - lib/solargraph/type_checker/param_def.rb
474
529
  - lib/solargraph/type_checker/problem.rb
530
+ - lib/solargraph/type_checker/rules.rb
475
531
  - lib/solargraph/version.rb
476
532
  - lib/solargraph/views/_method.erb
477
533
  - lib/solargraph/views/_name_type_tag.erb
@@ -511,7 +567,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
511
567
  - !ruby/object:Gem::Version
512
568
  version: '0'
513
569
  requirements: []
514
- rubygems_version: 3.0.3
570
+ rubygems_version: 3.1.2
515
571
  signing_key:
516
572
  specification_version: 4
517
573
  summary: A Ruby language server
@@ -1,37 +0,0 @@
1
- # An Overview of Solargraph
2
-
3
- The Solargraph library consists of two major groups of components: the data providers and the language servers. The data providers manage the maps of information about a program. The language servers are the concrete implementations of transports and messages that enable the language server protocol.
4
-
5
- ## Data Providers
6
-
7
- **ApiMap** (`Solargraph::ApiMap`): The component that provides information about a program based on its Workspace, external gems, and the Ruby core.
8
-
9
- **Workspace** (`Solargraph::Workspace`): A collection of Sources that comprise a project. Workspaces have configurations that define which files to include in maps and other project-related options. Users can configure the Workspace through a .solargraph.yml file in a project's root directory.
10
-
11
- **Source** (`Solargraph::Source`): Data about a single Ruby file. Sources parse Ruby code into an AST and handle incremental updates.
12
-
13
- **SourceMap** (`Solargraph::SourceMap`): A Source with generated pins for use in ApiMaps.
14
-
15
- **Pins** (`Solargraph::Pin`): Information about classes, modules, methods, variables, etc. Pins for different types of components extend `Pin::Base`. Most ApiMap queries return results as an array of Pins.
16
-
17
- **Cursor** (`Solargraph::Source::Cursor`): Information about a specific location in a Source.
18
-
19
- **Clip** (`Solargraph::SourceMap::Clip`): A Cursor bundled with an ApiMap to provide definitions, completions, and other information.
20
-
21
- **YardMap** (`Solargraph::YardMap`): A collection of YARD documents. ApiMaps use YardMaps to gather data from external gems and the Ruby core.
22
-
23
- **Library** (`Solargraph::Library`): The component that synchronizes a Workspace with an ApiMap. Libraries help ensure that the ApiMap gets updated when a file in the Workspace changes.
24
-
25
- ## Language Servers
26
-
27
- **Host** (`Solargraph::LanguageServer::Host`): The component responsible for processing messages between the server and the client. Hosts maintain a project's Library and provide thread-safe methods for asynchronous operations.
28
-
29
- **Messages** (`Solargraph::LanguageServer::Message`): Implementations of LSP methods and notifications. Each message implementation extends `Message::Base`.
30
-
31
- **Transports** (`Solargraph::LanguageServer::Transport`): Server implementations for various protocols. The two transports that are currently supported are socket and stdio. The `Transport::DataReader` class provides a common interface for processing incoming JSON-RPC messages.
32
-
33
- ## More Information
34
-
35
- The [EXAMPLES.md](EXAMPLES.md) document provides simple examples of how to use, extend, and modify the Solargraph library.
36
-
37
- Refer to [LANGUAGE_SERVER.md](LANGUAGE_SERVER.md) for information about connecting language clients to Solargraph language servers.
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- class Source
5
- # A custom builder for source parsers that ignores character encoding
6
- # issues in literal strings.
7
- #
8
- class FlawedBuilder < Parser::Builders::Default
9
- def string_value(token)
10
- value(token)
11
- end
12
- end
13
- private_constant :FlawedBuilder
14
- end
15
- end
@@ -1,111 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- class Source
5
- # A factory for generating chains from nodes.
6
- #
7
- class NodeChainer
8
- include Source::NodeMethods
9
-
10
- # @param node [Parser::AST::Node]
11
- # @param filename [String]
12
- def initialize node, filename = nil, in_block = false
13
- @node = node
14
- @filename = filename
15
- @in_block = in_block
16
- end
17
-
18
- # @return [Source::Chain]
19
- def chain
20
- links = generate_links(@node)
21
- Chain.new(links)
22
- end
23
-
24
- class << self
25
- # @param node [Parser::AST::Node]
26
- # @param filename [String]
27
- # @return [Chain]
28
- def chain node, filename = nil, in_block = false
29
- NodeChainer.new(node, filename, in_block).chain
30
- end
31
-
32
- # @param code [String]
33
- # @return [Chain]
34
- def load_string(code)
35
- node = Source.parse(code.sub(/\.$/, ''))
36
- chain = NodeChainer.new(node).chain
37
- chain.links.push(Chain::Link.new) if code.end_with?('.')
38
- chain
39
- end
40
- end
41
-
42
- private
43
-
44
- # @param n [Parser::AST::Node]
45
- # @return [Array<Chain::Link>]
46
- def generate_links n
47
- return [] unless n.is_a?(Parser::AST::Node)
48
- return generate_links(n.children[0]) if n.type == :begin
49
- result = []
50
- if n.type == :block
51
- @in_block = true
52
- result.concat generate_links(n.children[0])
53
- @in_block = false
54
- elsif n.type == :send
55
- if n.children[0].is_a?(Parser::AST::Node)
56
- result.concat generate_links(n.children[0])
57
- args = []
58
- n.children[2..-1].each do |c|
59
- args.push NodeChainer.chain(c)
60
- end
61
- result.push Chain::Call.new(n.children[1].to_s, args, @in_block || block_passed?(n))
62
- elsif n.children[0].nil?
63
- args = []
64
- n.children[2..-1].each do |c|
65
- args.push NodeChainer.chain(c)
66
- end
67
- result.push Chain::Call.new(n.children[1].to_s, args, @in_block || block_passed?(n))
68
- else
69
- raise "No idea what to do with #{n}"
70
- end
71
- elsif n.type == :self
72
- result.push Chain::Head.new('self')
73
- elsif n.type == :zsuper
74
- result.push Chain::Head.new('super')
75
- elsif n.type == :const
76
- const = unpack_name(n)
77
- result.push Chain::Constant.new(const)
78
- elsif [:lvar, :lvasgn].include?(n.type)
79
- result.push Chain::Call.new(n.children[0].to_s)
80
- elsif [:ivar, :ivasgn].include?(n.type)
81
- result.push Chain::InstanceVariable.new(n.children[0].to_s)
82
- elsif [:cvar, :cvasgn].include?(n.type)
83
- result.push Chain::ClassVariable.new(n.children[0].to_s)
84
- elsif [:gvar, :gvasgn].include?(n.type)
85
- result.push Chain::GlobalVariable.new(n.children[0].to_s)
86
- elsif n.type == :or_asgn
87
- result.concat generate_links n.children[1]
88
- elsif [:class, :module, :def, :defs].include?(n.type)
89
- # @todo Undefined or what?
90
- result.push Chain::UNDEFINED_CALL
91
- elsif n.type == :and
92
- result.concat generate_links(n.children.last)
93
- elsif n.type == :or
94
- result.push Chain::Or.new([NodeChainer.chain(n.children[0], @filename), NodeChainer.chain(n.children[1], @filename)])
95
- elsif [:begin, :kwbegin].include?(n.type)
96
- result.concat generate_links(n.children[0])
97
- elsif n.type == :block_pass
98
- result.push Chain::BlockVariable.new("&#{n.children[0].children[0].to_s}")
99
- else
100
- lit = infer_literal_node_type(n)
101
- result.push (lit ? Chain::Literal.new(lit) : Chain::Link.new)
102
- end
103
- result
104
- end
105
-
106
- def block_passed? node
107
- node.children.last.is_a?(Parser::AST::Node) && node.children.last.type == :block_pass
108
- end
109
- end
110
- end
111
- end
@@ -1,240 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- class Source
5
- module NodeMethods
6
- module_function
7
-
8
- # @param node [Parser::AST::Node]
9
- # @return [String]
10
- def unpack_name(node)
11
- pack_name(node).join("::")
12
- end
13
-
14
- # @param node [Parser::AST::Node]
15
- # @return [Array<String>]
16
- def pack_name(node)
17
- parts = []
18
- if node.is_a?(AST::Node)
19
- node.children.each { |n|
20
- if n.is_a?(AST::Node)
21
- if n.type == :cbase
22
- parts = [''] + pack_name(n)
23
- else
24
- parts += pack_name(n)
25
- end
26
- else
27
- parts.push n unless n.nil?
28
- end
29
- }
30
- end
31
- parts
32
- end
33
-
34
- # @param node [Parser::AST::Node]
35
- # @return [String]
36
- def const_from node
37
- if node.is_a?(AST::Node) and node.type == :const
38
- result = ''
39
- unless node.children[0].nil?
40
- result = const_from(node.children[0])
41
- end
42
- if result == ''
43
- result = node.children[1].to_s
44
- else
45
- result = result + '::' + node.children[1].to_s
46
- end
47
- result
48
- else
49
- nil
50
- end
51
- end
52
-
53
- # @param node [Parser::AST::Node]
54
- # @return [String]
55
- def infer_literal_node_type node
56
- return nil unless node.is_a?(AST::Node)
57
- if node.type == :str || node.type == :dstr
58
- return '::String'
59
- elsif node.type == :array
60
- return '::Array'
61
- elsif node.type == :hash
62
- return '::Hash'
63
- elsif node.type == :int
64
- return '::Integer'
65
- elsif node.type == :float
66
- return '::Float'
67
- elsif node.type == :sym
68
- return '::Symbol'
69
- elsif node.type == :regexp
70
- return '::Regexp'
71
- elsif node.type == :irange
72
- return '::Range'
73
- elsif node.type == :true || node.type == :false
74
- return '::Boolean'
75
- # @todo Support `nil` keyword in types
76
- # elsif node.type == :nil
77
- # return 'NilClass'
78
- end
79
- nil
80
- end
81
-
82
- # Get a call signature from a node.
83
- # The result should be a string in the form of a method path, e.g.,
84
- # String.new or variable.method.
85
- #
86
- # @param node [Parser::AST::Node]
87
- # @return [String]
88
- def resolve_node_signature node
89
- result = drill_signature node, ''
90
- return nil if result.empty?
91
- result
92
- end
93
-
94
- # @param node [Parser::AST::Node]
95
- # @return [Position]
96
- def get_node_start_position(node)
97
- Position.new(node.loc.line, node.loc.column)
98
- end
99
-
100
- # @param node [Parser::AST::Node]
101
- # @return [Position]
102
- def get_node_end_position(node)
103
- Position.new(node.loc.last_line, node.loc.last_column)
104
- end
105
-
106
- def drill_signature node, signature
107
- return signature unless node.is_a?(AST::Node)
108
- if node.type == :const or node.type == :cbase
109
- unless node.children[0].nil?
110
- signature += drill_signature(node.children[0], signature)
111
- end
112
- signature += '::' unless signature.empty?
113
- signature += node.children[1].to_s
114
- elsif node.type == :lvar or node.type == :ivar or node.type == :cvar
115
- signature += '.' unless signature.empty?
116
- signature += node.children[0].to_s
117
- elsif node.type == :send
118
- unless node.children[0].nil?
119
- signature += drill_signature(node.children[0], signature)
120
- end
121
- signature += '.' unless signature.empty?
122
- signature += node.children[1].to_s
123
- end
124
- signature
125
- end
126
-
127
- NIL_NODE = Parser::AST::Node.new(:nil)
128
-
129
- # Find all the nodes within the provided node that potentially return a
130
- # value.
131
- #
132
- # The node parameter typically represents a method's logic, e.g., the
133
- # second child (after the :args node) of a :def node. A simple one-line
134
- # method would typically return itself, while a node with conditions
135
- # would return the resulting node from each conditional branch. Nodes
136
- # that follow a :return node are assumed to be unreachable. Nil values
137
- # are converted to nil node types.
138
- #
139
- # @param node [Parser::AST::Node]
140
- # @return [Array<Parser::AST::Node>]
141
- def returns_from node
142
- DeepInference.get_return_nodes(node).map { |n| n || NIL_NODE }
143
- end
144
-
145
- module DeepInference
146
- class << self
147
- CONDITIONAL = [:if, :unless]
148
- REDUCEABLE = [:begin, :kwbegin]
149
- SKIPPABLE = [:def, :defs, :class, :sclass, :module]
150
-
151
- # @param node [Parser::AST::Node]
152
- # @return [Array<Parser::AST::Node>]
153
- def get_return_nodes node
154
- return [] unless node.is_a?(Parser::AST::Node)
155
- result = []
156
- if REDUCEABLE.include?(node.type)
157
- result.concat get_return_nodes_from_children(node)
158
- elsif CONDITIONAL.include?(node.type)
159
- result.concat reduce_to_value_nodes(node.children[1..-1])
160
- elsif node.type == :and || node.type == :or
161
- result.concat reduce_to_value_nodes(node.children)
162
- elsif node.type == :return
163
- result.concat reduce_to_value_nodes([node.children[0]])
164
- elsif node.type == :block
165
- result.push node
166
- # result.concat reduce_to_value_nodes([node.children[0]])
167
- result.concat get_return_nodes_only(node.children[2])
168
- else
169
- result.push node
170
- end
171
- result
172
- end
173
-
174
- private
175
-
176
- def get_return_nodes_from_children parent
177
- result = []
178
- nodes = parent.children.select{|n| n.is_a?(AST::Node)}
179
- nodes.each_with_index do |node, idx|
180
- if node.type == :block
181
- result.concat get_return_nodes_only(node.children[2])
182
- elsif SKIPPABLE.include?(node.type)
183
- next
184
- elsif node.type == :return
185
- result.concat reduce_to_value_nodes([node.children[0]])
186
- # Return the result here because the rest of the code is
187
- # unreachable
188
- return result
189
- else
190
- result.concat get_return_nodes_only(node)
191
- end
192
- result.concat reduce_to_value_nodes([nodes.last]) if idx == nodes.length - 1
193
- end
194
- result
195
- end
196
-
197
- def get_return_nodes_only parent
198
- return [] unless parent.is_a?(Parser::AST::Node)
199
- result = []
200
- nodes = parent.children.select{|n| n.is_a?(Parser::AST::Node)}
201
- nodes.each do |node|
202
- next if SKIPPABLE.include?(node.type)
203
- if node.type == :return
204
- result.concat reduce_to_value_nodes([node.children[0]])
205
- # Return the result here because the rest of the code is
206
- # unreachable
207
- return result
208
- else
209
- result.concat get_return_nodes_only(node)
210
- end
211
- end
212
- result
213
- end
214
-
215
- def reduce_to_value_nodes nodes
216
- result = []
217
- nodes.each do |node|
218
- if !node.is_a?(Parser::AST::Node)
219
- result.push nil
220
- elsif REDUCEABLE.include?(node.type)
221
- result.concat get_return_nodes_from_children(node)
222
- elsif CONDITIONAL.include?(node.type)
223
- result.concat reduce_to_value_nodes(node.children[1..-1])
224
- elsif node.type == :return
225
- result.concat get_return_nodes(node.children[0])
226
- elsif node.type == :and || node.type == :or
227
- result.concat reduce_to_value_nodes(node.children)
228
- elsif node.type == :block
229
- result.concat get_return_nodes_only(node.children[2])
230
- else
231
- result.push node
232
- end
233
- end
234
- result
235
- end
236
- end
237
- end
238
- end
239
- end
240
- end