solargraph 0.39.17 → 0.40.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -7
- data/CHANGELOG.md +984 -0
- data/SPONSORS.md +1 -0
- data/lib/solargraph.rb +2 -4
- data/lib/solargraph/api_map.rb +61 -64
- data/lib/solargraph/api_map/cache.rb +2 -2
- data/lib/solargraph/api_map/store.rb +3 -7
- data/lib/solargraph/{bundle.rb → bench.rb} +6 -2
- data/lib/solargraph/compat.rb +14 -0
- data/lib/solargraph/convention.rb +13 -4
- data/lib/solargraph/convention/base.rb +16 -8
- data/lib/solargraph/convention/gemfile.rb +2 -5
- data/lib/solargraph/convention/gemspec.rb +3 -6
- data/lib/solargraph/convention/rspec.rb +3 -6
- data/lib/solargraph/environ.rb +11 -6
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +6 -1
- data/lib/solargraph/language_server/message/text_document/definition.rb +1 -1
- data/lib/solargraph/library.rb +5 -5
- data/lib/solargraph/parser/legacy/node_processors/ivasgn_node.rb +1 -1
- data/lib/solargraph/parser/legacy/node_processors/send_node.rb +34 -22
- data/lib/solargraph/parser/node_processor/base.rb +3 -0
- data/lib/solargraph/parser/rubyvm/node_processors/args_node.rb +1 -1
- data/lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb +1 -1
- data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +38 -28
- data/lib/solargraph/pin.rb +0 -3
- data/lib/solargraph/pin/common.rb +1 -1
- data/lib/solargraph/pin/conversions.rb +1 -1
- data/lib/solargraph/pin/documenting.rb +3 -9
- data/lib/solargraph/pin/method.rb +141 -7
- data/lib/solargraph/pin/method_alias.rb +1 -1
- data/lib/solargraph/position.rb +2 -14
- data/lib/solargraph/source.rb +10 -6
- data/lib/solargraph/source/chain.rb +3 -3
- data/lib/solargraph/source_map.rb +4 -1
- data/lib/solargraph/source_map/clip.rb +3 -2
- data/lib/solargraph/source_map/mapper.rb +10 -6
- data/lib/solargraph/type_checker.rb +35 -39
- data/lib/solargraph/type_checker/param_def.rb +1 -1
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/yard_map.rb +38 -47
- data/lib/solargraph/yard_map/core_fills.rb +185 -0
- data/lib/solargraph/yard_map/helpers.rb +16 -0
- data/lib/solargraph/yard_map/mapper.rb +11 -5
- data/lib/solargraph/{pin/yard_pin/constant.rb → yard_map/mapper/to_constant.rb} +6 -6
- data/lib/solargraph/yard_map/mapper/to_method.rb +78 -0
- data/lib/solargraph/{pin/yard_pin/namespace.rb → yard_map/mapper/to_namespace.rb} +6 -6
- data/lib/solargraph/yard_map/rdoc_to_yard.rb +1 -1
- data/lib/solargraph/yard_map/stdlib_fills.rb +43 -0
- data/lib/solargraph/{pin/yard_pin/method.rb → yard_map/to_method.rb} +29 -30
- data/solargraph.gemspec +4 -4
- metadata +20 -34
- data/lib/solargraph/core_fills.rb +0 -164
- data/lib/solargraph/pin/attribute.rb +0 -49
- data/lib/solargraph/pin/base_method.rb +0 -149
- data/lib/solargraph/pin/yard_pin.rb +0 -12
- data/lib/solargraph/pin/yard_pin/yard_mixin.rb +0 -20
- data/lib/solargraph/stdlib_fills.rb +0 -40
- data/travis-bundler.rb +0 -11
@@ -2,22 +2,30 @@
|
|
2
2
|
|
3
3
|
module Solargraph
|
4
4
|
module Convention
|
5
|
+
# The base class for Conventions.
|
6
|
+
#
|
7
|
+
# A Convention provides Environs that customize ApiMaps with additional
|
8
|
+
# pins and other information. Subclasses should implement the `local` and
|
9
|
+
# `global` methods as necessary.
|
10
|
+
#
|
5
11
|
class Base
|
6
12
|
EMPTY_ENVIRON = Environ.new
|
7
13
|
|
8
|
-
#
|
9
|
-
# Subclasses
|
14
|
+
# The Environ for a source map.
|
15
|
+
# Subclasses can override this method.
|
10
16
|
#
|
11
|
-
# @param
|
12
|
-
|
13
|
-
|
17
|
+
# @param source_map [SourceMap]
|
18
|
+
# @return [Environ]
|
19
|
+
def local source_map
|
20
|
+
EMPTY_ENVIRON
|
14
21
|
end
|
15
22
|
|
16
|
-
# The Environ for
|
17
|
-
# Subclasses
|
23
|
+
# The Environ for a YARD map.
|
24
|
+
# Subclasses can override this method.
|
18
25
|
#
|
26
|
+
# @param yard_map [YardMap]
|
19
27
|
# @return [Environ]
|
20
|
-
def
|
28
|
+
def global yard_map
|
21
29
|
EMPTY_ENVIRON
|
22
30
|
end
|
23
31
|
end
|
@@ -3,11 +3,8 @@
|
|
3
3
|
module Solargraph
|
4
4
|
module Convention
|
5
5
|
class Gemfile < Base
|
6
|
-
def
|
7
|
-
File.basename(
|
8
|
-
end
|
9
|
-
|
10
|
-
def environ
|
6
|
+
def local source_map
|
7
|
+
return EMPTY_ENVIRON unless File.basename(source_map.filename) == 'Gemfile'
|
11
8
|
@environ ||= Environ.new(
|
12
9
|
requires: ['bundler'],
|
13
10
|
domains: ['Bundler::Dsl']
|
@@ -3,14 +3,11 @@
|
|
3
3
|
module Solargraph
|
4
4
|
module Convention
|
5
5
|
class Gemspec < Base
|
6
|
-
def
|
7
|
-
File.basename(
|
8
|
-
end
|
9
|
-
|
10
|
-
def environ
|
6
|
+
def local source_map
|
7
|
+
return EMPTY_ENVIRON unless File.basename(source_map.filename).end_with?('.gemspec')
|
11
8
|
@environ ||= Environ.new(
|
12
9
|
requires: ['rubygems'],
|
13
|
-
|
10
|
+
pins: [
|
14
11
|
Solargraph::Pin::Reference::Override.from_comment(
|
15
12
|
'Gem::Specification.new',
|
16
13
|
%(
|
@@ -3,18 +3,15 @@
|
|
3
3
|
module Solargraph
|
4
4
|
module Convention
|
5
5
|
class Rspec < Base
|
6
|
-
def
|
7
|
-
File.basename(
|
8
|
-
end
|
9
|
-
|
10
|
-
def environ
|
6
|
+
def local source_map
|
7
|
+
return EMPTY_ENVIRON unless File.basename(source_map.filename) =~ /_spec\.rb$/
|
11
8
|
@environ ||= Environ.new(
|
12
9
|
requires: ['rspec'],
|
13
10
|
domains: ['RSpec::Matchers', 'RSpec::ExpectationGroups'],
|
14
11
|
# This override is necessary due to an erroneous @return tag in
|
15
12
|
# rspec's YARD documentation.
|
16
13
|
# @todo The return types have been fixed (https://github.com/rspec/rspec-expectations/pull/1121)
|
17
|
-
|
14
|
+
pins: [
|
18
15
|
Solargraph::Pin::Reference::Override.method_return('RSpec::Matchers#expect', 'RSpec::Expectations::ExpectationTarget')
|
19
16
|
]
|
20
17
|
)
|
data/lib/solargraph/environ.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Solargraph
|
4
|
+
# A collection of additional data, such as map pins and required paths, that
|
5
|
+
# can be added to an ApiMap.
|
6
|
+
#
|
7
|
+
# Conventions are used to add Environs.
|
8
|
+
#
|
4
9
|
class Environ
|
5
10
|
# @return [Array<String>]
|
6
11
|
attr_reader :requires
|
@@ -9,22 +14,22 @@ module Solargraph
|
|
9
14
|
attr_reader :domains
|
10
15
|
|
11
16
|
# @return [Array<Pin::Reference::Override>]
|
12
|
-
attr_reader :
|
17
|
+
attr_reader :pins
|
13
18
|
|
14
19
|
# @param requires [Array<String>]
|
15
20
|
# @param domains [Array<String>]
|
16
|
-
# @param
|
17
|
-
def initialize requires: [], domains: [],
|
21
|
+
# @param pins [Array<Pin::Base>]
|
22
|
+
def initialize requires: [], domains: [], pins: []
|
18
23
|
@requires = requires
|
19
24
|
@domains = domains
|
20
|
-
@
|
25
|
+
@pins = pins
|
21
26
|
end
|
22
27
|
|
23
28
|
# @return [self]
|
24
29
|
def clear
|
25
30
|
domains.clear
|
26
31
|
requires.clear
|
27
|
-
|
32
|
+
pins.clear
|
28
33
|
self
|
29
34
|
end
|
30
35
|
|
@@ -33,7 +38,7 @@ module Solargraph
|
|
33
38
|
def merge other
|
34
39
|
domains.concat other.domains
|
35
40
|
requires.concat other.requires
|
36
|
-
|
41
|
+
pins.concat other.pins
|
37
42
|
self
|
38
43
|
end
|
39
44
|
end
|
@@ -34,7 +34,12 @@ module Solargraph
|
|
34
34
|
LanguageServer::MessageTypes::INFO,
|
35
35
|
['Update now'] do |result|
|
36
36
|
next unless result == 'Update now'
|
37
|
-
|
37
|
+
cmd = if host.options['useBundler']
|
38
|
+
'bundle update solargraph'
|
39
|
+
else
|
40
|
+
'gem update solargraph'
|
41
|
+
end
|
42
|
+
o, s = Open3.capture2(cmd)
|
38
43
|
if s == 0
|
39
44
|
host.show_message 'Successfully updated the Solargraph gem.', LanguageServer::MessageTypes::INFO
|
40
45
|
host.send_notification '$/solargraph/restart', {}
|
@@ -13,7 +13,7 @@ module Solargraph::LanguageServer::Message::TextDocument
|
|
13
13
|
def code_location
|
14
14
|
suggestions = host.definitions_at(params['textDocument']['uri'], @line, @column)
|
15
15
|
return nil if suggestions.empty?
|
16
|
-
suggestions.reject{|pin| pin.location.nil?}.map do |pin|
|
16
|
+
suggestions.reject { |pin| pin.location.nil? || pin.location.filename.nil? }.map do |pin|
|
17
17
|
{
|
18
18
|
uri: file_to_uri(pin.location.filename),
|
19
19
|
range: pin.location.range.to_hash
|
data/lib/solargraph/library.rb
CHANGED
@@ -20,7 +20,7 @@ module Solargraph
|
|
20
20
|
def initialize workspace = Solargraph::Workspace.new, name = nil
|
21
21
|
@workspace = workspace
|
22
22
|
@name = name
|
23
|
-
api_map.catalog
|
23
|
+
api_map.catalog bench
|
24
24
|
@synchronized = true
|
25
25
|
@catalog_mutex = Mutex.new
|
26
26
|
end
|
@@ -351,7 +351,7 @@ module Solargraph
|
|
351
351
|
@catalog_mutex.synchronize do
|
352
352
|
break if synchronized?
|
353
353
|
logger.info "Cataloging #{workspace.directory.empty? ? 'generic workspace' : workspace.directory}"
|
354
|
-
api_map.catalog
|
354
|
+
api_map.catalog bench
|
355
355
|
@synchronized = true
|
356
356
|
logger.info "Catalog complete (#{api_map.source_maps.length} files, #{api_map.pins.length} pins)" if logger.info?
|
357
357
|
end
|
@@ -403,9 +403,9 @@ module Solargraph
|
|
403
403
|
@api_map ||= Solargraph::ApiMap.new
|
404
404
|
end
|
405
405
|
|
406
|
-
# @return [
|
407
|
-
def
|
408
|
-
|
406
|
+
# @return [Bench]
|
407
|
+
def bench
|
408
|
+
Bench.new(
|
409
409
|
workspace: workspace,
|
410
410
|
opened: @current ? [@current] : []
|
411
411
|
)
|
@@ -19,7 +19,7 @@ module Solargraph
|
|
19
19
|
if region.visibility == :module_function
|
20
20
|
here = get_node_start_position(node)
|
21
21
|
named_path = named_path_pin(here)
|
22
|
-
if named_path.is_a?(Pin::
|
22
|
+
if named_path.is_a?(Pin::Method)
|
23
23
|
pins.push Solargraph::Pin::InstanceVariable.new(
|
24
24
|
location: loc,
|
25
25
|
closure: Pin::Namespace.new(type: :module, closure: region.closure.closure, name: region.closure.name),
|
@@ -10,20 +10,7 @@ module Solargraph
|
|
10
10
|
def process
|
11
11
|
if node.children[0].nil?
|
12
12
|
if [:private, :public, :protected].include?(node.children[1])
|
13
|
-
|
14
|
-
node.children[2..-1].each do |child|
|
15
|
-
next unless child.is_a?(AST::Node) && (child.type == :sym || child.type == :str)
|
16
|
-
name = child.children[0].to_s
|
17
|
-
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)}
|
18
|
-
matches.each do |pin|
|
19
|
-
# @todo Smelly instance variable access
|
20
|
-
pin.instance_variable_set(:@visibility, node.children[1])
|
21
|
-
end
|
22
|
-
end
|
23
|
-
else
|
24
|
-
# @todo Smelly instance variable access
|
25
|
-
region.instance_variable_set(:@visibility, node.children[1])
|
26
|
-
end
|
13
|
+
process_visibility
|
27
14
|
elsif node.children[1] == :module_function
|
28
15
|
process_module_function
|
29
16
|
elsif [:attr_reader, :attr_writer, :attr_accessor].include?(node.children[1])
|
@@ -54,6 +41,27 @@ module Solargraph
|
|
54
41
|
|
55
42
|
private
|
56
43
|
|
44
|
+
# @return [void]
|
45
|
+
def process_visibility
|
46
|
+
if (node.children.length > 2)
|
47
|
+
node.children[2..-1].each do |child|
|
48
|
+
if child.is_a?(AST::Node) && (child.type == :sym || child.type == :str)
|
49
|
+
name = child.children[0].to_s
|
50
|
+
matches = pins.select{ |pin| pin.is_a?(Pin::Method) && pin.name == name && pin.namespace == region.closure.full_context.namespace && pin.context.scope == (region.scope || :instance)}
|
51
|
+
matches.each do |pin|
|
52
|
+
# @todo Smelly instance variable access
|
53
|
+
pin.instance_variable_set(:@visibility, node.children[1])
|
54
|
+
end
|
55
|
+
else
|
56
|
+
process_children region.update(visibility: node.children[1])
|
57
|
+
end
|
58
|
+
end
|
59
|
+
else
|
60
|
+
# @todo Smelly instance variable access
|
61
|
+
region.instance_variable_set(:@visibility, node.children[1])
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
57
65
|
# @return [void]
|
58
66
|
def process_attribute
|
59
67
|
node.children[2..-1].each do |a|
|
@@ -61,26 +69,30 @@ module Solargraph
|
|
61
69
|
clos = region.closure
|
62
70
|
cmnt = comments_for(node)
|
63
71
|
if node.children[1] == :attr_reader || node.children[1] == :attr_accessor
|
64
|
-
pins.push Solargraph::Pin::
|
72
|
+
pins.push Solargraph::Pin::Method.new(
|
65
73
|
location: loc,
|
66
74
|
closure: clos,
|
67
75
|
name: a.children[0].to_s,
|
68
76
|
comments: cmnt,
|
69
|
-
access: :reader,
|
70
77
|
scope: region.scope || :instance,
|
71
|
-
visibility: region.visibility
|
78
|
+
visibility: region.visibility,
|
79
|
+
attribute: true
|
72
80
|
)
|
73
81
|
end
|
74
82
|
if node.children[1] == :attr_writer || node.children[1] == :attr_accessor
|
75
|
-
pins.push Solargraph::Pin::
|
83
|
+
pins.push Solargraph::Pin::Method.new(
|
76
84
|
location: loc,
|
77
85
|
closure: clos,
|
78
86
|
name: "#{a.children[0]}=",
|
79
87
|
comments: cmnt,
|
80
|
-
access: :writer,
|
81
88
|
scope: region.scope || :instance,
|
82
|
-
visibility: region.visibility
|
89
|
+
visibility: region.visibility,
|
90
|
+
attribute: true
|
83
91
|
)
|
92
|
+
pins.last.parameters.push Pin::Parameter.new(name: 'value', decl: :arg, closure: pins.last)
|
93
|
+
if pins.last.return_type.defined?
|
94
|
+
pins.last.docstring.add_tag YARD::Tags::Tag.new(:param, '', pins.last.return_type.to_s.split(', '), 'value')
|
95
|
+
end
|
84
96
|
end
|
85
97
|
end
|
86
98
|
end
|
@@ -157,7 +169,7 @@ module Solargraph
|
|
157
169
|
elsif node.children[2].type == :sym || node.children[2].type == :str
|
158
170
|
node.children[2..-1].each do |x|
|
159
171
|
cn = x.children[0].to_s
|
160
|
-
ref = pins.select{|p|
|
172
|
+
ref = pins.select{ |p| p.is_a?(Pin::Method) && p.namespace == region.closure.full_context.namespace && p.name == cn }.first
|
161
173
|
unless ref.nil?
|
162
174
|
pins.delete ref
|
163
175
|
mm = Solargraph::Pin::Method.new(
|
@@ -229,7 +241,7 @@ module Solargraph
|
|
229
241
|
# @return [Boolean]
|
230
242
|
def process_private_class_method
|
231
243
|
if node.children[2].type == :sym || node.children[2].type == :str
|
232
|
-
ref = pins.select{|p|
|
244
|
+
ref = pins.select { |p| p.is_a?(Pin::Method) && p.namespace == region.closure.full_context.namespace && p.name == node.children[2].children[0].to_s }.first
|
233
245
|
# HACK: Smelly instance variable access
|
234
246
|
ref.instance_variable_set(:@visibility, :private) unless ref.nil?
|
235
247
|
false
|
@@ -27,6 +27,7 @@ module Solargraph
|
|
27
27
|
@region = region
|
28
28
|
@pins = pins
|
29
29
|
@locals = locals
|
30
|
+
@processed_children = false
|
30
31
|
end
|
31
32
|
|
32
33
|
# Subclasses should override this method to generate new pins.
|
@@ -41,6 +42,8 @@ module Solargraph
|
|
41
42
|
# @param subregion [Region]
|
42
43
|
# @return [void]
|
43
44
|
def process_children subregion = region
|
45
|
+
return if @processed_children
|
46
|
+
@processed_children = true
|
44
47
|
node.children.each do |child|
|
45
48
|
next unless Parser.is_ast_node?(child)
|
46
49
|
NodeProcessor.process(child, subregion, pins, locals)
|
@@ -6,7 +6,7 @@ module Solargraph
|
|
6
6
|
module NodeProcessors
|
7
7
|
class ArgsNode < Parser::NodeProcessor::Base
|
8
8
|
def process
|
9
|
-
if region.closure.is_a?(Pin::
|
9
|
+
if region.closure.is_a?(Pin::Method) || region.closure.is_a?(Pin::Block)
|
10
10
|
if region.lvars[0].nil?
|
11
11
|
node.children[0].times do |i|
|
12
12
|
locals.push Solargraph::Pin::Parameter.new(
|
@@ -19,7 +19,7 @@ module Solargraph
|
|
19
19
|
if region.visibility == :module_function
|
20
20
|
rng = Range.from_node(node)
|
21
21
|
named_path = named_path_pin(rng.start)
|
22
|
-
if named_path.is_a?(Pin::
|
22
|
+
if named_path.is_a?(Pin::Method)
|
23
23
|
pins.push Solargraph::Pin::InstanceVariable.new(
|
24
24
|
location: loc,
|
25
25
|
closure: Pin::Namespace.new(type: :module, closure: region.closure.closure, name: region.closure.name),
|
@@ -9,21 +9,7 @@ module Solargraph
|
|
9
9
|
|
10
10
|
def process
|
11
11
|
if [:private, :public, :protected].include?(node.children[0])
|
12
|
-
|
13
|
-
node.children.last.children[0..-2].each do |child|
|
14
|
-
# next unless child.is_a?(AST::Node) && (child.type == :sym || child.type == :str)
|
15
|
-
next unless child.type == :LIT || child.type == :STR
|
16
|
-
name = child.children[0].to_s
|
17
|
-
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)}
|
18
|
-
matches.each do |pin|
|
19
|
-
# @todo Smelly instance variable access
|
20
|
-
pin.instance_variable_set(:@visibility, node.children[0])
|
21
|
-
end
|
22
|
-
end
|
23
|
-
else
|
24
|
-
# @todo Smelly instance variable access
|
25
|
-
region.instance_variable_set(:@visibility, node.children[0])
|
26
|
-
end
|
12
|
+
process_visibility
|
27
13
|
elsif node.children[0] == :module_function
|
28
14
|
process_module_function
|
29
15
|
elsif node.children[0] == :require
|
@@ -33,8 +19,7 @@ module Solargraph
|
|
33
19
|
elsif node.children[0] == :alias_method
|
34
20
|
process_alias_method
|
35
21
|
elsif node.children[0] == :private_class_method
|
36
|
-
|
37
|
-
return if process_private_class_method
|
22
|
+
process_private_class_method
|
38
23
|
elsif [:attr_reader, :attr_writer, :attr_accessor].include?(node.children[0])
|
39
24
|
process_attribute
|
40
25
|
elsif node.children[0] == :include
|
@@ -53,6 +38,28 @@ module Solargraph
|
|
53
38
|
|
54
39
|
private
|
55
40
|
|
41
|
+
# @return [void]
|
42
|
+
def process_visibility
|
43
|
+
if node.type == :FCALL && Parser.is_ast_node?(node.children.last)
|
44
|
+
node.children.last.children[0..-2].each do |child|
|
45
|
+
# next unless child.is_a?(AST::Node) && (child.type == :sym || child.type == :str)
|
46
|
+
if child.type == :LIT || child.type == :STR
|
47
|
+
name = child.children[0].to_s
|
48
|
+
matches = pins.select{ |pin| pin.is_a?(Pin::Method) && pin.name == name && pin.namespace == region.closure.full_context.namespace && pin.context.scope == (region.scope || :instance)}
|
49
|
+
matches.each do |pin|
|
50
|
+
# @todo Smelly instance variable access
|
51
|
+
pin.instance_variable_set(:@visibility, node.children[0])
|
52
|
+
end
|
53
|
+
else
|
54
|
+
process_children region.update(visibility: node.children[0])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
else
|
58
|
+
# @todo Smelly instance variable access
|
59
|
+
region.instance_variable_set(:@visibility, node.children[0])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
56
63
|
# @return [void]
|
57
64
|
def process_attribute
|
58
65
|
return unless Parser.is_ast_node?(node.children[1])
|
@@ -62,26 +69,30 @@ module Solargraph
|
|
62
69
|
clos = region.closure
|
63
70
|
cmnt = comments_for(node)
|
64
71
|
if node.children[0] == :attr_reader || node.children[0] == :attr_accessor
|
65
|
-
pins.push Solargraph::Pin::
|
72
|
+
pins.push Solargraph::Pin::Method.new(
|
66
73
|
location: loc,
|
67
74
|
closure: clos,
|
68
75
|
name: a.children[0].to_s,
|
69
76
|
comments: cmnt,
|
70
|
-
access: :reader,
|
71
77
|
scope: region.scope || :instance,
|
72
|
-
visibility: region.visibility
|
78
|
+
visibility: region.visibility,
|
79
|
+
attribute: true
|
73
80
|
)
|
74
81
|
end
|
75
82
|
if node.children[0] == :attr_writer || node.children[0] == :attr_accessor
|
76
|
-
pins.push Solargraph::Pin::
|
83
|
+
pins.push Solargraph::Pin::Method.new(
|
77
84
|
location: loc,
|
78
85
|
closure: clos,
|
79
86
|
name: "#{a.children[0]}=",
|
80
87
|
comments: cmnt,
|
81
|
-
access: :writer,
|
82
88
|
scope: region.scope || :instance,
|
83
|
-
visibility: region.visibility
|
89
|
+
visibility: region.visibility,
|
90
|
+
attribute: true
|
84
91
|
)
|
92
|
+
pins.last.parameters.push Pin::Parameter.new(name: 'value', decl: :arg, closure: pins.last)
|
93
|
+
if pins.last.return_type.defined?
|
94
|
+
pins.last.docstring.add_tag YARD::Tags::Tag.new(:param, '', pins.last.return_type.to_s.split(', '), 'value')
|
95
|
+
end
|
85
96
|
end
|
86
97
|
end
|
87
98
|
end
|
@@ -166,7 +177,7 @@ module Solargraph
|
|
166
177
|
node.children.last.children[0..-2].each do |x|
|
167
178
|
next unless [:LIT, :STR].include?(x.type)
|
168
179
|
cn = x.children[0].to_s
|
169
|
-
ref = pins.select{|p|
|
180
|
+
ref = pins.select { |p| p.is_a?(Pin::Method) && p.namespace == region.closure.full_context.namespace && p.name == cn }.first
|
170
181
|
unless ref.nil?
|
171
182
|
pins.delete ref
|
172
183
|
mm = Solargraph::Pin::Method.new(
|
@@ -215,6 +226,7 @@ module Solargraph
|
|
215
226
|
|
216
227
|
# @return [void]
|
217
228
|
def process_private_constant
|
229
|
+
# @todo Bare `private_constant` causes an error
|
218
230
|
node.children.last.children[0..-2].each do |child|
|
219
231
|
if [:LIT, :STR].include?(child.type)
|
220
232
|
cn = child.children[0].to_s
|
@@ -242,20 +254,18 @@ module Solargraph
|
|
242
254
|
)
|
243
255
|
end
|
244
256
|
|
245
|
-
# @return [
|
257
|
+
# @return [void]
|
246
258
|
def process_private_class_method
|
247
259
|
return false unless Parser.is_ast_node?(node.children.last)
|
248
260
|
if node.children.last.children.first.type == :DEFN
|
249
261
|
process_children region.update(scope: :class, visibility: :private)
|
250
|
-
true
|
251
262
|
else
|
252
263
|
node.children.last.children[0..-2].each do |child|
|
253
264
|
if child.type == :LIT && child.children.first.is_a?(::Symbol)
|
254
265
|
sym_name = child.children.first.to_s
|
255
|
-
ref = pins.select{|p|
|
266
|
+
ref = pins.select { |p| p.is_a?(Pin::Method) && p.namespace == region.closure.full_context.namespace && p.name == sym_name }.first
|
256
267
|
# HACK: Smelly instance variable access
|
257
268
|
ref.instance_variable_set(:@visibility, :private) unless ref.nil?
|
258
|
-
false
|
259
269
|
end
|
260
270
|
end
|
261
271
|
end
|