solargraph 0.39.15 → 0.40.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -8
- data/CHANGELOG.md +992 -0
- data/Rakefile +12 -1
- data/SPONSORS.md +1 -0
- data/lib/.rubocop.yml +2 -2
- data/lib/solargraph.rb +2 -4
- data/lib/solargraph/api_map.rb +75 -74
- data/lib/solargraph/api_map/cache.rb +2 -2
- data/lib/solargraph/api_map/store.rb +4 -8
- data/lib/solargraph/{bundle.rb → bench.rb} +6 -2
- data/lib/solargraph/compat.rb +14 -0
- data/lib/solargraph/complex_type.rb +2 -2
- data/lib/solargraph/convention.rb +13 -4
- data/lib/solargraph/convention/base.rb +16 -8
- data/lib/solargraph/convention/gemfile.rb +2 -5
- data/lib/solargraph/convention/gemspec.rb +3 -6
- data/lib/solargraph/convention/rspec.rb +3 -6
- data/lib/solargraph/environ.rb +11 -6
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +6 -1
- data/lib/solargraph/language_server/message/text_document/definition.rb +1 -1
- data/lib/solargraph/language_server/message/text_document/formatting.rb +17 -19
- data/lib/solargraph/library.rb +6 -8
- data/lib/solargraph/parser/legacy/node_methods.rb +9 -0
- data/lib/solargraph/parser/legacy/node_processors/ivasgn_node.rb +1 -1
- data/lib/solargraph/parser/legacy/node_processors/send_node.rb +36 -23
- data/lib/solargraph/parser/node_processor/base.rb +3 -0
- data/lib/solargraph/parser/rubyvm/node_methods.rb +18 -1
- data/lib/solargraph/parser/rubyvm/node_processors/args_node.rb +1 -1
- data/lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb +1 -1
- data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +40 -29
- data/lib/solargraph/pin.rb +0 -3
- data/lib/solargraph/pin/common.rb +1 -1
- data/lib/solargraph/pin/conversions.rb +3 -4
- data/lib/solargraph/pin/documenting.rb +3 -9
- data/lib/solargraph/pin/method.rb +141 -7
- data/lib/solargraph/pin/method_alias.rb +1 -1
- data/lib/solargraph/position.rb +2 -14
- data/lib/solargraph/source.rb +10 -6
- data/lib/solargraph/source/chain.rb +18 -5
- data/lib/solargraph/source_map.rb +4 -1
- data/lib/solargraph/source_map/clip.rb +3 -2
- data/lib/solargraph/source_map/mapper.rb +10 -6
- data/lib/solargraph/type_checker.rb +27 -24
- data/lib/solargraph/type_checker/param_def.rb +1 -1
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/yard_map.rb +40 -47
- data/lib/solargraph/yard_map/core_fills.rb +185 -0
- data/lib/solargraph/yard_map/helpers.rb +16 -0
- data/lib/solargraph/yard_map/mapper.rb +14 -8
- data/lib/solargraph/{pin/yard_pin/constant.rb → yard_map/mapper/to_constant.rb} +6 -6
- data/lib/solargraph/yard_map/mapper/to_method.rb +78 -0
- data/lib/solargraph/{pin/yard_pin/namespace.rb → yard_map/mapper/to_namespace.rb} +6 -6
- data/lib/solargraph/yard_map/rdoc_to_yard.rb +1 -1
- data/lib/solargraph/yard_map/stdlib_fills.rb +43 -0
- data/lib/solargraph/yard_map/to_method.rb +79 -0
- data/solargraph.gemspec +5 -5
- metadata +22 -36
- data/lib/solargraph/core_fills.rb +0 -160
- data/lib/solargraph/pin/attribute.rb +0 -49
- data/lib/solargraph/pin/base_method.rb +0 -141
- data/lib/solargraph/pin/yard_pin.rb +0 -12
- data/lib/solargraph/pin/yard_pin/method.rb +0 -80
- data/lib/solargraph/pin/yard_pin/yard_mixin.rb +0 -20
- data/lib/solargraph/stdlib_fills.rb +0 -40
- data/travis-bundler.rb +0 -11
data/solargraph.gemspec
CHANGED
@@ -17,18 +17,18 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.license = 'MIT'
|
18
18
|
s.executables = ['solargraph']
|
19
19
|
|
20
|
-
s.required_ruby_version = '>= 2.
|
20
|
+
s.required_ruby_version = '>= 2.4'
|
21
21
|
|
22
22
|
s.add_runtime_dependency 'backport', '~> 1.1'
|
23
23
|
s.add_runtime_dependency 'benchmark'
|
24
24
|
s.add_runtime_dependency 'bundler', '>= 1.17.2'
|
25
25
|
s.add_runtime_dependency 'e2mmap'
|
26
26
|
s.add_runtime_dependency 'jaro_winkler', '~> 1.5'
|
27
|
-
s.add_runtime_dependency '
|
28
|
-
s.add_runtime_dependency '
|
29
|
-
s.add_runtime_dependency 'parser', '~>
|
27
|
+
s.add_runtime_dependency 'kramdown', '~> 2.3'
|
28
|
+
s.add_runtime_dependency 'kramdown-parser-gfm', '~> 1.1'
|
29
|
+
s.add_runtime_dependency 'parser', '~> 3.0'
|
30
30
|
s.add_runtime_dependency 'reverse_markdown', '>= 1.0.5', '< 3'
|
31
|
-
s.add_runtime_dependency 'rubocop', '
|
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
34
|
s.add_runtime_dependency 'yard', '~> 0.9', '>= 0.9.24'
|
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.
|
4
|
+
version: 0.40.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backport
|
@@ -81,59 +81,47 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.5'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: kramdown
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
90
|
-
- - ">="
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
version: 0.7.3
|
89
|
+
version: '2.3'
|
93
90
|
type: :runtime
|
94
91
|
prerelease: false
|
95
92
|
version_requirements: !ruby/object:Gem::Requirement
|
96
93
|
requirements:
|
97
94
|
- - "~>"
|
98
95
|
- !ruby/object:Gem::Version
|
99
|
-
version: '
|
100
|
-
- - ">="
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: 0.7.3
|
96
|
+
version: '2.3'
|
103
97
|
- !ruby/object:Gem::Dependency
|
104
|
-
name:
|
98
|
+
name: kramdown-parser-gfm
|
105
99
|
requirement: !ruby/object:Gem::Requirement
|
106
100
|
requirements:
|
107
101
|
- - "~>"
|
108
102
|
- !ruby/object:Gem::Version
|
109
|
-
version: '1.
|
110
|
-
- - ">="
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
version: 1.9.1
|
103
|
+
version: '1.1'
|
113
104
|
type: :runtime
|
114
105
|
prerelease: false
|
115
106
|
version_requirements: !ruby/object:Gem::Requirement
|
116
107
|
requirements:
|
117
108
|
- - "~>"
|
118
109
|
- !ruby/object:Gem::Version
|
119
|
-
version: '1.
|
120
|
-
- - ">="
|
121
|
-
- !ruby/object:Gem::Version
|
122
|
-
version: 1.9.1
|
110
|
+
version: '1.1'
|
123
111
|
- !ruby/object:Gem::Dependency
|
124
112
|
name: parser
|
125
113
|
requirement: !ruby/object:Gem::Requirement
|
126
114
|
requirements:
|
127
115
|
- - "~>"
|
128
116
|
- !ruby/object:Gem::Version
|
129
|
-
version: '
|
117
|
+
version: '3.0'
|
130
118
|
type: :runtime
|
131
119
|
prerelease: false
|
132
120
|
version_requirements: !ruby/object:Gem::Requirement
|
133
121
|
requirements:
|
134
122
|
- - "~>"
|
135
123
|
- !ruby/object:Gem::Version
|
136
|
-
version: '
|
124
|
+
version: '3.0'
|
137
125
|
- !ruby/object:Gem::Dependency
|
138
126
|
name: reverse_markdown
|
139
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,14 +146,14 @@ dependencies:
|
|
158
146
|
name: rubocop
|
159
147
|
requirement: !ruby/object:Gem::Requirement
|
160
148
|
requirements:
|
161
|
-
- - "
|
149
|
+
- - ">="
|
162
150
|
- !ruby/object:Gem::Version
|
163
151
|
version: '0.52'
|
164
152
|
type: :runtime
|
165
153
|
prerelease: false
|
166
154
|
version_requirements: !ruby/object:Gem::Requirement
|
167
155
|
requirements:
|
168
|
-
- - "
|
156
|
+
- - ">="
|
169
157
|
- !ruby/object:Gem::Version
|
170
158
|
version: '0.52'
|
171
159
|
- !ruby/object:Gem::Dependency
|
@@ -303,6 +291,7 @@ files:
|
|
303
291
|
- ".rspec"
|
304
292
|
- ".travis.yml"
|
305
293
|
- ".yardopts"
|
294
|
+
- CHANGELOG.md
|
306
295
|
- Gemfile
|
307
296
|
- LICENSE
|
308
297
|
- README.md
|
@@ -316,7 +305,7 @@ files:
|
|
316
305
|
- lib/solargraph/api_map/cache.rb
|
317
306
|
- lib/solargraph/api_map/source_to_yard.rb
|
318
307
|
- lib/solargraph/api_map/store.rb
|
319
|
-
- lib/solargraph/
|
308
|
+
- lib/solargraph/bench.rb
|
320
309
|
- lib/solargraph/compat.rb
|
321
310
|
- lib/solargraph/complex_type.rb
|
322
311
|
- lib/solargraph/complex_type/type_methods.rb
|
@@ -330,7 +319,6 @@ files:
|
|
330
319
|
- lib/solargraph/converters/dl.rb
|
331
320
|
- lib/solargraph/converters/dt.rb
|
332
321
|
- lib/solargraph/converters/misc.rb
|
333
|
-
- lib/solargraph/core_fills.rb
|
334
322
|
- lib/solargraph/diagnostics.rb
|
335
323
|
- lib/solargraph/diagnostics/base.rb
|
336
324
|
- lib/solargraph/diagnostics/require_not_found.rb
|
@@ -460,9 +448,7 @@ files:
|
|
460
448
|
- lib/solargraph/parser/rubyvm/node_processors/sym_node.rb
|
461
449
|
- lib/solargraph/parser/snippet.rb
|
462
450
|
- lib/solargraph/pin.rb
|
463
|
-
- lib/solargraph/pin/attribute.rb
|
464
451
|
- lib/solargraph/pin/base.rb
|
465
|
-
- lib/solargraph/pin/base_method.rb
|
466
452
|
- lib/solargraph/pin/base_variable.rb
|
467
453
|
- lib/solargraph/pin/block.rb
|
468
454
|
- lib/solargraph/pin/class_variable.rb
|
@@ -492,11 +478,6 @@ files:
|
|
492
478
|
- lib/solargraph/pin/reference/superclass.rb
|
493
479
|
- lib/solargraph/pin/singleton.rb
|
494
480
|
- lib/solargraph/pin/symbol.rb
|
495
|
-
- lib/solargraph/pin/yard_pin.rb
|
496
|
-
- lib/solargraph/pin/yard_pin/constant.rb
|
497
|
-
- lib/solargraph/pin/yard_pin/method.rb
|
498
|
-
- lib/solargraph/pin/yard_pin/namespace.rb
|
499
|
-
- lib/solargraph/pin/yard_pin/yard_mixin.rb
|
500
481
|
- lib/solargraph/position.rb
|
501
482
|
- lib/solargraph/range.rb
|
502
483
|
- lib/solargraph/server_methods.rb
|
@@ -524,7 +505,6 @@ files:
|
|
524
505
|
- lib/solargraph/source_map/clip.rb
|
525
506
|
- lib/solargraph/source_map/completion.rb
|
526
507
|
- lib/solargraph/source_map/mapper.rb
|
527
|
-
- lib/solargraph/stdlib_fills.rb
|
528
508
|
- lib/solargraph/type_checker.rb
|
529
509
|
- lib/solargraph/type_checker/checks.rb
|
530
510
|
- lib/solargraph/type_checker/param_def.rb
|
@@ -543,12 +523,18 @@ files:
|
|
543
523
|
- lib/solargraph/yard_map.rb
|
544
524
|
- lib/solargraph/yard_map/cache.rb
|
545
525
|
- lib/solargraph/yard_map/core_docs.rb
|
526
|
+
- lib/solargraph/yard_map/core_fills.rb
|
546
527
|
- lib/solargraph/yard_map/core_gen.rb
|
528
|
+
- lib/solargraph/yard_map/helpers.rb
|
547
529
|
- lib/solargraph/yard_map/mapper.rb
|
530
|
+
- lib/solargraph/yard_map/mapper/to_constant.rb
|
531
|
+
- lib/solargraph/yard_map/mapper/to_method.rb
|
532
|
+
- lib/solargraph/yard_map/mapper/to_namespace.rb
|
548
533
|
- lib/solargraph/yard_map/rdoc_to_yard.rb
|
534
|
+
- lib/solargraph/yard_map/stdlib_fills.rb
|
535
|
+
- lib/solargraph/yard_map/to_method.rb
|
549
536
|
- lib/yard-solargraph.rb
|
550
537
|
- solargraph.gemspec
|
551
|
-
- travis-bundler.rb
|
552
538
|
- yardoc/2.2.2.tar.gz
|
553
539
|
homepage: http://solargraph.org
|
554
540
|
licenses:
|
@@ -562,7 +548,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
562
548
|
requirements:
|
563
549
|
- - ">="
|
564
550
|
- !ruby/object:Gem::Version
|
565
|
-
version: '2.
|
551
|
+
version: '2.4'
|
566
552
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
567
553
|
requirements:
|
568
554
|
- - ">="
|
@@ -1,160 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Solargraph
|
4
|
-
# Overrides for the Ruby core.
|
5
|
-
#
|
6
|
-
# The YardMap uses this module to add type information to core methods.
|
7
|
-
#
|
8
|
-
module CoreFills
|
9
|
-
Override = Pin::Reference::Override
|
10
|
-
|
11
|
-
KEYWORDS = [
|
12
|
-
'__ENCODING__', '__LINE__', '__FILE__', 'BEGIN', 'END', 'alias', 'and',
|
13
|
-
'begin', 'break', 'case', 'class', 'def', 'defined?', 'do', 'else',
|
14
|
-
'elsif', 'end', 'ensure', 'false', 'for', 'if', 'in', 'module', 'next',
|
15
|
-
'nil', 'not', 'or', 'redo', 'rescue', 'retry', 'return', 'self', 'super',
|
16
|
-
'then', 'true', 'undef', 'unless', 'until', 'when', 'while', 'yield'
|
17
|
-
].freeze
|
18
|
-
|
19
|
-
methods_with_yieldparam_subtypes = %w[
|
20
|
-
Array#each Array#map Array#map! Array#any? Array#all? Array#index
|
21
|
-
Array#keep_if Array#delete_if
|
22
|
-
Enumerable#each_entry Enumerable#map Enumerable#any? Enumerable#all?
|
23
|
-
Enumerable#select Enumerable#reject
|
24
|
-
Set#each
|
25
|
-
]
|
26
|
-
|
27
|
-
OVERRIDES = [
|
28
|
-
Override.method_return('Array#keep_if', 'self'),
|
29
|
-
Override.method_return('Array#delete_if', 'self'),
|
30
|
-
Override.from_comment('Array#reject', %(
|
31
|
-
@overload reject(&block)
|
32
|
-
@return [self]
|
33
|
-
@overload reject()
|
34
|
-
@return [Enumerator]
|
35
|
-
)),
|
36
|
-
Override.method_return('Array#reverse', 'self', delete: ['overload']),
|
37
|
-
Override.from_comment('Array#select', %(
|
38
|
-
@overload select(&block)
|
39
|
-
@return [self]
|
40
|
-
@overload select()
|
41
|
-
@return [Enumerator]
|
42
|
-
)),
|
43
|
-
Override.from_comment('Array#[]', %(
|
44
|
-
@overload [](range)
|
45
|
-
@param range [Range]
|
46
|
-
@return [self]
|
47
|
-
@overload [](num1, num2)
|
48
|
-
@param num1 [Integer]
|
49
|
-
@param num2 [Integer]
|
50
|
-
@return [self]
|
51
|
-
@overload [](num)
|
52
|
-
@param num [Integer]
|
53
|
-
@return_single_parameter
|
54
|
-
@return_single_parameter
|
55
|
-
)),
|
56
|
-
Override.from_comment('Array#first', %(
|
57
|
-
@overload first(num)
|
58
|
-
@param num [Integer]
|
59
|
-
@return [self]
|
60
|
-
@return_single_parameter
|
61
|
-
)),
|
62
|
-
Override.from_comment('Array#last', %(
|
63
|
-
@overload last(num)
|
64
|
-
@param num [Integer]
|
65
|
-
@return [self]
|
66
|
-
@return_single_parameter
|
67
|
-
)),
|
68
|
-
Override.method_return('Array#uniq', 'self'),
|
69
|
-
Override.method_return('Array#zip', 'Array, nil'),
|
70
|
-
|
71
|
-
Override.from_comment('BasicObject#==', %(
|
72
|
-
@param other [BasicObject]
|
73
|
-
@return [Boolean]
|
74
|
-
)),
|
75
|
-
Override.method_return('BasicObject#initialize', 'void'),
|
76
|
-
|
77
|
-
Override.method_return('Class#new', 'self'),
|
78
|
-
Override.method_return('Class.new', 'Class<Object>'),
|
79
|
-
Override.method_return('Class#allocate', 'self'),
|
80
|
-
Override.method_return('Class.allocate', 'Class<Object>'),
|
81
|
-
|
82
|
-
Override.method_return('Enumerable#select', 'self'),
|
83
|
-
|
84
|
-
Override.method_return('File.absolute_path', 'String'),
|
85
|
-
Override.method_return('File.basename', 'String'),
|
86
|
-
Override.method_return('File.dirname', 'String'),
|
87
|
-
Override.method_return('File.extname', 'String'),
|
88
|
-
Override.method_return('File.join', 'String'),
|
89
|
-
|
90
|
-
Override.from_comment('Float#+', %(
|
91
|
-
@param y [Numeric]
|
92
|
-
@return [Numeric]
|
93
|
-
)),
|
94
|
-
|
95
|
-
Override.from_comment('Hash#[]', %(
|
96
|
-
@return_value_parameter
|
97
|
-
)),
|
98
|
-
|
99
|
-
# @todo This override isn't robust enough. It needs to allow for
|
100
|
-
# parameterized Hash types, e.g., [Hash{Symbol => String}].
|
101
|
-
Override.from_comment('Hash#[]=', %(
|
102
|
-
@param_tuple
|
103
|
-
)),
|
104
|
-
|
105
|
-
Override.from_comment('Integer#+', %(
|
106
|
-
@param y [Numeric]
|
107
|
-
@return [Numeric]
|
108
|
-
)),
|
109
|
-
|
110
|
-
Override.method_return('Kernel#puts', 'nil'),
|
111
|
-
|
112
|
-
# Override.method_return('Module#attr_reader', 'void'),
|
113
|
-
# Override.method_return('Module#attr_writer', 'void'),
|
114
|
-
# Override.method_return('Module#attr_accessor', 'void'),
|
115
|
-
|
116
|
-
Override.from_comment('Numeric#+', %(
|
117
|
-
@param y [Numeric]
|
118
|
-
@return [Numeric]
|
119
|
-
)),
|
120
|
-
|
121
|
-
Override.method_return('Object#!', 'Boolean'),
|
122
|
-
Override.method_return('Object#clone', 'self', delete: [:overload]),
|
123
|
-
Override.method_return('Object#dup', 'self', delete: [:overload]),
|
124
|
-
Override.method_return('Object#freeze', 'self', delete: [:overload]),
|
125
|
-
Override.method_return('Object#inspect', 'String'),
|
126
|
-
Override.method_return('Object#taint', 'self'),
|
127
|
-
Override.method_return('Object#to_s', 'String'),
|
128
|
-
Override.method_return('Object#untaint', 'self'),
|
129
|
-
Override.from_comment('Object#tap', %(
|
130
|
-
@return [self]
|
131
|
-
@yieldparam [self]
|
132
|
-
)),
|
133
|
-
|
134
|
-
Override.from_comment('STDERR', %(
|
135
|
-
@type [IO]
|
136
|
-
)),
|
137
|
-
|
138
|
-
Override.from_comment('STDIN', %(
|
139
|
-
@type [IO]
|
140
|
-
)),
|
141
|
-
|
142
|
-
Override.from_comment('STDOUT', %(
|
143
|
-
@type [IO]
|
144
|
-
)),
|
145
|
-
|
146
|
-
Override.method_return('String#freeze', 'self'),
|
147
|
-
Override.method_return('String#split', 'Array<String>'),
|
148
|
-
Override.method_return('String#lines', 'Array<String>'),
|
149
|
-
Override.from_comment('String#each_line', %(
|
150
|
-
@yieldparam [String]
|
151
|
-
))
|
152
|
-
].concat(
|
153
|
-
methods_with_yieldparam_subtypes.map do |path|
|
154
|
-
Override.from_comment(path, %(
|
155
|
-
@yieldparam_single_parameter
|
156
|
-
))
|
157
|
-
end
|
158
|
-
)
|
159
|
-
end
|
160
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Solargraph
|
4
|
-
module Pin
|
5
|
-
class Attribute < BaseMethod
|
6
|
-
# @return [::Symbol] :reader or :writer
|
7
|
-
attr_reader :access
|
8
|
-
|
9
|
-
# @param access [::Symbol] :reader or :writer
|
10
|
-
def initialize access: :reader, **splat
|
11
|
-
super(**splat)
|
12
|
-
@access = access
|
13
|
-
if access == :writer
|
14
|
-
parameters.push(
|
15
|
-
Pin::Parameter.new(name: 'value', decl: :arg, closure: self)
|
16
|
-
)
|
17
|
-
if return_type.defined?
|
18
|
-
docstring.add_tag YARD::Tags::Tag.new(:param, '', return_type.to_s.split(', '), 'value')
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def completion_item_kind
|
24
|
-
Solargraph::LanguageServer::CompletionItemKinds::PROPERTY
|
25
|
-
end
|
26
|
-
|
27
|
-
def symbol_kind
|
28
|
-
Solargraph::LanguageServer::SymbolKinds::PROPERTY
|
29
|
-
end
|
30
|
-
|
31
|
-
def path
|
32
|
-
@path ||= namespace + (scope == :instance ? '#' : '.') + name
|
33
|
-
end
|
34
|
-
|
35
|
-
def probe api_map
|
36
|
-
types = []
|
37
|
-
varname = "@#{name.gsub(/=$/, '')}"
|
38
|
-
pins = api_map.get_instance_variable_pins(binder.namespace, binder.scope).select { |iv| iv.name == varname }
|
39
|
-
pins.each do |pin|
|
40
|
-
type = pin.typify(api_map)
|
41
|
-
type = pin.probe(api_map) if type.undefined?
|
42
|
-
types.push type if type.defined?
|
43
|
-
end
|
44
|
-
return ComplexType::UNDEFINED if types.empty?
|
45
|
-
ComplexType.try_parse(*types.map(&:tag).uniq)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,141 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Solargraph
|
4
|
-
module Pin
|
5
|
-
# The base class for method and attribute pins.
|
6
|
-
#
|
7
|
-
class BaseMethod < Closure
|
8
|
-
# @return [::Symbol] :public, :private, or :protected
|
9
|
-
attr_reader :visibility
|
10
|
-
|
11
|
-
# @return [Parser::AST::Node]
|
12
|
-
attr_reader :node
|
13
|
-
|
14
|
-
# @param visibility [::Symbol] :public, :protected, or :private
|
15
|
-
# @param explicit [Boolean]
|
16
|
-
def initialize visibility: :public, explicit: true, **splat
|
17
|
-
super(**splat)
|
18
|
-
@visibility = visibility
|
19
|
-
@explicit = explicit
|
20
|
-
end
|
21
|
-
|
22
|
-
def return_type
|
23
|
-
@return_type ||= generate_complex_type
|
24
|
-
end
|
25
|
-
|
26
|
-
def path
|
27
|
-
@path ||= "#{namespace}#{(scope == :instance ? '#' : '.')}#{name}"
|
28
|
-
end
|
29
|
-
|
30
|
-
def typify api_map
|
31
|
-
decl = super
|
32
|
-
return decl unless decl.undefined?
|
33
|
-
type = see_reference(api_map) || typify_from_super(api_map)
|
34
|
-
return type.qualify(api_map, namespace) unless type.nil?
|
35
|
-
name.end_with?('?') ? ComplexType::BOOLEAN : ComplexType::UNDEFINED
|
36
|
-
end
|
37
|
-
|
38
|
-
# @return [Array<Pin::Parameter>]
|
39
|
-
def parameters
|
40
|
-
@parameters ||= []
|
41
|
-
end
|
42
|
-
|
43
|
-
# @return [Array<String>]
|
44
|
-
def parameter_names
|
45
|
-
parameters.map(&:name)
|
46
|
-
end
|
47
|
-
|
48
|
-
def documentation
|
49
|
-
if @documentation.nil?
|
50
|
-
@documentation ||= super || ''
|
51
|
-
param_tags = docstring.tags(:param)
|
52
|
-
unless param_tags.nil? or param_tags.empty?
|
53
|
-
@documentation += "\n\n" unless @documentation.empty?
|
54
|
-
@documentation += "Params:\n"
|
55
|
-
lines = []
|
56
|
-
param_tags.each do |p|
|
57
|
-
l = "* #{p.name}"
|
58
|
-
l += " [#{escape_brackets(p.types.join(', '))}]" unless p.types.nil? or p.types.empty?
|
59
|
-
l += " #{p.text}"
|
60
|
-
lines.push l
|
61
|
-
end
|
62
|
-
@documentation += lines.join("\n")
|
63
|
-
end
|
64
|
-
return_tags = docstring.tags(:return)
|
65
|
-
unless return_tags.empty?
|
66
|
-
@documentation += "\n\n" unless @documentation.empty?
|
67
|
-
@documentation += "Returns:\n"
|
68
|
-
lines = []
|
69
|
-
return_tags.each do |r|
|
70
|
-
l = "*"
|
71
|
-
l += " [#{escape_brackets(r.types.join(', '))}]" unless r.types.nil? or r.types.empty?
|
72
|
-
l += " #{r.text}"
|
73
|
-
lines.push l
|
74
|
-
end
|
75
|
-
@documentation += lines.join("\n")
|
76
|
-
end
|
77
|
-
@documentation += "\n\n" unless @documentation.empty?
|
78
|
-
@documentation += "Visibility: #{visibility}"
|
79
|
-
end
|
80
|
-
@documentation.to_s
|
81
|
-
end
|
82
|
-
|
83
|
-
def explicit?
|
84
|
-
@explicit
|
85
|
-
end
|
86
|
-
|
87
|
-
private
|
88
|
-
|
89
|
-
# @return [ComplexType]
|
90
|
-
def generate_complex_type
|
91
|
-
tags = docstring.tags(:return).map(&:types).flatten.reject(&:nil?)
|
92
|
-
return ComplexType::UNDEFINED if tags.empty?
|
93
|
-
ComplexType.try_parse *tags
|
94
|
-
end
|
95
|
-
|
96
|
-
# @param api_map [ApiMap]
|
97
|
-
# @return [ComplexType, nil]
|
98
|
-
def see_reference api_map
|
99
|
-
docstring.ref_tags.each do |ref|
|
100
|
-
next unless ref.tag_name == 'return' && ref.owner
|
101
|
-
result = resolve_reference(ref.owner.to_s, api_map)
|
102
|
-
return result unless result.nil?
|
103
|
-
end
|
104
|
-
match = comments.match(/^[ \t]*\(see (.*)\)/m)
|
105
|
-
return nil if match.nil?
|
106
|
-
resolve_reference match[1], api_map
|
107
|
-
end
|
108
|
-
|
109
|
-
# @param api_map [ApiMap]
|
110
|
-
# @return [ComplexType, nil]
|
111
|
-
def typify_from_super api_map
|
112
|
-
stack = api_map.get_method_stack(namespace, name, scope: scope).reject { |pin| pin.path == path }
|
113
|
-
return nil if stack.empty?
|
114
|
-
stack.each do |pin|
|
115
|
-
return pin.return_type unless pin.return_type.undefined?
|
116
|
-
end
|
117
|
-
nil
|
118
|
-
end
|
119
|
-
|
120
|
-
# @param ref [String]
|
121
|
-
# @param api_map [ApiMap]
|
122
|
-
# @return [ComplexType]
|
123
|
-
def resolve_reference ref, api_map
|
124
|
-
parts = ref.split(/[\.#]/)
|
125
|
-
if parts.first.empty? || parts.one?
|
126
|
-
path = "#{namespace}#{ref}"
|
127
|
-
else
|
128
|
-
fqns = api_map.qualify(parts.first, namespace)
|
129
|
-
return ComplexType::UNDEFINED if fqns.nil?
|
130
|
-
path = fqns + ref[parts.first.length] + parts.last
|
131
|
-
end
|
132
|
-
pins = api_map.get_path_pins(path)
|
133
|
-
pins.each do |pin|
|
134
|
-
type = pin.typify(api_map)
|
135
|
-
return type unless type.undefined?
|
136
|
-
end
|
137
|
-
nil
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|