solargraph 0.39.3 → 0.39.4
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/.rubocop.yml +21 -0
- data/lib/solargraph/diagnostics/rubocop.rb +2 -1
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +4 -1
- data/lib/solargraph/language_server/message/text_document/formatting.rb +6 -2
- data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +1 -1
- data/lib/solargraph/source.rb +14 -3
- data/lib/solargraph/source_map/mapper.rb +2 -2
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/yard_map/rdoc_to_yard.rb +11 -6
- metadata +3 -3
- data/.rubocop.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a45c7684317779d321e953079f5da5532f7b7eecc852b73e609ce03dafc81dc
|
4
|
+
data.tar.gz: '08f96cb16887491e334fa276959cd019da3c356656a9a670c6133e491745fa55'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a9d7ec1fb35b5d870d33f16a9bf6b229b1f62a6221f7fac5d1d35e65620ac030cef5bd53c558a1ee007c37b4e187a43315abfa4cecaf146c3746e9b97a46f3f
|
7
|
+
data.tar.gz: 7537aa6bd14209895350f40830dd5986683982609c8e18d257eaca8993b0ab759b2e635ec6c952499a0d8559663b870c1db9b9a3c1955bd8dd096eaedde04d73
|
data/lib/.rubocop.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Layout/EndOfLine:
|
2
|
+
EnforcedStyle: lf
|
3
|
+
Style/MethodDefParentheses:
|
4
|
+
Enabled: false
|
5
|
+
Layout/EmptyLineAfterGuardClause:
|
6
|
+
Enabled: false
|
7
|
+
Layout/SpaceAroundMethodCallOperator:
|
8
|
+
Enabled: true
|
9
|
+
Lint/RaiseException:
|
10
|
+
Enabled: true
|
11
|
+
Lint/StructNewOverride:
|
12
|
+
Enabled: true
|
13
|
+
Style/ExponentialNotation:
|
14
|
+
Enabled: true
|
15
|
+
Style/HashEachMethods:
|
16
|
+
Enabled: true
|
17
|
+
Style/HashTransformKeys:
|
18
|
+
Enabled: true
|
19
|
+
Style/HashTransformValues:
|
20
|
+
Enabled: true
|
21
|
+
|
@@ -24,7 +24,8 @@ module Solargraph
|
|
24
24
|
# @return [Array<Hash>]
|
25
25
|
def diagnose source, _api_map
|
26
26
|
options, paths = generate_options(source.filename, source.code)
|
27
|
-
|
27
|
+
store = RuboCop::ConfigStore.new
|
28
|
+
runner = RuboCop::Runner.new(options, store)
|
28
29
|
result = redirect_stdout{ runner.run(paths) }
|
29
30
|
make_array JSON.parse(result)
|
30
31
|
rescue RuboCop::ValidationError, RuboCop::ConfigNotFoundError => e
|
@@ -17,7 +17,8 @@ module Solargraph
|
|
17
17
|
rubocop_file = find_rubocop_file(filename)
|
18
18
|
args.push('-c', fix_drive_letter(rubocop_file)) unless rubocop_file.nil?
|
19
19
|
args.push filename
|
20
|
-
|
20
|
+
base_options = RuboCop::Options.new
|
21
|
+
options, paths = base_options.parse(args)
|
21
22
|
options[:stdin] = code
|
22
23
|
[options, paths]
|
23
24
|
end
|
@@ -27,6 +28,8 @@ module Solargraph
|
|
27
28
|
# @param filename [String]
|
28
29
|
# @return [String, nil]
|
29
30
|
def find_rubocop_file filename
|
31
|
+
return nil unless File.exist?(filename)
|
32
|
+
filename = File.realpath(filename)
|
30
33
|
dir = File.dirname(filename)
|
31
34
|
until File.dirname(dir) == dir
|
32
35
|
here = File.join(dir, '.rubocop.yml')
|
@@ -16,11 +16,15 @@ module Solargraph
|
|
16
16
|
# detects the correct configuration
|
17
17
|
# the .rb extension is needed for ruby file without extension, else rubocop won't format
|
18
18
|
tempfile = File.join(File.dirname(filename), "_tmp_#{SecureRandom.hex(8)}_#{File.basename(filename)}.rb")
|
19
|
+
rubocop_file = Diagnostics::RubocopHelpers.find_rubocop_file(filename)
|
19
20
|
original = host.read_text(params['textDocument']['uri'])
|
20
21
|
File.write tempfile, original
|
21
22
|
begin
|
22
|
-
|
23
|
-
|
23
|
+
args = ['-a', '-f', 'fi', tempfile]
|
24
|
+
args.unshift('-c', fix_drive_letter(rubocop_file)) unless rubocop_file.nil?
|
25
|
+
options, paths = RuboCop::Options.new.parse(args)
|
26
|
+
store = RuboCop::ConfigStore.new
|
27
|
+
redirect_stdout { RuboCop::Runner.new(options, store).run(paths) }
|
24
28
|
result = File.read(tempfile)
|
25
29
|
File.unlink tempfile
|
26
30
|
format original, result
|
@@ -9,7 +9,7 @@ module Solargraph
|
|
9
9
|
|
10
10
|
def process
|
11
11
|
if [:private, :public, :protected].include?(node.children[0])
|
12
|
-
if
|
12
|
+
if node.type == :FCALL && Parser.is_ast_node?(node.children.last)
|
13
13
|
node.children.last.children[0..-2].each do |child|
|
14
14
|
# next unless child.is_a?(AST::Node) && (child.type == :sym || child.type == :str)
|
15
15
|
next unless child.type == :LIT || child.type == :STR
|
data/lib/solargraph/source.rb
CHANGED
@@ -338,8 +338,8 @@ module Solargraph
|
|
338
338
|
|
339
339
|
def first_not_empty_from line
|
340
340
|
cursor = line
|
341
|
-
cursor += 1 while cursor <
|
342
|
-
cursor = line if cursor >
|
341
|
+
cursor += 1 while cursor < code_lines.length && code_lines[cursor].strip.empty?
|
342
|
+
cursor = line if cursor > code_lines.length - 1
|
343
343
|
cursor
|
344
344
|
end
|
345
345
|
|
@@ -468,8 +468,12 @@ module Solargraph
|
|
468
468
|
# @return [Integer]
|
469
469
|
attr_writer :version
|
470
470
|
|
471
|
+
# @param val [String]
|
471
472
|
# @return [String]
|
472
|
-
|
473
|
+
def code=(val)
|
474
|
+
@code_lines= nil
|
475
|
+
@code = val
|
476
|
+
end
|
473
477
|
|
474
478
|
# @return [Parser::AST::Node]
|
475
479
|
attr_writer :node
|
@@ -492,6 +496,13 @@ module Solargraph
|
|
492
496
|
# @return [Source::Updater]
|
493
497
|
attr_accessor :last_updater
|
494
498
|
|
499
|
+
private
|
500
|
+
|
501
|
+
# @return [Array<String>]
|
502
|
+
def code_lines
|
503
|
+
@code_lines ||= code.lines
|
504
|
+
end
|
505
|
+
|
495
506
|
class << self
|
496
507
|
# @param filename [String]
|
497
508
|
# @return [Solargraph::Source]
|
@@ -185,9 +185,9 @@ module Solargraph
|
|
185
185
|
# @return [void]
|
186
186
|
def process_comment_directives
|
187
187
|
return unless @code =~ MACRO_REGEXP
|
188
|
-
|
188
|
+
code_lines = @code.lines
|
189
189
|
@source.associated_comments.each do |line, comments|
|
190
|
-
src_pos = line ? Position.new(line,
|
190
|
+
src_pos = line ? Position.new(line, code_lines[line].to_s.chomp.index(/[^\s]/) || 0) : Position.new(code_lines.length, 0)
|
191
191
|
com_pos = Position.new(line - 1, 0)
|
192
192
|
process_comment(src_pos, com_pos, comments)
|
193
193
|
end
|
data/lib/solargraph/version.rb
CHANGED
@@ -11,18 +11,23 @@ module Solargraph
|
|
11
11
|
extend ApiMap::SourceToYard
|
12
12
|
|
13
13
|
# @param spec [Gem::Specification]
|
14
|
-
|
14
|
+
# @param cache_dir [String]
|
15
|
+
# @return [void]
|
16
|
+
def self.run spec, cache_dir: nil
|
15
17
|
Dir.mktmpdir do |tmpdir|
|
16
18
|
rdir = File.join(tmpdir, 'rdoc')
|
17
19
|
Dir.chdir spec.full_gem_path do
|
18
20
|
pins = []
|
19
21
|
pins.push Solargraph::Pin::ROOT_PIN
|
20
22
|
name_hash = {}
|
21
|
-
|
23
|
+
|
24
|
+
argv = ['-q', '-N', '-r', '-o', rdir]
|
22
25
|
spec.load_paths.each do |path|
|
23
|
-
|
26
|
+
argv.concat ['-i', path]
|
24
27
|
end
|
25
|
-
|
28
|
+
rdoc = RDoc::RDoc.new
|
29
|
+
rdoc.document argv
|
30
|
+
|
26
31
|
store = RDoc::Store.new(rdir)
|
27
32
|
store.load_all
|
28
33
|
store.cache[:modules].each do |mod|
|
@@ -64,7 +69,7 @@ module Solargraph
|
|
64
69
|
closure: namepin,
|
65
70
|
comments: commentary(met.comment),
|
66
71
|
scope: met.type.to_sym,
|
67
|
-
|
72
|
+
parameters: pin.parameters,
|
68
73
|
visibility: met.visibility,
|
69
74
|
location: locate(met)
|
70
75
|
)
|
@@ -85,7 +90,7 @@ module Solargraph
|
|
85
90
|
code_object_map.values.each do |co|
|
86
91
|
YARD::Registry.register(co)
|
87
92
|
end
|
88
|
-
cache_dir
|
93
|
+
cache_dir ||= File.join(Solargraph::YardMap::CoreDocs.cache_dir, 'gems', "#{spec.name}-#{spec.version}", "yardoc")
|
89
94
|
FileUtils.remove_entry_secure cache_dir if File.exist?(cache_dir)
|
90
95
|
FileUtils.mkdir_p cache_dir
|
91
96
|
# @todo Should merge be true?
|
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.4
|
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-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backport
|
@@ -301,7 +301,6 @@ extra_rdoc_files: []
|
|
301
301
|
files:
|
302
302
|
- ".gitignore"
|
303
303
|
- ".rspec"
|
304
|
-
- ".rubocop.yml"
|
305
304
|
- ".travis.yml"
|
306
305
|
- ".yardopts"
|
307
306
|
- Gemfile
|
@@ -310,6 +309,7 @@ files:
|
|
310
309
|
- Rakefile
|
311
310
|
- SPONSORS.md
|
312
311
|
- bin/solargraph
|
312
|
+
- lib/.rubocop.yml
|
313
313
|
- lib/solargraph.rb
|
314
314
|
- lib/solargraph/api_map.rb
|
315
315
|
- lib/solargraph/api_map/bundler_methods.rb
|