solargraph 0.39.4 → 0.39.9
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/lib/solargraph.rb +3 -0
- data/lib/solargraph/api_map.rb +27 -21
- data/lib/solargraph/api_map/cache.rb +4 -0
- data/lib/solargraph/api_map/store.rb +35 -47
- data/lib/solargraph/compat.rb +9 -0
- data/lib/solargraph/documentor.rb +2 -0
- data/lib/solargraph/language_server/host.rb +1 -1
- data/lib/solargraph/language_server/uri_helpers.rb +23 -3
- data/lib/solargraph/library.rb +1 -1
- data/lib/solargraph/parser/legacy/node_processors/send_node.rb +10 -0
- data/lib/solargraph/parser/rubyvm/node_methods.rb +1 -0
- data/lib/solargraph/parser/rubyvm/node_processors.rb +1 -0
- data/lib/solargraph/parser/rubyvm/node_processors/kw_arg_node.rb +6 -1
- data/lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb +6 -1
- data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +12 -39
- data/lib/solargraph/pin/attribute.rb +1 -1
- data/lib/solargraph/pin/base.rb +2 -2
- data/lib/solargraph/pin/base_method.rb +1 -1
- data/lib/solargraph/pin/base_variable.rb +1 -1
- data/lib/solargraph/pin/block.rb +28 -14
- data/lib/solargraph/pin/closure.rb +1 -1
- data/lib/solargraph/pin/constant.rb +1 -1
- data/lib/solargraph/pin/local_variable.rb +1 -1
- data/lib/solargraph/pin/method.rb +2 -2
- data/lib/solargraph/pin/method_alias.rb +1 -1
- data/lib/solargraph/pin/namespace.rb +1 -1
- data/lib/solargraph/pin/parameter.rb +2 -2
- data/lib/solargraph/pin/proxy_type.rb +1 -1
- data/lib/solargraph/shell.rb +1 -1
- data/lib/solargraph/source/chain.rb +0 -31
- data/lib/solargraph/source/source_chainer.rb +2 -1
- data/lib/solargraph/source_map.rb +16 -1
- data/lib/solargraph/source_map/mapper.rb +21 -7
- data/lib/solargraph/stdlib_fills.rb +8 -0
- data/lib/solargraph/type_checker.rb +2 -3
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/views/_name_type_tag.erb +1 -1
- data/lib/solargraph/workspace.rb +1 -1
- data/lib/solargraph/yard_map.rb +23 -1
- data/lib/solargraph/yard_map/mapper.rb +3 -0
- data/lib/solargraph/yard_map/rdoc_to_yard.rb +14 -10
- data/solargraph.gemspec +1 -1
- data/yardoc/2.2.2.tar.gz +0 -0
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aafa8f2eb715c3a50670e40b951c2965b66c4391f0fd3809cc18640038de8d4e
|
4
|
+
data.tar.gz: 162435cd9263a0e1a97762c48b2b77f654c8775c9461614b9c8700c554ad2bfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a08253ac143f7d5367f5cfc21d719114ff692065e2b4d9343a73dee8be883e1c219a991d3ae64d91566b18df4449ce122aa998c28392fd769184da8f574d8080
|
7
|
+
data.tar.gz: f748e9b60cedc4c4e1862be52043c9dfa9f79bbefe9ce209ab5f80dfce21df7342eed664d890d32b57e7f4b0f850f74c45e9fef788eadb2b9ebe03f8eb55df9f
|
data/lib/solargraph.rb
CHANGED
data/lib/solargraph/api_map.rb
CHANGED
@@ -26,7 +26,6 @@ module Solargraph
|
|
26
26
|
def initialize pins: []
|
27
27
|
@source_map_hash = {}
|
28
28
|
@cache = Cache.new
|
29
|
-
@mutex = Mutex.new
|
30
29
|
@method_alias_stack = []
|
31
30
|
index pins
|
32
31
|
end
|
@@ -34,13 +33,11 @@ module Solargraph
|
|
34
33
|
# @param pins [Array<Pin::Base>]
|
35
34
|
# @return [self]
|
36
35
|
def index pins
|
37
|
-
@
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
workspace_filenames.clear
|
43
|
-
}
|
36
|
+
@source_map_hash.clear
|
37
|
+
@cache.clear
|
38
|
+
@store = Store.new(pins + YardMap.new.pins)
|
39
|
+
@unresolved_requires = []
|
40
|
+
workspace_filenames.clear
|
44
41
|
self
|
45
42
|
end
|
46
43
|
|
@@ -123,14 +120,14 @@ module Solargraph
|
|
123
120
|
reqs.merge br.keys
|
124
121
|
yard_map.change(reqs.to_a, br, bundle.workspace.gemnames)
|
125
122
|
new_store = Store.new(pins + yard_map.pins)
|
126
|
-
@
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
}
|
123
|
+
@cache.clear
|
124
|
+
@source_map_hash = new_map_hash
|
125
|
+
@store = new_store
|
126
|
+
@unresolved_requires = yard_map.unresolved_requires
|
127
|
+
workspace_filenames.clear
|
128
|
+
workspace_filenames.concat bundle.workspace.filenames
|
129
|
+
@rebindable_method_names = nil
|
130
|
+
store.block_pins.each { |blk| blk.rebind(self) }
|
134
131
|
self
|
135
132
|
end
|
136
133
|
|
@@ -179,6 +176,16 @@ module Solargraph
|
|
179
176
|
store.pins
|
180
177
|
end
|
181
178
|
|
179
|
+
def rebindable_method_names
|
180
|
+
@rebindable_method_names ||= begin
|
181
|
+
result = yard_map.rebindable_method_names
|
182
|
+
source_maps.each do |map|
|
183
|
+
result.merge map.rebindable_method_names
|
184
|
+
end
|
185
|
+
result
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
182
189
|
# An array of pins based on Ruby keywords (`if`, `end`, etc.).
|
183
190
|
#
|
184
191
|
# @return [Array<Solargraph::Pin::Keyword>]
|
@@ -280,8 +287,7 @@ module Solargraph
|
|
280
287
|
|
281
288
|
# @return [Array<Solargraph::Pin::GlobalVariable>]
|
282
289
|
def get_global_variable_pins
|
283
|
-
|
284
|
-
pins.select{ |p| p.is_a?(Pin::GlobalVariable) }
|
290
|
+
store.pins_by_class(Pin::GlobalVariable)
|
285
291
|
end
|
286
292
|
|
287
293
|
# Get an array of methods available in a particular context.
|
@@ -535,17 +541,17 @@ module Solargraph
|
|
535
541
|
#
|
536
542
|
# @return [Hash{String => SourceMap}]
|
537
543
|
def source_map_hash
|
538
|
-
@
|
544
|
+
@source_map_hash
|
539
545
|
end
|
540
546
|
|
541
547
|
# @return [ApiMap::Store]
|
542
548
|
def store
|
543
|
-
@
|
549
|
+
@store
|
544
550
|
end
|
545
551
|
|
546
552
|
# @return [Solargraph::ApiMap::Cache]
|
547
553
|
def cache
|
548
|
-
@
|
554
|
+
@cache
|
549
555
|
end
|
550
556
|
|
551
557
|
# @param fqns [String] A fully qualified namespace
|
@@ -10,6 +10,7 @@ module Solargraph
|
|
10
10
|
@receiver_definitions = {}
|
11
11
|
end
|
12
12
|
|
13
|
+
# @return [Array<Pin::BaseMethod>]
|
13
14
|
def get_methods fqns, scope, visibility, deep
|
14
15
|
@methods[[fqns, scope, visibility.sort, deep]]
|
15
16
|
end
|
@@ -18,6 +19,7 @@ module Solargraph
|
|
18
19
|
@methods[[fqns, scope, visibility.sort, deep]] = value
|
19
20
|
end
|
20
21
|
|
22
|
+
# @return [Array<Pin::Base>]
|
21
23
|
def get_constants namespace, context
|
22
24
|
@constants[[namespace, context]]
|
23
25
|
end
|
@@ -26,6 +28,7 @@ module Solargraph
|
|
26
28
|
@constants[[namespace, context]] = value
|
27
29
|
end
|
28
30
|
|
31
|
+
# @return [String]
|
29
32
|
def get_qualified_namespace name, context
|
30
33
|
@qualified_namespaces[[name, context]]
|
31
34
|
end
|
@@ -38,6 +41,7 @@ module Solargraph
|
|
38
41
|
@receiver_definitions.key? path
|
39
42
|
end
|
40
43
|
|
44
|
+
# @return [Pin::BaseMethod]
|
41
45
|
def get_receiver_definition path
|
42
46
|
@receiver_definitions[path]
|
43
47
|
end
|
@@ -99,12 +99,12 @@ module Solargraph
|
|
99
99
|
|
100
100
|
# @return [Array<Solargraph::Pin::Base>]
|
101
101
|
def namespace_pins
|
102
|
-
|
102
|
+
pins_by_class(Solargraph::Pin::Namespace)
|
103
103
|
end
|
104
104
|
|
105
|
-
# @return [Array<Solargraph::Pin::
|
105
|
+
# @return [Array<Solargraph::Pin::BaseMethod>]
|
106
106
|
def method_pins
|
107
|
-
|
107
|
+
pins_by_class(Solargraph::Pin::BaseMethod)
|
108
108
|
end
|
109
109
|
|
110
110
|
# @param fqns [String]
|
@@ -133,7 +133,7 @@ module Solargraph
|
|
133
133
|
|
134
134
|
# @return [Array<Pin::Block>]
|
135
135
|
def block_pins
|
136
|
-
|
136
|
+
pins_by_class(Pin::Block)
|
137
137
|
end
|
138
138
|
|
139
139
|
def inspect
|
@@ -141,6 +141,12 @@ module Solargraph
|
|
141
141
|
to_s
|
142
142
|
end
|
143
143
|
|
144
|
+
# @param klass [Class]
|
145
|
+
# @return [Array<Solargraph::Pin::Base>]
|
146
|
+
def pins_by_class klass
|
147
|
+
@pin_select_cache[klass] ||= @pin_class_hash.select { |key, _| key <= klass }.values.flatten
|
148
|
+
end
|
149
|
+
|
144
150
|
private
|
145
151
|
|
146
152
|
# @param fqns [String]
|
@@ -167,7 +173,7 @@ module Solargraph
|
|
167
173
|
|
168
174
|
# @return [Array<Solargraph::Pin::Symbol>]
|
169
175
|
def symbols
|
170
|
-
|
176
|
+
pins_by_class(Pin::Symbol)
|
171
177
|
end
|
172
178
|
|
173
179
|
def superclass_references
|
@@ -198,7 +204,7 @@ module Solargraph
|
|
198
204
|
end
|
199
205
|
|
200
206
|
def all_instance_variables
|
201
|
-
|
207
|
+
pins_by_class(Pin::InstanceVariable)
|
202
208
|
end
|
203
209
|
|
204
210
|
def path_pin_hash
|
@@ -207,48 +213,29 @@ module Solargraph
|
|
207
213
|
|
208
214
|
# @return [void]
|
209
215
|
def index
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
prepend_references[pin.namespace] ||= []
|
232
|
-
prepend_references[pin.namespace].push pin.name
|
233
|
-
elsif pin.is_a?(Pin::Reference::Extend)
|
234
|
-
extend_references[pin.namespace] ||= []
|
235
|
-
extend_references[pin.namespace].push pin.name
|
236
|
-
elsif pin.is_a?(Pin::Reference::Superclass)
|
237
|
-
superclass_references[pin.namespace] ||= []
|
238
|
-
superclass_references[pin.namespace].push pin.name
|
239
|
-
elsif pin.is_a?(Pin::Block)
|
240
|
-
block_pins.push pin
|
241
|
-
elsif pin.is_a?(Pin::InstanceVariable)
|
242
|
-
all_instance_variables.push pin
|
243
|
-
elsif pin.is_a?(Pin::Reference::Override)
|
244
|
-
override_pins.push pin
|
245
|
-
end
|
246
|
-
if pin.path
|
247
|
-
path_pin_hash[pin.path] ||= []
|
248
|
-
path_pin_hash[pin.path].push pin
|
249
|
-
end
|
216
|
+
set = pins.to_set
|
217
|
+
@pin_class_hash = set.classify(&:class).transform_values(&:to_a)
|
218
|
+
@pin_select_cache = {}
|
219
|
+
@namespace_map = set.classify(&:namespace).transform_values(&:to_a)
|
220
|
+
@path_pin_hash = set.classify(&:path).transform_values(&:to_a)
|
221
|
+
@namespaces = @path_pin_hash.keys.compact
|
222
|
+
pins_by_class(Pin::Reference::Include).each do |pin|
|
223
|
+
include_references[pin.namespace] ||= []
|
224
|
+
include_references[pin.namespace].push pin.name
|
225
|
+
end
|
226
|
+
pins_by_class(Pin::Reference::Prepend).each do |pin|
|
227
|
+
prepend_references[pin.namespace] ||= []
|
228
|
+
prepend_references[pin.namespace].push pin.name
|
229
|
+
end
|
230
|
+
pins_by_class(Pin::Reference::Extend).each do |pin|
|
231
|
+
extend_references[pin.namespace] ||= []
|
232
|
+
extend_references[pin.namespace].push pin.name
|
233
|
+
end
|
234
|
+
pins_by_class(Pin::Reference::Superclass).each do |pin|
|
235
|
+
superclass_references[pin.namespace] ||= []
|
236
|
+
superclass_references[pin.namespace].push pin.name
|
250
237
|
end
|
251
|
-
|
238
|
+
pins_by_class(Pin::Reference::Override).each do |ovr|
|
252
239
|
pin = get_path_pins(ovr.name).first
|
253
240
|
next if pin.nil?
|
254
241
|
(ovr.tags.map(&:tag_name) + ovr.delete).uniq.each do |tag|
|
@@ -261,6 +248,7 @@ module Solargraph
|
|
261
248
|
# @todo This is probably not the best place for these overrides
|
262
249
|
superclass_references['Integer'] = ['Numeric']
|
263
250
|
superclass_references['Float'] = ['Numeric']
|
251
|
+
superclass_references['File'] = ['IO']
|
264
252
|
end
|
265
253
|
end
|
266
254
|
end
|
@@ -5,6 +5,7 @@ require 'json'
|
|
5
5
|
require 'open3'
|
6
6
|
require 'shellwords'
|
7
7
|
require 'yard'
|
8
|
+
require 'fileutils'
|
8
9
|
|
9
10
|
module Solargraph
|
10
11
|
class Documentor
|
@@ -25,6 +26,7 @@ module Solargraph
|
|
25
26
|
Documentor.specs_from_bundle(@directory).each_pair do |name, version|
|
26
27
|
yd = YARD::Registry.yardoc_file_for_gem(name, "= #{version}")
|
27
28
|
if !yd || @rebuild
|
29
|
+
FileUtils.safe_unlink File.join(YardMap::CoreDocs.cache_dir, 'gems', "#{name}-#{version}.ser")
|
28
30
|
@out.puts "Documenting #{name} #{version}"
|
29
31
|
`yard gems #{name} #{version} #{@rebuild ? '--rebuild' : ''}`
|
30
32
|
yd = YARD::Registry.yardoc_file_for_gem(name, "= #{version}")
|
@@ -99,7 +99,7 @@ module Solargraph
|
|
99
99
|
message = Message.select(request['method']).new(self, request)
|
100
100
|
begin
|
101
101
|
message.process
|
102
|
-
rescue
|
102
|
+
rescue StandardError => e
|
103
103
|
logger.warn "Error processing request: [#{e.class}] #{e.message}"
|
104
104
|
logger.warn e.backtrace.join("\n")
|
105
105
|
message.set_error Solargraph::LanguageServer::ErrorCodes::INTERNAL_ERROR, "[#{e.class}] #{e.message}"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'cgi'
|
4
4
|
|
5
5
|
module Solargraph
|
6
6
|
module LanguageServer
|
@@ -14,7 +14,7 @@ module Solargraph
|
|
14
14
|
# @param uri [String]
|
15
15
|
# @return [String]
|
16
16
|
def uri_to_file uri
|
17
|
-
|
17
|
+
decode(uri).sub(/^file\:\/\//, '').sub(/^\/([a-z]\:)/i, '\1')
|
18
18
|
end
|
19
19
|
|
20
20
|
# Convert a file path to a URI.
|
@@ -22,7 +22,27 @@ module Solargraph
|
|
22
22
|
# @param file [String]
|
23
23
|
# @return [String]
|
24
24
|
def file_to_uri file
|
25
|
-
"file://#{
|
25
|
+
"file://#{encode(file.gsub(/^([a-z]\:)/i, '/\1'))}"
|
26
|
+
end
|
27
|
+
|
28
|
+
# Encode text to be used as a URI path component in LSP.
|
29
|
+
#
|
30
|
+
# @param text [String]
|
31
|
+
# @return [String]
|
32
|
+
def encode text
|
33
|
+
CGI.escape(text)
|
34
|
+
.gsub('%3A', ':')
|
35
|
+
.gsub('%5C', '\\')
|
36
|
+
.gsub('%2F', '/')
|
37
|
+
.gsub('+', '%20')
|
38
|
+
end
|
39
|
+
|
40
|
+
# Decode text from a URI path component in LSP.
|
41
|
+
#
|
42
|
+
# @param text [String]
|
43
|
+
# @return [String]
|
44
|
+
def decode text
|
45
|
+
CGI.unescape(text)
|
26
46
|
end
|
27
47
|
end
|
28
48
|
end
|
data/lib/solargraph/library.rb
CHANGED
@@ -339,7 +339,7 @@ module Solargraph
|
|
339
339
|
logger.info "Cataloging #{workspace.directory.empty? ? 'generic workspace' : workspace.directory}"
|
340
340
|
api_map.catalog bundle
|
341
341
|
@synchronized = true
|
342
|
-
logger.info "Catalog complete (#{api_map.pins.length} pins)"
|
342
|
+
logger.info "Catalog complete (#{api_map.source_maps.length} files, #{api_map.pins.length} pins)" if logger.info?
|
343
343
|
end
|
344
344
|
end
|
345
345
|
|
@@ -36,6 +36,8 @@ module Solargraph
|
|
36
36
|
process_prepend
|
37
37
|
elsif node.children[1] == :require
|
38
38
|
process_require
|
39
|
+
elsif node.children[1] == :autoload
|
40
|
+
process_autoload
|
39
41
|
elsif node.children[1] == :private_constant
|
40
42
|
process_private_constant
|
41
43
|
elsif node.children[1] == :alias_method && node.children[2] && node.children[2] && node.children[2].type == :sym && node.children[3] && node.children[3].type == :sym
|
@@ -138,6 +140,14 @@ module Solargraph
|
|
138
140
|
end
|
139
141
|
end
|
140
142
|
|
143
|
+
# @return [void]
|
144
|
+
def process_autoload
|
145
|
+
if node.children[3].is_a?(AST::Node) && node.children[3].type == :str
|
146
|
+
path = node.children[3].children[0].to_s
|
147
|
+
pins.push Pin::Reference::Require.new(get_node_location(node), path)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
141
151
|
# @return [void]
|
142
152
|
def process_module_function
|
143
153
|
if node.children[2].nil?
|
@@ -95,6 +95,7 @@ module Solargraph
|
|
95
95
|
index = 0
|
96
96
|
until index > node.children[0].children.length - 2
|
97
97
|
k = node.children[0].children[index]
|
98
|
+
return {} unless node?(k)
|
98
99
|
v = node.children[0].children[index + 1]
|
99
100
|
result[k.children[0]] = Solargraph::Parser.chain(v)
|
100
101
|
index += 2
|
@@ -36,6 +36,7 @@ module Solargraph
|
|
36
36
|
register :RESBODY, Rubyvm::NodeProcessors::ResbodyNode
|
37
37
|
register :DEFN, Rubyvm::NodeProcessors::DefNode
|
38
38
|
register :DEFS, Rubyvm::NodeProcessors::DefsNode
|
39
|
+
register :CALL, Rubyvm::NodeProcessors::SendNode
|
39
40
|
register :FCALL, Rubyvm::NodeProcessors::SendNode
|
40
41
|
register :VCALL, Rubyvm::NodeProcessors::SendNode
|
41
42
|
register :CLASS, Rubyvm::NodeProcessors::NamespaceNode
|
@@ -16,7 +16,12 @@ module Solargraph
|
|
16
16
|
presence: region.closure.location.range,
|
17
17
|
decl: require_keyword?(node) ? :kwarg : :kwoptarg
|
18
18
|
)
|
19
|
-
region.closure.parameters.
|
19
|
+
idx = region.closure.parameters.find_index { |par| [:kwrestarg, :blockarg].include?(par.decl) }
|
20
|
+
if idx
|
21
|
+
region.closure.parameters.insert idx, locals.last
|
22
|
+
else
|
23
|
+
region.closure.parameters.push locals.last
|
24
|
+
end
|
20
25
|
node.children[1] && NodeProcessor.process(node.children[1], region, pins, locals)
|
21
26
|
end
|
22
27
|
|
@@ -16,7 +16,12 @@ module Solargraph
|
|
16
16
|
presence: region.closure.location.range,
|
17
17
|
decl: :optarg
|
18
18
|
)
|
19
|
-
region.closure.parameters.
|
19
|
+
idx = region.closure.parameters.find_index { |par| par.decl != :arg }
|
20
|
+
if idx
|
21
|
+
region.closure.parameters.insert idx, locals.last
|
22
|
+
else
|
23
|
+
region.closure.parameters.push locals.last
|
24
|
+
end
|
20
25
|
node.children[1] && NodeProcessor.process(node.children[1], region, pins, locals)
|
21
26
|
end
|
22
27
|
end
|
@@ -28,6 +28,8 @@ module Solargraph
|
|
28
28
|
process_module_function
|
29
29
|
elsif node.children[0] == :require
|
30
30
|
process_require
|
31
|
+
elsif node.children[0] == :autoload
|
32
|
+
process_autoload
|
31
33
|
elsif node.children[0] == :alias_method
|
32
34
|
process_alias_method
|
33
35
|
elsif node.children[0] == :private_class_method
|
@@ -43,45 +45,7 @@ module Solargraph
|
|
43
45
|
process_prepend
|
44
46
|
elsif node.children[0] == :private_constant
|
45
47
|
process_private_constant
|
46
|
-
|
47
|
-
process_children
|
48
|
-
return
|
49
|
-
# @todo Get rid of legacy
|
50
|
-
if node.children[0].nil?
|
51
|
-
if [:private, :public, :protected].include?(node.children[1])
|
52
|
-
if (node.children.length > 2)
|
53
|
-
node.children[2..-1].each do |child|
|
54
|
-
next unless child.is_a?(AST::Node) && (child.type == :sym || child.type == :str)
|
55
|
-
name = child.children[0].to_s
|
56
|
-
matches = pins.select{ |pin| pin.is_a?(Pin::BaseMethod) && pin.name == name && pin.namespace == region.closure.full_context.namespace && pin.context.scope == (region.scope || :instance)}
|
57
|
-
matches.each do |pin|
|
58
|
-
# @todo Smelly instance variable access
|
59
|
-
pin.instance_variable_set(:@visibility, node.children[1])
|
60
|
-
end
|
61
|
-
end
|
62
|
-
else
|
63
|
-
# @todo Smelly instance variable access
|
64
|
-
region.instance_variable_set(:@visibility, node.children[1])
|
65
|
-
end
|
66
|
-
elsif node.children[1] == :module_function
|
67
|
-
process_module_function
|
68
|
-
elsif [:attr_reader, :attr_writer, :attr_accessor].include?(node.children[1])
|
69
|
-
process_attribute
|
70
|
-
elsif node.children[1] == :include
|
71
|
-
process_include
|
72
|
-
elsif node.children[1] == :extend
|
73
|
-
process_extend
|
74
|
-
elsif node.children[1] == :require
|
75
|
-
process_require
|
76
|
-
elsif node.children[1] == :private_constant
|
77
|
-
process_private_constant
|
78
|
-
elsif node.children[1] == :alias_method && node.children[2] && node.children[2] && node.children[2].type == :sym && node.children[3] && node.children[3].type == :sym
|
79
|
-
process_alias_method
|
80
|
-
elsif node.children[1] == :private_class_method && node.children[2].is_a?(AST::Node)
|
81
|
-
# Processing a private class can potentially handle children on its own
|
82
|
-
return if process_private_class_method
|
83
|
-
end
|
84
|
-
elsif node.children[1] == :require && node.children[0].to_s == '(const nil :Bundler)'
|
48
|
+
elsif node.children[1] == :require && unpack_name(node.children[0]) == 'Bundler'
|
85
49
|
pins.push Pin::Reference::Require.new(Solargraph::Location.new(region.filename, Solargraph::Range.from_to(0, 0, 0, 0)), 'bundler/require')
|
86
50
|
end
|
87
51
|
process_children
|
@@ -181,6 +145,15 @@ module Solargraph
|
|
181
145
|
end
|
182
146
|
end
|
183
147
|
|
148
|
+
# @return [void]
|
149
|
+
def process_autoload
|
150
|
+
return unless Parser.is_ast_node?(node.children[1]) && Parser.is_ast_node?(node.children[1].children[1])
|
151
|
+
arg = node.children[1].children[1]
|
152
|
+
if arg.type == :STR
|
153
|
+
pins.push Pin::Reference::Require.new(get_node_location(arg), arg.children[0])
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
184
157
|
# @return [void]
|
185
158
|
def process_module_function
|
186
159
|
if node.type == :VCALL
|
data/lib/solargraph/pin/base.rb
CHANGED
@@ -23,7 +23,7 @@ module Solargraph
|
|
23
23
|
|
24
24
|
# @param location [Solargraph::Location]
|
25
25
|
# @param kind [Integer]
|
26
|
-
# @param closure [
|
26
|
+
# @param closure [Solargraph::Pin::Closure]
|
27
27
|
# @param name [String]
|
28
28
|
# @param comments [String]
|
29
29
|
def initialize location: nil, closure: nil, name: '', comments: ''
|
@@ -38,7 +38,7 @@ module Solargraph
|
|
38
38
|
@comments ||= ''
|
39
39
|
end
|
40
40
|
|
41
|
-
# @return [String]
|
41
|
+
# @return [String, nil]
|
42
42
|
def filename
|
43
43
|
return nil if location.nil?
|
44
44
|
location.filename
|
@@ -14,7 +14,7 @@ module Solargraph
|
|
14
14
|
# @param visibility [::Symbol] :public, :protected, or :private
|
15
15
|
# @param explicit [Boolean]
|
16
16
|
def initialize visibility: :public, explicit: true, **splat
|
17
|
-
super(splat)
|
17
|
+
super(**splat)
|
18
18
|
@visibility = visibility
|
19
19
|
@explicit = explicit
|
20
20
|
end
|
data/lib/solargraph/pin/block.rb
CHANGED
@@ -9,22 +9,19 @@ module Solargraph
|
|
9
9
|
attr_reader :receiver
|
10
10
|
|
11
11
|
def initialize receiver: nil, args: [], **splat
|
12
|
-
super(splat)
|
12
|
+
super(**splat)
|
13
13
|
@receiver = receiver
|
14
14
|
@parameters = args
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
def rebound?
|
23
|
-
@rebound ||= false
|
17
|
+
# @param api_map [ApiMap]
|
18
|
+
# @return [void]
|
19
|
+
def rebind api_map
|
20
|
+
@binder ||= binder_or_nil(api_map)
|
24
21
|
end
|
25
22
|
|
26
23
|
def binder
|
27
|
-
@binder ||
|
24
|
+
@binder || closure.binder
|
28
25
|
end
|
29
26
|
|
30
27
|
# @return [Array<String>]
|
@@ -37,11 +34,28 @@ module Solargraph
|
|
37
34
|
@parameter_names ||= parameters.map(&:name)
|
38
35
|
end
|
39
36
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
37
|
+
private
|
38
|
+
|
39
|
+
# @param api_map [ApiMap]
|
40
|
+
# @return [ComplexType, nil]
|
41
|
+
def binder_or_nil api_map
|
42
|
+
return nil unless receiver
|
43
|
+
word = receiver.children.find { |c| c.is_a?(::Symbol) }.to_s
|
44
|
+
return nil unless api_map.rebindable_method_names.include?(word)
|
45
|
+
chain = Parser.chain(receiver, location.filename)
|
46
|
+
locals = api_map.source_map(location.filename).locals_at(location)
|
47
|
+
if ['instance_eval', 'instance_exec', 'class_eval', 'class_exec', 'module_eval', 'module_exec'].include?(chain.links.last.word)
|
48
|
+
return chain.base.infer(api_map, self, locals)
|
49
|
+
else
|
50
|
+
receiver_pin = chain.define(api_map, self, locals).first
|
51
|
+
if receiver_pin && receiver_pin.docstring
|
52
|
+
ys = receiver_pin.docstring.tag(:yieldself)
|
53
|
+
if ys && ys.types && !ys.types.empty?
|
54
|
+
return ComplexType.try_parse(*ys.types).qualify(api_map, receiver_pin.context.namespace)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
nil
|
45
59
|
end
|
46
60
|
end
|
47
61
|
end
|
@@ -5,13 +5,13 @@ module Solargraph
|
|
5
5
|
class Method < BaseMethod
|
6
6
|
include Solargraph::Parser::NodeMethods
|
7
7
|
|
8
|
-
# @return [Array<
|
8
|
+
# @return [Array<Pin::Parameter>]
|
9
9
|
attr_reader :parameters
|
10
10
|
|
11
11
|
# @param args [Array<String>]
|
12
12
|
# @param node [Parser::AST::Node, nil]
|
13
13
|
def initialize parameters: [], node: nil, **splat
|
14
|
-
super(splat)
|
14
|
+
super(**splat)
|
15
15
|
@parameters = parameters
|
16
16
|
@node = node
|
17
17
|
end
|
@@ -14,7 +14,7 @@ module Solargraph
|
|
14
14
|
# @param gates [Array<String>]
|
15
15
|
def initialize type: :class, visibility: :public, gates: [''], **splat
|
16
16
|
# super(location, namespace, name, comments)
|
17
|
-
super(splat)
|
17
|
+
super(**splat)
|
18
18
|
@type = type
|
19
19
|
@visibility = visibility
|
20
20
|
if name.start_with?('::')
|
@@ -8,7 +8,7 @@ module Solargraph
|
|
8
8
|
attr_reader :asgn_code
|
9
9
|
|
10
10
|
def initialize decl: :arg, asgn_code: nil, **splat
|
11
|
-
super(splat)
|
11
|
+
super(**splat)
|
12
12
|
@asgn_code = asgn_code
|
13
13
|
@decl = decl
|
14
14
|
end
|
@@ -41,7 +41,7 @@ module Solargraph
|
|
41
41
|
"*#{name}"
|
42
42
|
when :kwrestarg
|
43
43
|
"**#{name}"
|
44
|
-
when :block
|
44
|
+
when :block, :blockarg
|
45
45
|
"&#{name}"
|
46
46
|
else
|
47
47
|
name
|
data/lib/solargraph/shell.rb
CHANGED
@@ -175,7 +175,7 @@ module Solargraph
|
|
175
175
|
puts pin_description(pin) if options[:verbose]
|
176
176
|
pin.typify api_map
|
177
177
|
pin.probe api_map
|
178
|
-
rescue
|
178
|
+
rescue StandardError => e
|
179
179
|
STDERR.puts "Error testing #{pin_description(pin)} #{pin.location ? "at #{pin.location.filename}:#{pin.location.range.start.line + 1}" : ''}"
|
180
180
|
STDERR.puts "[#{e.class}]: #{e.message}"
|
181
181
|
STDERR.puts e.backtrace.join("\n")
|
@@ -57,7 +57,6 @@ module Solargraph
|
|
57
57
|
# @param locals [Array<Pin::Base>]
|
58
58
|
# @return [Array<Pin::Base>]
|
59
59
|
def define api_map, name_pin, locals
|
60
|
-
rebind_block name_pin, api_map, locals
|
61
60
|
return [] if undefined?
|
62
61
|
working_pin = name_pin
|
63
62
|
links[0..-2].each do |link|
|
@@ -79,7 +78,6 @@ module Solargraph
|
|
79
78
|
# @param locals [Array<Pin::Base>]
|
80
79
|
# @return [ComplexType]
|
81
80
|
def infer api_map, name_pin, locals
|
82
|
-
rebind_block name_pin, api_map, locals
|
83
81
|
pins = define(api_map, name_pin, locals)
|
84
82
|
infer_first_defined(pins, links.last.last_context, api_map)
|
85
83
|
end
|
@@ -138,35 +136,6 @@ module Solargraph
|
|
138
136
|
return type if context.nil? || context.return_type.undefined?
|
139
137
|
type.self_to(context.return_type.namespace)
|
140
138
|
end
|
141
|
-
|
142
|
-
def skippable_block_receivers api_map
|
143
|
-
@@skippable_block_receivers ||= (
|
144
|
-
api_map.get_methods('Array', deep: false).map(&:name) +
|
145
|
-
api_map.get_methods('Enumerable', deep: false).map(&:name) +
|
146
|
-
api_map.get_methods('Hash', deep: false).map(&:name) +
|
147
|
-
['new']
|
148
|
-
).to_set
|
149
|
-
end
|
150
|
-
|
151
|
-
def rebind_block pin, api_map, locals
|
152
|
-
return unless pin.is_a?(Pin::Block) && pin.receiver && !pin.rebound?
|
153
|
-
# This first rebind just sets the block pin's rebound state
|
154
|
-
pin.rebind ComplexType::UNDEFINED
|
155
|
-
chain = Parser.chain(pin.receiver, pin.location.filename)
|
156
|
-
return if skippable_block_receivers(api_map).include?(chain.links.last.word)
|
157
|
-
if ['instance_eval', 'instance_exec', 'class_eval', 'class_exec', 'module_eval', 'module_exec'].include?(chain.links.last.word)
|
158
|
-
type = chain.base.infer(api_map, pin, locals)
|
159
|
-
pin.rebind type
|
160
|
-
else
|
161
|
-
receiver_pin = chain.define(api_map, pin, locals).first
|
162
|
-
return if receiver_pin.nil? || receiver_pin.docstring.nil?
|
163
|
-
ys = receiver_pin.docstring.tag(:yieldself)
|
164
|
-
unless ys.nil? || ys.types.nil? || ys.types.empty?
|
165
|
-
ysct = ComplexType.try_parse(*ys.types).qualify(api_map, receiver_pin.context.namespace)
|
166
|
-
pin.rebind ysct
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
139
|
end
|
171
140
|
end
|
172
141
|
end
|
@@ -17,7 +17,6 @@ module Solargraph
|
|
17
17
|
# @param position [Position]
|
18
18
|
# @return [Source::Chain]
|
19
19
|
def chain source, position
|
20
|
-
# raise "Not a source" unless source.is_a?(Source)
|
21
20
|
new(source, position).chain
|
22
21
|
end
|
23
22
|
end
|
@@ -32,6 +31,8 @@ module Solargraph
|
|
32
31
|
|
33
32
|
# @return [Source::Chain]
|
34
33
|
def chain
|
34
|
+
# Special handling for files that end with an integer and a period
|
35
|
+
return Chain.new([Chain::Literal.new('Integer'), Chain::UNDEFINED_CALL]) if phrase =~ /^[0-9]+\.$/
|
35
36
|
return Chain.new([Chain::Literal.new('Symbol')]) if phrase.start_with?(':') && !phrase.start_with?('::')
|
36
37
|
begin
|
37
38
|
return Chain.new([]) if phrase.end_with?('..')
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'jaro_winkler'
|
4
4
|
require 'yard'
|
5
5
|
require 'yard-solargraph'
|
6
|
+
require 'set'
|
6
7
|
|
7
8
|
module Solargraph
|
8
9
|
# An index of pins and other ApiMap-related data for a Source.
|
@@ -30,6 +31,19 @@ module Solargraph
|
|
30
31
|
@pins = pins
|
31
32
|
@locals = locals
|
32
33
|
environ.merge Convention.for(source)
|
34
|
+
@pin_class_hash = pins.to_set.classify(&:class).transform_values(&:to_a)
|
35
|
+
@pin_select_cache = {}
|
36
|
+
end
|
37
|
+
|
38
|
+
def pins_by_class klass
|
39
|
+
@pin_select_cache[klass] ||= @pin_class_hash.select { |key, _| key <= klass }.values.flatten
|
40
|
+
end
|
41
|
+
|
42
|
+
def rebindable_method_names
|
43
|
+
@rebindable_method_names ||= pins_by_class(Pin::Method)
|
44
|
+
.select { |pin| pin.comments && pin.comments.include?('@yieldself') }
|
45
|
+
.map(&:name)
|
46
|
+
.to_set
|
33
47
|
end
|
34
48
|
|
35
49
|
# @return [String]
|
@@ -44,7 +58,7 @@ module Solargraph
|
|
44
58
|
|
45
59
|
# @return [Array<Pin::Reference::Require>]
|
46
60
|
def requires
|
47
|
-
|
61
|
+
pins_by_class(Pin::Reference::Require)
|
48
62
|
end
|
49
63
|
|
50
64
|
# @return [Environ]
|
@@ -62,6 +76,7 @@ module Solargraph
|
|
62
76
|
# @param query [String]
|
63
77
|
# @return [Array<Pin::Base>]
|
64
78
|
def query_symbols query
|
79
|
+
return document_symbols if query && query.empty?
|
65
80
|
document_symbols.select{ |pin| fuzzy_string_match(pin.path, query) || fuzzy_string_match(pin.name, query) }
|
66
81
|
end
|
67
82
|
|
@@ -82,6 +82,8 @@ module Solargraph
|
|
82
82
|
# @param comment [String]
|
83
83
|
# @return [Integer]
|
84
84
|
def find_directive_line_number comment, tag, start
|
85
|
+
# Avoid overruning the index
|
86
|
+
return start unless start < comment.lines.length
|
85
87
|
num = comment.lines[start..-1].find_index do |line|
|
86
88
|
# Legacy method directives might be `@method` instead of `@!method`
|
87
89
|
# @todo Legacy syntax should probably emit a warning
|
@@ -93,6 +95,7 @@ module Solargraph
|
|
93
95
|
# @param source_position [Position]
|
94
96
|
# @param comment_position [Position]
|
95
97
|
# @param directive [YARD::Tags::Directive]
|
98
|
+
# @return [void]
|
96
99
|
def process_directive source_position, comment_position, directive
|
97
100
|
docstring = Solargraph::Source.parse_docstring(directive.tag.text).to_docstring
|
98
101
|
location = Location.new(@filename, Range.new(comment_position, comment_position))
|
@@ -102,10 +105,10 @@ module Solargraph
|
|
102
105
|
if namespace.location.range.start.line < comment_position.line
|
103
106
|
namespace = closure_at(comment_position)
|
104
107
|
end
|
105
|
-
region = Parser::Region.new(source: @source, closure: namespace)
|
106
108
|
begin
|
107
|
-
|
108
|
-
|
109
|
+
src = Solargraph::Source.load_string("def #{directive.tag.name};end", @source.filename)
|
110
|
+
region = Parser::Region.new(source: src, closure: namespace)
|
111
|
+
gen_pin = Parser.process_node(src.node, region).first.last
|
109
112
|
return if gen_pin.nil?
|
110
113
|
# Move the location to the end of the line so it gets recognized
|
111
114
|
# as originating from a comment
|
@@ -146,12 +149,23 @@ module Solargraph
|
|
146
149
|
)
|
147
150
|
end
|
148
151
|
when 'parse'
|
149
|
-
ns = closure_at(source_position)
|
150
|
-
region = Parser::Region.new(source: @source, closure: ns)
|
151
152
|
begin
|
152
|
-
|
153
|
+
ns = closure_at(source_position)
|
154
|
+
src = Solargraph::Source.load_string(directive.tag.text, @source.filename)
|
155
|
+
region = Parser::Region.new(source: src, closure: ns)
|
153
156
|
# @todo These pins may need to be marked not explicit
|
154
|
-
|
157
|
+
index = @pins.length
|
158
|
+
loff = if @code.lines[comment_position.line].strip.end_with?('@!parse')
|
159
|
+
comment_position.line + 1
|
160
|
+
else
|
161
|
+
comment_position.line
|
162
|
+
end
|
163
|
+
Parser.process_node(src.node, region, @pins)
|
164
|
+
@pins[index..-1].each do |p|
|
165
|
+
# @todo Smelly instance variable access
|
166
|
+
p.location.range.start.instance_variable_set(:@line, p.location.range.start.line + loff)
|
167
|
+
p.location.range.ending.instance_variable_set(:@line, p.location.range.ending.line + loff)
|
168
|
+
end
|
155
169
|
rescue Parser::SyntaxError => e
|
156
170
|
# @todo Handle parser errors in !parse directives
|
157
171
|
end
|
@@ -20,6 +20,14 @@ module Solargraph
|
|
20
20
|
Override.method_return('Pathname#cleanpath', 'Pathname'),
|
21
21
|
Override.method_return('Pathname#children', 'Array<Pathname>'),
|
22
22
|
Override.method_return('Pathname#entries', 'Array<Pathname>')
|
23
|
+
],
|
24
|
+
|
25
|
+
'set' => [
|
26
|
+
Override.method_return('Enumerable#to_set', 'Set'),
|
27
|
+
Override.method_return('Set#add', 'self'),
|
28
|
+
Override.method_return('Set#add?', 'self, nil'),
|
29
|
+
Override.method_return('Set#classify', 'Hash'),
|
30
|
+
Override.from_comment('Set#each', '@yieldparam_single_parameter')
|
23
31
|
]
|
24
32
|
}
|
25
33
|
|
@@ -74,7 +74,7 @@ module Solargraph
|
|
74
74
|
def method_tag_problems
|
75
75
|
result = []
|
76
76
|
# @param pin [Pin::BaseMethod]
|
77
|
-
source_map.
|
77
|
+
source_map.pins_by_class(Pin::BaseMethod).each do |pin|
|
78
78
|
result.concat method_return_type_problems_for(pin)
|
79
79
|
result.concat method_param_type_problems_for(pin)
|
80
80
|
end
|
@@ -184,8 +184,7 @@ module Solargraph
|
|
184
184
|
|
185
185
|
# @return [Array<Pin::BaseVariable>]
|
186
186
|
def all_variables
|
187
|
-
source_map.
|
188
|
-
source_map.locals.select { |pin| pin.is_a?(Pin::LocalVariable) }
|
187
|
+
source_map.pins_by_class(Pin::BaseVariable) + source_map.locals.select { |pin| pin.is_a?(Pin::LocalVariable) }
|
189
188
|
end
|
190
189
|
|
191
190
|
def const_problems
|
data/lib/solargraph/version.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
<% unless tag.types.nil? or tag.types.empty? %>
|
3
3
|
[<%= escape(tag.types.join(', ')) %>]
|
4
4
|
<% end %>
|
5
|
-
<% unless tag.text.empty? %>
|
5
|
+
<% unless tag.text.nil? || tag.text.empty? %>
|
6
6
|
<% unless (tag.name.nil? or tag.name.empty?) and (tag.types.nil? or tag.types.empty?) %>
|
7
7
|
-
|
8
8
|
<% end %>
|
data/lib/solargraph/workspace.rb
CHANGED
@@ -170,7 +170,7 @@ module Solargraph
|
|
170
170
|
Dir.chdir base do
|
171
171
|
begin
|
172
172
|
# @type [Gem::Specification]
|
173
|
-
spec = eval(File.read(file),
|
173
|
+
spec = eval(File.read(file), TOPLEVEL_BINDING, file)
|
174
174
|
next unless Gem::Specification === spec
|
175
175
|
@gemnames.push spec.name
|
176
176
|
result.concat(spec.require_paths.map { |path| File.join(base, path) })
|
data/lib/solargraph/yard_map.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'yard'
|
4
4
|
require 'yard-solargraph'
|
5
5
|
require 'rubygems/package'
|
6
|
+
require 'set'
|
6
7
|
|
7
8
|
module Solargraph
|
8
9
|
# The YardMap provides access to YARD documentation for the Ruby core, the
|
@@ -56,6 +57,7 @@ module Solargraph
|
|
56
57
|
@source_gems = []
|
57
58
|
process_requires
|
58
59
|
yardocs.uniq!
|
60
|
+
@pin_select_cache = {}
|
59
61
|
end
|
60
62
|
|
61
63
|
# @return [Array<Solargraph::Pin::Base>]
|
@@ -80,10 +82,22 @@ module Solargraph
|
|
80
82
|
@gemset = new_gemset
|
81
83
|
@source_gems = source_gems
|
82
84
|
process_requires
|
85
|
+
@rebindable_method_names = nil
|
86
|
+
@pin_class_hash = nil
|
87
|
+
@pin_select_cache = {}
|
83
88
|
true
|
84
89
|
end
|
85
90
|
end
|
86
91
|
|
92
|
+
# @return [Set<String>]
|
93
|
+
def rebindable_method_names
|
94
|
+
@rebindable_method_names ||= pins_by_class(Pin::Method)
|
95
|
+
.select { |pin| pin.comments && pin.comments.include?('@yieldself') }
|
96
|
+
.map(&:name)
|
97
|
+
.concat(['instance_eval', 'instance_exec', 'class_eval', 'class_exec', 'module_eval', 'module_exec'])
|
98
|
+
.to_set
|
99
|
+
end
|
100
|
+
|
87
101
|
# @return [Array<String>]
|
88
102
|
def yardocs
|
89
103
|
@yardocs ||= []
|
@@ -102,7 +116,7 @@ module Solargraph
|
|
102
116
|
else
|
103
117
|
YARD::Registry.load! y
|
104
118
|
end
|
105
|
-
rescue
|
119
|
+
rescue StandardError => e
|
106
120
|
Solargraph::Logging.logger.warn "Error loading yardoc '#{y}' #{e.class} #{e.message}"
|
107
121
|
yardocs.delete y
|
108
122
|
nil
|
@@ -144,6 +158,14 @@ module Solargraph
|
|
144
158
|
@cache ||= YardMap::Cache.new
|
145
159
|
end
|
146
160
|
|
161
|
+
def pin_class_hash
|
162
|
+
@pin_class_hash ||= pins.to_set.classify(&:class).transform_values(&:to_a)
|
163
|
+
end
|
164
|
+
|
165
|
+
def pins_by_class klass
|
166
|
+
@pin_select_cache[klass] ||= pin_class_hash.select { |key, _| key <= klass }.values.flatten
|
167
|
+
end
|
168
|
+
|
147
169
|
# @param ns [YARD::CodeObjects::NamespaceObject]
|
148
170
|
# @return [Array<YARD::CodeObjects::Base>]
|
149
171
|
def recurse_namespace_object ns
|
@@ -17,6 +17,9 @@ module Solargraph
|
|
17
17
|
@code_objects.each do |co|
|
18
18
|
@pins.concat generate_pins co
|
19
19
|
end
|
20
|
+
# Some yardocs contain documentation for dependencies that can be
|
21
|
+
# ignored here. The YardMap will load dependencies separately.
|
22
|
+
@pins.keep_if { |pin| pin.location.nil? || File.file?(pin.location.filename) } if @spec
|
20
23
|
@pins
|
21
24
|
end
|
22
25
|
|
@@ -15,23 +15,23 @@ module Solargraph
|
|
15
15
|
# @return [void]
|
16
16
|
def self.run spec, cache_dir: nil
|
17
17
|
Dir.mktmpdir do |tmpdir|
|
18
|
-
rdir = File.join(tmpdir, '
|
19
|
-
Dir.
|
18
|
+
rdir = File.join(tmpdir, 'sg_tmp_rdoc')
|
19
|
+
FileUtils.cp_r Dir.glob(File.join(spec.full_gem_path, '*')), tmpdir
|
20
|
+
Dir.chdir tmpdir do
|
20
21
|
pins = []
|
21
22
|
pins.push Solargraph::Pin::ROOT_PIN
|
22
23
|
name_hash = {}
|
23
24
|
|
24
|
-
argv = ['-q', '-
|
25
|
+
argv = ['-q', '-r', '-N', '-o', rdir]
|
25
26
|
spec.load_paths.each do |path|
|
26
27
|
argv.concat ['-i', path]
|
27
28
|
end
|
28
29
|
rdoc = RDoc::RDoc.new
|
29
30
|
rdoc.document argv
|
30
|
-
|
31
|
-
store =
|
32
|
-
store.
|
31
|
+
# @type [RDoc::Store]
|
32
|
+
store = rdoc.store
|
33
|
+
store.path = rdir
|
33
34
|
store.cache[:modules].each do |mod|
|
34
|
-
# store.load_class(mod)
|
35
35
|
# @type [RDoc::NormalClass]
|
36
36
|
mod = store.find_class_or_module(mod)
|
37
37
|
closure = pins.select { |pin| pin.path == mod.full_name.split('::')[0..-2].join('::') }.first || pins.first
|
@@ -51,7 +51,7 @@ module Solargraph
|
|
51
51
|
closure: namepin
|
52
52
|
)
|
53
53
|
end
|
54
|
-
# @param
|
54
|
+
# @param ext [RDoc::Extend]
|
55
55
|
mod.extends.each do |ext|
|
56
56
|
pins.push Solargraph::Pin::Reference::Extend.new(
|
57
57
|
location: locate(ext),
|
@@ -95,6 +95,8 @@ module Solargraph
|
|
95
95
|
FileUtils.mkdir_p cache_dir
|
96
96
|
# @todo Should merge be true?
|
97
97
|
YARD::Registry.save true, cache_dir
|
98
|
+
# Clear the serialized cache if it exists
|
99
|
+
FileUtils.safe_unlink File.join(CoreDocs.cache_dir, 'gems', "#{spec.name}-#{spec.version}.ser")
|
98
100
|
end
|
99
101
|
end
|
100
102
|
end
|
@@ -103,7 +105,9 @@ module Solargraph
|
|
103
105
|
mod.full_name.split('::')[0..-2].join('::')
|
104
106
|
end
|
105
107
|
|
108
|
+
# @param cmnt [RDoc::Comment]
|
106
109
|
def self.commentary cmnt
|
110
|
+
return cmnt.text if cmnt.is_a?(RDoc::Comment)
|
107
111
|
result = []
|
108
112
|
cmnt.parts.each do |part|
|
109
113
|
result.push RDoc::Markup::ToHtml.new({}).to_html(part.text) if part.respond_to?(:text)
|
@@ -124,9 +128,9 @@ module Solargraph
|
|
124
128
|
|
125
129
|
def self.find_file obj
|
126
130
|
if obj.respond_to?(:in_files) && !obj.in_files.empty?
|
127
|
-
[obj.in_files.first.to_s.sub(/^file /, ''), obj.
|
131
|
+
[obj.in_files.first.to_s.sub(/^file /, ''), obj.line]
|
128
132
|
else
|
129
|
-
[obj.
|
133
|
+
[obj.file, obj.line]
|
130
134
|
end
|
131
135
|
end
|
132
136
|
end
|
data/solargraph.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.add_runtime_dependency 'maruku', '~> 0.7', '>= 0.7.3'
|
28
28
|
s.add_runtime_dependency 'nokogiri', '~> 1.9', '>= 1.9.1'
|
29
29
|
s.add_runtime_dependency 'parser', '~> 2.3'
|
30
|
-
s.add_runtime_dependency 'reverse_markdown', '
|
30
|
+
s.add_runtime_dependency 'reverse_markdown', '>= 1.0.5', '< 3'
|
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'
|
data/yardoc/2.2.2.tar.gz
CHANGED
Binary file
|
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.39.
|
4
|
+
version: 0.39.9
|
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-
|
11
|
+
date: 2020-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backport
|
@@ -138,22 +138,22 @@ dependencies:
|
|
138
138
|
name: reverse_markdown
|
139
139
|
requirement: !ruby/object:Gem::Requirement
|
140
140
|
requirements:
|
141
|
-
- - "~>"
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
version: '1.0'
|
144
141
|
- - ">="
|
145
142
|
- !ruby/object:Gem::Version
|
146
143
|
version: 1.0.5
|
144
|
+
- - "<"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '3'
|
147
147
|
type: :runtime
|
148
148
|
prerelease: false
|
149
149
|
version_requirements: !ruby/object:Gem::Requirement
|
150
150
|
requirements:
|
151
|
-
- - "~>"
|
152
|
-
- !ruby/object:Gem::Version
|
153
|
-
version: '1.0'
|
154
151
|
- - ">="
|
155
152
|
- !ruby/object:Gem::Version
|
156
153
|
version: 1.0.5
|
154
|
+
- - "<"
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '3'
|
157
157
|
- !ruby/object:Gem::Dependency
|
158
158
|
name: rubocop
|
159
159
|
requirement: !ruby/object:Gem::Requirement
|
@@ -317,6 +317,7 @@ files:
|
|
317
317
|
- lib/solargraph/api_map/source_to_yard.rb
|
318
318
|
- lib/solargraph/api_map/store.rb
|
319
319
|
- lib/solargraph/bundle.rb
|
320
|
+
- lib/solargraph/compat.rb
|
320
321
|
- lib/solargraph/complex_type.rb
|
321
322
|
- lib/solargraph/complex_type/type_methods.rb
|
322
323
|
- lib/solargraph/complex_type/unique_type.rb
|