solargraph 0.32.5 → 0.33.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +2 -11
- data/lib/solargraph.rb +1 -2
- data/lib/solargraph/api_map.rb +93 -63
- data/lib/solargraph/api_map/cache.rb +16 -1
- data/lib/solargraph/api_map/source_to_yard.rb +16 -7
- data/lib/solargraph/api_map/store.rb +55 -12
- data/lib/solargraph/complex_type.rb +58 -14
- data/lib/solargraph/complex_type/type_methods.rb +2 -2
- data/lib/solargraph/complex_type/unique_type.rb +33 -4
- data/lib/solargraph/core_fills.rb +40 -12
- data/lib/solargraph/diagnostics.rb +4 -3
- data/lib/solargraph/diagnostics/base.rb +6 -0
- data/lib/solargraph/diagnostics/require_not_found.rb +17 -10
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +2 -0
- data/lib/solargraph/diagnostics/type_check.rb +51 -0
- data/lib/solargraph/diagnostics/update_errors.rb +1 -0
- data/lib/solargraph/language_server/host.rb +55 -25
- data/lib/solargraph/language_server/host/diagnoser.rb +1 -2
- data/lib/solargraph/language_server/host/dispatch.rb +4 -8
- data/lib/solargraph/language_server/host/sources.rb +1 -1
- data/lib/solargraph/language_server/message.rb +1 -0
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +4 -2
- data/lib/solargraph/language_server/message/initialize.rb +9 -0
- data/lib/solargraph/language_server/message/initialized.rb +1 -0
- data/lib/solargraph/language_server/message/text_document.rb +1 -0
- data/lib/solargraph/language_server/message/text_document/code_action.rb +15 -0
- data/lib/solargraph/language_server/message/text_document/completion.rb +1 -1
- data/lib/solargraph/language_server/message/text_document/definition.rb +25 -5
- data/lib/solargraph/language_server/message/text_document/hover.rb +1 -1
- data/lib/solargraph/language_server/message/text_document/signature_help.rb +4 -0
- data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +8 -4
- data/lib/solargraph/language_server/transport/adapter.rb +12 -15
- data/lib/solargraph/library.rb +23 -6
- data/lib/solargraph/location.rb +4 -0
- data/lib/solargraph/pin.rb +7 -3
- data/lib/solargraph/pin/attribute.rb +14 -13
- data/lib/solargraph/pin/base.rb +56 -43
- data/lib/solargraph/pin/base_method.rb +41 -18
- data/lib/solargraph/pin/base_variable.rb +17 -15
- data/lib/solargraph/pin/block.rb +22 -4
- data/lib/solargraph/pin/closure.rb +28 -0
- data/lib/solargraph/pin/common.rb +59 -0
- data/lib/solargraph/pin/constant.rb +4 -4
- data/lib/solargraph/pin/conversions.rb +8 -8
- data/lib/solargraph/pin/duck_method.rb +3 -3
- data/lib/solargraph/pin/instance_variable.rb +30 -0
- data/lib/solargraph/pin/keyword.rb +1 -1
- data/lib/solargraph/pin/local_variable.rb +3 -3
- data/lib/solargraph/pin/localized.rb +9 -5
- data/lib/solargraph/pin/method.rb +26 -40
- data/lib/solargraph/pin/method_alias.rb +9 -6
- data/lib/solargraph/pin/namespace.rb +33 -10
- data/lib/solargraph/pin/parameter.rb +150 -0
- data/lib/solargraph/pin/proxy_type.rb +8 -8
- data/lib/solargraph/pin/reference.rb +1 -12
- data/lib/solargraph/pin/reference/override.rb +18 -0
- data/lib/solargraph/pin/reference/require.rb +2 -1
- data/lib/solargraph/pin/singleton.rb +9 -0
- data/lib/solargraph/pin/symbol.rb +9 -4
- data/lib/solargraph/pin/yard_pin/constant.rb +12 -3
- data/lib/solargraph/pin/yard_pin/method.rb +18 -6
- data/lib/solargraph/pin/yard_pin/namespace.rb +13 -1
- data/lib/solargraph/position.rb +1 -1
- data/lib/solargraph/range.rb +4 -0
- data/lib/solargraph/shell.rb +83 -4
- data/lib/solargraph/source.rb +32 -12
- data/lib/solargraph/source/chain.rb +48 -28
- data/lib/solargraph/source/chain/call.rb +37 -38
- data/lib/solargraph/source/chain/constant.rb +1 -1
- data/lib/solargraph/source/chain/head.rb +2 -8
- data/lib/solargraph/source/chain/instance_variable.rb +1 -1
- data/lib/solargraph/source/chain/link.rb +2 -0
- data/lib/solargraph/source/cursor.rb +59 -24
- data/lib/solargraph/source/node_chainer.rb +0 -2
- data/lib/solargraph/source/node_methods.rb +12 -6
- data/lib/solargraph/source/source_chainer.rb +38 -44
- data/lib/solargraph/source_map.rb +11 -18
- data/lib/solargraph/source_map/clip.rb +13 -15
- data/lib/solargraph/source_map/mapper.rb +37 -26
- data/lib/solargraph/source_map/node_processor.rb +13 -8
- data/lib/solargraph/source_map/node_processor/alias_node.rb +8 -8
- data/lib/solargraph/source_map/node_processor/args_node.rb +10 -16
- data/lib/solargraph/source_map/node_processor/base.rb +47 -4
- data/lib/solargraph/source_map/node_processor/block_node.rb +9 -4
- data/lib/solargraph/source_map/node_processor/casgn_node.rb +7 -2
- data/lib/solargraph/source_map/node_processor/cvasgn_node.rb +8 -3
- data/lib/solargraph/source_map/node_processor/def_node.rb +45 -38
- data/lib/solargraph/source_map/node_processor/defs_node.rb +16 -6
- data/lib/solargraph/source_map/node_processor/gvasgn_node.rb +8 -1
- data/lib/solargraph/source_map/node_processor/ivasgn_node.rb +20 -6
- data/lib/solargraph/source_map/node_processor/lvasgn_node.rb +10 -4
- data/lib/solargraph/source_map/node_processor/namespace_node.rb +18 -12
- data/lib/solargraph/source_map/node_processor/orasgn_node.rb +1 -1
- data/lib/solargraph/source_map/node_processor/resbody_node.rb +30 -0
- data/lib/solargraph/source_map/node_processor/sclass_node.rb +7 -1
- data/lib/solargraph/source_map/node_processor/send_node.rb +102 -52
- data/lib/solargraph/source_map/node_processor/sym_node.rb +4 -1
- data/lib/solargraph/source_map/region.rb +9 -8
- data/lib/solargraph/type_checker.rb +282 -0
- data/lib/solargraph/type_checker/param_def.rb +47 -0
- data/lib/solargraph/type_checker/problem.rb +25 -0
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/views/environment.erb +1 -1
- data/lib/solargraph/workspace.rb +2 -2
- data/lib/solargraph/workspace/config.rb +0 -8
- data/lib/solargraph/yard_map.rb +25 -69
- data/lib/solargraph/yard_map/core_docs.rb +8 -3
- data/lib/solargraph/yard_map/core_gen.rb +1 -3
- data/lib/solargraph/yard_map/mapper.rb +85 -0
- data/lib/yard-solargraph.rb +2 -0
- metadata +14 -14
- data/lib/solargraph/diagnostics/type_not_defined.rb +0 -108
- data/lib/solargraph/live_map.rb +0 -126
- data/lib/solargraph/live_map/cache.rb +0 -38
- data/lib/solargraph/pin/block_parameter.rb +0 -103
- data/lib/solargraph/pin/method_parameter.rb +0 -40
- data/lib/solargraph/pin/plugin/method.rb +0 -25
- data/lib/solargraph/plugin.rb +0 -8
- data/lib/solargraph/plugin/base.rb +0 -41
- data/lib/solargraph/plugin/canceler.rb +0 -11
- data/lib/solargraph/plugin/process.rb +0 -172
- data/lib/solargraph/plugin/runtime.rb +0 -134
- data/lib/yard-coregen.rb +0 -16
@@ -19,6 +19,7 @@ module Solargraph
|
|
19
19
|
autoload :Rename, 'solargraph/language_server/message/text_document/rename'
|
20
20
|
autoload :PrepareRename, 'solargraph/language_server/message/text_document/prepare_rename'
|
21
21
|
autoload :FoldingRange, 'solargraph/language_server/message/text_document/folding_range'
|
22
|
+
autoload :CodeAction, 'solargraph/language_server/message/text_document/code_action'
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
@@ -3,16 +3,36 @@ require 'uri'
|
|
3
3
|
module Solargraph::LanguageServer::Message::TextDocument
|
4
4
|
class Definition < Base
|
5
5
|
def process
|
6
|
-
line = params['position']['line']
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
@line = params['position']['line']
|
7
|
+
@column = params['position']['character']
|
8
|
+
set_result(code_location || require_location || [])
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def code_location
|
14
|
+
suggestions = host.definitions_at(params['textDocument']['uri'], @line, @column)
|
15
|
+
return nil if suggestions.empty?
|
16
|
+
suggestions.reject{|pin| pin.location.nil?}.map do |pin|
|
10
17
|
{
|
11
18
|
uri: file_to_uri(pin.location.filename),
|
12
19
|
range: pin.location.range.to_hash
|
13
20
|
}
|
14
21
|
end
|
15
|
-
|
22
|
+
end
|
23
|
+
|
24
|
+
def require_location
|
25
|
+
# @todo Terrible hack
|
26
|
+
lib = host.library_for(params['textDocument']['uri'])
|
27
|
+
rloc = Solargraph::Location.new(uri_to_file(params['textDocument']['uri']), Solargraph::Range.from_to(@line, @column, @line, @column))
|
28
|
+
dloc = lib.locate_ref(rloc)
|
29
|
+
return nil if dloc.nil?
|
30
|
+
[
|
31
|
+
{
|
32
|
+
uri: file_to_uri(dloc.filename),
|
33
|
+
range: dloc.range.to_hash
|
34
|
+
}
|
35
|
+
]
|
16
36
|
end
|
17
37
|
end
|
18
38
|
end
|
@@ -9,21 +9,25 @@ module Solargraph::LanguageServer::Message::Workspace
|
|
9
9
|
include Solargraph::LanguageServer::UriHelpers
|
10
10
|
|
11
11
|
def process
|
12
|
+
need_catalog = false
|
12
13
|
# @param change [Hash]
|
13
14
|
params['changes'].each do |change|
|
14
|
-
# @todo Changes might need to be handled here even if the file is open
|
15
15
|
if change['type'] == CREATED
|
16
|
-
host.create change['uri']
|
16
|
+
host.create change['uri']
|
17
|
+
need_catalog = true
|
17
18
|
elsif change['type'] == CHANGED
|
18
|
-
|
19
|
+
next if host.open?(change['uri'])
|
20
|
+
host.create change['uri']
|
21
|
+
need_catalog = true
|
19
22
|
elsif change['type'] == DELETED
|
20
23
|
host.delete change['uri']
|
24
|
+
need_catalog = true
|
21
25
|
else
|
22
26
|
set_error Solargraph::LanguageServer::ErrorCodes::INVALID_PARAMS, "Unknown change type ##{change['type']} for #{uri_to_file(change['uri'])}"
|
23
27
|
end
|
24
28
|
end
|
25
29
|
# Force host to catalog libraries after file changes (see castwide/solargraph#139)
|
26
|
-
host.catalog
|
30
|
+
host.catalog if need_catalog
|
27
31
|
end
|
28
32
|
end
|
29
33
|
end
|
@@ -8,12 +8,12 @@ module Solargraph
|
|
8
8
|
module Adapter
|
9
9
|
def opening
|
10
10
|
@host = Solargraph::LanguageServer::Host.new
|
11
|
+
@host.add_observer self
|
11
12
|
@host.start
|
12
13
|
@data_reader = Solargraph::LanguageServer::Transport::DataReader.new
|
13
14
|
@data_reader.set_message_handler do |message|
|
14
15
|
process message
|
15
16
|
end
|
16
|
-
start_timer
|
17
17
|
end
|
18
18
|
|
19
19
|
def closing
|
@@ -28,6 +28,15 @@ module Solargraph
|
|
28
28
|
# the Backport API
|
29
29
|
alias sending receiving
|
30
30
|
|
31
|
+
def update
|
32
|
+
if @host.stopped?
|
33
|
+
shutdown
|
34
|
+
else
|
35
|
+
tmp = @host.flush
|
36
|
+
write tmp unless tmp.empty?
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
31
40
|
private
|
32
41
|
|
33
42
|
# @param request [String]
|
@@ -35,20 +44,8 @@ module Solargraph
|
|
35
44
|
def process request
|
36
45
|
message = @host.receive(request)
|
37
46
|
message.send_response
|
38
|
-
tmp = @host.flush
|
39
|
-
write tmp unless tmp.empty?
|
40
|
-
end
|
41
|
-
|
42
|
-
def start_timer
|
43
|
-
Backport.prepare_interval 0.1 do |server|
|
44
|
-
if @host.stopped?
|
45
|
-
server.stop
|
46
|
-
shutdown
|
47
|
-
else
|
48
|
-
tmp = @host.flush
|
49
|
-
write tmp unless tmp.empty?
|
50
|
-
end
|
51
|
-
end
|
47
|
+
# tmp = @host.flush
|
48
|
+
# write tmp unless tmp.empty?
|
52
49
|
end
|
53
50
|
|
54
51
|
def shutdown
|
data/lib/solargraph/library.rb
CHANGED
@@ -174,7 +174,7 @@ module Solargraph
|
|
174
174
|
def definitions_at filename, line, column
|
175
175
|
position = Position.new(line, column)
|
176
176
|
cursor = Source::Cursor.new(checkout(filename), position)
|
177
|
-
api_map.clip(cursor).define
|
177
|
+
api_map.clip(cursor).define.map { |pin| pin.realize(api_map) }
|
178
178
|
end
|
179
179
|
|
180
180
|
# Get signature suggestions for the method at the specified file and
|
@@ -232,7 +232,11 @@ module Solargraph
|
|
232
232
|
# @param location [Location]
|
233
233
|
# @return [Solargraph::Pin::Base]
|
234
234
|
def locate_pins location
|
235
|
-
api_map.locate_pins
|
235
|
+
api_map.locate_pins(location).map { |pin| pin.realize(api_map) }
|
236
|
+
end
|
237
|
+
|
238
|
+
def locate_ref location
|
239
|
+
api_map.require_reference_at location
|
236
240
|
end
|
237
241
|
|
238
242
|
# Get an array of pins that match a path.
|
@@ -329,10 +333,23 @@ module Solargraph
|
|
329
333
|
catalog
|
330
334
|
result = []
|
331
335
|
source = read(filename)
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
+
repargs = {}
|
337
|
+
workspace.config.reporters.each do |line|
|
338
|
+
if line == 'all!'
|
339
|
+
Diagnostics.reporters.each do |reporter|
|
340
|
+
repargs[reporter] ||= []
|
341
|
+
end
|
342
|
+
else
|
343
|
+
args = line.split(':').map(&:strip)
|
344
|
+
name = args.shift
|
345
|
+
reporter = Diagnostics.reporter(name)
|
346
|
+
raise DiagnosticsError, "Diagnostics reporter #{name} does not exist" if reporter.nil?
|
347
|
+
repargs[reporter] ||= []
|
348
|
+
repargs[reporter].concat args
|
349
|
+
end
|
350
|
+
end
|
351
|
+
repargs.each_pair do |reporter, args|
|
352
|
+
result.concat reporter.new(*args.uniq).diagnose(source, api_map)
|
336
353
|
end
|
337
354
|
result
|
338
355
|
end
|
data/lib/solargraph/location.rb
CHANGED
data/lib/solargraph/pin.rb
CHANGED
@@ -2,6 +2,7 @@ module Solargraph
|
|
2
2
|
# The namespace for pins used in maps.
|
3
3
|
#
|
4
4
|
module Pin
|
5
|
+
autoload :Common, 'solargraph/pin/common'
|
5
6
|
autoload :Conversions, 'solargraph/pin/conversions'
|
6
7
|
autoload :Base, 'solargraph/pin/base'
|
7
8
|
autoload :BaseMethod, 'solargraph/pin/base_method'
|
@@ -15,10 +16,10 @@ module Solargraph
|
|
15
16
|
autoload :GlobalVariable, 'solargraph/pin/global_variable'
|
16
17
|
autoload :Constant, 'solargraph/pin/constant'
|
17
18
|
autoload :Symbol, 'solargraph/pin/symbol'
|
19
|
+
autoload :Closure, 'solargraph/pin/closure'
|
18
20
|
autoload :Namespace, 'solargraph/pin/namespace'
|
19
21
|
autoload :Keyword, 'solargraph/pin/keyword'
|
20
|
-
autoload :
|
21
|
-
autoload :BlockParameter, 'solargraph/pin/block_parameter'
|
22
|
+
autoload :Parameter, 'solargraph/pin/parameter'
|
22
23
|
autoload :Reference, 'solargraph/pin/reference'
|
23
24
|
autoload :Documenting, 'solargraph/pin/documenting'
|
24
25
|
autoload :Block, 'solargraph/pin/block'
|
@@ -26,6 +27,7 @@ module Solargraph
|
|
26
27
|
autoload :ProxyType, 'solargraph/pin/proxy_type'
|
27
28
|
autoload :DuckMethod, 'solargraph/pin/duck_method'
|
28
29
|
autoload :YardPin, 'solargraph/pin/yard_pin'
|
30
|
+
autoload :Singleton, 'solargraph/pin/singleton'
|
29
31
|
|
30
32
|
ATTRIBUTE = 1
|
31
33
|
CLASS_VARIABLE = 2
|
@@ -44,7 +46,9 @@ module Solargraph
|
|
44
46
|
INCLUDE_REFERENCE = 15
|
45
47
|
EXTEND_REFERENCE = 16
|
46
48
|
METHOD_ALIAS = 17
|
49
|
+
OVERRIDE_REFERENCE = 18
|
47
50
|
|
48
|
-
ROOT_PIN = Pin::Namespace.new(nil, '', '', '', :class, :public)
|
51
|
+
# ROOT_PIN = Pin::Namespace.new(nil, '', '', '', :class, :public)
|
52
|
+
ROOT_PIN = Pin::Namespace.new(type: :class, name: '', closure: nil)
|
49
53
|
end
|
50
54
|
end
|
@@ -1,14 +1,12 @@
|
|
1
1
|
module Solargraph
|
2
2
|
module Pin
|
3
3
|
class Attribute < BaseMethod
|
4
|
-
# @return [Symbol] :reader or :writer
|
4
|
+
# @return [::Symbol] :reader or :writer
|
5
5
|
attr_reader :access
|
6
6
|
|
7
|
-
def initialize
|
8
|
-
super(
|
7
|
+
def initialize access: :reader, **splat
|
8
|
+
super(splat)
|
9
9
|
@access = access
|
10
|
-
@scope = scope
|
11
|
-
@visibility = visibility
|
12
10
|
end
|
13
11
|
|
14
12
|
def kind
|
@@ -27,14 +25,17 @@ module Solargraph
|
|
27
25
|
@path ||= namespace + (scope == :instance ? '#' : '.') + name
|
28
26
|
end
|
29
27
|
|
30
|
-
def
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
28
|
+
def probe api_map
|
29
|
+
types = []
|
30
|
+
varname = "@#{name.gsub(/=$/, '')}"
|
31
|
+
pins = api_map.get_instance_variable_pins(binder.namespace, binder.scope).select { |iv| iv.name == varname }
|
32
|
+
pins.each do |pin|
|
33
|
+
type = pin.typify(api_map)
|
34
|
+
type = pin.probe(api_map) if type.undefined?
|
35
|
+
types.push type if type.defined?
|
36
|
+
end
|
37
|
+
return ComplexType::UNDEFINED if types.empty?
|
38
|
+
ComplexType.try_parse(*types.map(&:tag).uniq)
|
38
39
|
end
|
39
40
|
end
|
40
41
|
end
|
data/lib/solargraph/pin/base.rb
CHANGED
@@ -3,18 +3,16 @@ module Solargraph
|
|
3
3
|
# The base class for map pins.
|
4
4
|
#
|
5
5
|
class Base
|
6
|
+
include Common
|
6
7
|
include Conversions
|
7
8
|
include Documenting
|
8
9
|
|
10
|
+
# @return [YARD::CodeObjects::Base]
|
11
|
+
attr_reader :code_object
|
12
|
+
|
9
13
|
# @return [Solargraph::Location]
|
10
14
|
attr_reader :location
|
11
15
|
|
12
|
-
# The namespace in which this pin is defined.
|
13
|
-
# The root namespace is an empty string.
|
14
|
-
#
|
15
|
-
# @return [String]
|
16
|
-
attr_reader :namespace
|
17
|
-
|
18
16
|
# @return [String]
|
19
17
|
attr_reader :name
|
20
18
|
|
@@ -25,12 +23,14 @@ module Solargraph
|
|
25
23
|
attr_reader :path
|
26
24
|
|
27
25
|
# @param location [Solargraph::Location]
|
28
|
-
# @param
|
26
|
+
# @param kind [Integer]
|
27
|
+
# @param closure [String]
|
29
28
|
# @param name [String]
|
30
29
|
# @param comments [String]
|
31
|
-
def initialize location,
|
30
|
+
def initialize location: nil, kind: KEYWORD, closure: nil, name: '', comments: ''
|
32
31
|
@location = location
|
33
|
-
@
|
32
|
+
@kind = kind
|
33
|
+
@closure = closure
|
34
34
|
@name = name
|
35
35
|
@comments = comments
|
36
36
|
end
|
@@ -65,11 +65,6 @@ module Solargraph
|
|
65
65
|
false
|
66
66
|
end
|
67
67
|
|
68
|
-
# @return [ComplexType]
|
69
|
-
def context
|
70
|
-
@context ||= ComplexType.try_parse(namespace || '')
|
71
|
-
end
|
72
|
-
|
73
68
|
# Pin equality is determined using the #nearly? method and also
|
74
69
|
# requiring both pins to have the same location.
|
75
70
|
#
|
@@ -86,26 +81,19 @@ module Solargraph
|
|
86
81
|
# @return [Boolean]
|
87
82
|
def nearly? other
|
88
83
|
self.class == other.class &&
|
89
|
-
namespace == other.namespace &&
|
90
84
|
name == other.name &&
|
85
|
+
(closure == other.closure || (closure && closure.nearly?(other.closure))) &&
|
91
86
|
(comments == other.comments ||
|
92
87
|
(((maybe_directives? == false && other.maybe_directives? == false) || compare_directives(directives, other.directives)) &&
|
93
88
|
compare_docstring_tags(docstring, other.docstring))
|
94
89
|
)
|
95
90
|
end
|
96
91
|
|
97
|
-
#
|
92
|
+
# The pin's return type.
|
98
93
|
#
|
99
94
|
# @return [ComplexType]
|
100
95
|
def return_type
|
101
|
-
|
102
|
-
end
|
103
|
-
|
104
|
-
# All of the pin's return types as an array of ComplexTypes.
|
105
|
-
#
|
106
|
-
# @return [ComplexType]
|
107
|
-
def return_complex_type
|
108
|
-
@return_complex_type ||= ComplexType::UNDEFINED
|
96
|
+
@return_type ||= ComplexType::UNDEFINED
|
109
97
|
end
|
110
98
|
|
111
99
|
# @return [YARD::Docstring]
|
@@ -152,7 +140,7 @@ module Solargraph
|
|
152
140
|
# @param api_map [ApiMap]
|
153
141
|
# @return [ComplexType]
|
154
142
|
def typify api_map
|
155
|
-
|
143
|
+
return_type.qualify(api_map, namespace)
|
156
144
|
end
|
157
145
|
|
158
146
|
# Infer the pin's return type via static code analysis.
|
@@ -182,10 +170,11 @@ module Solargraph
|
|
182
170
|
def try_merge! pin
|
183
171
|
return false unless nearly?(pin)
|
184
172
|
@location = pin.location
|
173
|
+
@closure = pin.closure
|
185
174
|
return true if comments == pin.comments
|
186
175
|
@comments = pin.comments
|
187
176
|
@docstring = pin.docstring
|
188
|
-
@
|
177
|
+
@return_type = pin.return_type
|
189
178
|
@documentation = nil
|
190
179
|
@deprecated = nil
|
191
180
|
reset_conversions
|
@@ -196,6 +185,23 @@ module Solargraph
|
|
196
185
|
@proxied ||= false
|
197
186
|
end
|
198
187
|
|
188
|
+
def probed?
|
189
|
+
@probed ||= false
|
190
|
+
end
|
191
|
+
|
192
|
+
# @param api_map [ApiMap]
|
193
|
+
# @return [self]
|
194
|
+
def realize api_map
|
195
|
+
return self if return_type.defined?
|
196
|
+
type = typify(api_map)
|
197
|
+
return proxy(type) if type.defined?
|
198
|
+
type = probe(api_map)
|
199
|
+
return self if type.undefined?
|
200
|
+
result = proxy(type)
|
201
|
+
result.probed = true
|
202
|
+
result
|
203
|
+
end
|
204
|
+
|
199
205
|
# Return a proxy for this pin with the specified return type. Other than
|
200
206
|
# the return type and the #proxied? setting, the proxy should be a clone
|
201
207
|
# of the original.
|
@@ -204,18 +210,25 @@ module Solargraph
|
|
204
210
|
# @return [self]
|
205
211
|
def proxy return_type
|
206
212
|
result = dup
|
207
|
-
result.
|
213
|
+
result.return_type = return_type
|
208
214
|
result.proxied = true
|
209
215
|
result
|
210
216
|
end
|
211
217
|
|
218
|
+
def inspect
|
219
|
+
"#<#{self.class} at #{self.location.inspect}>"
|
220
|
+
end
|
221
|
+
|
212
222
|
protected
|
213
223
|
|
224
|
+
# @return [Boolean]
|
225
|
+
attr_writer :probed
|
226
|
+
|
214
227
|
# @return [Boolean]
|
215
228
|
attr_writer :proxied
|
216
229
|
|
217
230
|
# @return [ComplexType]
|
218
|
-
attr_writer :
|
231
|
+
attr_writer :return_type
|
219
232
|
|
220
233
|
private
|
221
234
|
|
@@ -238,7 +251,7 @@ module Solargraph
|
|
238
251
|
#
|
239
252
|
# @param d1 [YARD::Docstring]
|
240
253
|
# @param d2 [YARD::Docstring]
|
241
|
-
# @return [
|
254
|
+
# @return [Boolean]
|
242
255
|
def compare_docstring_tags d1, d2
|
243
256
|
return false if d1.tags.length != d2.tags.length
|
244
257
|
d1.tags.each_index do |i|
|
@@ -247,26 +260,26 @@ module Solargraph
|
|
247
260
|
true
|
248
261
|
end
|
249
262
|
|
250
|
-
# @param
|
251
|
-
# @param
|
263
|
+
# @param dir1 [Array<YARD::Tags::Directive>]
|
264
|
+
# @param dir2 [Array<YARD::Tags::Directive>]
|
252
265
|
# @return [Boolean]
|
253
|
-
def compare_directives
|
254
|
-
return false if
|
255
|
-
|
256
|
-
return false unless compare_tags(
|
266
|
+
def compare_directives dir1, dir2
|
267
|
+
return false if dir1.length != dir2.length
|
268
|
+
dir1.each_index do |i|
|
269
|
+
return false unless compare_tags(dir1[i].tag, dir2[i].tag)
|
257
270
|
end
|
258
271
|
true
|
259
272
|
end
|
260
273
|
|
261
|
-
# @param
|
262
|
-
# @param
|
274
|
+
# @param tag1 [YARD::Tags::Tag]
|
275
|
+
# @param tag2 [YARD::Tags::Tag]
|
263
276
|
# @return [Boolean]
|
264
|
-
def compare_tags
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
277
|
+
def compare_tags tag1, tag2
|
278
|
+
tag1.class == tag2.class &&
|
279
|
+
tag1.tag_name == tag2.tag_name &&
|
280
|
+
tag1.text == tag2.text &&
|
281
|
+
tag1.name == tag2.name &&
|
282
|
+
tag1.types == tag2.types
|
270
283
|
end
|
271
284
|
|
272
285
|
# @return [Array<YARD::Tags::Handlers::Directive>]
|