solargraph 0.39.0 → 0.39.6
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/documentor.rb +2 -0
- data/lib/solargraph/language_server/host.rb +1 -1
- data/lib/solargraph/language_server/message/text_document/formatting.rb +6 -2
- data/lib/solargraph/language_server/uri_helpers.rb +22 -3
- data/lib/solargraph/parser/legacy/class_methods.rb +4 -0
- data/lib/solargraph/parser/legacy/node_chainer.rb +5 -2
- data/lib/solargraph/parser/legacy/node_methods.rb +13 -2
- data/lib/solargraph/parser/legacy/node_processors/send_node.rb +2 -0
- data/lib/solargraph/parser/rubyvm/class_methods.rb +6 -2
- data/lib/solargraph/parser/rubyvm/node_chainer.rb +4 -2
- data/lib/solargraph/parser/rubyvm/node_methods.rb +4 -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 +4 -41
- data/lib/solargraph/parser/rubyvm/node_processors.rb +1 -0
- data/lib/solargraph/pin/attribute.rb +1 -1
- data/lib/solargraph/pin/base_method.rb +1 -1
- data/lib/solargraph/pin/base_variable.rb +1 -1
- data/lib/solargraph/pin/block.rb +1 -1
- 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 +1 -1
- 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/call.rb +9 -0
- data/lib/solargraph/source/chain/head.rb +14 -8
- data/lib/solargraph/source/chain/z_super.rb +184 -0
- data/lib/solargraph/source/chain.rb +1 -0
- data/lib/solargraph/source.rb +14 -3
- data/lib/solargraph/source_map/mapper.rb +11 -7
- data/lib/solargraph/type_checker.rb +25 -1
- 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/mapper.rb +3 -0
- data/lib/solargraph/yard_map/rdoc_to_yard.rb +13 -6
- data/lib/solargraph/yard_map.rb +102 -69
- metadata +4 -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: 4a81ce77f7d8227f2e1bf419edb00bbb35c104f9432f3bf9fca55453f70d118b
|
|
4
|
+
data.tar.gz: 3a3fa7eab3220e6933d4aa79d882caf25f2ec2a21e267b062237d4f3f1437ca2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 12fac0ebf0358c1949dde571705a5969049ff72b27d2d2385f72d1272f813ebf133a4aebb5f567462b7d31f105e4960e33fe11f87b2987b00a0a3858e7d533c7
|
|
7
|
+
data.tar.gz: f2562a24884685db6290dfd7c13894949dab71989466dc60ade3a3c2694c90c27ad1d110cc0001e0b03adb1aaabc4ab7ef34d3b8b6fb0ffe5fd8b268c7b70d36
|
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')
|
|
@@ -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}"
|
|
@@ -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
|
|
@@ -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,26 @@ 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
|
+
end
|
|
38
|
+
|
|
39
|
+
# Decode text from a URI path component in LSP.
|
|
40
|
+
#
|
|
41
|
+
# @param text [String]
|
|
42
|
+
# @return [String]
|
|
43
|
+
def decode text
|
|
44
|
+
CGI.unescape(text)
|
|
26
45
|
end
|
|
27
46
|
end
|
|
28
47
|
end
|
|
@@ -73,8 +73,11 @@ module Solargraph
|
|
|
73
73
|
end
|
|
74
74
|
elsif n.type == :self
|
|
75
75
|
result.push Chain::Head.new('self')
|
|
76
|
-
elsif
|
|
77
|
-
result.push Chain::
|
|
76
|
+
elsif n.type == :zsuper
|
|
77
|
+
result.push Chain::ZSuper.new('super', @in_block || block_passed?(n))
|
|
78
|
+
elsif n.type == :super
|
|
79
|
+
args = n.children.map { |c| NodeChainer.chain(c) }
|
|
80
|
+
result.push Chain::Call.new('super', args, @in_block || block_passed?(n))
|
|
78
81
|
elsif n.type == :const
|
|
79
82
|
const = unpack_name(n)
|
|
80
83
|
result.push Chain::Constant.new(const)
|
|
@@ -129,6 +129,13 @@ module Solargraph
|
|
|
129
129
|
elsif node.type == :send
|
|
130
130
|
result.push node
|
|
131
131
|
node.children[2..-1].each { |child| result.concat call_nodes_from(child) }
|
|
132
|
+
elsif [:super, :zsuper].include?(node.type)
|
|
133
|
+
result.push node
|
|
134
|
+
node.children.each { |child| result.concat call_nodes_from(child) }
|
|
135
|
+
elsif node.type == :masgn
|
|
136
|
+
# @todo We're treating a mass assignment as a call node, but the
|
|
137
|
+
# type checker still needs the logic to handle it.
|
|
138
|
+
result.push node
|
|
132
139
|
else
|
|
133
140
|
node.children.each { |child| result.concat call_nodes_from(child) }
|
|
134
141
|
end
|
|
@@ -210,8 +217,12 @@ module Solargraph
|
|
|
210
217
|
result.concat get_return_nodes_only(node.children[2])
|
|
211
218
|
elsif node.type == :case
|
|
212
219
|
node.children[1..-1].each do |cc|
|
|
213
|
-
|
|
214
|
-
|
|
220
|
+
if cc.nil?
|
|
221
|
+
result.push NIL_NODE
|
|
222
|
+
else
|
|
223
|
+
result.concat reduce_to_value_nodes(cc.children[1..-2]) unless cc.children.length < 1
|
|
224
|
+
result.concat reduce_to_value_nodes([cc.children.last])
|
|
225
|
+
end
|
|
215
226
|
end
|
|
216
227
|
else
|
|
217
228
|
result.push node
|
|
@@ -153,6 +153,7 @@ module Solargraph
|
|
|
153
153
|
location: ref.location,
|
|
154
154
|
closure: ref.closure,
|
|
155
155
|
name: ref.name,
|
|
156
|
+
parameters: ref.parameters,
|
|
156
157
|
comments: ref.comments,
|
|
157
158
|
scope: :class,
|
|
158
159
|
visibility: :public,
|
|
@@ -162,6 +163,7 @@ module Solargraph
|
|
|
162
163
|
location: ref.location,
|
|
163
164
|
closure: ref.closure,
|
|
164
165
|
name: ref.name,
|
|
166
|
+
parameters: ref.parameters,
|
|
165
167
|
comments: ref.comments,
|
|
166
168
|
scope: :instance,
|
|
167
169
|
visibility: :private,
|
|
@@ -8,7 +8,7 @@ module Solargraph
|
|
|
8
8
|
# @param filename [String]
|
|
9
9
|
# @return [Array(Parser::AST::Node, Array<Parser::Source::Comment>)]
|
|
10
10
|
def parse_with_comments code, filename = nil
|
|
11
|
-
node = RubyVM::AbstractSyntaxTree.parse(code)
|
|
11
|
+
node = RubyVM::AbstractSyntaxTree.parse(code).children[2]
|
|
12
12
|
comments = CommentRipper.new(code).parse
|
|
13
13
|
[node, comments]
|
|
14
14
|
rescue ::SyntaxError => e
|
|
@@ -20,7 +20,7 @@ module Solargraph
|
|
|
20
20
|
# @param line [Integer]
|
|
21
21
|
# @return [Parser::AST::Node]
|
|
22
22
|
def parse code, filename = nil, line = 0
|
|
23
|
-
RubyVM::AbstractSyntaxTree.parse(code)
|
|
23
|
+
RubyVM::AbstractSyntaxTree.parse(code).children[2]
|
|
24
24
|
rescue ::SyntaxError => e
|
|
25
25
|
raise Parser::SyntaxError, e.message
|
|
26
26
|
end
|
|
@@ -83,6 +83,10 @@ module Solargraph
|
|
|
83
83
|
NodeChainer.chain *args
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
+
def chain_string *args
|
|
87
|
+
NodeChainer.load_string *args
|
|
88
|
+
end
|
|
89
|
+
|
|
86
90
|
def process_node *args
|
|
87
91
|
Solargraph::Parser::NodeProcessor.process *args
|
|
88
92
|
end
|
|
@@ -69,8 +69,10 @@ module Solargraph
|
|
|
69
69
|
result.push Chain::Call.new(n.children[0].to_s, node_to_argchains(n.children[1]), @in_block || block_passed?(n))
|
|
70
70
|
elsif n.type == :SELF
|
|
71
71
|
result.push Chain::Head.new('self')
|
|
72
|
-
elsif
|
|
73
|
-
result.push Chain::
|
|
72
|
+
elsif n.type == :ZSUPER
|
|
73
|
+
result.push Chain::ZSuper.new('super', @in_block || block_passed?(n))
|
|
74
|
+
elsif n.type == :SUPER
|
|
75
|
+
result.push Chain::Call.new('super', node_to_argchains(n.children.last), @in_block || block_passed?(n))
|
|
74
76
|
elsif [:COLON2, :COLON3, :CONST].include?(n.type)
|
|
75
77
|
const = unpack_name(n)
|
|
76
78
|
result.push Chain::Constant.new(const)
|
|
@@ -76,6 +76,10 @@ module Solargraph
|
|
|
76
76
|
if node.type == :ITER
|
|
77
77
|
result.push node.children[0]
|
|
78
78
|
node.children[1..-1].each { |child| result.concat call_nodes_from(child) }
|
|
79
|
+
elsif node.type == :MASGN
|
|
80
|
+
# @todo We're treating a mass assignment as a call node, but the
|
|
81
|
+
# type checker still needs the logic to handle it.
|
|
82
|
+
result.push node
|
|
79
83
|
elsif [:CALL, :VCALL, :FCALL, :ATTRASGN, :OPCALL].include?(node.type)
|
|
80
84
|
result.push node
|
|
81
85
|
node.children.each { |child| result.concat call_nodes_from(child) }
|
|
@@ -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
|
|
@@ -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
|
|
@@ -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])
|
|
@@ -43,45 +43,7 @@ module Solargraph
|
|
|
43
43
|
process_prepend
|
|
44
44
|
elsif node.children[0] == :private_constant
|
|
45
45
|
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)'
|
|
46
|
+
elsif node.children[1] == :require && unpack_name(node.children[0]) == 'Bundler'
|
|
85
47
|
pins.push Pin::Reference::Require.new(Solargraph::Location.new(region.filename, Solargraph::Range.from_to(0, 0, 0, 0)), 'bundler/require')
|
|
86
48
|
end
|
|
87
49
|
process_children
|
|
@@ -270,6 +232,7 @@ module Solargraph
|
|
|
270
232
|
|
|
271
233
|
# @return [Boolean]
|
|
272
234
|
def process_private_class_method
|
|
235
|
+
return false unless Parser.is_ast_node?(node.children.last)
|
|
273
236
|
if node.children.last.children.first.type == :DEFN
|
|
274
237
|
process_children region.update(scope: :class, visibility: :private)
|
|
275
238
|
true
|
|
@@ -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
|
|
@@ -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
|
@@ -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")
|
|
@@ -28,6 +28,7 @@ module Solargraph
|
|
|
28
28
|
# @param name_pin [Pin::Base]
|
|
29
29
|
# @param locals [Array<Pin::Base>]
|
|
30
30
|
def resolve api_map, name_pin, locals
|
|
31
|
+
return super_pins(api_map, name_pin) if word == 'super'
|
|
31
32
|
found = if head?
|
|
32
33
|
locals.select { |p| p.name == word }
|
|
33
34
|
else
|
|
@@ -188,6 +189,14 @@ module Solargraph
|
|
|
188
189
|
return false if argcount < parcount && !(argcount == parcount - 1 && parameters.last.first.start_with?('*'))
|
|
189
190
|
true
|
|
190
191
|
end
|
|
192
|
+
|
|
193
|
+
# @param api_map [ApiMap]
|
|
194
|
+
# @param name_pin [Pin::Base]
|
|
195
|
+
# @return [Array<Pin::Base>]
|
|
196
|
+
def super_pins api_map, name_pin
|
|
197
|
+
pins = api_map.get_method_stack(name_pin.namespace, name_pin.name, scope: name_pin.scope)
|
|
198
|
+
pins.reject{|p| p.path == name_pin.path}
|
|
199
|
+
end
|
|
191
200
|
end
|
|
192
201
|
end
|
|
193
202
|
end
|
|
@@ -10,19 +10,25 @@ module Solargraph
|
|
|
10
10
|
class Head < Link
|
|
11
11
|
def resolve api_map, name_pin, locals
|
|
12
12
|
return [Pin::ProxyType.anonymous(name_pin.binder)] if word == 'self'
|
|
13
|
-
return super_pins(api_map, name_pin) if word == 'super'
|
|
13
|
+
# return super_pins(api_map, name_pin) if word == 'super'
|
|
14
14
|
[]
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
# @todo This is temporary. Chain heads need to handle arguments to
|
|
18
|
+
# `super`.
|
|
19
|
+
# def arguments
|
|
20
|
+
# []
|
|
21
|
+
# end
|
|
22
|
+
|
|
17
23
|
private
|
|
18
24
|
|
|
19
|
-
# @param api_map [ApiMap]
|
|
20
|
-
# @param name_pin [Pin::Base]
|
|
21
|
-
# @return [Array<Pin::Base>]
|
|
22
|
-
def super_pins api_map, name_pin
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
end
|
|
25
|
+
# # @param api_map [ApiMap]
|
|
26
|
+
# # @param name_pin [Pin::Base]
|
|
27
|
+
# # @return [Array<Pin::Base>]
|
|
28
|
+
# def super_pins api_map, name_pin
|
|
29
|
+
# pins = api_map.get_method_stack(name_pin.namespace, name_pin.name, scope: name_pin.scope)
|
|
30
|
+
# pins.reject{|p| p.path == name_pin.path}
|
|
31
|
+
# end
|
|
26
32
|
end
|
|
27
33
|
end
|
|
28
34
|
end
|