solargraph 0.38.2 → 0.38.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/Gemfile +2 -0
- data/lib/solargraph.rb +1 -2
- data/lib/solargraph/api_map.rb +30 -23
- data/lib/solargraph/api_map/store.rb +2 -0
- data/lib/solargraph/core_fills.rb +10 -2
- data/lib/solargraph/pin/base_method.rb +3 -3
- data/lib/solargraph/pin/common.rb +14 -1
- data/lib/solargraph/pin/localized.rb +17 -2
- data/lib/solargraph/pin/method.rb +8 -12
- data/lib/solargraph/pin/yard_pin/namespace.rb +2 -2
- data/lib/solargraph/source/chain.rb +10 -2
- data/lib/solargraph/source/chain/call.rb +6 -7
- data/lib/solargraph/source/chain/link.rb +29 -0
- data/lib/solargraph/source/node_chainer.rb +2 -2
- data/lib/solargraph/source/node_methods.rb +2 -1
- data/lib/solargraph/stdlib_fills.rb +32 -0
- data/lib/solargraph/type_checker.rb +2 -2
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/yard_map.rb +32 -4
- data/lib/solargraph/yard_map/mapper.rb +1 -3
- 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: b938f9be15a1bf0d05152f83b00bb4b04018b37b3da1ab921963f57d7a837484
|
4
|
+
data.tar.gz: 8dc52f3e77661d53fd107610e33441f94cab71c4529e47559cbcb055bf04fddd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5d48c9e67760aca62df62495ce1ad372327f556462498e7aaf9149eabc047be796a8c59dd5ea2874aa88827fcc204059f18f74f32ed4ed4912e49c7986ae783
|
7
|
+
data.tar.gz: 27fa823a0b024ee78aafbfc69d6ea555351155bf6a963abcd9f94a1d15e79ca630f5b32cb0acfe97192e5ef0e0d8d730d34f4bcd9091cb91c699f8684930554e
|
data/Gemfile
CHANGED
data/lib/solargraph.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# require 'yard'
|
4
3
|
require 'solargraph/version'
|
5
|
-
# require 'yard-solargraph'
|
6
4
|
|
7
5
|
# The top-level namespace for the Solargraph code mapping, documentation,
|
8
6
|
# static analysis, and language server libraries.
|
@@ -27,6 +25,7 @@ module Solargraph
|
|
27
25
|
autoload :Pin, 'solargraph/pin'
|
28
26
|
autoload :ServerMethods, 'solargraph/server_methods'
|
29
27
|
autoload :CoreFills, 'solargraph/core_fills'
|
28
|
+
autoload :StdlibFills, 'solargraph/stdlib_fills'
|
30
29
|
autoload :LanguageServer, 'solargraph/language_server'
|
31
30
|
autoload :Workspace, 'solargraph/workspace'
|
32
31
|
autoload :Page, 'solargraph/page'
|
data/lib/solargraph/api_map.rb
CHANGED
@@ -93,34 +93,35 @@ module Solargraph
|
|
93
93
|
return self if merged
|
94
94
|
implicit.clear
|
95
95
|
pins = []
|
96
|
-
reqs =
|
96
|
+
reqs = Set.new
|
97
97
|
# @param map [SourceMap]
|
98
98
|
new_map_hash.values.each do |map|
|
99
99
|
implicit.merge map.environ
|
100
100
|
pins.concat map.pins
|
101
|
-
reqs.
|
101
|
+
reqs.merge map.requires.map(&:name)
|
102
102
|
end
|
103
|
-
reqs.
|
103
|
+
reqs.merge bundle.workspace.config.required
|
104
104
|
local_path_hash.clear
|
105
105
|
unless bundle.workspace.require_paths.empty?
|
106
|
+
file_keys = new_map_hash.keys
|
107
|
+
workspace_path = Pathname.new(bundle.workspace.directory)
|
106
108
|
reqs.delete_if do |r|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
109
|
+
bundle.workspace.require_paths.any? do |base|
|
110
|
+
pn = workspace_path.join(base, "#{r}.rb").to_s
|
111
|
+
if file_keys.include? pn
|
112
|
+
local_path_hash[r] = pn
|
113
|
+
true
|
114
|
+
else
|
115
|
+
false
|
114
116
|
end
|
115
117
|
end
|
116
|
-
result
|
117
118
|
end
|
118
119
|
end
|
119
|
-
reqs.
|
120
|
+
reqs.merge implicit.requires
|
120
121
|
pins.concat implicit.overrides
|
121
122
|
br = reqs.include?('bundler/require') ? require_from_bundle(bundle.workspace.directory) : {}
|
122
|
-
reqs.
|
123
|
-
yard_map.change(reqs, br)
|
123
|
+
reqs.merge br.keys
|
124
|
+
yard_map.change(reqs.to_a, br)
|
124
125
|
new_store = Store.new(pins + yard_map.pins)
|
125
126
|
@mutex.synchronize {
|
126
127
|
@cache.clear
|
@@ -567,27 +568,30 @@ module Solargraph
|
|
567
568
|
result = []
|
568
569
|
result.concat store.get_methods(fqns, scope: scope, visibility: visibility).sort{ |a, b| a.name <=> b.name }
|
569
570
|
if deep
|
570
|
-
sc = store.get_superclass(fqns)
|
571
|
-
unless sc.nil?
|
572
|
-
fqsc = qualify(sc, fqns.split('::')[0..-2].join('::'))
|
573
|
-
result.concat inner_get_methods(fqsc, scope, visibility, true, skip, true) unless fqsc.nil?
|
574
|
-
end
|
575
571
|
if scope == :instance
|
576
572
|
store.get_includes(fqns).reverse.each do |im|
|
577
573
|
fqim = qualify(im, fqns)
|
578
574
|
result.concat inner_get_methods(fqim, scope, visibility, deep, skip, true) unless fqim.nil?
|
579
575
|
end
|
580
|
-
|
581
|
-
|
576
|
+
sc = store.get_superclass(fqns)
|
577
|
+
unless sc.nil?
|
578
|
+
fqsc = qualify(sc, fqns.split('::')[0..-2].join('::'))
|
579
|
+
result.concat inner_get_methods(fqsc, scope, visibility, true, skip, no_core) unless fqsc.nil?
|
580
|
+
end
|
582
581
|
else
|
583
582
|
store.get_extends(fqns).reverse.each do |em|
|
584
583
|
fqem = qualify(em, fqns)
|
585
584
|
result.concat inner_get_methods(fqem, :instance, visibility, deep, skip, true) unless fqem.nil?
|
586
585
|
end
|
586
|
+
sc = store.get_superclass(fqns)
|
587
|
+
unless sc.nil?
|
588
|
+
fqsc = qualify(sc, fqns.split('::')[0..-2].join('::'))
|
589
|
+
result.concat inner_get_methods(fqsc, scope, visibility, true, skip, true) unless fqsc.nil?
|
590
|
+
end
|
587
591
|
unless no_core || fqns.empty?
|
588
592
|
type = get_namespace_type(fqns)
|
589
593
|
result.concat inner_get_methods('Class', :instance, visibility, deep, skip, no_core) if type == :class
|
590
|
-
result.concat inner_get_methods('Module', :instance,visibility, deep, skip, no_core)
|
594
|
+
result.concat inner_get_methods('Module', :instance, visibility, deep, skip, no_core)
|
591
595
|
end
|
592
596
|
end
|
593
597
|
store.domains(fqns).each do |d|
|
@@ -610,7 +614,10 @@ module Solargraph
|
|
610
614
|
store.get_includes(fqns).each do |is|
|
611
615
|
result.concat inner_get_constants(qualify(is, fqns), [:public], skip)
|
612
616
|
end
|
613
|
-
|
617
|
+
sc = store.get_superclass(fqns)
|
618
|
+
unless %w[Object BasicObject].include?(sc)
|
619
|
+
result.concat inner_get_constants(store.get_superclass(fqns), [:public], skip)
|
620
|
+
end
|
614
621
|
result
|
615
622
|
end
|
616
623
|
|
@@ -37,6 +37,8 @@ module Solargraph
|
|
37
37
|
# @return [String]
|
38
38
|
def get_superclass fqns
|
39
39
|
return superclass_references[fqns].first if superclass_references.key?(fqns)
|
40
|
+
return 'Object' if fqns != 'BasicObject' && namespace_exists?(fqns)
|
41
|
+
return 'Object' if fqns == 'Boolean'
|
40
42
|
nil
|
41
43
|
end
|
42
44
|
|
@@ -1,6 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Solargraph
|
4
|
+
# Overrides for the Ruby core.
|
5
|
+
#
|
6
|
+
# The YardMap uses this module to add type information to core methods.
|
7
|
+
#
|
4
8
|
module CoreFills
|
5
9
|
Override = Pin::Reference::Override
|
6
10
|
|
@@ -13,8 +17,8 @@ module Solargraph
|
|
13
17
|
].freeze
|
14
18
|
|
15
19
|
methods_with_yieldparam_subtypes = %w[
|
16
|
-
Array#each Array#map Array#any? Array#all? Array#index
|
17
|
-
Array#delete_if
|
20
|
+
Array#each Array#map Array#map! Array#any? Array#all? Array#index
|
21
|
+
Array#keep_if Array#delete_if
|
18
22
|
Enumerable#each_entry Enumerable#map Enumerable#any? Enumerable#all?
|
19
23
|
Enumerable#select Enumerable#reject
|
20
24
|
Set#each
|
@@ -74,7 +78,11 @@ module Solargraph
|
|
74
78
|
|
75
79
|
Override.method_return('Enumerable#select', 'self'),
|
76
80
|
|
81
|
+
Override.method_return('File.absolute_path', 'String'),
|
82
|
+
Override.method_return('File.basename', 'String'),
|
77
83
|
Override.method_return('File.dirname', 'String'),
|
84
|
+
Override.method_return('File.extname', 'String'),
|
85
|
+
Override.method_return('File.join', 'String'),
|
78
86
|
|
79
87
|
Override.from_comment('Hash#[]', %(
|
80
88
|
@return_value_parameter
|
@@ -66,9 +66,9 @@ module Solargraph
|
|
66
66
|
|
67
67
|
# @return [ComplexType]
|
68
68
|
def generate_complex_type
|
69
|
-
|
70
|
-
return ComplexType::UNDEFINED if
|
71
|
-
ComplexType.try_parse *
|
69
|
+
tags = docstring.tags(:return).map(&:types).flatten.reject(&:nil?)
|
70
|
+
return ComplexType::UNDEFINED if tags.empty?
|
71
|
+
ComplexType.try_parse *tags
|
72
72
|
end
|
73
73
|
|
74
74
|
# @param api_map [ApiMap]
|
@@ -3,6 +3,7 @@
|
|
3
3
|
module Solargraph
|
4
4
|
module Pin
|
5
5
|
module Common
|
6
|
+
# @return [Location]
|
6
7
|
attr_reader :location
|
7
8
|
|
8
9
|
# @return [Pin::Base, nil]
|
@@ -13,6 +14,7 @@ module Solargraph
|
|
13
14
|
@name ||= ''
|
14
15
|
end
|
15
16
|
|
17
|
+
# @return [ComplexType]
|
16
18
|
def return_type
|
17
19
|
@return_type ||= ComplexType::UNDEFINED
|
18
20
|
end
|
@@ -24,6 +26,7 @@ module Solargraph
|
|
24
26
|
end
|
25
27
|
alias full_context context
|
26
28
|
|
29
|
+
# @return [String]
|
27
30
|
def namespace
|
28
31
|
context.namespace.to_s
|
29
32
|
end
|
@@ -33,10 +36,12 @@ module Solargraph
|
|
33
36
|
@binder || context
|
34
37
|
end
|
35
38
|
|
39
|
+
# @return [String]
|
36
40
|
def comments
|
37
41
|
@comments ||= ''
|
38
42
|
end
|
39
43
|
|
44
|
+
# @return [String]
|
40
45
|
def path
|
41
46
|
@path ||= name.empty? ? context.namespace : "#{context.namespace}::#{name}"
|
42
47
|
end
|
@@ -47,7 +52,15 @@ module Solargraph
|
|
47
52
|
def find_context
|
48
53
|
here = closure
|
49
54
|
until here.nil?
|
50
|
-
|
55
|
+
if here.is_a?(Pin::Namespace)
|
56
|
+
return here.return_type
|
57
|
+
elsif here.is_a?(Pin::BaseMethod)
|
58
|
+
if here.scope == :instance
|
59
|
+
return ComplexType.try_parse(here.context.namespace)
|
60
|
+
else
|
61
|
+
return here.closure.return_type
|
62
|
+
end
|
63
|
+
end
|
51
64
|
here = here.closure
|
52
65
|
end
|
53
66
|
ComplexType::ROOT
|
@@ -11,9 +11,10 @@ module Solargraph
|
|
11
11
|
# @return [Boolean]
|
12
12
|
def visible_from?(other, position)
|
13
13
|
position = Position.normalize(position)
|
14
|
-
other.filename == filename
|
14
|
+
other.filename == filename &&
|
15
|
+
match_tags(other.full_context.tag, full_context.tag) &&
|
15
16
|
(other == closure ||
|
16
|
-
(closure.location.range.contain?(
|
17
|
+
(closure.location.range.contain?(other.location.range.start) && closure.location.range.contain?(other.location.range.ending))
|
17
18
|
) &&
|
18
19
|
presence.contain?(position)
|
19
20
|
end
|
@@ -23,6 +24,20 @@ module Solargraph
|
|
23
24
|
return false if location.filename != other_loc.filename
|
24
25
|
presence.include?(other_loc.range.start)
|
25
26
|
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
# @param tag1 [String]
|
31
|
+
# @param tag2 [String]
|
32
|
+
# @return [Boolean]
|
33
|
+
def match_tags tag1, tag2
|
34
|
+
# @todo This is an unfortunate hack made necessary by a discrepancy in
|
35
|
+
# how tags indicate the root namespace. The long-term solution is to
|
36
|
+
# standardize it, whether it's `Class<>`, an empty string, or
|
37
|
+
# something else.
|
38
|
+
tag1 == tag2 ||
|
39
|
+
(['', 'Class<>'].include?(tag1) && ['', 'Class<>'].include?(tag2))
|
40
|
+
end
|
26
41
|
end
|
27
42
|
end
|
28
43
|
end
|
@@ -81,18 +81,14 @@ module Solargraph
|
|
81
81
|
has_nil = true
|
82
82
|
next
|
83
83
|
end
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
)
|
93
|
-
type = clip.infer
|
94
|
-
result.push type unless type.undefined?
|
95
|
-
end
|
84
|
+
next if n.loc.nil? || n.loc.expression.nil?
|
85
|
+
clip = api_map.clip_at(
|
86
|
+
location.filename,
|
87
|
+
[n.loc.expression.last_line, n.loc.expression.last_column]
|
88
|
+
)
|
89
|
+
chain = Solargraph::Source::NodeChainer.chain(n, location.filename)
|
90
|
+
type = chain.infer(api_map, self, clip.locals)
|
91
|
+
result.push type unless type.undefined?
|
96
92
|
end
|
97
93
|
result.push ComplexType::NIL if has_nil
|
98
94
|
return ComplexType::UNDEFINED if result.empty?
|
@@ -6,10 +6,10 @@ module Solargraph
|
|
6
6
|
class Namespace < Pin::Namespace
|
7
7
|
include YardMixin
|
8
8
|
|
9
|
-
def initialize code_object, spec
|
9
|
+
def initialize code_object, spec, closure = nil
|
10
10
|
@code_object = code_object
|
11
11
|
@spec = spec
|
12
|
-
closure
|
12
|
+
closure ||= Solargraph::Pin::Namespace.new(
|
13
13
|
name: code_object.namespace.to_s,
|
14
14
|
closure: Pin::ROOT_PIN,
|
15
15
|
gates: [code_object.namespace.to_s]
|
@@ -34,8 +34,14 @@ module Solargraph
|
|
34
34
|
|
35
35
|
# @param links [Array<Chain::Link>]
|
36
36
|
def initialize links
|
37
|
-
@links = links
|
37
|
+
@links = links.clone
|
38
38
|
@links.push UNDEFINED_CALL if @links.empty?
|
39
|
+
head = true
|
40
|
+
@links.map! do |link|
|
41
|
+
result = (head ? link.clone_head : link.clone_body)
|
42
|
+
head = false
|
43
|
+
result
|
44
|
+
end
|
39
45
|
end
|
40
46
|
|
41
47
|
# @return [Chain]
|
@@ -54,7 +60,9 @@ module Solargraph
|
|
54
60
|
links[0..-2].each do |link|
|
55
61
|
pins = link.resolve(api_map, working_pin, locals)
|
56
62
|
# Locals are only used when resolving the first link
|
57
|
-
|
63
|
+
# @todo There's a problem here. Call links need to resolve arguments
|
64
|
+
# that might refer to local variables.
|
65
|
+
# locals = []
|
58
66
|
type = infer_first_defined(pins, working_pin, api_map)
|
59
67
|
return [] if type.undefined?
|
60
68
|
working_pin = Pin::ProxyType.anonymous(type)
|
@@ -14,26 +14,25 @@ module Solargraph
|
|
14
14
|
# @param arguments [Array<Chain>]
|
15
15
|
# @param with_block [Boolean] True if the chain is inside a block
|
16
16
|
# @param head [Boolean] True if the call is the start of its chain
|
17
|
-
def initialize word, arguments = [], with_block = false
|
17
|
+
def initialize word, arguments = [], with_block = false
|
18
18
|
@word = word
|
19
19
|
@arguments = arguments
|
20
20
|
@with_block = with_block
|
21
|
-
@head = head
|
22
21
|
end
|
23
22
|
|
24
23
|
def with_block?
|
25
24
|
@with_block
|
26
25
|
end
|
27
26
|
|
28
|
-
def head?
|
29
|
-
@head
|
30
|
-
end
|
31
|
-
|
32
27
|
# @param api_map [ApiMap]
|
33
28
|
# @param name_pin [Pin::Base]
|
34
29
|
# @param locals [Array<Pin::Base>]
|
35
30
|
def resolve api_map, name_pin, locals
|
36
|
-
found =
|
31
|
+
found = if head?
|
32
|
+
locals.select { |p| p.name == word }
|
33
|
+
else
|
34
|
+
[]
|
35
|
+
end
|
37
36
|
return inferred_pins(found, api_map, name_pin.context, locals) unless found.empty?
|
38
37
|
pins = api_map.get_method_stack(name_pin.binder.namespace, word, scope: name_pin.binder.scope)
|
39
38
|
pins.concat api_map.get_method_stack('Kernel', word, scope: :instance) if head?
|
@@ -28,9 +28,38 @@ module Solargraph
|
|
28
28
|
[]
|
29
29
|
end
|
30
30
|
|
31
|
+
def head?
|
32
|
+
@head ||= false
|
33
|
+
end
|
34
|
+
|
31
35
|
def == other
|
32
36
|
self.class == other.class and word == other.word
|
33
37
|
end
|
38
|
+
|
39
|
+
# Make a copy of this link marked as the head of a chain
|
40
|
+
#
|
41
|
+
# @return [self]
|
42
|
+
def clone_head
|
43
|
+
clone.mark_head(true)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Make a copy of this link unmarked as the head of a chain
|
47
|
+
#
|
48
|
+
# @return [self]
|
49
|
+
def clone_body
|
50
|
+
clone.mark_head(false)
|
51
|
+
end
|
52
|
+
|
53
|
+
protected
|
54
|
+
|
55
|
+
# Mark whether this link is the head of a chain
|
56
|
+
#
|
57
|
+
# @param bool [Boolean]
|
58
|
+
# @return [self]
|
59
|
+
def mark_head bool
|
60
|
+
@head = bool
|
61
|
+
self
|
62
|
+
end
|
34
63
|
end
|
35
64
|
end
|
36
65
|
end
|
@@ -58,13 +58,13 @@ module Solargraph
|
|
58
58
|
n.children[2..-1].each do |c|
|
59
59
|
args.push NodeChainer.chain(c)
|
60
60
|
end
|
61
|
-
result.push Chain::Call.new(n.children[1].to_s, args, @in_block || block_passed?(n)
|
61
|
+
result.push Chain::Call.new(n.children[1].to_s, args, @in_block || block_passed?(n))
|
62
62
|
elsif n.children[0].nil?
|
63
63
|
args = []
|
64
64
|
n.children[2..-1].each do |c|
|
65
65
|
args.push NodeChainer.chain(c)
|
66
66
|
end
|
67
|
-
result.push Chain::Call.new(n.children[1].to_s, args, @in_block || block_passed?(n)
|
67
|
+
result.push Chain::Call.new(n.children[1].to_s, args, @in_block || block_passed?(n))
|
68
68
|
else
|
69
69
|
raise "No idea what to do with #{n}"
|
70
70
|
end
|
@@ -162,7 +162,8 @@ module Solargraph
|
|
162
162
|
elsif node.type == :return
|
163
163
|
result.concat reduce_to_value_nodes([node.children[0]])
|
164
164
|
elsif node.type == :block
|
165
|
-
result.
|
165
|
+
result.push node
|
166
|
+
# result.concat reduce_to_value_nodes([node.children[0]])
|
166
167
|
result.concat get_return_nodes_only(node.children[2])
|
167
168
|
else
|
168
169
|
result.push node
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Solargraph
|
4
|
+
# Overrides for the Ruby stdlib.
|
5
|
+
#
|
6
|
+
# The YardMap uses this module to add type information to stdlib methods.
|
7
|
+
#
|
8
|
+
module StdlibFills
|
9
|
+
Override = Pin::Reference::Override
|
10
|
+
|
11
|
+
LIBS = {
|
12
|
+
'benchmark' => [
|
13
|
+
Override.method_return('Benchmark.measure', 'Benchmark::Tms')
|
14
|
+
],
|
15
|
+
|
16
|
+
'pathname' => [
|
17
|
+
Override.method_return('Pathname#join', 'Pathname'),
|
18
|
+
Override.method_return('Pathname#basename', 'Pathname'),
|
19
|
+
Override.method_return('Pathname#dirname', 'Pathname'),
|
20
|
+
Override.method_return('Pathname#cleanpath', 'Pathname'),
|
21
|
+
Override.method_return('Pathname#children', 'Array<Pathname>'),
|
22
|
+
Override.method_return('Pathname#entries', 'Array<Pathname>')
|
23
|
+
]
|
24
|
+
}
|
25
|
+
|
26
|
+
# @param path [String]
|
27
|
+
# @return [Array<Pin::Reference::Override>]
|
28
|
+
def self.get path
|
29
|
+
LIBS[path] || []
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -316,9 +316,9 @@ module Solargraph
|
|
316
316
|
return false unless par.duck_type?
|
317
317
|
meths = api_map.get_complex_type_methods(arg).map(&:name)
|
318
318
|
par.each do |quack|
|
319
|
-
return
|
319
|
+
return true if quack.duck_type? && meths.include?(quack.to_s[1..-1])
|
320
320
|
end
|
321
|
-
|
321
|
+
false
|
322
322
|
end
|
323
323
|
|
324
324
|
# @param pin [Pin::Base]
|
data/lib/solargraph/version.rb
CHANGED
data/lib/solargraph/yard_map.rb
CHANGED
@@ -23,8 +23,10 @@ module Solargraph
|
|
23
23
|
next if ns.nil? || ns.file.nil?
|
24
24
|
path = ns.file.sub(/^(ext|lib)\//, '').sub(/\.(rb|c)$/, '')
|
25
25
|
next if path.start_with?('-')
|
26
|
-
|
27
|
-
@@stdlib_paths[
|
26
|
+
base = path.split('/').first
|
27
|
+
@@stdlib_paths[base] ||= {}
|
28
|
+
@@stdlib_paths[base][path] ||= []
|
29
|
+
@@stdlib_paths[base][path].push ns
|
28
30
|
end
|
29
31
|
|
30
32
|
# @return [Array<String>]
|
@@ -167,6 +169,7 @@ module Solargraph
|
|
167
169
|
unresolved_requires.clear
|
168
170
|
stdnames = {}
|
169
171
|
done = []
|
172
|
+
from_std = []
|
170
173
|
required.each do |r|
|
171
174
|
next if r.nil? || r.empty? || done.include?(r)
|
172
175
|
done.push r
|
@@ -188,11 +191,19 @@ module Solargraph
|
|
188
191
|
yardocs.unshift yd
|
189
192
|
result.concat process_yardoc yd, spec
|
190
193
|
result.concat add_gem_dependencies(spec) if with_dependencies?
|
194
|
+
stdlib_fill r, result
|
191
195
|
end
|
192
196
|
rescue Gem::LoadError => e
|
197
|
+
base = r.split('/').first
|
193
198
|
stdtmp = []
|
194
|
-
@@stdlib_paths
|
195
|
-
|
199
|
+
if @@stdlib_paths[base]
|
200
|
+
@@stdlib_paths[base].each_pair do |path, objects|
|
201
|
+
next if from_std.include?(path)
|
202
|
+
if path == r || path.start_with?("#{r}/")
|
203
|
+
from_std.push path
|
204
|
+
stdtmp.concat objects
|
205
|
+
end
|
206
|
+
end
|
196
207
|
end
|
197
208
|
if stdtmp.empty?
|
198
209
|
unresolved_requires.push r
|
@@ -227,6 +238,7 @@ module Solargraph
|
|
227
238
|
result.concat Mapper.new(all).map
|
228
239
|
end
|
229
240
|
result.delete_if(&:nil?)
|
241
|
+
stdlib_fill r, result
|
230
242
|
cache.set_path_pins(r, result) unless result.empty?
|
231
243
|
pins.concat result
|
232
244
|
end
|
@@ -301,6 +313,22 @@ module Solargraph
|
|
301
313
|
end
|
302
314
|
spec
|
303
315
|
end
|
316
|
+
|
317
|
+
# @param path [String]
|
318
|
+
# @param pins [Array<Pin::Base>]
|
319
|
+
# @return [void]
|
320
|
+
def stdlib_fill path, pins
|
321
|
+
StdlibFills.get(path).each do |ovr|
|
322
|
+
pin = pins.select { |p| p.path == ovr.name }.first
|
323
|
+
next if pin.nil?
|
324
|
+
(ovr.tags.map(&:tag_name) + ovr.delete).uniq.each do |tag|
|
325
|
+
pin.docstring.delete_tags tag.to_sym
|
326
|
+
end
|
327
|
+
ovr.tags.each do |tag|
|
328
|
+
pin.docstring.add_tag(tag)
|
329
|
+
end
|
330
|
+
end
|
331
|
+
end
|
304
332
|
end
|
305
333
|
end
|
306
334
|
|
@@ -3,8 +3,6 @@
|
|
3
3
|
module Solargraph
|
4
4
|
class YardMap
|
5
5
|
class Mapper
|
6
|
-
@@object_file_cache = {}
|
7
|
-
|
8
6
|
# @param code_objects [Array<YARD::CodeObjects::Base>]
|
9
7
|
# @param spec [Gem::Specification]
|
10
8
|
def initialize code_objects, spec = nil
|
@@ -27,7 +25,7 @@ module Solargraph
|
|
27
25
|
def generate_pins code_object
|
28
26
|
result = []
|
29
27
|
if code_object.is_a?(YARD::CodeObjects::NamespaceObject)
|
30
|
-
nspin = Solargraph::Pin::YardPin::Namespace.new(code_object, @spec)
|
28
|
+
nspin = Solargraph::Pin::YardPin::Namespace.new(code_object, @spec, @namespace_pins[code_object.namespace.to_s])
|
31
29
|
@namespace_pins[code_object.path] = nspin
|
32
30
|
result.push nspin
|
33
31
|
if code_object.is_a?(YARD::CodeObjects::ClassObject) and !code_object.superclass.nil?
|
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.
|
4
|
+
version: 0.38.3
|
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-01-
|
11
|
+
date: 2020-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backport
|
@@ -468,6 +468,7 @@ files:
|
|
468
468
|
- lib/solargraph/source_map/node_processor/send_node.rb
|
469
469
|
- lib/solargraph/source_map/node_processor/sym_node.rb
|
470
470
|
- lib/solargraph/source_map/region.rb
|
471
|
+
- lib/solargraph/stdlib_fills.rb
|
471
472
|
- lib/solargraph/type_checker.rb
|
472
473
|
- lib/solargraph/type_checker/param_def.rb
|
473
474
|
- lib/solargraph/type_checker/problem.rb
|