solargraph 0.47.2 → 0.53.3
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 +4 -4
- data/.github/FUNDING.yml +1 -0
- data/.github/workflows/plugins.yml +40 -0
- data/.github/workflows/rspec.yml +4 -8
- data/.github/workflows/typecheck.yml +34 -0
- data/.yardopts +2 -2
- data/CHANGELOG.md +137 -3
- data/LICENSE +1 -1
- data/README.md +19 -16
- data/SPONSORS.md +2 -9
- data/lib/solargraph/api_map/cache.rb +60 -20
- data/lib/solargraph/api_map/source_to_yard.rb +17 -10
- data/lib/solargraph/api_map/store.rb +60 -12
- data/lib/solargraph/api_map.rb +171 -99
- data/lib/solargraph/bench.rb +3 -2
- data/lib/solargraph/cache.rb +77 -0
- data/lib/solargraph/complex_type/type_methods.rb +61 -12
- data/lib/solargraph/complex_type/unique_type.rb +193 -16
- data/lib/solargraph/complex_type.rb +113 -10
- data/lib/solargraph/convention/rakefile.rb +17 -0
- data/lib/solargraph/convention.rb +2 -3
- data/lib/solargraph/converters/dd.rb +5 -0
- data/lib/solargraph/converters/dl.rb +3 -0
- data/lib/solargraph/converters/dt.rb +3 -0
- data/lib/solargraph/diagnostics/rubocop.rb +23 -8
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +4 -1
- data/lib/solargraph/diagnostics/type_check.rb +1 -0
- data/lib/solargraph/diagnostics.rb +2 -2
- data/lib/solargraph/doc_map.rb +171 -0
- data/lib/solargraph/gem_pins.rb +64 -0
- data/lib/solargraph/language_server/host/cataloger.rb +2 -1
- data/lib/solargraph/language_server/host/diagnoser.rb +2 -2
- data/lib/solargraph/language_server/host/dispatch.rb +15 -5
- data/lib/solargraph/language_server/host/message_worker.rb +4 -0
- data/lib/solargraph/language_server/host/sources.rb +7 -4
- data/lib/solargraph/language_server/host.rb +50 -26
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +3 -1
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +13 -1
- data/lib/solargraph/language_server/message/extended/download_core.rb +1 -5
- data/lib/solargraph/language_server/message/initialize.rb +13 -0
- data/lib/solargraph/language_server/message/initialized.rb +1 -0
- data/lib/solargraph/language_server/message/text_document/document_symbol.rb +4 -1
- data/lib/solargraph/language_server/message/text_document/formatting.rb +4 -4
- data/lib/solargraph/language_server/message/text_document/hover.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/signature_help.rb +1 -6
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +24 -0
- data/lib/solargraph/language_server/message/text_document.rb +1 -1
- data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +5 -0
- data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +10 -3
- data/lib/solargraph/language_server/message.rb +1 -0
- data/lib/solargraph/language_server/transport/adapter.rb +16 -1
- data/lib/solargraph/language_server/transport/data_reader.rb +2 -0
- data/lib/solargraph/library.rb +124 -37
- data/lib/solargraph/location.rb +1 -0
- data/lib/solargraph/page.rb +6 -0
- data/lib/solargraph/parser/comment_ripper.rb +4 -0
- data/lib/solargraph/parser/node_methods.rb +47 -7
- data/lib/solargraph/parser/node_processor/base.rb +9 -0
- data/lib/solargraph/parser/{legacy → parser_gem}/class_methods.rb +31 -5
- data/lib/solargraph/parser/{legacy → parser_gem}/flawed_builder.rb +3 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_chainer.rb +57 -41
- data/lib/solargraph/parser/parser_gem/node_methods.rb +499 -0
- data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/alias_node.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +53 -0
- data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/begin_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/block_node.rb +3 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/casgn_node.rb +14 -4
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/cvasgn_node.rb +1 -1
- data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/def_node.rb +7 -20
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/defs_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/gvasgn_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/ivasgn_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/lvasgn_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/namespace_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/orasgn_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/resbody_node.rb +3 -3
- data/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb +42 -0
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/send_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/sym_node.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_processors.rb +54 -0
- data/lib/solargraph/parser/parser_gem.rb +12 -0
- data/lib/solargraph/parser/region.rb +1 -1
- data/lib/solargraph/parser/snippet.rb +2 -0
- data/lib/solargraph/parser.rb +9 -10
- data/lib/solargraph/pin/base.rb +69 -11
- data/lib/solargraph/pin/base_variable.rb +8 -4
- data/lib/solargraph/pin/block.rb +21 -28
- data/lib/solargraph/pin/closure.rb +17 -2
- data/lib/solargraph/pin/common.rb +7 -3
- data/lib/solargraph/pin/conversions.rb +34 -8
- data/lib/solargraph/pin/delegated_method.rb +97 -0
- data/lib/solargraph/pin/documenting.rb +25 -34
- data/lib/solargraph/pin/instance_variable.rb +4 -0
- data/lib/solargraph/pin/local_variable.rb +13 -1
- data/lib/solargraph/pin/method.rb +270 -16
- data/lib/solargraph/pin/namespace.rb +17 -1
- data/lib/solargraph/pin/parameter.rb +52 -17
- data/lib/solargraph/pin/reference/override.rb +2 -2
- data/lib/solargraph/pin/reference.rb +8 -0
- data/lib/solargraph/pin/search.rb +4 -4
- data/lib/solargraph/pin/signature.rb +143 -0
- data/lib/solargraph/pin.rb +2 -1
- data/lib/solargraph/range.rb +4 -6
- data/lib/solargraph/rbs_map/conversions.rb +601 -0
- data/lib/solargraph/rbs_map/core_fills.rb +47 -0
- data/lib/solargraph/rbs_map/core_map.rb +28 -0
- data/lib/solargraph/rbs_map/stdlib_map.rb +33 -0
- data/lib/solargraph/rbs_map.rb +84 -0
- data/lib/solargraph/shell.rb +69 -48
- data/lib/solargraph/source/chain/array.rb +32 -0
- data/lib/solargraph/source/chain/block_symbol.rb +13 -0
- data/lib/solargraph/source/chain/call.rb +125 -61
- data/lib/solargraph/source/chain/constant.rb +15 -1
- data/lib/solargraph/source/chain/if.rb +23 -0
- data/lib/solargraph/source/chain/link.rb +8 -2
- data/lib/solargraph/source/chain/or.rb +1 -1
- data/lib/solargraph/source/chain/z_super.rb +3 -3
- data/lib/solargraph/source/chain.rb +44 -14
- data/lib/solargraph/source/change.rb +3 -0
- data/lib/solargraph/source/cursor.rb +2 -0
- data/lib/solargraph/source/source_chainer.rb +8 -5
- data/lib/solargraph/source.rb +18 -19
- data/lib/solargraph/source_map/clip.rb +30 -23
- data/lib/solargraph/source_map/mapper.rb +20 -5
- data/lib/solargraph/source_map.rb +28 -13
- data/lib/solargraph/type_checker/checks.rb +10 -2
- data/lib/solargraph/type_checker.rb +201 -98
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/views/environment.erb +2 -2
- data/lib/solargraph/workspace/config.rb +14 -11
- data/lib/solargraph/workspace.rb +28 -17
- data/lib/solargraph/yard_map/cache.rb +6 -0
- data/lib/solargraph/yard_map/helpers.rb +1 -1
- data/lib/solargraph/yard_map/mapper/to_method.rb +18 -5
- data/lib/solargraph/yard_map/mapper.rb +1 -1
- data/lib/solargraph/yard_map/to_method.rb +11 -4
- data/lib/solargraph/yard_map.rb +1 -443
- data/lib/solargraph/yard_tags.rb +20 -0
- data/lib/solargraph/yardoc.rb +52 -0
- data/lib/solargraph.rb +8 -6
- data/solargraph.gemspec +19 -8
- metadata +162 -98
- data/.travis.yml +0 -19
- data/lib/solargraph/api_map/bundler_methods.rb +0 -22
- data/lib/solargraph/compat.rb +0 -37
- data/lib/solargraph/convention/rspec.rb +0 -30
- data/lib/solargraph/documentor.rb +0 -76
- data/lib/solargraph/parser/legacy/node_methods.rb +0 -325
- data/lib/solargraph/parser/legacy/node_processors/alias_node.rb +0 -23
- data/lib/solargraph/parser/legacy/node_processors/args_node.rb +0 -35
- data/lib/solargraph/parser/legacy/node_processors/begin_node.rb +0 -15
- data/lib/solargraph/parser/legacy/node_processors/def_node.rb +0 -63
- data/lib/solargraph/parser/legacy/node_processors/sclass_node.rb +0 -21
- data/lib/solargraph/parser/legacy/node_processors.rb +0 -54
- data/lib/solargraph/parser/legacy.rb +0 -12
- data/lib/solargraph/parser/rubyvm/class_methods.rb +0 -144
- data/lib/solargraph/parser/rubyvm/node_chainer.rb +0 -160
- data/lib/solargraph/parser/rubyvm/node_methods.rb +0 -315
- data/lib/solargraph/parser/rubyvm/node_processors/args_node.rb +0 -85
- data/lib/solargraph/parser/rubyvm/node_processors/block_node.rb +0 -42
- data/lib/solargraph/parser/rubyvm/node_processors/casgn_node.rb +0 -22
- data/lib/solargraph/parser/rubyvm/node_processors/cvasgn_node.rb +0 -23
- data/lib/solargraph/parser/rubyvm/node_processors/defs_node.rb +0 -57
- data/lib/solargraph/parser/rubyvm/node_processors/gvasgn_node.rb +0 -23
- data/lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb +0 -38
- data/lib/solargraph/parser/rubyvm/node_processors/kw_arg_node.rb +0 -39
- data/lib/solargraph/parser/rubyvm/node_processors/lit_node.rb +0 -20
- data/lib/solargraph/parser/rubyvm/node_processors/lvasgn_node.rb +0 -27
- data/lib/solargraph/parser/rubyvm/node_processors/namespace_node.rb +0 -39
- data/lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb +0 -26
- data/lib/solargraph/parser/rubyvm/node_processors/orasgn_node.rb +0 -15
- data/lib/solargraph/parser/rubyvm/node_processors/resbody_node.rb +0 -45
- data/lib/solargraph/parser/rubyvm/node_processors/sclass_node.rb +0 -21
- data/lib/solargraph/parser/rubyvm/node_processors/scope_node.rb +0 -15
- data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +0 -277
- data/lib/solargraph/parser/rubyvm/node_processors/sym_node.rb +0 -18
- data/lib/solargraph/parser/rubyvm/node_processors.rb +0 -63
- data/lib/solargraph/parser/rubyvm.rb +0 -40
- data/lib/solargraph/yard_map/core_docs.rb +0 -170
- data/lib/solargraph/yard_map/core_fills.rb +0 -208
- data/lib/solargraph/yard_map/core_gen.rb +0 -76
- data/lib/solargraph/yard_map/rdoc_to_yard.rb +0 -140
- data/lib/solargraph/yard_map/stdlib_fills.rb +0 -43
- data/lib/yard-solargraph.rb +0 -33
- data/yardoc/2.2.2.tar.gz +0 -0
@@ -12,7 +12,7 @@ module Solargraph
|
|
12
12
|
|
13
13
|
private_class_method :new
|
14
14
|
|
15
|
-
|
15
|
+
DIRECTIVE_REGEXP = /(@\!method|@\!attribute|@\!visibility|@\!domain|@\!macro|@\!parse|@\!override)/.freeze
|
16
16
|
|
17
17
|
# Generate the data.
|
18
18
|
#
|
@@ -24,6 +24,8 @@ module Solargraph
|
|
24
24
|
@code = source.code
|
25
25
|
@comments = source.comments
|
26
26
|
@pins, @locals = Parser.map(source)
|
27
|
+
@pins.each { |p| p.source = :code }
|
28
|
+
@locals.each { |l| l.source = :code }
|
27
29
|
process_comment_directives
|
28
30
|
[@pins, @locals]
|
29
31
|
# rescue Exception => e
|
@@ -62,8 +64,12 @@ module Solargraph
|
|
62
64
|
pins.select{|pin| pin.is_a?(Pin::Closure) and pin.location.range.contain?(position)}.last
|
63
65
|
end
|
64
66
|
|
67
|
+
# @param source_position [Position]
|
68
|
+
# @param comment_position [Position]
|
69
|
+
# @param comment [String]
|
70
|
+
# @return [void]
|
65
71
|
def process_comment source_position, comment_position, comment
|
66
|
-
return unless comment.encode('UTF-8', invalid: :replace, replace: '?') =~
|
72
|
+
return unless comment.encode('UTF-8', invalid: :replace, replace: '?') =~ DIRECTIVE_REGEXP
|
67
73
|
cmnt = remove_inline_comment_hashes(comment)
|
68
74
|
parse = Solargraph::Source.parse_docstring(cmnt)
|
69
75
|
last_line = 0
|
@@ -77,6 +83,8 @@ module Solargraph
|
|
77
83
|
end
|
78
84
|
|
79
85
|
# @param comment [String]
|
86
|
+
# @param tag [String]
|
87
|
+
# @param start [Integer]
|
80
88
|
# @return [Integer]
|
81
89
|
def find_directive_line_number comment, tag, start
|
82
90
|
# Avoid overruning the index
|
@@ -105,7 +113,8 @@ module Solargraph
|
|
105
113
|
begin
|
106
114
|
src = Solargraph::Source.load_string("def #{directive.tag.name};end", @source.filename)
|
107
115
|
region = Parser::Region.new(source: src, closure: namespace)
|
108
|
-
|
116
|
+
method_gen_pins = Parser.process_node(src.node, region).first.select { |pin| pin.is_a?(Pin::Method) }
|
117
|
+
gen_pin = method_gen_pins.last
|
109
118
|
return if gen_pin.nil?
|
110
119
|
# Move the location to the end of the line so it gets recognized
|
111
120
|
# as originating from a comment
|
@@ -196,20 +205,26 @@ module Solargraph
|
|
196
205
|
namespace.domains.concat directive.tag.types unless directive.tag.types.nil?
|
197
206
|
when 'override'
|
198
207
|
pins.push Pin::Reference::Override.new(location, directive.tag.name, docstring.tags)
|
208
|
+
when 'macro'
|
209
|
+
# @todo Handle macros
|
199
210
|
end
|
200
211
|
end
|
201
212
|
|
213
|
+
# @param line1 [Integer]
|
214
|
+
# @param line2 [Integer]
|
202
215
|
def no_empty_lines?(line1, line2)
|
203
216
|
@code.lines[line1..line2].none? { |line| line.strip.empty? }
|
204
217
|
end
|
205
218
|
|
219
|
+
# @param comment [String]
|
220
|
+
# @return [String]
|
206
221
|
def remove_inline_comment_hashes comment
|
207
222
|
ctxt = ''
|
208
223
|
num = nil
|
209
224
|
started = false
|
210
225
|
comment.lines.each { |l|
|
211
226
|
# Trim the comment and minimum leading whitespace
|
212
|
-
p = l.encode('UTF-8', invalid: :replace, replace: '?').gsub(
|
227
|
+
p = l.encode('UTF-8', invalid: :replace, replace: '?').gsub(/^#+/, '')
|
213
228
|
if num.nil? && !p.strip.empty?
|
214
229
|
num = p.index(/[^ ]/)
|
215
230
|
started = true
|
@@ -224,7 +239,7 @@ module Solargraph
|
|
224
239
|
|
225
240
|
# @return [void]
|
226
241
|
def process_comment_directives
|
227
|
-
return unless @code.encode('UTF-8', invalid: :replace, replace: '?') =~
|
242
|
+
return unless @code.encode('UTF-8', invalid: :replace, replace: '?') =~ DIRECTIVE_REGEXP
|
228
243
|
code_lines = @code.lines
|
229
244
|
@source.associated_comments.each do |line, comments|
|
230
245
|
src_pos = line ? Position.new(line, code_lines[line].to_s.chomp.index(/[^\s]/) || 0) : Position.new(code_lines.length, 0)
|
@@ -1,8 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'yard'
|
4
|
-
require '
|
5
|
-
require 'set'
|
4
|
+
require 'solargraph/yard_tags'
|
6
5
|
|
7
6
|
module Solargraph
|
8
7
|
# An index of pins and other ApiMap-related data for a Source.
|
@@ -18,7 +17,7 @@ module Solargraph
|
|
18
17
|
# @return [Array<Pin::Base>]
|
19
18
|
attr_reader :pins
|
20
19
|
|
21
|
-
# @return [Array<Pin::
|
20
|
+
# @return [Array<Pin::LocalVariable>]
|
22
21
|
attr_reader :locals
|
23
22
|
|
24
23
|
# @param source [Source]
|
@@ -30,21 +29,17 @@ module Solargraph
|
|
30
29
|
@pins = pins
|
31
30
|
@locals = locals
|
32
31
|
environ.merge Convention.for_local(self) unless filename.nil?
|
32
|
+
self.convention_pins = environ.pins
|
33
33
|
@pin_class_hash = pins.to_set.classify(&:class).transform_values(&:to_a)
|
34
34
|
@pin_select_cache = {}
|
35
35
|
end
|
36
36
|
|
37
|
+
# @param klass [Class]
|
38
|
+
# @return [Array<Pin::Base>]
|
37
39
|
def pins_by_class klass
|
38
40
|
@pin_select_cache[klass] ||= @pin_class_hash.select { |key, _| key <= klass }.values.flatten
|
39
41
|
end
|
40
42
|
|
41
|
-
def rebindable_method_names
|
42
|
-
@rebindable_method_names ||= pins_by_class(Pin::Method)
|
43
|
-
.select { |pin| pin.comments && pin.comments.include?('@yieldself') }
|
44
|
-
.map(&:name)
|
45
|
-
.to_set
|
46
|
-
end
|
47
|
-
|
48
43
|
# @return [String]
|
49
44
|
def filename
|
50
45
|
source.filename
|
@@ -65,11 +60,12 @@ module Solargraph
|
|
65
60
|
@environ ||= Environ.new
|
66
61
|
end
|
67
62
|
|
63
|
+
# all pins except Solargraph::Pin::Reference::Reference
|
68
64
|
# @return [Array<Pin::Base>]
|
69
65
|
def document_symbols
|
70
|
-
@document_symbols ||= pins.select
|
66
|
+
@document_symbols ||= (pins + convention_pins).select do |pin|
|
71
67
|
pin.path && !pin.path.empty?
|
72
|
-
|
68
|
+
end
|
73
69
|
end
|
74
70
|
|
75
71
|
# @param query [String]
|
@@ -97,10 +93,16 @@ module Solargraph
|
|
97
93
|
(pins + locals).select { |pin| pin.location == location }
|
98
94
|
end
|
99
95
|
|
96
|
+
# @param line [Integer]
|
97
|
+
# @param character [Integer]
|
98
|
+
# @return [Pin::Method,Pin::Namespace]
|
100
99
|
def locate_named_path_pin line, character
|
101
100
|
_locate_pin line, character, Pin::Namespace, Pin::Method
|
102
101
|
end
|
103
102
|
|
103
|
+
# @param line [Integer]
|
104
|
+
# @param character [Integer]
|
105
|
+
# @return [Pin::Namespace,Pin::Method,Pin::Block]
|
104
106
|
def locate_block_pin line, character
|
105
107
|
_locate_pin line, character, Pin::Namespace, Pin::Method, Pin::Block
|
106
108
|
end
|
@@ -159,10 +161,23 @@ module Solargraph
|
|
159
161
|
|
160
162
|
private
|
161
163
|
|
164
|
+
# @return [Array<Pin::Base>]
|
165
|
+
def convention_pins
|
166
|
+
@convention_pins || []
|
167
|
+
end
|
168
|
+
|
169
|
+
# @param pins [Array<Pin::Base>]
|
170
|
+
# @return [Array<Pin::Base>]
|
171
|
+
def convention_pins=(pins)
|
172
|
+
# unmemoizing the document_symbols in case it was called from any of convnetions
|
173
|
+
@document_symbols = nil
|
174
|
+
@convention_pins = pins
|
175
|
+
end
|
176
|
+
|
162
177
|
# @param line [Integer]
|
163
178
|
# @param character [Integer]
|
164
179
|
# @param klasses [Array<Class>]
|
165
|
-
# @return [Pin::Base]
|
180
|
+
# @return [Pin::Base, nil]
|
166
181
|
def _locate_pin line, character, *klasses
|
167
182
|
position = Position.new(line, character)
|
168
183
|
found = nil
|
@@ -51,8 +51,13 @@ module Solargraph
|
|
51
51
|
# @return [Boolean]
|
52
52
|
def any_types_match? api_map, expected, inferred
|
53
53
|
return duck_types_match?(api_map, expected, inferred) if expected.duck_type?
|
54
|
+
# walk through the union expected type and see if any members
|
55
|
+
# of the union match the inferred type
|
54
56
|
expected.each do |exp|
|
55
57
|
next if exp.duck_type?
|
58
|
+
# @todo: there should be a level of typechecking where all
|
59
|
+
# unique types in the inferred must match one of the
|
60
|
+
# expected unique types
|
56
61
|
inferred.each do |inf|
|
57
62
|
# return true if exp == inf || api_map.super_and_sub?(fuzz(inf), fuzz(exp))
|
58
63
|
return true if exp == inf || either_way?(api_map, inf, exp)
|
@@ -103,9 +108,12 @@ module Solargraph
|
|
103
108
|
# @param cls2 [ComplexType::UniqueType]
|
104
109
|
# @return [Boolean]
|
105
110
|
def either_way?(api_map, cls1, cls2)
|
106
|
-
|
107
|
-
|
111
|
+
# @todo there should be a level of typechecking which uses the
|
112
|
+
# full tag with parameters to determine compatibility
|
113
|
+
f1 = cls1.name
|
114
|
+
f2 = cls2.name
|
108
115
|
api_map.type_include?(f1, f2) || api_map.super_and_sub?(f1, f2) || api_map.super_and_sub?(f2, f1)
|
116
|
+
# api_map.type_include?(f1, f2) || api_map.super_and_sub?(f1, f2) || api_map.super_and_sub?(f2, f1)
|
109
117
|
end
|
110
118
|
end
|
111
119
|
end
|