solargraph 0.45.0 → 0.47.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 +4 -4
- data/CHANGELOG.md +14 -0
- data/SPONSORS.md +1 -1
- data/lib/solargraph/api_map.rb +25 -20
- data/lib/solargraph/complex_type.rb +2 -2
- data/lib/solargraph/diagnostics/require_not_found.rb +16 -0
- data/lib/solargraph/language_server/message/text_document/hover.rb +16 -4
- data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +1 -1
- data/lib/solargraph/parser/rubyvm/class_methods.rb +1 -1
- data/lib/solargraph/parser/rubyvm/node_processors/def_node.rb +0 -1
- data/lib/solargraph/parser/rubyvm/node_processors/kw_arg_node.rb +2 -2
- data/lib/solargraph/pin/block.rb +2 -1
- data/lib/solargraph/pin/parameter.rb +2 -4
- data/lib/solargraph/pin/search.rb +56 -0
- data/lib/solargraph/pin.rb +1 -0
- data/lib/solargraph/shell.rb +5 -1
- data/lib/solargraph/source.rb +3 -1
- data/lib/solargraph/source_map/mapper.rb +29 -2
- data/lib/solargraph/source_map.rb +1 -10
- data/lib/solargraph/type_checker.rb +20 -6
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace.rb +1 -0
- data/lib/solargraph/yard_map.rb +29 -14
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65ba1769be95a6c7c20aa57ed559135063379214439bc7ab168a40f4bba0c698
|
4
|
+
data.tar.gz: 37fcbabd10f82493704e38ccb8b849a358b59c8cee568ce53b92a7493ee82dc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '04701577441892c4f9c596873dbbdf8c841125a83b642928be5e1e22adf8d8f3293dc1fe5f2b02a468328d3ecf530b27333cbbdf0be1187777a0637004aaae4a'
|
7
|
+
data.tar.gz: 943f42ecf94e5c0fa26455d5974a8baa452a7382f23f215d01cd122031b65db78f2bacc90c51ad51df954f6171106377356a8ff30146c48b33f98d3e3abce96d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## 0.47.0 - September 25, 2022
|
2
|
+
- Completion candidates for union types (#507)
|
3
|
+
- Nullify Hover object instead of contents value (#583)
|
4
|
+
- Mapping workspace stuck in 0 (#587)
|
5
|
+
- Fix parsing of nested subtypes (#589)
|
6
|
+
- Update YARD tags on Pin::Block methods (#588)
|
7
|
+
- @!visibility directive support (#566)
|
8
|
+
|
9
|
+
## 0.46.0 - August 22, 2022
|
10
|
+
- Ignore typecheck errors with @sg-ignore tag (#419)
|
11
|
+
- Strict checks report undefined method calls on variables (#553)
|
12
|
+
- Infer type from method arguments (#554)
|
13
|
+
- Return nil value for empty hover contents (#543)
|
14
|
+
|
1
15
|
## 0.45.0 - May 23, 2022
|
2
16
|
- Basic support for RSpec #describe and #it
|
3
17
|
- fix: domain can complete private method (#490)
|
data/SPONSORS.md
CHANGED
data/lib/solargraph/api_map.rb
CHANGED
@@ -21,6 +21,9 @@ module Solargraph
|
|
21
21
|
# @return [Array<String>]
|
22
22
|
attr_reader :unresolved_requires
|
23
23
|
|
24
|
+
# @return [Array<String>]
|
25
|
+
attr_reader :missing_docs
|
26
|
+
|
24
27
|
# @param pins [Array<Solargraph::Pin::Base>]
|
25
28
|
def initialize pins: []
|
26
29
|
@source_map_hash = {}
|
@@ -68,6 +71,7 @@ module Solargraph
|
|
68
71
|
yard_map.change(external_requires, bench.workspace.directory, bench.workspace.source_gems)
|
69
72
|
@store = Store.new(yard_map.pins + implicit.pins + pins)
|
70
73
|
@unresolved_requires = yard_map.unresolved_requires
|
74
|
+
@missing_docs = yard_map.missing_docs
|
71
75
|
@rebindable_method_names = nil
|
72
76
|
store.block_pins.each { |blk| blk.rebind(self) }
|
73
77
|
self
|
@@ -281,33 +285,33 @@ module Solargraph
|
|
281
285
|
# type = Solargraph::ComplexType.parse('String')
|
282
286
|
# api_map.get_complex_type_methods(type)
|
283
287
|
#
|
284
|
-
# @param
|
288
|
+
# @param complex_type [Solargraph::ComplexType] The complex type of the namespace
|
285
289
|
# @param context [String] The context from which the type is referenced
|
286
290
|
# @param internal [Boolean] True to include private methods
|
287
291
|
# @return [Array<Solargraph::Pin::Base>]
|
288
|
-
def get_complex_type_methods
|
292
|
+
def get_complex_type_methods complex_type, context = '', internal = false
|
289
293
|
# This method does not qualify the complex type's namespace because
|
290
294
|
# it can cause conflicts between similar names, e.g., `Foo` vs.
|
291
295
|
# `Other::Foo`. It still takes a context argument to determine whether
|
292
296
|
# protected and private methods are visible.
|
293
|
-
return [] if
|
294
|
-
result =
|
295
|
-
|
296
|
-
type.
|
297
|
-
result.
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
297
|
+
return [] if complex_type.undefined? || complex_type.void?
|
298
|
+
result = Set.new
|
299
|
+
complex_type.each do |type|
|
300
|
+
if type.duck_type?
|
301
|
+
result.add Pin::DuckMethod.new(name: type.to_s[1..-1])
|
302
|
+
result.merge get_methods('Object')
|
303
|
+
else
|
304
|
+
unless type.nil? || type.name == 'void'
|
305
|
+
visibility = [:public]
|
306
|
+
if type.namespace == context || super_and_sub?(type.namespace, context)
|
307
|
+
visibility.push :protected
|
308
|
+
visibility.push :private if internal
|
309
|
+
end
|
310
|
+
result.merge get_methods(type.namespace, scope: type.scope, visibility: visibility)
|
306
311
|
end
|
307
|
-
result.concat get_methods(type.namespace, scope: type.scope, visibility: visibility)
|
308
312
|
end
|
309
313
|
end
|
310
|
-
result
|
314
|
+
result.to_a
|
311
315
|
end
|
312
316
|
|
313
317
|
# Get a stack of method pins for a method name in a namespace. The order
|
@@ -383,9 +387,10 @@ module Solargraph
|
|
383
387
|
# @param query [String]
|
384
388
|
# @return [Array<Pin::Base>]
|
385
389
|
def query_symbols query
|
386
|
-
|
387
|
-
|
388
|
-
|
390
|
+
Pin::Search.new(
|
391
|
+
source_map_hash.values.flat_map(&:document_symbols),
|
392
|
+
query
|
393
|
+
).results
|
389
394
|
end
|
390
395
|
|
391
396
|
# @param location [Solargraph::Location]
|
@@ -154,9 +154,9 @@ module Solargraph
|
|
154
154
|
subtype_string.clear
|
155
155
|
next
|
156
156
|
else
|
157
|
+
raise ComplexTypeError, "Invalid close in type #{type_string}" if point_stack == 0
|
157
158
|
point_stack -= 1
|
158
|
-
subtype_string += char
|
159
|
-
raise ComplexTypeError, "Invalid close in type #{type_string}" if point_stack < 0
|
159
|
+
subtype_string += char
|
160
160
|
end
|
161
161
|
next
|
162
162
|
elsif char == '{'
|
@@ -12,6 +12,10 @@ module Solargraph
|
|
12
12
|
refs = {}
|
13
13
|
map = api_map.source_map(source.filename)
|
14
14
|
map.requires.each { |ref| refs[ref.name] = ref }
|
15
|
+
api_map.missing_docs.each do |r|
|
16
|
+
next unless refs.key?(r)
|
17
|
+
result.push docs_error(r, refs[r].location)
|
18
|
+
end
|
15
19
|
api_map.unresolved_requires.each do |r|
|
16
20
|
next unless refs.key?(r)
|
17
21
|
result.push require_error(r, refs[r].location)
|
@@ -21,6 +25,18 @@ module Solargraph
|
|
21
25
|
|
22
26
|
private
|
23
27
|
|
28
|
+
# @param path [String]
|
29
|
+
# @param location [Location]
|
30
|
+
# @return [Hash]
|
31
|
+
def docs_error path, location
|
32
|
+
{
|
33
|
+
range: location.range.to_hash,
|
34
|
+
severity: Diagnostics::Severities::WARNING,
|
35
|
+
source: 'RequireNotFound',
|
36
|
+
message: "YARD docs not found for #{path}"
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
24
40
|
# @param path [String]
|
25
41
|
# @param location [Location]
|
26
42
|
# @return [Hash]
|
@@ -27,16 +27,28 @@ module Solargraph
|
|
27
27
|
last_link = this_link unless this_link.nil?
|
28
28
|
end
|
29
29
|
set_result(
|
30
|
-
contents
|
31
|
-
kind: 'markdown',
|
32
|
-
value: contents.join("\n\n")
|
33
|
-
}
|
30
|
+
contents_or_nil(contents)
|
34
31
|
)
|
35
32
|
rescue FileNotFoundError => e
|
36
33
|
Logging.logger.warn "[#{e.class}] #{e.message}"
|
37
34
|
Logging.logger.warn e.backtrace.join("\n")
|
38
35
|
set_result nil
|
39
36
|
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def contents_or_nil contents
|
41
|
+
stripped = contents
|
42
|
+
.map(&:strip)
|
43
|
+
.reject { |c| c.empty? }
|
44
|
+
return nil if stripped.empty?
|
45
|
+
{
|
46
|
+
contents: {
|
47
|
+
kind: 'markdown',
|
48
|
+
value: stripped.join("\n\n")
|
49
|
+
}
|
50
|
+
}
|
51
|
+
end
|
40
52
|
end
|
41
53
|
end
|
42
54
|
end
|
@@ -8,7 +8,7 @@ class Solargraph::LanguageServer::Message::Workspace::WorkspaceSymbol < Solargra
|
|
8
8
|
info = pins.map do |pin|
|
9
9
|
uri = file_to_uri(pin.location.filename)
|
10
10
|
{
|
11
|
-
name: pin.
|
11
|
+
name: pin.path,
|
12
12
|
containerName: pin.namespace,
|
13
13
|
kind: pin.symbol_kind,
|
14
14
|
location: {
|
@@ -11,8 +11,8 @@ module Solargraph
|
|
11
11
|
closure: region.closure,
|
12
12
|
comments: comments_for(node),
|
13
13
|
name: node.children[0].children[0].to_s,
|
14
|
-
|
15
|
-
asgn_code: require_keyword?(node) ? nil: region.code_for(node.children[0].children[1]),
|
14
|
+
assignment: require_keyword?(node) ? nil : node.children[0].children[1],
|
15
|
+
asgn_code: require_keyword?(node) ? nil : region.code_for(node.children[0].children[1]),
|
16
16
|
presence: region.closure.location.range,
|
17
17
|
decl: require_keyword?(node) ? :kwarg : :kwoptarg
|
18
18
|
)
|
data/lib/solargraph/pin/block.rb
CHANGED
@@ -8,6 +8,7 @@ module Solargraph
|
|
8
8
|
# @return [Parser::AST::Node]
|
9
9
|
attr_reader :receiver
|
10
10
|
|
11
|
+
# @param args [Array<Parameter>]
|
11
12
|
def initialize receiver: nil, args: [], context: nil, **splat
|
12
13
|
super(**splat)
|
13
14
|
@receiver = receiver
|
@@ -25,7 +26,7 @@ module Solargraph
|
|
25
26
|
@binder || closure.binder
|
26
27
|
end
|
27
28
|
|
28
|
-
# @return [Array<
|
29
|
+
# @return [Array<Parameter>]
|
29
30
|
def parameters
|
30
31
|
@parameters ||= []
|
31
32
|
end
|
@@ -3,8 +3,10 @@
|
|
3
3
|
module Solargraph
|
4
4
|
module Pin
|
5
5
|
class Parameter < LocalVariable
|
6
|
+
# @return [Symbol]
|
6
7
|
attr_reader :decl
|
7
8
|
|
9
|
+
# @return [String]
|
8
10
|
attr_reader :asgn_code
|
9
11
|
|
10
12
|
def initialize decl: :arg, asgn_code: nil, **splat
|
@@ -91,10 +93,6 @@ module Solargraph
|
|
91
93
|
true
|
92
94
|
end
|
93
95
|
|
94
|
-
def probe api_map
|
95
|
-
typify api_map
|
96
|
-
end
|
97
|
-
|
98
96
|
private
|
99
97
|
|
100
98
|
# @return [YARD::Tags::Tag]
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'jaro_winkler'
|
4
|
+
|
5
|
+
module Solargraph
|
6
|
+
module Pin
|
7
|
+
class Search
|
8
|
+
class Result
|
9
|
+
# @return [Float]
|
10
|
+
attr_reader :match
|
11
|
+
|
12
|
+
# @return [Pin::Base]
|
13
|
+
attr_reader :pin
|
14
|
+
|
15
|
+
def initialize match, pin
|
16
|
+
@match = match
|
17
|
+
@pin = pin
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# @param pins [Array<Pin::Base>]
|
22
|
+
# @param query [String]
|
23
|
+
def initialize pins, query
|
24
|
+
@pins = pins
|
25
|
+
@query = query
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [Array<Pin::Base>]
|
29
|
+
def results
|
30
|
+
@results ||= do_query
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
# @return [Array<Pin::Base>]
|
36
|
+
def do_query
|
37
|
+
return @pins if @query.nil? || @query.empty?
|
38
|
+
@pins.map do |pin|
|
39
|
+
match = [fuzzy_string_match(pin.path, @query), fuzzy_string_match(pin.name, @query)].max
|
40
|
+
Result.new(match, pin) if match > 0.7
|
41
|
+
end
|
42
|
+
.compact
|
43
|
+
.sort { |a, b| b.match <=> a.match }
|
44
|
+
.map(&:pin)
|
45
|
+
end
|
46
|
+
|
47
|
+
# @param str1 [String]
|
48
|
+
# @param str2 [String]
|
49
|
+
# @return [Float]
|
50
|
+
def fuzzy_string_match str1, str2
|
51
|
+
return (1.0 + (str2.length.to_f / str1.length.to_f)) if str1.downcase.include?(str2.downcase)
|
52
|
+
JaroWinkler.distance(str1, str2, ignore_case: true)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/solargraph/pin.rb
CHANGED
@@ -30,6 +30,7 @@ module Solargraph
|
|
30
30
|
autoload :DuckMethod, 'solargraph/pin/duck_method'
|
31
31
|
autoload :Singleton, 'solargraph/pin/singleton'
|
32
32
|
autoload :KeywordParam, 'solargraph/pin/keyword_param'
|
33
|
+
autoload :Search, 'solargraph/pin/search'
|
33
34
|
|
34
35
|
ROOT_PIN = Pin::Namespace.new(type: :class, name: '', closure: nil)
|
35
36
|
end
|
data/lib/solargraph/shell.rb
CHANGED
@@ -175,7 +175,11 @@ module Solargraph
|
|
175
175
|
api_map = nil
|
176
176
|
time = Benchmark.measure {
|
177
177
|
api_map = Solargraph::ApiMap.load(directory)
|
178
|
-
api_map.pins
|
178
|
+
pins = api_map.pins
|
179
|
+
api_map.source_maps.each do |sm|
|
180
|
+
pins.concat sm.locals
|
181
|
+
end
|
182
|
+
pins.each do |pin|
|
179
183
|
begin
|
180
184
|
puts pin_description(pin) if options[:verbose]
|
181
185
|
pin.typify api_map
|
data/lib/solargraph/source.rb
CHANGED
@@ -45,6 +45,8 @@ module Solargraph
|
|
45
45
|
@node, @comments = Solargraph::Parser.parse_with_comments(@code, filename)
|
46
46
|
@parsed = true
|
47
47
|
rescue Parser::SyntaxError, EncodingError => e
|
48
|
+
puts "[#{e.class}] #{e.message}"
|
49
|
+
puts e.backtrace
|
48
50
|
@node = nil
|
49
51
|
@comments = {}
|
50
52
|
@parsed = false
|
@@ -360,7 +362,7 @@ module Solargraph
|
|
360
362
|
skip = nil
|
361
363
|
comments.lines.each { |l|
|
362
364
|
# Trim the comment and minimum leading whitespace
|
363
|
-
p = l.encode('UTF-8', invalid: :replace, replace: '?').gsub(/^#+/, '')
|
365
|
+
p = l.force_encoding('UTF-8').encode('UTF-8', invalid: :replace, replace: '?').gsub(/^#+/, '')
|
364
366
|
if p.strip.empty?
|
365
367
|
next unless started
|
366
368
|
ctxt.concat p
|
@@ -12,7 +12,7 @@ module Solargraph
|
|
12
12
|
|
13
13
|
private_class_method :new
|
14
14
|
|
15
|
-
MACRO_REGEXP = /(@\!method|@\!attribute|@\!domain|@\!macro|@\!parse|@\!override)/.freeze
|
15
|
+
MACRO_REGEXP = /(@\!method|@\!attribute|@\!visibility|@\!domain|@\!macro|@\!parse|@\!override)/.freeze
|
16
16
|
|
17
17
|
# Generate the data.
|
18
18
|
#
|
@@ -56,8 +56,10 @@ module Solargraph
|
|
56
56
|
@pins ||= []
|
57
57
|
end
|
58
58
|
|
59
|
+
# @param position [Solargraph::Position]
|
60
|
+
# @return [Solargraph::Pin::Closure]
|
59
61
|
def closure_at(position)
|
60
|
-
|
62
|
+
pins.select{|pin| pin.is_a?(Pin::Closure) and pin.location.range.contain?(position)}.last
|
61
63
|
end
|
62
64
|
|
63
65
|
def process_comment source_position, comment_position, comment
|
@@ -147,6 +149,27 @@ module Solargraph
|
|
147
149
|
pins.last.docstring.add_tag YARD::Tags::Tag.new(:param, '', pins.last.return_type.to_s.split(', '), 'value')
|
148
150
|
end
|
149
151
|
end
|
152
|
+
when 'visibility'
|
153
|
+
begin
|
154
|
+
kind = directive.tag.text&.to_sym
|
155
|
+
return unless [:private, :protected, :public].include?(kind)
|
156
|
+
|
157
|
+
name = directive.tag.name
|
158
|
+
closure = closure_at(source_position) || @pins.first
|
159
|
+
if closure.location.range.start.line < comment_position.line
|
160
|
+
closure = closure_at(comment_position)
|
161
|
+
end
|
162
|
+
if closure.is_a?(Pin::Method) && no_empty_lines?(comment_position.line, source_position.line)
|
163
|
+
# @todo Smelly instance variable access
|
164
|
+
closure.instance_variable_set(:@visibility, kind)
|
165
|
+
else
|
166
|
+
matches = pins.select{ |pin| pin.is_a?(Pin::Method) && pin.name == name && pin.namespace == namespace && pin.context.scope == namespace.is_a?(Pin::Singleton) ? :class : :instance }
|
167
|
+
matches.each do |pin|
|
168
|
+
# @todo Smelly instance variable access
|
169
|
+
pin.instance_variable_set(:@visibility, kind)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
150
173
|
when 'parse'
|
151
174
|
begin
|
152
175
|
ns = closure_at(source_position)
|
@@ -176,6 +199,10 @@ module Solargraph
|
|
176
199
|
end
|
177
200
|
end
|
178
201
|
|
202
|
+
def no_empty_lines?(line1, line2)
|
203
|
+
@code.lines[line1..line2].none? { |line| line.strip.empty? }
|
204
|
+
end
|
205
|
+
|
179
206
|
def remove_inline_comment_hashes comment
|
180
207
|
ctxt = ''
|
181
208
|
num = nil
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'jaro_winkler'
|
4
3
|
require 'yard'
|
5
4
|
require 'yard-solargraph'
|
6
5
|
require 'set'
|
@@ -76,8 +75,7 @@ module Solargraph
|
|
76
75
|
# @param query [String]
|
77
76
|
# @return [Array<Pin::Base>]
|
78
77
|
def query_symbols query
|
79
|
-
|
80
|
-
document_symbols.select{ |pin| fuzzy_string_match(pin.path, query) || fuzzy_string_match(pin.name, query) }
|
78
|
+
Pin::Search.new(document_symbols, query).results
|
81
79
|
end
|
82
80
|
|
83
81
|
# @param position [Position]
|
@@ -178,12 +176,5 @@ module Solargraph
|
|
178
176
|
# Assuming the root pin is always valid
|
179
177
|
found || pins.first
|
180
178
|
end
|
181
|
-
|
182
|
-
# @param str1 [String]
|
183
|
-
# @param str2 [String]
|
184
|
-
# @return [Boolean]
|
185
|
-
def fuzzy_string_match str1, str2
|
186
|
-
JaroWinkler.distance(str1, str2) > 0.6
|
187
|
-
end
|
188
179
|
end
|
189
180
|
end
|
@@ -40,10 +40,12 @@ module Solargraph
|
|
40
40
|
# @return [Array<Problem>]
|
41
41
|
def problems
|
42
42
|
@problems ||= begin
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
without_ignored(
|
44
|
+
method_tag_problems
|
45
|
+
.concat variable_type_tag_problems
|
46
|
+
.concat const_problems
|
47
|
+
.concat call_problems
|
48
|
+
)
|
47
49
|
end
|
48
50
|
end
|
49
51
|
|
@@ -118,7 +120,12 @@ module Solargraph
|
|
118
120
|
# @param pin [Pin::Base]
|
119
121
|
# @return [Boolean]
|
120
122
|
def resolved_constant? pin
|
121
|
-
api_map.get_constants('', pin.binder.tag)
|
123
|
+
api_map.get_constants('', pin.binder.tag)
|
124
|
+
.select { |p| p.name == pin.return_type.namespace }
|
125
|
+
.any? do |p|
|
126
|
+
inferred = p.infer(api_map)
|
127
|
+
['Class', 'Module'].include?(inferred.name)
|
128
|
+
end
|
122
129
|
end
|
123
130
|
|
124
131
|
def virtual_pin? pin
|
@@ -235,7 +242,7 @@ module Solargraph
|
|
235
242
|
base = base.base
|
236
243
|
end
|
237
244
|
closest = found.typify(api_map) if found
|
238
|
-
if !found || (closest.defined? && internal_or_core?(found))
|
245
|
+
if !found || found.is_a?(Pin::BaseVariable) || (closest.defined? && internal_or_core?(found))
|
239
246
|
unless ignored_pins.include?(found)
|
240
247
|
result.push Problem.new(location, "Unresolved call to #{missing.links.last.word}")
|
241
248
|
@marked_ranges.push rng
|
@@ -525,5 +532,12 @@ module Solargraph
|
|
525
532
|
args.push Solargraph::Parser.chain_string('&') if with_block
|
526
533
|
args
|
527
534
|
end
|
535
|
+
|
536
|
+
def without_ignored problems
|
537
|
+
problems.reject do |problem|
|
538
|
+
node = source_map.source.node_at(problem.location.range.start.line, problem.location.range.start.column)
|
539
|
+
source_map.source.comments_for(node)&.include?('@sg-ignore')
|
540
|
+
end
|
541
|
+
end
|
528
542
|
end
|
529
543
|
end
|
data/lib/solargraph/version.rb
CHANGED
data/lib/solargraph/workspace.rb
CHANGED
data/lib/solargraph/yard_map.rb
CHANGED
@@ -107,6 +107,11 @@ module Solargraph
|
|
107
107
|
@unresolved_requires ||= []
|
108
108
|
end
|
109
109
|
|
110
|
+
# @return [Array<String>]
|
111
|
+
def missing_docs
|
112
|
+
@missing_docs ||= []
|
113
|
+
end
|
114
|
+
|
110
115
|
# @param y [String]
|
111
116
|
# @return [YARD::Registry]
|
112
117
|
def load_yardoc y
|
@@ -196,10 +201,11 @@ module Solargraph
|
|
196
201
|
required.merge @gemset.keys if required.include?('bundler/require')
|
197
202
|
pins.replace core_pins
|
198
203
|
unresolved_requires.clear
|
204
|
+
missing_docs.clear
|
199
205
|
stdlib_pins.clear
|
200
206
|
environ = Convention.for_global(self)
|
201
207
|
done = []
|
202
|
-
|
208
|
+
already_errored = []
|
203
209
|
(required + environ.requires).each do |r|
|
204
210
|
next if r.nil? || r.empty? || done.include?(r)
|
205
211
|
done.push r
|
@@ -219,24 +225,18 @@ module Solargraph
|
|
219
225
|
# YARD detects gems for certain libraries that do not have a yardoc
|
220
226
|
# but exist in the stdlib. `fileutils` is an example. Treat those
|
221
227
|
# cases as errors and check the stdlib yardoc.
|
222
|
-
|
228
|
+
if yd.nil?
|
229
|
+
process_error(r, result, already_errored, nil)
|
230
|
+
next
|
231
|
+
end
|
223
232
|
@gem_paths[spec.name] = spec.full_gem_path
|
224
233
|
unless yardocs.include?(yd)
|
225
234
|
yardocs.unshift yd
|
226
235
|
result.concat process_yardoc yd, spec
|
227
236
|
result.concat add_gem_dependencies(spec) if with_dependencies?
|
228
237
|
end
|
229
|
-
rescue Gem::LoadError, NoYardocError
|
230
|
-
|
231
|
-
next if from_std.include?(base)
|
232
|
-
from_std.push base
|
233
|
-
stdtmp = load_stdlib_pins(base)
|
234
|
-
if stdtmp.empty?
|
235
|
-
unresolved_requires.push r
|
236
|
-
else
|
237
|
-
stdlib_pins.concat stdtmp
|
238
|
-
result.concat stdtmp
|
239
|
-
end
|
238
|
+
rescue Gem::LoadError, NoYardocError
|
239
|
+
process_error(r, result, already_errored)
|
240
240
|
end
|
241
241
|
result.delete_if(&:nil?)
|
242
242
|
unless result.empty?
|
@@ -253,6 +253,21 @@ module Solargraph
|
|
253
253
|
pins.concat environ.pins
|
254
254
|
end
|
255
255
|
|
256
|
+
def process_error(req, result, already_errored, yd = 1)
|
257
|
+
base = req.split('/').first
|
258
|
+
return if already_errored.include?(base)
|
259
|
+
already_errored.push base
|
260
|
+
stdtmp = load_stdlib_pins(base)
|
261
|
+
if yd.nil?
|
262
|
+
missing_docs.push req
|
263
|
+
elsif stdtmp.empty?
|
264
|
+
unresolved_requires.push req
|
265
|
+
else
|
266
|
+
stdlib_pins.concat stdtmp
|
267
|
+
result.concat stdtmp
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
256
271
|
def process_gemsets
|
257
272
|
return {} if directory.empty? || !File.file?(File.join(directory, 'Gemfile'))
|
258
273
|
require_from_bundle(directory)
|
@@ -270,7 +285,7 @@ module Solargraph
|
|
270
285
|
@gem_paths[depspec.name] = depspec.full_gem_path
|
271
286
|
gy = yardoc_file_for_spec(depspec)
|
272
287
|
if gy.nil?
|
273
|
-
|
288
|
+
missing_docs.push dep.name
|
274
289
|
else
|
275
290
|
next if yardocs.include?(gy)
|
276
291
|
yardocs.unshift gy
|
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.47.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: 2022-
|
11
|
+
date: 2022-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backport
|
@@ -492,6 +492,7 @@ files:
|
|
492
492
|
- lib/solargraph/pin/reference/prepend.rb
|
493
493
|
- lib/solargraph/pin/reference/require.rb
|
494
494
|
- lib/solargraph/pin/reference/superclass.rb
|
495
|
+
- lib/solargraph/pin/search.rb
|
495
496
|
- lib/solargraph/pin/singleton.rb
|
496
497
|
- lib/solargraph/pin/symbol.rb
|
497
498
|
- lib/solargraph/position.rb
|