solargraph 0.33.2 → 0.34.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/README.md +1 -1
- data/lib/solargraph.rb +5 -0
- data/lib/solargraph/api_map.rb +36 -18
- data/lib/solargraph/api_map/cache.rb +2 -0
- data/lib/solargraph/api_map/source_to_yard.rb +14 -5
- data/lib/solargraph/api_map/store.rb +17 -19
- data/lib/solargraph/bundle.rb +2 -0
- data/lib/solargraph/complex_type.rb +18 -4
- data/lib/solargraph/complex_type/type_methods.rb +2 -0
- data/lib/solargraph/complex_type/unique_type.rb +2 -0
- data/lib/solargraph/convention.rb +38 -0
- data/lib/solargraph/convention/base.rb +28 -0
- data/lib/solargraph/convention/gemfile.rb +18 -0
- data/lib/solargraph/convention/gemspec.rb +25 -0
- data/lib/solargraph/convention/rspec.rb +23 -0
- data/lib/solargraph/core_fills.rb +66 -42
- data/lib/solargraph/diagnostics.rb +2 -0
- data/lib/solargraph/diagnostics/base.rb +2 -0
- data/lib/solargraph/diagnostics/require_not_found.rb +2 -0
- data/lib/solargraph/diagnostics/rubocop.rb +2 -0
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +2 -0
- data/lib/solargraph/diagnostics/severities.rb +15 -13
- data/lib/solargraph/diagnostics/type_check.rb +2 -0
- data/lib/solargraph/diagnostics/update_errors.rb +2 -0
- data/lib/solargraph/documentor.rb +42 -0
- data/lib/solargraph/environ.rb +40 -0
- data/lib/solargraph/language_server.rb +19 -17
- data/lib/solargraph/language_server/completion_item_kinds.rb +2 -0
- data/lib/solargraph/language_server/error_codes.rb +2 -0
- data/lib/solargraph/language_server/host.rb +3 -1
- data/lib/solargraph/language_server/host/cataloger.rb +2 -0
- data/lib/solargraph/language_server/host/diagnoser.rb +2 -0
- data/lib/solargraph/language_server/host/dispatch.rb +2 -0
- data/lib/solargraph/language_server/host/sources.rb +2 -0
- data/lib/solargraph/language_server/message.rb +2 -0
- data/lib/solargraph/language_server/message/base.rb +2 -0
- data/lib/solargraph/language_server/message/cancel_request.rb +13 -11
- data/lib/solargraph/language_server/message/client.rb +11 -9
- data/lib/solargraph/language_server/message/client/register_capability.rb +15 -13
- data/lib/solargraph/language_server/message/completion_item.rb +11 -9
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +2 -0
- data/lib/solargraph/language_server/message/exit_notification.rb +2 -0
- data/lib/solargraph/language_server/message/extended.rb +2 -0
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +2 -0
- data/lib/solargraph/language_server/message/extended/document.rb +2 -0
- data/lib/solargraph/language_server/message/extended/document_gems.rb +2 -0
- data/lib/solargraph/language_server/message/extended/download_core.rb +27 -25
- data/lib/solargraph/language_server/message/extended/environment.rb +5 -0
- data/lib/solargraph/language_server/message/extended/search.rb +2 -0
- data/lib/solargraph/language_server/message/initialize.rb +2 -0
- data/lib/solargraph/language_server/message/initialized.rb +2 -0
- data/lib/solargraph/language_server/message/method_not_found.rb +16 -14
- data/lib/solargraph/language_server/message/method_not_implemented.rb +14 -12
- data/lib/solargraph/language_server/message/shutdown.rb +2 -0
- data/lib/solargraph/language_server/message/text_document.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/base.rb +19 -17
- data/lib/solargraph/language_server/message/text_document/code_action.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/completion.rb +3 -1
- data/lib/solargraph/language_server/message/text_document/definition.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/did_change.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/did_close.rb +15 -13
- data/lib/solargraph/language_server/message/text_document/did_open.rb +15 -13
- data/lib/solargraph/language_server/message/text_document/did_save.rb +17 -15
- data/lib/solargraph/language_server/message/text_document/document_symbol.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/folding_range.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/formatting.rb +8 -1
- data/lib/solargraph/language_server/message/text_document/hover.rb +3 -1
- data/lib/solargraph/language_server/message/text_document/on_type_formatting.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/prepare_rename.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/references.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/rename.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/signature_help.rb +7 -1
- data/lib/solargraph/language_server/message/workspace.rb +2 -0
- data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +2 -0
- data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +2 -0
- data/lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb +2 -0
- data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +2 -0
- data/lib/solargraph/language_server/message_types.rb +14 -12
- data/lib/solargraph/language_server/request.rb +2 -0
- data/lib/solargraph/language_server/symbol_kinds.rb +2 -0
- data/lib/solargraph/language_server/transport.rb +2 -0
- data/lib/solargraph/language_server/transport/adapter.rb +2 -0
- data/lib/solargraph/language_server/transport/data_reader.rb +3 -1
- data/lib/solargraph/language_server/uri_helpers.rb +2 -0
- data/lib/solargraph/library.rb +2 -0
- data/lib/solargraph/location.rb +2 -0
- data/lib/solargraph/logging.rb +2 -0
- data/lib/solargraph/page.rb +2 -0
- data/lib/solargraph/pin.rb +3 -20
- data/lib/solargraph/pin/attribute.rb +2 -4
- data/lib/solargraph/pin/base.rb +3 -5
- data/lib/solargraph/pin/base_method.rb +2 -4
- data/lib/solargraph/pin/base_variable.rb +2 -0
- data/lib/solargraph/pin/block.rb +2 -4
- data/lib/solargraph/pin/class_variable.rb +2 -3
- data/lib/solargraph/pin/closure.rb +9 -0
- data/lib/solargraph/pin/common.rb +3 -5
- data/lib/solargraph/pin/constant.rb +2 -4
- data/lib/solargraph/pin/conversions.rb +4 -2
- data/lib/solargraph/pin/documenting.rb +2 -0
- data/lib/solargraph/pin/duck_method.rb +2 -0
- data/lib/solargraph/pin/global_variable.rb +2 -3
- data/lib/solargraph/pin/instance_variable.rb +2 -4
- data/lib/solargraph/pin/keyword.rb +2 -4
- data/lib/solargraph/pin/keyword_param.rb +8 -0
- data/lib/solargraph/pin/local_variable.rb +2 -4
- data/lib/solargraph/pin/localized.rb +2 -0
- data/lib/solargraph/pin/method.rb +14 -4
- data/lib/solargraph/pin/method_alias.rb +2 -4
- data/lib/solargraph/pin/namespace.rb +22 -14
- data/lib/solargraph/pin/parameter.rb +4 -6
- data/lib/solargraph/pin/proxy_type.rb +2 -0
- data/lib/solargraph/pin/reference.rb +2 -0
- data/lib/solargraph/pin/reference/extend.rb +2 -3
- data/lib/solargraph/pin/reference/include.rb +2 -3
- data/lib/solargraph/pin/reference/override.rb +12 -3
- data/lib/solargraph/pin/reference/require.rb +2 -4
- data/lib/solargraph/pin/reference/superclass.rb +2 -3
- data/lib/solargraph/pin/singleton.rb +2 -0
- data/lib/solargraph/pin/symbol.rb +2 -4
- data/lib/solargraph/pin/yard_pin.rb +2 -0
- data/lib/solargraph/pin/yard_pin/constant.rb +7 -3
- data/lib/solargraph/pin/yard_pin/method.rb +12 -10
- data/lib/solargraph/pin/yard_pin/namespace.rb +9 -4
- data/lib/solargraph/pin/yard_pin/yard_mixin.rb +30 -3
- data/lib/solargraph/position.rb +2 -0
- data/lib/solargraph/range.rb +2 -0
- data/lib/solargraph/server_methods.rb +2 -0
- data/lib/solargraph/shell.rb +33 -2
- data/lib/solargraph/source.rb +2 -0
- data/lib/solargraph/source/chain.rb +2 -0
- data/lib/solargraph/source/chain/call.rb +63 -14
- data/lib/solargraph/source/chain/class_variable.rb +2 -0
- data/lib/solargraph/source/chain/constant.rb +18 -11
- data/lib/solargraph/source/chain/global_variable.rb +2 -0
- data/lib/solargraph/source/chain/head.rb +2 -0
- data/lib/solargraph/source/chain/instance_variable.rb +2 -0
- data/lib/solargraph/source/chain/link.rb +2 -0
- data/lib/solargraph/source/chain/literal.rb +2 -0
- data/lib/solargraph/source/chain/or.rb +2 -0
- data/lib/solargraph/source/chain/variable.rb +2 -0
- data/lib/solargraph/source/change.rb +2 -0
- data/lib/solargraph/source/cursor.rb +4 -1
- data/lib/solargraph/source/encoding_fixes.rb +2 -0
- data/lib/solargraph/source/flawed_builder.rb +15 -13
- data/lib/solargraph/source/node_chainer.rb +2 -0
- data/lib/solargraph/source/node_methods.rb +9 -5
- data/lib/solargraph/source/source_chainer.rb +2 -0
- data/lib/solargraph/source/updater.rb +52 -50
- data/lib/solargraph/source_map.rb +15 -7
- data/lib/solargraph/source_map/clip.rb +35 -3
- data/lib/solargraph/source_map/completion.rb +2 -0
- data/lib/solargraph/source_map/mapper.rb +2 -0
- data/lib/solargraph/source_map/node_processor.rb +2 -0
- data/lib/solargraph/source_map/node_processor/alias_node.rb +2 -0
- data/lib/solargraph/source_map/node_processor/args_node.rb +2 -0
- data/lib/solargraph/source_map/node_processor/base.rb +5 -3
- data/lib/solargraph/source_map/node_processor/begin_node.rb +2 -0
- data/lib/solargraph/source_map/node_processor/block_node.rb +2 -0
- data/lib/solargraph/source_map/node_processor/casgn_node.rb +2 -0
- data/lib/solargraph/source_map/node_processor/cvasgn_node.rb +2 -0
- data/lib/solargraph/source_map/node_processor/def_node.rb +2 -0
- data/lib/solargraph/source_map/node_processor/defs_node.rb +2 -0
- data/lib/solargraph/source_map/node_processor/gvasgn_node.rb +2 -0
- data/lib/solargraph/source_map/node_processor/ivasgn_node.rb +3 -1
- data/lib/solargraph/source_map/node_processor/lvasgn_node.rb +2 -0
- data/lib/solargraph/source_map/node_processor/namespace_node.rb +4 -1
- data/lib/solargraph/source_map/node_processor/orasgn_node.rb +2 -0
- data/lib/solargraph/source_map/node_processor/resbody_node.rb +2 -0
- data/lib/solargraph/source_map/node_processor/sclass_node.rb +2 -0
- data/lib/solargraph/source_map/node_processor/send_node.rb +11 -6
- data/lib/solargraph/source_map/node_processor/sym_node.rb +2 -0
- data/lib/solargraph/source_map/region.rb +2 -0
- data/lib/solargraph/type_checker.rb +35 -17
- data/lib/solargraph/type_checker/param_def.rb +2 -0
- data/lib/solargraph/type_checker/problem.rb +2 -0
- data/lib/solargraph/version.rb +3 -1
- data/lib/solargraph/views/document.erb +3 -3
- data/lib/solargraph/views/environment.erb +3 -0
- data/lib/solargraph/workspace.rb +5 -1
- data/lib/solargraph/workspace/config.rb +14 -0
- data/lib/solargraph/yard_map.rb +64 -5
- data/lib/solargraph/yard_map/cache.rb +2 -0
- data/lib/solargraph/yard_map/core_docs.rb +2 -0
- data/lib/solargraph/yard_map/core_gen.rb +2 -0
- data/lib/solargraph/yard_map/mapper.rb +15 -14
- data/lib/solargraph/yard_map/rdoc_to_yard.rb +129 -0
- data/lib/yard-solargraph.rb +8 -0
- metadata +11 -2
@@ -1,35 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Solargraph
|
2
4
|
module Pin
|
3
5
|
module YardPin
|
4
6
|
class Method < Pin::Method
|
5
7
|
include YardMixin
|
6
8
|
|
7
|
-
def initialize code_object,
|
9
|
+
def initialize code_object, name = nil, scope = nil, visibility = nil, closure = nil, spec = nil
|
8
10
|
@code_object = code_object
|
9
|
-
|
11
|
+
@spec = spec
|
10
12
|
closure ||= Solargraph::Pin::Namespace.new(
|
11
|
-
name: code_object.namespace.to_s
|
13
|
+
name: code_object.namespace.to_s,
|
14
|
+
gates: [code_object.namespace.to_s]
|
12
15
|
)
|
13
16
|
super(
|
14
17
|
location: location,
|
15
18
|
closure: closure,
|
16
19
|
name: name || code_object.name.to_s,
|
17
|
-
comments:
|
20
|
+
comments: nil,
|
18
21
|
scope: scope || code_object.scope,
|
19
22
|
visibility: visibility || code_object.visibility,
|
20
|
-
args:
|
23
|
+
args: nil
|
21
24
|
)
|
22
25
|
end
|
23
26
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
# end
|
27
|
+
def parameters
|
28
|
+
@parameters ||= get_parameters(code_object)
|
29
|
+
end
|
28
30
|
|
29
31
|
private
|
30
32
|
|
31
33
|
def get_parameters code_object
|
32
|
-
return [] unless code_object.
|
34
|
+
return [] unless code_object.is_a?(YARD::CodeObjects::MethodObject)
|
33
35
|
args = []
|
34
36
|
code_object.parameters.each do |a|
|
35
37
|
p = a[0]
|
@@ -1,22 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Solargraph
|
2
4
|
module Pin
|
3
5
|
module YardPin
|
4
6
|
class Namespace < Pin::Namespace
|
5
7
|
include YardMixin
|
6
8
|
|
7
|
-
def initialize code_object,
|
9
|
+
def initialize code_object, spec
|
8
10
|
@code_object = code_object
|
11
|
+
@spec = spec
|
9
12
|
closure = Solargraph::Pin::Namespace.new(
|
10
13
|
name: code_object.namespace.to_s,
|
11
|
-
closure: Pin::ROOT_PIN
|
14
|
+
closure: Pin::ROOT_PIN,
|
15
|
+
gates: [code_object.namespace.to_s]
|
12
16
|
)
|
13
17
|
super(
|
14
18
|
location: location,
|
15
19
|
name: code_object.name.to_s,
|
16
|
-
comments:
|
20
|
+
comments: nil,
|
17
21
|
type: namespace_type(code_object),
|
18
22
|
visibility: code_object.visibility,
|
19
|
-
closure: closure
|
23
|
+
closure: closure,
|
24
|
+
gates: split_to_gates(code_object.path)
|
20
25
|
)
|
21
26
|
end
|
22
27
|
|
@@ -1,12 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Solargraph
|
2
4
|
module Pin
|
3
5
|
module YardPin
|
4
6
|
module YardMixin
|
7
|
+
attr_reader :code_object
|
8
|
+
|
9
|
+
attr_reader :spec
|
10
|
+
|
11
|
+
@@gate_cache ||= {}
|
12
|
+
|
13
|
+
def comments
|
14
|
+
@comments ||= code_object.docstring ? code_object.docstring.all : ''
|
15
|
+
end
|
16
|
+
|
17
|
+
def location
|
18
|
+
return @location if @located
|
19
|
+
@located = true
|
20
|
+
@location = Solargraph::YardMap::Mapper.object_location(code_object, spec)
|
21
|
+
end
|
22
|
+
|
5
23
|
private
|
6
24
|
|
7
|
-
def
|
8
|
-
|
9
|
-
|
25
|
+
def split_to_gates namespace
|
26
|
+
@@gate_cache[namespace] || begin
|
27
|
+
parts = namespace.split('::')
|
28
|
+
result = []
|
29
|
+
until parts.empty?
|
30
|
+
result.push parts.join('::')
|
31
|
+
parts.pop
|
32
|
+
end
|
33
|
+
result.push ''
|
34
|
+
@@gate_cache[namespace] = result.freeze
|
35
|
+
result
|
36
|
+
end
|
10
37
|
end
|
11
38
|
end
|
12
39
|
end
|
data/lib/solargraph/position.rb
CHANGED
data/lib/solargraph/range.rb
CHANGED
data/lib/solargraph/shell.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'thor'
|
2
4
|
require 'backport'
|
3
5
|
require 'benchmark'
|
@@ -14,6 +16,7 @@ module Solargraph
|
|
14
16
|
end
|
15
17
|
|
16
18
|
desc 'socket', 'Run a Solargraph socket server'
|
19
|
+
|
17
20
|
option :host, type: :string, aliases: :h, desc: 'The server host', default: '127.0.0.1'
|
18
21
|
option :port, type: :numeric, aliases: :p, desc: 'The server port', default: 7658
|
19
22
|
def socket
|
@@ -90,10 +93,24 @@ module Solargraph
|
|
90
93
|
puts Solargraph::YardMap::CoreDocs.available.join("\n")
|
91
94
|
end
|
92
95
|
|
93
|
-
desc 'clear
|
94
|
-
def
|
96
|
+
desc 'clear', 'Delete the cached documentation'
|
97
|
+
def clear
|
98
|
+
puts "Deleting the cached documentation"
|
95
99
|
Solargraph::YardMap::CoreDocs.clear
|
96
100
|
end
|
101
|
+
map 'clear-cache' => :clear
|
102
|
+
map 'clear-cores' => :clear
|
103
|
+
|
104
|
+
desc 'uncache GEM [...GEM]', "Delete cached gem documentation"
|
105
|
+
def uncache *gems
|
106
|
+
raise ArgumentError, 'No gems specified.' if gems.empty?
|
107
|
+
gems.each do |gem|
|
108
|
+
Dir[File.join(Solargraph::YardMap::CoreDocs.cache_dir, 'gems', "#{gem}-*")].each do |dir|
|
109
|
+
puts "Deleting cache: #{dir}"
|
110
|
+
FileUtils.remove_entry_secure dir
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
97
114
|
|
98
115
|
desc 'reporters', 'Get a list of diagnostics reporters'
|
99
116
|
def reporters
|
@@ -162,6 +179,20 @@ module Solargraph
|
|
162
179
|
puts "Scanned #{directory} (#{api_map.pins.length} pins) in #{time.real} seconds."
|
163
180
|
end
|
164
181
|
|
182
|
+
desc 'bundle', 'Generate documentation for bundled gems'
|
183
|
+
option :directory, type: :string, aliases: :d, desc: 'The workspace directory', default: '.'
|
184
|
+
option :rebuild, type: :boolean, aliases: :r, desc: 'Rebuild existing documentation', default: false
|
185
|
+
def bundle
|
186
|
+
Documentor.new(options[:directory]).document
|
187
|
+
end
|
188
|
+
|
189
|
+
desc 'rdoc GEM [VERSION]', 'Use RDoc to cache documentation'
|
190
|
+
def rdoc gem, version = '>= 0'
|
191
|
+
spec = Gem::Specification.find_by_name(gem, version)
|
192
|
+
puts "Caching #{spec.name} #{spec.version} from RDoc"
|
193
|
+
Solargraph::YardMap::RdocToYard.run(spec)
|
194
|
+
end
|
195
|
+
|
165
196
|
private
|
166
197
|
|
167
198
|
# @param pin [Solargraph::Pin::Base]
|
data/lib/solargraph/source.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Solargraph
|
2
4
|
class Source
|
3
5
|
class Chain
|
@@ -28,33 +30,61 @@ module Solargraph
|
|
28
30
|
|
29
31
|
private
|
30
32
|
|
33
|
+
# @param pins [Array<Pin::Base>]
|
34
|
+
# @param api_map [ApiMap]
|
35
|
+
# @param context [ComplexType]
|
36
|
+
# @param locals [Pin::LocalVariable]
|
37
|
+
# @return [Array<Pin::Base>]
|
31
38
|
def inferred_pins pins, api_map, context, locals
|
32
39
|
result = pins.map do |p|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
overloads = p.docstring.tags(:overload)
|
41
|
+
# next p if overloads.empty?
|
42
|
+
type = ComplexType::UNDEFINED
|
43
|
+
# @param [YARD::Tags::OverloadTag]
|
44
|
+
overloads.each do |ol|
|
45
|
+
next if arguments.length < ol.parameters.length &&
|
46
|
+
!(arguments.length == ol.parameters.length - 1 && ol.parameters.last.first.start_with?('*'))
|
47
|
+
match = true
|
48
|
+
arguments.each_with_index do |arg, idx|
|
49
|
+
achain = arguments[idx]
|
50
|
+
next if achain.nil?
|
51
|
+
param = ol.parameters[idx]
|
52
|
+
if param.nil?
|
53
|
+
match = false unless ol.parameters.last && ol.parameters.last.first.start_with?('*')
|
54
|
+
break
|
55
|
+
end
|
56
|
+
par = ol.tags(:param).select { |pp| pp.name == param.first }.first
|
57
|
+
next if par.nil? || par.types.nil? || par.types.empty?
|
58
|
+
atype = achain.infer(api_map, Pin::ProxyType.anonymous(context), locals)
|
59
|
+
other = ComplexType.try_parse(*par.types)
|
60
|
+
# @todo Weak type comparison
|
61
|
+
unless atype.tag == other.tag || api_map.super_and_sub?(other.tag, atype.tag)
|
62
|
+
match = false
|
63
|
+
break
|
64
|
+
end
|
65
|
+
end
|
66
|
+
if match
|
67
|
+
type = extra_return_type(ol, context)
|
68
|
+
type = ComplexType.try_parse(*ol.tag(:return).types).self_to(context.to_s).qualify(api_map, context.namespace) if ol.has_tag?(:return) && ol.tag(:return).types && !ol.tag(:return).types.empty? && (type.nil? || type.undefined?)
|
69
|
+
type ||= ComplexType::UNDEFINED
|
70
|
+
end
|
71
|
+
break if type.defined?
|
44
72
|
end
|
45
|
-
|
73
|
+
next p.proxy(type) if type.defined?
|
74
|
+
type = extra_return_type(p.docstring, context)
|
75
|
+
if type
|
46
76
|
next Solargraph::Pin::Method.new(
|
47
77
|
location: p.location,
|
48
78
|
closure: p.closure,
|
49
79
|
name: p.name,
|
50
|
-
comments: "@return [#{context.
|
80
|
+
comments: "@return [#{context.subtypes.first.to_s}]",
|
51
81
|
scope: p.scope,
|
52
82
|
visibility: p.visibility,
|
53
83
|
args: p.parameters,
|
54
84
|
node: p.node
|
55
85
|
)
|
56
86
|
end
|
57
|
-
if p.
|
87
|
+
if p.is_a?(Pin::Method) && !p.macros.empty?
|
58
88
|
result = process_macro(p, api_map, context, locals)
|
59
89
|
next result unless result.return_type.undefined?
|
60
90
|
elsif !p.directives.empty?
|
@@ -92,9 +122,15 @@ module Solargraph
|
|
92
122
|
Pin::ProxyType.anonymous ComplexType::UNDEFINED
|
93
123
|
end
|
94
124
|
|
125
|
+
# @param api_map [ApiMap]
|
126
|
+
# @param macro [YARD::Tags::MacroDirective]
|
95
127
|
def inner_process_macro pin, macro, api_map, context, locals
|
96
128
|
vals = arguments.map{ |c| Pin::ProxyType.anonymous(c.infer(api_map, pin, locals)) }
|
97
129
|
txt = macro.tag.text.clone
|
130
|
+
if txt.empty? && macro.tag.name
|
131
|
+
named = api_map.named_macro(macro.tag.name)
|
132
|
+
txt = named.tag.text.clone if named
|
133
|
+
end
|
98
134
|
i = 1
|
99
135
|
vals.each do |v|
|
100
136
|
txt.gsub!(/\$#{i}/, v.context.namespace)
|
@@ -107,6 +143,19 @@ module Solargraph
|
|
107
143
|
end
|
108
144
|
Pin::ProxyType.anonymous(ComplexType::UNDEFINED)
|
109
145
|
end
|
146
|
+
|
147
|
+
# @param docstring [YARD::Docstring]
|
148
|
+
# @param context [ComplexType]
|
149
|
+
def extra_return_type docstring, context
|
150
|
+
if docstring.has_tag?(:return_single_parameter) && context.subtypes.one?
|
151
|
+
return context.subtypes.first
|
152
|
+
elsif docstring.has_tag?(:return_value_parameter) && context.value_types.one?
|
153
|
+
return context.value_types.first
|
154
|
+
# elsif docstring.has_tag?(:return) && docstring.tag(:return).types && !docstring.tag(:return).types.empty?
|
155
|
+
# return ComplexType.try_parse(*docstring.tag(:return).types)
|
156
|
+
end
|
157
|
+
nil
|
158
|
+
end
|
110
159
|
end
|
111
160
|
end
|
112
161
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Solargraph
|
2
4
|
class Source
|
3
5
|
class Chain
|
@@ -9,20 +11,25 @@ module Solargraph
|
|
9
11
|
def resolve api_map, name_pin, locals
|
10
12
|
return [Pin::ROOT_PIN] if word.empty?
|
11
13
|
if word.start_with?('::')
|
12
|
-
|
13
|
-
|
14
|
+
bottom = ''
|
15
|
+
gates = [word[2..-1].split('::')[0..-2].join('::')]
|
14
16
|
else
|
15
|
-
|
16
|
-
|
17
|
+
bottom = word.split('::')[0..-2].join('::')
|
18
|
+
gates = crawl_gates(name_pin)
|
17
19
|
end
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
result = api_map.get_constants(bottom, *gates)
|
21
|
+
result.select{ |p| p.path == word || "::#{p.path}" == word || p.path.end_with?("::#{word}") }
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def crawl_gates pin
|
27
|
+
clos = pin
|
28
|
+
until clos.nil?
|
29
|
+
return clos.gates if clos.is_a?(Pin::Namespace)
|
30
|
+
clos = clos.closure
|
22
31
|
end
|
23
|
-
|
24
|
-
last_name = bottom.split('::').last
|
25
|
-
result.select{ |p| p.name == last_name }
|
32
|
+
['']
|
26
33
|
end
|
27
34
|
end
|
28
35
|
end
|