solargraph 0.39.2 → 0.39.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7445b5b059ff10d5ff6b998209d3988a4d9f20b48b0b3e51b8e6b63000f18d1b
|
4
|
+
data.tar.gz: d17e09c8fecf38bb4bff9ca4d6985c898a2256cc6c56e4c54599b4be907e27b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61ed8f3f9f68ce49f2496e5fe07eeefbc1121350c15827bc0d600a2417e041d4f2b5d89c861c2f3b4873c20e02bd8fa708d2697b3e73d8e0ee0c858cb7c0f090
|
7
|
+
data.tar.gz: 6c3646376224f2237e404e4c6fcea9eaf02eaa1cfedebf9a01b6f89896d6454c03b7cbbdc16255549b528243d4c7f73a491f7d94e2d5866c6d15bc18a6db0323
|
@@ -30,7 +30,7 @@ module Solargraph
|
|
30
30
|
process_require
|
31
31
|
elsif node.children[0] == :alias_method
|
32
32
|
process_alias_method
|
33
|
-
elsif node.children[0] == :private_class_method
|
33
|
+
elsif node.children[0] == :private_class_method
|
34
34
|
# Processing a private class can potentially handle children on its own
|
35
35
|
return if process_private_class_method
|
36
36
|
elsif [:attr_reader, :attr_writer, :attr_accessor].include?(node.children[0])
|
@@ -270,6 +270,7 @@ module Solargraph
|
|
270
270
|
|
271
271
|
# @return [Boolean]
|
272
272
|
def process_private_class_method
|
273
|
+
return false unless Parser.is_ast_node?(node.children.last)
|
273
274
|
if node.children.last.children.first.type == :DEFN
|
274
275
|
process_children region.update(scope: :class, visibility: :private)
|
275
276
|
true
|
data/lib/solargraph/source.rb
CHANGED
@@ -339,7 +339,7 @@ module Solargraph
|
|
339
339
|
def first_not_empty_from line
|
340
340
|
cursor = line
|
341
341
|
cursor += 1 while cursor < code.lines.length && code.lines[cursor].strip.empty?
|
342
|
-
cursor = line if cursor > code.lines.length
|
342
|
+
cursor = line if cursor > code.lines.length - 1
|
343
343
|
cursor
|
344
344
|
end
|
345
345
|
|
@@ -68,7 +68,7 @@ module Solargraph
|
|
68
68
|
# @param d [YARD::Tags::Directive]
|
69
69
|
parse.directives.each do |d|
|
70
70
|
line_num = find_directive_line_number(cmnt, d.tag.tag_name, last_line)
|
71
|
-
pos = Solargraph::Position.new(comment_position.line + line_num, comment_position.column)
|
71
|
+
pos = Solargraph::Position.new(comment_position.line + line_num - 1, comment_position.column)
|
72
72
|
process_directive(source_position, pos, d)
|
73
73
|
last_line = line_num + 1
|
74
74
|
# @todo The below call assumes the topmost comment line. The above
|
@@ -79,6 +79,8 @@ module Solargraph
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
+
# @param comment [String]
|
83
|
+
# @return [Integer]
|
82
84
|
def find_directive_line_number comment, tag, start
|
83
85
|
num = comment.lines[start..-1].find_index do |line|
|
84
86
|
# Legacy method directives might be `@method` instead of `@!method`
|
@@ -96,7 +98,7 @@ module Solargraph
|
|
96
98
|
location = Location.new(@filename, Range.new(comment_position, comment_position))
|
97
99
|
case directive.tag.tag_name
|
98
100
|
when 'method'
|
99
|
-
namespace = closure_at(source_position)
|
101
|
+
namespace = closure_at(source_position) || @pins.first
|
100
102
|
if namespace.location.range.start.line < comment_position.line
|
101
103
|
namespace = closure_at(comment_position)
|
102
104
|
end
|
@@ -105,9 +107,9 @@ module Solargraph
|
|
105
107
|
src_node = Parser.parse("def #{directive.tag.name};end", @filename, location.range.start.line)
|
106
108
|
gen_pin = Parser.process_node(src_node, region).first.last
|
107
109
|
return if gen_pin.nil?
|
108
|
-
# Move the location to the end of the line so
|
109
|
-
#
|
110
|
-
shifted = Solargraph::Position.new(comment_position.line, @code.lines[comment_position.line].chomp.length)
|
110
|
+
# Move the location to the end of the line so it gets recognized
|
111
|
+
# as originating from a comment
|
112
|
+
shifted = Solargraph::Position.new(comment_position.line, @code.lines[comment_position.line].to_s.chomp.length)
|
111
113
|
# @todo: Smelly instance variable access
|
112
114
|
gen_pin.instance_variable_set(:@comments, docstring.all.to_s)
|
113
115
|
gen_pin.instance_variable_set(:@location, Solargraph::Location.new(@filename, Range.new(shifted, shifted)))
|
data/lib/solargraph/version.rb
CHANGED
data/lib/solargraph/yard_map.rb
CHANGED
@@ -110,52 +110,8 @@ module Solargraph
|
|
110
110
|
|
111
111
|
# @return [Array<Solargraph::Pin::Base>]
|
112
112
|
def core_pins
|
113
|
-
|
114
|
-
|
115
|
-
ser = File.join(File.dirname(yd), 'core.ser')
|
116
|
-
result = []
|
117
|
-
if File.file?(ser)
|
118
|
-
file = File.open(ser, 'rb')
|
119
|
-
dump = file.read
|
120
|
-
file.close
|
121
|
-
result.concat Marshal.load(dump)
|
122
|
-
else
|
123
|
-
load_yardoc CoreDocs.yardoc_file
|
124
|
-
result.concat Mapper.new(YARD::Registry.all).map
|
125
|
-
# HACK: Assume core methods with a single `args` parameter accept restarg
|
126
|
-
result.select { |pin| pin.is_a?(Solargraph::Pin::BaseMethod )}.each do |pin|
|
127
|
-
if pin.parameters.length == 1 && pin.parameters.first.name == 'args' && pin.parameters.first.decl == :arg
|
128
|
-
# @todo Smelly instance variable access
|
129
|
-
pin.parameters.first.instance_variable_set(:@decl, :restarg)
|
130
|
-
end
|
131
|
-
end
|
132
|
-
# HACK: Set missing parameters on `==` methods, e.g., `Symbol#==`
|
133
|
-
result.select { |pin| pin.name == '==' && pin.parameters.empty? }.each do |pin|
|
134
|
-
pin.parameters.push Pin::Parameter.new(decl: :arg, name: 'obj2')
|
135
|
-
end
|
136
|
-
dump = Marshal.dump(result)
|
137
|
-
file = File.open(ser, 'wb')
|
138
|
-
file.write dump
|
139
|
-
file.close
|
140
|
-
end
|
141
|
-
# HACK: Add Errno exception classes
|
142
|
-
errno = result.select{ |pin| pin.path == 'Errno' }.first
|
143
|
-
Errno.constants.each do |const|
|
144
|
-
result.push Solargraph::Pin::Namespace.new(type: :class, name: const.to_s, closure: errno)
|
145
|
-
result.push Solargraph::Pin::Reference::Superclass.new(closure: result.last, name: 'SystemCallError')
|
146
|
-
end
|
147
|
-
CoreFills::OVERRIDES.each do |ovr|
|
148
|
-
pin = result.select { |p| p.path == ovr.name }.first
|
149
|
-
next if pin.nil?
|
150
|
-
(ovr.tags.map(&:tag_name) + ovr.delete).uniq.each do |tag|
|
151
|
-
pin.docstring.delete_tags tag.to_sym
|
152
|
-
end
|
153
|
-
ovr.tags.each do |tag|
|
154
|
-
pin.docstring.add_tag(tag)
|
155
|
-
end
|
156
|
-
end
|
157
|
-
result
|
158
|
-
end
|
113
|
+
# Using a class variable to reduce loads
|
114
|
+
@@core_pins ||= load_core_pins
|
159
115
|
end
|
160
116
|
|
161
117
|
# @param path [String]
|
@@ -237,31 +193,12 @@ module Solargraph
|
|
237
193
|
base = r.split('/').first
|
238
194
|
next if from_std.include?(base)
|
239
195
|
from_std.push base
|
240
|
-
stdtmp =
|
241
|
-
ser = File.join(File.dirname(CoreDocs.yardoc_stdlib_file), "#{base}.ser")
|
242
|
-
if File.file?(ser)
|
243
|
-
Solargraph.logger.info "Loading #{base} stdlib from cache"
|
244
|
-
file = File.open(ser, 'rb')
|
245
|
-
dump = file.read
|
246
|
-
file.close
|
247
|
-
stdtmp.concat Marshal.load(dump)
|
248
|
-
else
|
249
|
-
if stdlib_paths[base]
|
250
|
-
Solargraph.logger.info "Loading #{base} stdlib from yardoc"
|
251
|
-
stdtmp.concat Mapper.new(stdlib_paths[base]).map
|
252
|
-
next if stdtmp.empty?
|
253
|
-
dump = Marshal.dump(stdtmp)
|
254
|
-
file = File.open(ser, 'wb')
|
255
|
-
file.write dump
|
256
|
-
file.close
|
257
|
-
end
|
258
|
-
end
|
196
|
+
stdtmp = load_stdlib_pins(base)
|
259
197
|
if stdtmp.empty?
|
260
198
|
unresolved_requires.push r
|
261
199
|
else
|
262
200
|
stdlib_fill base, stdtmp
|
263
201
|
result.concat stdtmp
|
264
|
-
# stdnames[r] = stdtmp
|
265
202
|
end
|
266
203
|
end
|
267
204
|
result.delete_if(&:nil?)
|
@@ -270,7 +207,6 @@ module Solargraph
|
|
270
207
|
pins.concat result
|
271
208
|
end
|
272
209
|
end
|
273
|
-
# pins.concat process_stdlib(stdnames)
|
274
210
|
pins.concat core_pins
|
275
211
|
end
|
276
212
|
|
@@ -316,7 +252,12 @@ module Solargraph
|
|
316
252
|
file = File.open(ser, 'rb')
|
317
253
|
dump = file.read
|
318
254
|
file.close
|
319
|
-
|
255
|
+
begin
|
256
|
+
return Marshal.load(dump)
|
257
|
+
rescue StandardError => e
|
258
|
+
Solargraph.logger.warn "Error loading pin cache: [#{e.class}] #{e.message}"
|
259
|
+
File.unlink ser
|
260
|
+
end
|
320
261
|
end
|
321
262
|
end
|
322
263
|
if !size.nil? && size > 20_000_000
|
@@ -379,6 +320,98 @@ module Solargraph
|
|
379
320
|
end
|
380
321
|
end
|
381
322
|
end
|
323
|
+
|
324
|
+
def load_core_pins
|
325
|
+
yd = CoreDocs.yardoc_file
|
326
|
+
ser = File.join(File.dirname(yd), 'core.ser')
|
327
|
+
result = if File.file?(ser)
|
328
|
+
file = File.open(ser, 'rb')
|
329
|
+
dump = file.read
|
330
|
+
file.close
|
331
|
+
begin
|
332
|
+
Marshal.load(dump)
|
333
|
+
rescue StandardError => e
|
334
|
+
Solargraph.logger.warn "Error loading core pin cache: [#{e.class}] #{e.message}"
|
335
|
+
File.unlink ser
|
336
|
+
read_core_and_save_cache(yd, ser)
|
337
|
+
end
|
338
|
+
else
|
339
|
+
read_core_and_save_cache(yd, ser)
|
340
|
+
end
|
341
|
+
# HACK: Add Errno exception classes
|
342
|
+
errno = result.select{ |pin| pin.path == 'Errno' }.first
|
343
|
+
Errno.constants.each do |const|
|
344
|
+
result.push Solargraph::Pin::Namespace.new(type: :class, name: const.to_s, closure: errno)
|
345
|
+
result.push Solargraph::Pin::Reference::Superclass.new(closure: result.last, name: 'SystemCallError')
|
346
|
+
end
|
347
|
+
CoreFills::OVERRIDES.each do |ovr|
|
348
|
+
pin = result.select { |p| p.path == ovr.name }.first
|
349
|
+
next if pin.nil?
|
350
|
+
(ovr.tags.map(&:tag_name) + ovr.delete).uniq.each do |tag|
|
351
|
+
pin.docstring.delete_tags tag.to_sym
|
352
|
+
end
|
353
|
+
ovr.tags.each do |tag|
|
354
|
+
pin.docstring.add_tag(tag)
|
355
|
+
end
|
356
|
+
end
|
357
|
+
result
|
358
|
+
end
|
359
|
+
|
360
|
+
def read_core_and_save_cache yd, ser
|
361
|
+
result = []
|
362
|
+
load_yardoc yd
|
363
|
+
result.concat Mapper.new(YARD::Registry.all).map
|
364
|
+
# HACK: Assume core methods with a single `args` parameter accept restarg
|
365
|
+
result.select { |pin| pin.is_a?(Solargraph::Pin::BaseMethod )}.each do |pin|
|
366
|
+
if pin.parameters.length == 1 && pin.parameters.first.name == 'args' && pin.parameters.first.decl == :arg
|
367
|
+
# @todo Smelly instance variable access
|
368
|
+
pin.parameters.first.instance_variable_set(:@decl, :restarg)
|
369
|
+
end
|
370
|
+
end
|
371
|
+
# HACK: Set missing parameters on `==` methods, e.g., `Symbol#==`
|
372
|
+
result.select { |pin| pin.name == '==' && pin.parameters.empty? }.each do |pin|
|
373
|
+
pin.parameters.push Pin::Parameter.new(decl: :arg, name: 'obj2')
|
374
|
+
end
|
375
|
+
dump = Marshal.dump(result)
|
376
|
+
file = File.open(ser, 'wb')
|
377
|
+
file.write dump
|
378
|
+
file.close
|
379
|
+
result
|
380
|
+
end
|
381
|
+
|
382
|
+
def load_stdlib_pins base
|
383
|
+
ser = File.join(File.dirname(CoreDocs.yardoc_stdlib_file), "#{base}.ser")
|
384
|
+
if File.file?(ser)
|
385
|
+
Solargraph.logger.info "Loading #{base} stdlib from cache"
|
386
|
+
file = File.open(ser, 'rb')
|
387
|
+
dump = file.read
|
388
|
+
file.close
|
389
|
+
begin
|
390
|
+
Marshal.load(dump)
|
391
|
+
rescue StandardError => e
|
392
|
+
Solargraph.logger.warn "Error loading #{base} stdlib pin cache: [#{e.class}] #{e.message}"
|
393
|
+
File.unlink ser
|
394
|
+
read_stdlib_and_save_cache(base, ser)
|
395
|
+
end
|
396
|
+
else
|
397
|
+
read_stdlib_and_save_cache(base, ser)
|
398
|
+
end
|
399
|
+
end
|
400
|
+
|
401
|
+
def read_stdlib_and_save_cache base, ser
|
402
|
+
result = []
|
403
|
+
if stdlib_paths[base]
|
404
|
+
Solargraph.logger.info "Loading #{base} stdlib from yardoc"
|
405
|
+
result.concat Mapper.new(stdlib_paths[base]).map
|
406
|
+
unless result.empty?
|
407
|
+
dump = Marshal.dump(result)
|
408
|
+
file = File.open(ser, 'wb')
|
409
|
+
file.write dump
|
410
|
+
file.close
|
411
|
+
end
|
412
|
+
end
|
413
|
+
result
|
414
|
+
end
|
382
415
|
end
|
383
416
|
end
|
384
417
|
|
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.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-04-
|
11
|
+
date: 2020-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backport
|