solargraph 0.32.1 → 0.32.2
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/.gitignore +9 -0
- data/.rspec +2 -0
- data/.rubocop.yml +6 -0
- data/.travis.yml +25 -0
- data/EXAMPLES.md +76 -0
- data/Gemfile +3 -0
- data/LANGUAGE_SERVER.md +51 -0
- data/LICENSE +21 -0
- data/OVERVIEW.md +37 -0
- data/README.md +106 -0
- data/Rakefile +14 -0
- data/SERVER.md +95 -0
- data/bin/solargraph +0 -0
- data/bin/solargraph-runtime +5 -5
- data/lib/solargraph.rb +54 -54
- data/lib/solargraph/api_map.rb +659 -659
- data/lib/solargraph/api_map/cache.rb +49 -49
- data/lib/solargraph/api_map/source_to_yard.rb +67 -67
- data/lib/solargraph/api_map/store.rb +201 -201
- data/lib/solargraph/bundle.rb +24 -24
- data/lib/solargraph/complex_type.rb +150 -150
- data/lib/solargraph/complex_type/type_methods.rb +124 -124
- data/lib/solargraph/complex_type/unique_type.rb +44 -44
- data/lib/solargraph/core_fills.rb +37 -37
- data/lib/solargraph/diagnostics.rb +52 -52
- data/lib/solargraph/diagnostics/base.rb +20 -20
- data/lib/solargraph/diagnostics/require_not_found.rb +28 -28
- data/lib/solargraph/diagnostics/rubocop.rb +98 -98
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +46 -46
- data/lib/solargraph/diagnostics/type_not_defined.rb +108 -108
- data/lib/solargraph/diagnostics/update_errors.rb +38 -38
- data/lib/solargraph/language_server/completion_item_kinds.rb +33 -33
- data/lib/solargraph/language_server/error_codes.rb +18 -18
- data/lib/solargraph/language_server/host.rb +684 -681
- data/lib/solargraph/language_server/host/cataloger.rb +54 -79
- data/lib/solargraph/language_server/host/diagnoser.rb +80 -80
- data/lib/solargraph/language_server/host/dispatch.rb +112 -113
- data/lib/solargraph/language_server/host/sources.rb +138 -138
- data/lib/solargraph/language_server/message.rb +90 -90
- data/lib/solargraph/language_server/message/base.rb +83 -83
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +40 -40
- data/lib/solargraph/language_server/message/exit_notification.rb +11 -11
- data/lib/solargraph/language_server/message/extended.rb +19 -19
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +86 -86
- data/lib/solargraph/language_server/message/extended/document.rb +18 -18
- data/lib/solargraph/language_server/message/extended/document_gems.rb +30 -30
- data/lib/solargraph/language_server/message/extended/environment.rb +20 -20
- data/lib/solargraph/language_server/message/extended/search.rb +18 -18
- data/lib/solargraph/language_server/message/initialize.rb +141 -141
- data/lib/solargraph/language_server/message/initialized.rb +23 -23
- data/lib/solargraph/language_server/message/shutdown.rb +11 -11
- data/lib/solargraph/language_server/message/text_document.rb +25 -25
- data/lib/solargraph/language_server/message/text_document/completion.rb +51 -51
- data/lib/solargraph/language_server/message/text_document/definition.rb +18 -18
- data/lib/solargraph/language_server/message/text_document/did_change.rb +13 -13
- data/lib/solargraph/language_server/message/text_document/document_symbol.rb +21 -21
- data/lib/solargraph/language_server/message/text_document/folding_range.rb +24 -24
- data/lib/solargraph/language_server/message/text_document/formatting.rb +50 -50
- data/lib/solargraph/language_server/message/text_document/hover.rb +31 -31
- data/lib/solargraph/language_server/message/text_document/on_type_formatting.rb +32 -32
- data/lib/solargraph/language_server/message/text_document/prepare_rename.rb +9 -9
- data/lib/solargraph/language_server/message/text_document/references.rb +14 -14
- data/lib/solargraph/language_server/message/text_document/rename.rb +17 -17
- data/lib/solargraph/language_server/message/text_document/signature_help.rb +19 -19
- data/lib/solargraph/language_server/message/workspace.rb +12 -12
- data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +29 -29
- data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +29 -27
- data/lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb +24 -24
- data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +21 -21
- data/lib/solargraph/language_server/request.rb +22 -22
- data/lib/solargraph/language_server/symbol_kinds.rb +34 -34
- data/lib/solargraph/language_server/transport.rb +11 -11
- data/lib/solargraph/language_server/transport/adapter.rb +60 -60
- data/lib/solargraph/language_server/transport/data_reader.rb +66 -66
- data/lib/solargraph/language_server/uri_helpers.rb +25 -25
- data/lib/solargraph/library.rb +421 -419
- data/lib/solargraph/live_map.rb +126 -126
- data/lib/solargraph/live_map/cache.rb +38 -38
- data/lib/solargraph/location.rb +31 -31
- data/lib/solargraph/logging.rb +25 -25
- data/lib/solargraph/page.rb +68 -68
- data/lib/solargraph/pin.rb +50 -50
- data/lib/solargraph/pin/attribute.rb +41 -41
- data/lib/solargraph/pin/base.rb +280 -280
- data/lib/solargraph/pin/base_method.rb +76 -76
- data/lib/solargraph/pin/base_variable.rb +72 -72
- data/lib/solargraph/pin/block.rb +32 -32
- data/lib/solargraph/pin/block_parameter.rb +103 -103
- data/lib/solargraph/pin/class_variable.rb +9 -9
- data/lib/solargraph/pin/constant.rb +30 -30
- data/lib/solargraph/pin/conversions.rb +79 -79
- data/lib/solargraph/pin/documenting.rb +41 -41
- data/lib/solargraph/pin/duck_method.rb +14 -14
- data/lib/solargraph/pin/global_variable.rb +9 -9
- data/lib/solargraph/pin/instance_variable.rb +9 -9
- data/lib/solargraph/pin/keyword.rb +17 -17
- data/lib/solargraph/pin/local_variable.rb +23 -23
- data/lib/solargraph/pin/localized.rb +22 -22
- data/lib/solargraph/pin/method.rb +126 -126
- data/lib/solargraph/pin/method_alias.rb +30 -30
- data/lib/solargraph/pin/method_parameter.rb +40 -40
- data/lib/solargraph/pin/namespace.rb +54 -54
- data/lib/solargraph/pin/plugin/method.rb +25 -25
- data/lib/solargraph/pin/proxy_type.rb +35 -35
- data/lib/solargraph/pin/reference.rb +22 -22
- data/lib/solargraph/pin/reference/extend.rb +11 -11
- data/lib/solargraph/pin/reference/include.rb +11 -11
- data/lib/solargraph/pin/reference/require.rb +15 -15
- data/lib/solargraph/pin/reference/superclass.rb +11 -11
- data/lib/solargraph/pin/symbol.rb +44 -44
- data/lib/solargraph/pin/yard_pin.rb +10 -10
- data/lib/solargraph/pin/yard_pin/constant.rb +14 -14
- data/lib/solargraph/pin/yard_pin/method.rb +35 -35
- data/lib/solargraph/pin/yard_pin/namespace.rb +19 -19
- data/lib/solargraph/pin/yard_pin/yard_mixin.rb +14 -14
- data/lib/solargraph/plugin.rb +8 -8
- data/lib/solargraph/plugin/base.rb +41 -41
- data/lib/solargraph/plugin/canceler.rb +11 -11
- data/lib/solargraph/plugin/process.rb +172 -172
- data/lib/solargraph/plugin/runtime.rb +134 -134
- data/lib/solargraph/position.rb +110 -110
- data/lib/solargraph/range.rb +83 -83
- data/lib/solargraph/server_methods.rb +14 -14
- data/lib/solargraph/shell.rb +102 -102
- data/lib/solargraph/source.rb +521 -521
- data/lib/solargraph/source/chain.rb +120 -120
- data/lib/solargraph/source/chain/call.rb +107 -107
- data/lib/solargraph/source/chain/class_variable.rb +11 -11
- data/lib/solargraph/source/chain/constant.rb +30 -30
- data/lib/solargraph/source/chain/global_variable.rb +11 -11
- data/lib/solargraph/source/chain/head.rb +33 -33
- data/lib/solargraph/source/chain/instance_variable.rb +11 -11
- data/lib/solargraph/source/chain/link.rb +33 -33
- data/lib/solargraph/source/chain/literal.rb +21 -21
- data/lib/solargraph/source/chain/variable.rb +11 -11
- data/lib/solargraph/source/change.rb +77 -77
- data/lib/solargraph/source/cursor.rb +157 -157
- data/lib/solargraph/source/node_chainer.rb +96 -96
- data/lib/solargraph/source/node_methods.rb +225 -225
- data/lib/solargraph/source/source_chainer.rb +183 -183
- data/lib/solargraph/source_map.rb +169 -169
- data/lib/solargraph/source_map/clip.rb +145 -145
- data/lib/solargraph/source_map/completion.rb +21 -21
- data/lib/solargraph/source_map/mapper.rb +149 -149
- data/lib/solargraph/source_map/node_processor.rb +78 -78
- data/lib/solargraph/source_map/node_processor/alias_node.rb +19 -19
- data/lib/solargraph/source_map/node_processor/args_node.rb +28 -28
- data/lib/solargraph/source_map/node_processor/base.rb +68 -68
- data/lib/solargraph/source_map/node_processor/begin_node.rb +11 -11
- data/lib/solargraph/source_map/node_processor/block_node.rb +14 -14
- data/lib/solargraph/source_map/node_processor/casgn_node.rb +14 -14
- data/lib/solargraph/source_map/node_processor/cvasgn_node.rb +14 -14
- data/lib/solargraph/source_map/node_processor/def_node.rb +54 -54
- data/lib/solargraph/source_map/node_processor/defs_node.rb +21 -21
- data/lib/solargraph/source_map/node_processor/gvasgn_node.rb +12 -12
- data/lib/solargraph/source_map/node_processor/ivasgn_node.rb +18 -18
- data/lib/solargraph/source_map/node_processor/lvasgn_node.rb +16 -16
- data/lib/solargraph/source_map/node_processor/namespace_node.rb +26 -26
- data/lib/solargraph/source_map/node_processor/orasgn_node.rb +12 -12
- data/lib/solargraph/source_map/node_processor/sclass_node.rb +11 -11
- data/lib/solargraph/source_map/node_processor/send_node.rb +162 -162
- data/lib/solargraph/source_map/node_processor/sym_node.rb +11 -11
- data/lib/solargraph/source_map/region.rb +58 -58
- data/lib/solargraph/version.rb +3 -3
- data/lib/solargraph/views/environment.erb +53 -53
- data/lib/solargraph/workspace.rb +183 -183
- data/lib/solargraph/workspace/config.rb +170 -170
- data/lib/solargraph/yard_map.rb +298 -298
- data/lib/solargraph/yard_map/cache.rb +17 -17
- data/lib/solargraph/yard_map/core_docs.rb +163 -163
- data/lib/solargraph/yard_map/core_gen.rb +76 -76
- data/lib/yard-coregen.rb +16 -16
- data/lib/yard-solargraph.rb +18 -18
- data/solargraph.gemspec +37 -0
- data/travis-bundler.rb +10 -0
- metadata +19 -6
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
module Solargraph
|
|
2
|
-
module Pin
|
|
3
|
-
module Localized
|
|
4
|
-
attr_reader :block
|
|
5
|
-
|
|
6
|
-
# @return [Range]
|
|
7
|
-
attr_reader :presence
|
|
8
|
-
|
|
9
|
-
# @param other [Pin::Base] The caller's block
|
|
10
|
-
# @param position [Position, Array(Integer, Integer)] The caller's position
|
|
11
|
-
# @return [Boolean]
|
|
12
|
-
def visible_from?(other, position)
|
|
13
|
-
position = Position.normalize(position)
|
|
14
|
-
other.filename == filename and
|
|
15
|
-
( other == block or
|
|
16
|
-
(block.location.range.contain?(other.location.range.start) and block.location.range.contain?(other.location.range.ending))
|
|
17
|
-
) and
|
|
18
|
-
presence.contain?(position)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
1
|
+
module Solargraph
|
|
2
|
+
module Pin
|
|
3
|
+
module Localized
|
|
4
|
+
attr_reader :block
|
|
5
|
+
|
|
6
|
+
# @return [Range]
|
|
7
|
+
attr_reader :presence
|
|
8
|
+
|
|
9
|
+
# @param other [Pin::Base] The caller's block
|
|
10
|
+
# @param position [Position, Array(Integer, Integer)] The caller's position
|
|
11
|
+
# @return [Boolean]
|
|
12
|
+
def visible_from?(other, position)
|
|
13
|
+
position = Position.normalize(position)
|
|
14
|
+
other.filename == filename and
|
|
15
|
+
( other == block or
|
|
16
|
+
(block.location.range.contain?(other.location.range.start) and block.location.range.contain?(other.location.range.ending))
|
|
17
|
+
) and
|
|
18
|
+
presence.contain?(position)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
module Solargraph
|
|
2
|
-
module Pin
|
|
3
|
-
class Method < BaseMethod
|
|
4
|
-
include Source::NodeMethods
|
|
5
|
-
|
|
6
|
-
# @return [Array<String>]
|
|
7
|
-
attr_reader :parameters
|
|
8
|
-
|
|
9
|
-
# @return [Parser::AST::Node]
|
|
10
|
-
attr_reader :node
|
|
11
|
-
|
|
12
|
-
def initialize location, namespace, name, comments, scope, visibility, args, node = nil
|
|
13
|
-
super(location, namespace, name, comments)
|
|
14
|
-
@scope = scope
|
|
15
|
-
@visibility = visibility
|
|
16
|
-
@parameters = args
|
|
17
|
-
@node = node
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# @return [Array<String>]
|
|
21
|
-
def parameter_names
|
|
22
|
-
@parameter_names ||= parameters.map{|p| p.split(/[ =:]/).first}
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def kind
|
|
26
|
-
Solargraph::Pin::METHOD
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def path
|
|
30
|
-
@path ||= namespace + (scope == :instance ? '#' : '.') + name
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def context
|
|
34
|
-
@context ||= begin
|
|
35
|
-
if scope == :class
|
|
36
|
-
# @todo Determine whether the namespace is a class or a module
|
|
37
|
-
ComplexType.try_parse("Class<#{namespace}>")
|
|
38
|
-
else
|
|
39
|
-
ComplexType.try_parse(namespace)
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def completion_item_kind
|
|
45
|
-
Solargraph::LanguageServer::CompletionItemKinds::METHOD
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def symbol_kind
|
|
49
|
-
LanguageServer::SymbolKinds::METHOD
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def documentation
|
|
53
|
-
if @documentation.nil?
|
|
54
|
-
@documentation ||= super || ''
|
|
55
|
-
param_tags = docstring.tags(:param)
|
|
56
|
-
unless param_tags.nil? or param_tags.empty?
|
|
57
|
-
@documentation += "\n\n" unless @documentation.empty?
|
|
58
|
-
@documentation += "Params:\n"
|
|
59
|
-
lines = []
|
|
60
|
-
param_tags.each do |p|
|
|
61
|
-
l = "* #{p.name}"
|
|
62
|
-
l += " [#{p.types.join(', ')}]" unless p.types.nil? or p.types.empty?
|
|
63
|
-
l += " #{p.text}"
|
|
64
|
-
lines.push l
|
|
65
|
-
end
|
|
66
|
-
@documentation += lines.join("\n")
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
@documentation
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def nearly? other
|
|
73
|
-
return false unless super
|
|
74
|
-
parameters == other.parameters and
|
|
75
|
-
scope == other.scope and
|
|
76
|
-
visibility == other.visibility
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def probe api_map
|
|
80
|
-
infer_from_return_nodes(api_map)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
# @deprecated Use #typify and/or #probe instead
|
|
84
|
-
def infer api_map
|
|
85
|
-
Solargraph::Logging.logger.warn 'WARNING: Pin #infer methods are deprecated. Use #typify or #probe instead.'
|
|
86
|
-
type = typify(api_map)
|
|
87
|
-
return type unless type.undefined?
|
|
88
|
-
probe api_map
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def try_merge! pin
|
|
92
|
-
return false unless super
|
|
93
|
-
@node = pin.node
|
|
94
|
-
true
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
private
|
|
98
|
-
|
|
99
|
-
# @return [Parser::AST:Node, nil]
|
|
100
|
-
def method_body_node
|
|
101
|
-
return nil if node.nil?
|
|
102
|
-
return node.children[2] if node.type == :def
|
|
103
|
-
return node.children[3] if node.type == :defs
|
|
104
|
-
nil
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
# @param api_map [ApiMap]
|
|
108
|
-
# @return [ComplexType]
|
|
109
|
-
def infer_from_return_nodes api_map
|
|
110
|
-
result = []
|
|
111
|
-
returns_from(method_body_node).each do |n|
|
|
112
|
-
next if n.loc.nil?
|
|
113
|
-
clip = api_map.clip_at(
|
|
114
|
-
location.filename,
|
|
115
|
-
[n.loc.expression.last_line, n.loc.expression.last_column]
|
|
116
|
-
)
|
|
117
|
-
chain = Solargraph::Source::NodeChainer.chain(n, location.filename)
|
|
118
|
-
type = chain.infer(api_map, self, clip.locals)
|
|
119
|
-
result.push type unless type.undefined?
|
|
120
|
-
end
|
|
121
|
-
return ComplexType::UNDEFINED if result.empty?
|
|
122
|
-
ComplexType.try_parse(*result.map(&:tag))
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
end
|
|
1
|
+
module Solargraph
|
|
2
|
+
module Pin
|
|
3
|
+
class Method < BaseMethod
|
|
4
|
+
include Source::NodeMethods
|
|
5
|
+
|
|
6
|
+
# @return [Array<String>]
|
|
7
|
+
attr_reader :parameters
|
|
8
|
+
|
|
9
|
+
# @return [Parser::AST::Node]
|
|
10
|
+
attr_reader :node
|
|
11
|
+
|
|
12
|
+
def initialize location, namespace, name, comments, scope, visibility, args, node = nil
|
|
13
|
+
super(location, namespace, name, comments)
|
|
14
|
+
@scope = scope
|
|
15
|
+
@visibility = visibility
|
|
16
|
+
@parameters = args
|
|
17
|
+
@node = node
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# @return [Array<String>]
|
|
21
|
+
def parameter_names
|
|
22
|
+
@parameter_names ||= parameters.map{|p| p.split(/[ =:]/).first}
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def kind
|
|
26
|
+
Solargraph::Pin::METHOD
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def path
|
|
30
|
+
@path ||= namespace + (scope == :instance ? '#' : '.') + name
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def context
|
|
34
|
+
@context ||= begin
|
|
35
|
+
if scope == :class
|
|
36
|
+
# @todo Determine whether the namespace is a class or a module
|
|
37
|
+
ComplexType.try_parse("Class<#{namespace}>")
|
|
38
|
+
else
|
|
39
|
+
ComplexType.try_parse(namespace)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def completion_item_kind
|
|
45
|
+
Solargraph::LanguageServer::CompletionItemKinds::METHOD
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def symbol_kind
|
|
49
|
+
LanguageServer::SymbolKinds::METHOD
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def documentation
|
|
53
|
+
if @documentation.nil?
|
|
54
|
+
@documentation ||= super || ''
|
|
55
|
+
param_tags = docstring.tags(:param)
|
|
56
|
+
unless param_tags.nil? or param_tags.empty?
|
|
57
|
+
@documentation += "\n\n" unless @documentation.empty?
|
|
58
|
+
@documentation += "Params:\n"
|
|
59
|
+
lines = []
|
|
60
|
+
param_tags.each do |p|
|
|
61
|
+
l = "* #{p.name}"
|
|
62
|
+
l += " [#{p.types.join(', ')}]" unless p.types.nil? or p.types.empty?
|
|
63
|
+
l += " #{p.text}"
|
|
64
|
+
lines.push l
|
|
65
|
+
end
|
|
66
|
+
@documentation += lines.join("\n")
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
@documentation
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def nearly? other
|
|
73
|
+
return false unless super
|
|
74
|
+
parameters == other.parameters and
|
|
75
|
+
scope == other.scope and
|
|
76
|
+
visibility == other.visibility
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def probe api_map
|
|
80
|
+
infer_from_return_nodes(api_map)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# @deprecated Use #typify and/or #probe instead
|
|
84
|
+
def infer api_map
|
|
85
|
+
Solargraph::Logging.logger.warn 'WARNING: Pin #infer methods are deprecated. Use #typify or #probe instead.'
|
|
86
|
+
type = typify(api_map)
|
|
87
|
+
return type unless type.undefined?
|
|
88
|
+
probe api_map
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def try_merge! pin
|
|
92
|
+
return false unless super
|
|
93
|
+
@node = pin.node
|
|
94
|
+
true
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
private
|
|
98
|
+
|
|
99
|
+
# @return [Parser::AST:Node, nil]
|
|
100
|
+
def method_body_node
|
|
101
|
+
return nil if node.nil?
|
|
102
|
+
return node.children[2] if node.type == :def
|
|
103
|
+
return node.children[3] if node.type == :defs
|
|
104
|
+
nil
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# @param api_map [ApiMap]
|
|
108
|
+
# @return [ComplexType]
|
|
109
|
+
def infer_from_return_nodes api_map
|
|
110
|
+
result = []
|
|
111
|
+
returns_from(method_body_node).each do |n|
|
|
112
|
+
next if n.loc.nil?
|
|
113
|
+
clip = api_map.clip_at(
|
|
114
|
+
location.filename,
|
|
115
|
+
[n.loc.expression.last_line, n.loc.expression.last_column]
|
|
116
|
+
)
|
|
117
|
+
chain = Solargraph::Source::NodeChainer.chain(n, location.filename)
|
|
118
|
+
type = chain.infer(api_map, self, clip.locals)
|
|
119
|
+
result.push type unless type.undefined?
|
|
120
|
+
end
|
|
121
|
+
return ComplexType::UNDEFINED if result.empty?
|
|
122
|
+
ComplexType.try_parse(*result.map(&:tag))
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
module Solargraph
|
|
2
|
-
module Pin
|
|
3
|
-
# Use this class to track method aliases for later remapping. Common
|
|
4
|
-
# examples that defer mapping are aliases for superclass methods or
|
|
5
|
-
# methods from included modules.
|
|
6
|
-
#
|
|
7
|
-
class MethodAlias < Base
|
|
8
|
-
attr_reader :scope
|
|
9
|
-
|
|
10
|
-
attr_reader :original
|
|
11
|
-
|
|
12
|
-
def initialize location, namespace, name, scope, original
|
|
13
|
-
# @todo Determine how to handle these parameters. Among other things,
|
|
14
|
-
# determine if the visibility is defined by the location of the
|
|
15
|
-
# alias call or the original method.
|
|
16
|
-
super(location, namespace, name, '')
|
|
17
|
-
@scope = scope
|
|
18
|
-
@original = original
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def kind
|
|
22
|
-
Pin::METHOD_ALIAS
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def path
|
|
26
|
-
@path ||= namespace + (scope == :instance ? '#' : '.') + name
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
1
|
+
module Solargraph
|
|
2
|
+
module Pin
|
|
3
|
+
# Use this class to track method aliases for later remapping. Common
|
|
4
|
+
# examples that defer mapping are aliases for superclass methods or
|
|
5
|
+
# methods from included modules.
|
|
6
|
+
#
|
|
7
|
+
class MethodAlias < Base
|
|
8
|
+
attr_reader :scope
|
|
9
|
+
|
|
10
|
+
attr_reader :original
|
|
11
|
+
|
|
12
|
+
def initialize location, namespace, name, scope, original
|
|
13
|
+
# @todo Determine how to handle these parameters. Among other things,
|
|
14
|
+
# determine if the visibility is defined by the location of the
|
|
15
|
+
# alias call or the original method.
|
|
16
|
+
super(location, namespace, name, '')
|
|
17
|
+
@scope = scope
|
|
18
|
+
@original = original
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def kind
|
|
22
|
+
Pin::METHOD_ALIAS
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def path
|
|
26
|
+
@path ||= namespace + (scope == :instance ? '#' : '.') + name
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
module Solargraph
|
|
2
|
-
module Pin
|
|
3
|
-
class MethodParameter < LocalVariable
|
|
4
|
-
def return_complex_type
|
|
5
|
-
if @return_complex_type.nil?
|
|
6
|
-
@return_complex_type = ComplexType.new
|
|
7
|
-
found = nil
|
|
8
|
-
params = block.docstring.tags(:param)
|
|
9
|
-
params.each do |p|
|
|
10
|
-
next unless p.name == name
|
|
11
|
-
found = p
|
|
12
|
-
break
|
|
13
|
-
end
|
|
14
|
-
if found.nil? and !index.nil?
|
|
15
|
-
found = params[index] if params[index] && (params[index].name.nil? || params[index].name.empty?)
|
|
16
|
-
end
|
|
17
|
-
@return_complex_type = ComplexType.try_parse(*found.types) unless found.nil? or found.types.nil?
|
|
18
|
-
end
|
|
19
|
-
super
|
|
20
|
-
@return_complex_type
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# The parameter's zero-based location in the block's signature.
|
|
24
|
-
#
|
|
25
|
-
# @return [Integer]
|
|
26
|
-
def index
|
|
27
|
-
block.parameter_names.index(name)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def try_merge! pin
|
|
31
|
-
return false unless super
|
|
32
|
-
# @todo This is a little expensive, but it's necessary because
|
|
33
|
-
# parameter data depends on the method's docstring.
|
|
34
|
-
@return_complex_type = pin.return_complex_type
|
|
35
|
-
reset_conversions
|
|
36
|
-
true
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
1
|
+
module Solargraph
|
|
2
|
+
module Pin
|
|
3
|
+
class MethodParameter < LocalVariable
|
|
4
|
+
def return_complex_type
|
|
5
|
+
if @return_complex_type.nil?
|
|
6
|
+
@return_complex_type = ComplexType.new
|
|
7
|
+
found = nil
|
|
8
|
+
params = block.docstring.tags(:param)
|
|
9
|
+
params.each do |p|
|
|
10
|
+
next unless p.name == name
|
|
11
|
+
found = p
|
|
12
|
+
break
|
|
13
|
+
end
|
|
14
|
+
if found.nil? and !index.nil?
|
|
15
|
+
found = params[index] if params[index] && (params[index].name.nil? || params[index].name.empty?)
|
|
16
|
+
end
|
|
17
|
+
@return_complex_type = ComplexType.try_parse(*found.types) unless found.nil? or found.types.nil?
|
|
18
|
+
end
|
|
19
|
+
super
|
|
20
|
+
@return_complex_type
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# The parameter's zero-based location in the block's signature.
|
|
24
|
+
#
|
|
25
|
+
# @return [Integer]
|
|
26
|
+
def index
|
|
27
|
+
block.parameter_names.index(name)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def try_merge! pin
|
|
31
|
+
return false unless super
|
|
32
|
+
# @todo This is a little expensive, but it's necessary because
|
|
33
|
+
# parameter data depends on the method's docstring.
|
|
34
|
+
@return_complex_type = pin.return_complex_type
|
|
35
|
+
reset_conversions
|
|
36
|
+
true
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
module Solargraph
|
|
2
|
-
module Pin
|
|
3
|
-
class Namespace < Pin::Base
|
|
4
|
-
# @return [Symbol] :public or :private
|
|
5
|
-
attr_reader :visibility
|
|
6
|
-
|
|
7
|
-
# @return [Symbol] :class or :module
|
|
8
|
-
attr_reader :type
|
|
9
|
-
|
|
10
|
-
def initialize location, namespace, name, comments, type, visibility
|
|
11
|
-
super(location, namespace, name, comments)
|
|
12
|
-
@type = type
|
|
13
|
-
@visibility = visibility
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def kind
|
|
17
|
-
Pin::NAMESPACE
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def context
|
|
21
|
-
@context ||= ComplexType.try_parse("#{type.to_s.capitalize}<#{path}>")
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def scope
|
|
25
|
-
context.scope
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def completion_item_kind
|
|
29
|
-
(type == :class ? LanguageServer::CompletionItemKinds::CLASS : LanguageServer::CompletionItemKinds::MODULE)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# @return [Integer]
|
|
33
|
-
def symbol_kind
|
|
34
|
-
(type == :class ? LanguageServer::SymbolKinds::CLASS : LanguageServer::SymbolKinds::MODULE)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def path
|
|
38
|
-
@path ||= (namespace.empty? ? '' : "#{namespace}::") + name
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def return_complex_type
|
|
42
|
-
@return_complex_type ||= ComplexType.try_parse( (type == :class ? 'Class' : 'Module') + "<#{path}>" )
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def domains
|
|
46
|
-
@domains ||= []
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def typify api_map
|
|
50
|
-
return_complex_type
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
1
|
+
module Solargraph
|
|
2
|
+
module Pin
|
|
3
|
+
class Namespace < Pin::Base
|
|
4
|
+
# @return [Symbol] :public or :private
|
|
5
|
+
attr_reader :visibility
|
|
6
|
+
|
|
7
|
+
# @return [Symbol] :class or :module
|
|
8
|
+
attr_reader :type
|
|
9
|
+
|
|
10
|
+
def initialize location, namespace, name, comments, type, visibility
|
|
11
|
+
super(location, namespace, name, comments)
|
|
12
|
+
@type = type
|
|
13
|
+
@visibility = visibility
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def kind
|
|
17
|
+
Pin::NAMESPACE
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def context
|
|
21
|
+
@context ||= ComplexType.try_parse("#{type.to_s.capitalize}<#{path}>")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def scope
|
|
25
|
+
context.scope
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def completion_item_kind
|
|
29
|
+
(type == :class ? LanguageServer::CompletionItemKinds::CLASS : LanguageServer::CompletionItemKinds::MODULE)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# @return [Integer]
|
|
33
|
+
def symbol_kind
|
|
34
|
+
(type == :class ? LanguageServer::SymbolKinds::CLASS : LanguageServer::SymbolKinds::MODULE)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def path
|
|
38
|
+
@path ||= (namespace.empty? ? '' : "#{namespace}::") + name
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def return_complex_type
|
|
42
|
+
@return_complex_type ||= ComplexType.try_parse( (type == :class ? 'Class' : 'Module') + "<#{path}>" )
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def domains
|
|
46
|
+
@domains ||= []
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def typify api_map
|
|
50
|
+
return_complex_type
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|