solargraph 0.47.2 → 0.53.3
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/.github/FUNDING.yml +1 -0
- data/.github/workflows/plugins.yml +40 -0
- data/.github/workflows/rspec.yml +4 -8
- data/.github/workflows/typecheck.yml +34 -0
- data/.yardopts +2 -2
- data/CHANGELOG.md +137 -3
- data/LICENSE +1 -1
- data/README.md +19 -16
- data/SPONSORS.md +2 -9
- data/lib/solargraph/api_map/cache.rb +60 -20
- data/lib/solargraph/api_map/source_to_yard.rb +17 -10
- data/lib/solargraph/api_map/store.rb +60 -12
- data/lib/solargraph/api_map.rb +171 -99
- data/lib/solargraph/bench.rb +3 -2
- data/lib/solargraph/cache.rb +77 -0
- data/lib/solargraph/complex_type/type_methods.rb +61 -12
- data/lib/solargraph/complex_type/unique_type.rb +193 -16
- data/lib/solargraph/complex_type.rb +113 -10
- data/lib/solargraph/convention/rakefile.rb +17 -0
- data/lib/solargraph/convention.rb +2 -3
- data/lib/solargraph/converters/dd.rb +5 -0
- data/lib/solargraph/converters/dl.rb +3 -0
- data/lib/solargraph/converters/dt.rb +3 -0
- data/lib/solargraph/diagnostics/rubocop.rb +23 -8
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +4 -1
- data/lib/solargraph/diagnostics/type_check.rb +1 -0
- data/lib/solargraph/diagnostics.rb +2 -2
- data/lib/solargraph/doc_map.rb +171 -0
- data/lib/solargraph/gem_pins.rb +64 -0
- data/lib/solargraph/language_server/host/cataloger.rb +2 -1
- data/lib/solargraph/language_server/host/diagnoser.rb +2 -2
- data/lib/solargraph/language_server/host/dispatch.rb +15 -5
- data/lib/solargraph/language_server/host/message_worker.rb +4 -0
- data/lib/solargraph/language_server/host/sources.rb +7 -4
- data/lib/solargraph/language_server/host.rb +50 -26
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +3 -1
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +13 -1
- data/lib/solargraph/language_server/message/extended/download_core.rb +1 -5
- data/lib/solargraph/language_server/message/initialize.rb +13 -0
- data/lib/solargraph/language_server/message/initialized.rb +1 -0
- data/lib/solargraph/language_server/message/text_document/document_symbol.rb +4 -1
- data/lib/solargraph/language_server/message/text_document/formatting.rb +4 -4
- data/lib/solargraph/language_server/message/text_document/hover.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/signature_help.rb +1 -6
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +24 -0
- data/lib/solargraph/language_server/message/text_document.rb +1 -1
- data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +5 -0
- data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +10 -3
- data/lib/solargraph/language_server/message.rb +1 -0
- data/lib/solargraph/language_server/transport/adapter.rb +16 -1
- data/lib/solargraph/language_server/transport/data_reader.rb +2 -0
- data/lib/solargraph/library.rb +124 -37
- data/lib/solargraph/location.rb +1 -0
- data/lib/solargraph/page.rb +6 -0
- data/lib/solargraph/parser/comment_ripper.rb +4 -0
- data/lib/solargraph/parser/node_methods.rb +47 -7
- data/lib/solargraph/parser/node_processor/base.rb +9 -0
- data/lib/solargraph/parser/{legacy → parser_gem}/class_methods.rb +31 -5
- data/lib/solargraph/parser/{legacy → parser_gem}/flawed_builder.rb +3 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_chainer.rb +57 -41
- data/lib/solargraph/parser/parser_gem/node_methods.rb +499 -0
- data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/alias_node.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +53 -0
- data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/begin_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/block_node.rb +3 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/casgn_node.rb +14 -4
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/cvasgn_node.rb +1 -1
- data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/def_node.rb +7 -20
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/defs_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/gvasgn_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/ivasgn_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/lvasgn_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/namespace_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/orasgn_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/resbody_node.rb +3 -3
- data/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb +42 -0
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/send_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/sym_node.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_processors.rb +54 -0
- data/lib/solargraph/parser/parser_gem.rb +12 -0
- data/lib/solargraph/parser/region.rb +1 -1
- data/lib/solargraph/parser/snippet.rb +2 -0
- data/lib/solargraph/parser.rb +9 -10
- data/lib/solargraph/pin/base.rb +69 -11
- data/lib/solargraph/pin/base_variable.rb +8 -4
- data/lib/solargraph/pin/block.rb +21 -28
- data/lib/solargraph/pin/closure.rb +17 -2
- data/lib/solargraph/pin/common.rb +7 -3
- data/lib/solargraph/pin/conversions.rb +34 -8
- data/lib/solargraph/pin/delegated_method.rb +97 -0
- data/lib/solargraph/pin/documenting.rb +25 -34
- data/lib/solargraph/pin/instance_variable.rb +4 -0
- data/lib/solargraph/pin/local_variable.rb +13 -1
- data/lib/solargraph/pin/method.rb +270 -16
- data/lib/solargraph/pin/namespace.rb +17 -1
- data/lib/solargraph/pin/parameter.rb +52 -17
- data/lib/solargraph/pin/reference/override.rb +2 -2
- data/lib/solargraph/pin/reference.rb +8 -0
- data/lib/solargraph/pin/search.rb +4 -4
- data/lib/solargraph/pin/signature.rb +143 -0
- data/lib/solargraph/pin.rb +2 -1
- data/lib/solargraph/range.rb +4 -6
- data/lib/solargraph/rbs_map/conversions.rb +601 -0
- data/lib/solargraph/rbs_map/core_fills.rb +47 -0
- data/lib/solargraph/rbs_map/core_map.rb +28 -0
- data/lib/solargraph/rbs_map/stdlib_map.rb +33 -0
- data/lib/solargraph/rbs_map.rb +84 -0
- data/lib/solargraph/shell.rb +69 -48
- data/lib/solargraph/source/chain/array.rb +32 -0
- data/lib/solargraph/source/chain/block_symbol.rb +13 -0
- data/lib/solargraph/source/chain/call.rb +125 -61
- data/lib/solargraph/source/chain/constant.rb +15 -1
- data/lib/solargraph/source/chain/if.rb +23 -0
- data/lib/solargraph/source/chain/link.rb +8 -2
- data/lib/solargraph/source/chain/or.rb +1 -1
- data/lib/solargraph/source/chain/z_super.rb +3 -3
- data/lib/solargraph/source/chain.rb +44 -14
- data/lib/solargraph/source/change.rb +3 -0
- data/lib/solargraph/source/cursor.rb +2 -0
- data/lib/solargraph/source/source_chainer.rb +8 -5
- data/lib/solargraph/source.rb +18 -19
- data/lib/solargraph/source_map/clip.rb +30 -23
- data/lib/solargraph/source_map/mapper.rb +20 -5
- data/lib/solargraph/source_map.rb +28 -13
- data/lib/solargraph/type_checker/checks.rb +10 -2
- data/lib/solargraph/type_checker.rb +201 -98
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/views/environment.erb +2 -2
- data/lib/solargraph/workspace/config.rb +14 -11
- data/lib/solargraph/workspace.rb +28 -17
- data/lib/solargraph/yard_map/cache.rb +6 -0
- data/lib/solargraph/yard_map/helpers.rb +1 -1
- data/lib/solargraph/yard_map/mapper/to_method.rb +18 -5
- data/lib/solargraph/yard_map/mapper.rb +1 -1
- data/lib/solargraph/yard_map/to_method.rb +11 -4
- data/lib/solargraph/yard_map.rb +1 -443
- data/lib/solargraph/yard_tags.rb +20 -0
- data/lib/solargraph/yardoc.rb +52 -0
- data/lib/solargraph.rb +8 -6
- data/solargraph.gemspec +19 -8
- metadata +162 -98
- data/.travis.yml +0 -19
- data/lib/solargraph/api_map/bundler_methods.rb +0 -22
- data/lib/solargraph/compat.rb +0 -37
- data/lib/solargraph/convention/rspec.rb +0 -30
- data/lib/solargraph/documentor.rb +0 -76
- data/lib/solargraph/parser/legacy/node_methods.rb +0 -325
- data/lib/solargraph/parser/legacy/node_processors/alias_node.rb +0 -23
- data/lib/solargraph/parser/legacy/node_processors/args_node.rb +0 -35
- data/lib/solargraph/parser/legacy/node_processors/begin_node.rb +0 -15
- data/lib/solargraph/parser/legacy/node_processors/def_node.rb +0 -63
- data/lib/solargraph/parser/legacy/node_processors/sclass_node.rb +0 -21
- data/lib/solargraph/parser/legacy/node_processors.rb +0 -54
- data/lib/solargraph/parser/legacy.rb +0 -12
- data/lib/solargraph/parser/rubyvm/class_methods.rb +0 -144
- data/lib/solargraph/parser/rubyvm/node_chainer.rb +0 -160
- data/lib/solargraph/parser/rubyvm/node_methods.rb +0 -315
- data/lib/solargraph/parser/rubyvm/node_processors/args_node.rb +0 -85
- data/lib/solargraph/parser/rubyvm/node_processors/block_node.rb +0 -42
- data/lib/solargraph/parser/rubyvm/node_processors/casgn_node.rb +0 -22
- data/lib/solargraph/parser/rubyvm/node_processors/cvasgn_node.rb +0 -23
- data/lib/solargraph/parser/rubyvm/node_processors/defs_node.rb +0 -57
- data/lib/solargraph/parser/rubyvm/node_processors/gvasgn_node.rb +0 -23
- data/lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb +0 -38
- data/lib/solargraph/parser/rubyvm/node_processors/kw_arg_node.rb +0 -39
- data/lib/solargraph/parser/rubyvm/node_processors/lit_node.rb +0 -20
- data/lib/solargraph/parser/rubyvm/node_processors/lvasgn_node.rb +0 -27
- data/lib/solargraph/parser/rubyvm/node_processors/namespace_node.rb +0 -39
- data/lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb +0 -26
- data/lib/solargraph/parser/rubyvm/node_processors/orasgn_node.rb +0 -15
- data/lib/solargraph/parser/rubyvm/node_processors/resbody_node.rb +0 -45
- data/lib/solargraph/parser/rubyvm/node_processors/sclass_node.rb +0 -21
- data/lib/solargraph/parser/rubyvm/node_processors/scope_node.rb +0 -15
- data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +0 -277
- data/lib/solargraph/parser/rubyvm/node_processors/sym_node.rb +0 -18
- data/lib/solargraph/parser/rubyvm/node_processors.rb +0 -63
- data/lib/solargraph/parser/rubyvm.rb +0 -40
- data/lib/solargraph/yard_map/core_docs.rb +0 -170
- data/lib/solargraph/yard_map/core_fills.rb +0 -208
- data/lib/solargraph/yard_map/core_gen.rb +0 -76
- data/lib/solargraph/yard_map/rdoc_to_yard.rb +0 -140
- data/lib/solargraph/yard_map/stdlib_fills.rb +0 -43
- data/lib/yard-solargraph.rb +0 -33
- data/yardoc/2.2.2.tar.gz +0 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Solargraph
|
4
|
+
module Parser
|
5
|
+
module ParserGem
|
6
|
+
module NodeProcessors
|
7
|
+
class ArgsNode < Parser::NodeProcessor::Base
|
8
|
+
def process
|
9
|
+
if node.type == :forward_args
|
10
|
+
forward
|
11
|
+
else
|
12
|
+
node.children.each do |u|
|
13
|
+
loc = get_node_location(u)
|
14
|
+
locals.push Solargraph::Pin::Parameter.new(
|
15
|
+
location: loc,
|
16
|
+
closure: region.closure,
|
17
|
+
comments: comments_for(node),
|
18
|
+
name: u.children[0].to_s,
|
19
|
+
assignment: u.children[1],
|
20
|
+
asgn_code: u.children[1] ? region.code_for(u.children[1]) : nil,
|
21
|
+
presence: region.closure.location.range,
|
22
|
+
decl: get_decl(u)
|
23
|
+
)
|
24
|
+
region.closure.parameters.push locals.last
|
25
|
+
end
|
26
|
+
end
|
27
|
+
process_children
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
# @return [void]
|
33
|
+
def forward
|
34
|
+
loc = get_node_location(node)
|
35
|
+
locals.push Solargraph::Pin::Parameter.new(
|
36
|
+
location: loc,
|
37
|
+
closure: region.closure,
|
38
|
+
presence: region.closure.location.range,
|
39
|
+
decl: get_decl(node)
|
40
|
+
)
|
41
|
+
region.closure.parameters.push locals.last
|
42
|
+
end
|
43
|
+
|
44
|
+
# @param node [AST::Node]
|
45
|
+
# @return [Symbol]
|
46
|
+
def get_decl node
|
47
|
+
node.type
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module Solargraph
|
4
4
|
module Parser
|
5
|
-
module
|
5
|
+
module ParserGem
|
6
6
|
module NodeProcessors
|
7
7
|
class BlockNode < Parser::NodeProcessor::Base
|
8
|
-
include
|
8
|
+
include ParserGem::NodeMethods
|
9
9
|
|
10
10
|
def process
|
11
11
|
location = get_node_location(node)
|
@@ -21,6 +21,7 @@ module Solargraph
|
|
21
21
|
pins.push Solargraph::Pin::Block.new(
|
22
22
|
location: location,
|
23
23
|
closure: parent,
|
24
|
+
node: node,
|
24
25
|
receiver: node.children[0],
|
25
26
|
comments: comments_for(node),
|
26
27
|
scope: region.scope || region.closure.context.scope
|
@@ -2,22 +2,32 @@
|
|
2
2
|
|
3
3
|
module Solargraph
|
4
4
|
module Parser
|
5
|
-
module
|
5
|
+
module ParserGem
|
6
6
|
module NodeProcessors
|
7
7
|
class CasgnNode < Parser::NodeProcessor::Base
|
8
|
-
include
|
8
|
+
include ParserGem::NodeMethods
|
9
9
|
|
10
10
|
def process
|
11
|
-
here = get_node_start_position(node)
|
12
11
|
pins.push Solargraph::Pin::Constant.new(
|
13
12
|
location: get_node_location(node),
|
14
13
|
closure: region.closure,
|
15
|
-
name:
|
14
|
+
name: const_name,
|
16
15
|
comments: comments_for(node),
|
17
16
|
assignment: node.children[2]
|
18
17
|
)
|
19
18
|
process_children
|
20
19
|
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
# @return [String]
|
24
|
+
def const_name
|
25
|
+
if node.children[0]
|
26
|
+
Parser::NodeMethods.unpack_name(node.children[0]) + "::#{node.children[1]}"
|
27
|
+
else
|
28
|
+
node.children[1].to_s
|
29
|
+
end
|
30
|
+
end
|
21
31
|
end
|
22
32
|
end
|
23
33
|
end
|
@@ -2,35 +2,22 @@
|
|
2
2
|
|
3
3
|
module Solargraph
|
4
4
|
module Parser
|
5
|
-
module
|
5
|
+
module ParserGem
|
6
6
|
module NodeProcessors
|
7
7
|
class DefNode < Parser::NodeProcessor::Base
|
8
8
|
def process
|
9
|
+
name = node.children[0].to_s
|
10
|
+
scope = region.scope || (region.closure.is_a?(Pin::Singleton) ? :class : :instance)
|
9
11
|
methpin = Solargraph::Pin::Method.new(
|
10
12
|
location: get_node_location(node),
|
11
13
|
closure: region.closure,
|
12
|
-
name:
|
14
|
+
name: name,
|
13
15
|
comments: comments_for(node),
|
14
|
-
scope:
|
15
|
-
visibility: region.visibility,
|
16
|
+
scope: scope,
|
17
|
+
visibility: scope == :instance && name == 'initialize' ? :private : region.visibility,
|
16
18
|
node: node
|
17
19
|
)
|
18
|
-
if
|
19
|
-
pins.push Solargraph::Pin::Method.new(
|
20
|
-
location: methpin.location,
|
21
|
-
closure: methpin.closure,
|
22
|
-
name: 'new',
|
23
|
-
comments: methpin.comments,
|
24
|
-
scope: :class,
|
25
|
-
parameters: methpin.parameters
|
26
|
-
)
|
27
|
-
# @todo Smelly instance variable access.
|
28
|
-
pins.last.instance_variable_set(:@return_type, ComplexType::SELF)
|
29
|
-
pins.push methpin
|
30
|
-
# @todo Smelly instance variable access.
|
31
|
-
methpin.instance_variable_set(:@visibility, :private)
|
32
|
-
methpin.instance_variable_set(:@return_type, ComplexType::VOID)
|
33
|
-
elsif region.visibility == :module_function
|
20
|
+
if region.visibility == :module_function
|
34
21
|
pins.push Solargraph::Pin::Method.new(
|
35
22
|
location: methpin.location,
|
36
23
|
closure: methpin.closure,
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module Solargraph
|
4
4
|
module Parser
|
5
|
-
module
|
5
|
+
module ParserGem
|
6
6
|
module NodeProcessors
|
7
7
|
class IvasgnNode < Parser::NodeProcessor::Base
|
8
|
-
include
|
8
|
+
include ParserGem::NodeMethods
|
9
9
|
|
10
10
|
def process
|
11
11
|
loc = get_node_location(node)
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module Solargraph
|
4
4
|
module Parser
|
5
|
-
module
|
5
|
+
module ParserGem
|
6
6
|
module NodeProcessors
|
7
7
|
class LvasgnNode < Parser::NodeProcessor::Base
|
8
|
-
include
|
8
|
+
include ParserGem::NodeMethods
|
9
9
|
|
10
10
|
def process
|
11
11
|
here = get_node_start_position(node)
|
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
module Solargraph
|
4
4
|
module Parser
|
5
|
-
module
|
5
|
+
module ParserGem
|
6
6
|
module NodeProcessors
|
7
7
|
class ResbodyNode < Parser::NodeProcessor::Base
|
8
|
-
include
|
8
|
+
include ParserGem::NodeMethods
|
9
9
|
|
10
10
|
def process
|
11
|
-
if node.children[1]
|
11
|
+
if node.children[1] # Exception local variable name
|
12
12
|
here = get_node_start_position(node.children[1])
|
13
13
|
presence = Range.new(here, region.closure.location.range.ending)
|
14
14
|
loc = get_node_location(node.children[1])
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Solargraph
|
4
|
+
module Parser
|
5
|
+
module ParserGem
|
6
|
+
module NodeProcessors
|
7
|
+
class SclassNode < Parser::NodeProcessor::Base
|
8
|
+
def process
|
9
|
+
sclass = node.children[0]
|
10
|
+
if sclass.is_a?(AST::Node) && sclass.type == :self
|
11
|
+
closure = region.closure
|
12
|
+
elsif sclass.is_a?(AST::Node) && sclass.type == :casgn
|
13
|
+
names = [region.closure.namespace, region.closure.name]
|
14
|
+
if sclass.children[0].nil? && names.last != sclass.children[1].to_s
|
15
|
+
names << sclass.children[1].to_s
|
16
|
+
else
|
17
|
+
names.concat [NodeMethods.unpack_name(sclass.children[0]), sclass.children[1].to_s]
|
18
|
+
end
|
19
|
+
name = names.reject(&:empty?).join('::')
|
20
|
+
closure = Solargraph::Pin::Namespace.new(name: name, location: region.closure.location)
|
21
|
+
elsif sclass.is_a?(AST::Node) && sclass.type == :const
|
22
|
+
names = [region.closure.namespace, region.closure.name]
|
23
|
+
also = NodeMethods.unpack_name(sclass)
|
24
|
+
if also != region.closure.name
|
25
|
+
names << also
|
26
|
+
end
|
27
|
+
name = names.reject(&:empty?).join('::')
|
28
|
+
closure = Solargraph::Pin::Namespace.new(name: name, location: region.closure.location)
|
29
|
+
else
|
30
|
+
return
|
31
|
+
end
|
32
|
+
pins.push Solargraph::Pin::Singleton.new(
|
33
|
+
location: get_node_location(node),
|
34
|
+
closure: closure
|
35
|
+
)
|
36
|
+
process_children region.update(visibility: :public, scope: :class, closure: pins.last)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'solargraph/parser/node_processor'
|
4
|
+
|
5
|
+
module Solargraph
|
6
|
+
module Parser
|
7
|
+
module ParserGem
|
8
|
+
module NodeProcessors
|
9
|
+
autoload :BeginNode, 'solargraph/parser/parser_gem/node_processors/begin_node'
|
10
|
+
autoload :DefNode, 'solargraph/parser/parser_gem/node_processors/def_node'
|
11
|
+
autoload :DefsNode, 'solargraph/parser/parser_gem/node_processors/defs_node'
|
12
|
+
autoload :SendNode, 'solargraph/parser/parser_gem/node_processors/send_node'
|
13
|
+
autoload :NamespaceNode, 'solargraph/parser/parser_gem/node_processors/namespace_node'
|
14
|
+
autoload :SclassNode, 'solargraph/parser/parser_gem/node_processors/sclass_node'
|
15
|
+
autoload :IvasgnNode, 'solargraph/parser/parser_gem/node_processors/ivasgn_node'
|
16
|
+
autoload :CvasgnNode, 'solargraph/parser/parser_gem/node_processors/cvasgn_node'
|
17
|
+
autoload :LvasgnNode, 'solargraph/parser/parser_gem/node_processors/lvasgn_node'
|
18
|
+
autoload :GvasgnNode, 'solargraph/parser/parser_gem/node_processors/gvasgn_node'
|
19
|
+
autoload :CasgnNode, 'solargraph/parser/parser_gem/node_processors/casgn_node'
|
20
|
+
autoload :AliasNode, 'solargraph/parser/parser_gem/node_processors/alias_node'
|
21
|
+
autoload :ArgsNode, 'solargraph/parser/parser_gem/node_processors/args_node'
|
22
|
+
autoload :BlockNode, 'solargraph/parser/parser_gem/node_processors/block_node'
|
23
|
+
autoload :OrasgnNode, 'solargraph/parser/parser_gem/node_processors/orasgn_node'
|
24
|
+
autoload :SymNode, 'solargraph/parser/parser_gem/node_processors/sym_node'
|
25
|
+
autoload :ResbodyNode, 'solargraph/parser/parser_gem/node_processors/resbody_node'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
module NodeProcessor
|
30
|
+
register :source, ParserGem::NodeProcessors::BeginNode
|
31
|
+
register :begin, ParserGem::NodeProcessors::BeginNode
|
32
|
+
register :kwbegin, ParserGem::NodeProcessors::BeginNode
|
33
|
+
register :rescue, ParserGem::NodeProcessors::BeginNode
|
34
|
+
register :resbody, ParserGem::NodeProcessors::ResbodyNode
|
35
|
+
register :def, ParserGem::NodeProcessors::DefNode
|
36
|
+
register :defs, ParserGem::NodeProcessors::DefsNode
|
37
|
+
register :send, ParserGem::NodeProcessors::SendNode
|
38
|
+
register :class, ParserGem::NodeProcessors::NamespaceNode
|
39
|
+
register :module, ParserGem::NodeProcessors::NamespaceNode
|
40
|
+
register :sclass, ParserGem::NodeProcessors::SclassNode
|
41
|
+
register :ivasgn, ParserGem::NodeProcessors::IvasgnNode
|
42
|
+
register :cvasgn, ParserGem::NodeProcessors::CvasgnNode
|
43
|
+
register :lvasgn, ParserGem::NodeProcessors::LvasgnNode
|
44
|
+
register :gvasgn, ParserGem::NodeProcessors::GvasgnNode
|
45
|
+
register :casgn, ParserGem::NodeProcessors::CasgnNode
|
46
|
+
register :alias, ParserGem::NodeProcessors::AliasNode
|
47
|
+
register :args, ParserGem::NodeProcessors::ArgsNode
|
48
|
+
register :forward_args, ParserGem::NodeProcessors::ArgsNode
|
49
|
+
register :block, ParserGem::NodeProcessors::BlockNode
|
50
|
+
register :or_asgn, ParserGem::NodeProcessors::OrasgnNode
|
51
|
+
register :sym, ParserGem::NodeProcessors::SymNode
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Solargraph
|
2
|
+
module Parser
|
3
|
+
module ParserGem
|
4
|
+
autoload :FlawedBuilder, 'solargraph/parser/parser_gem/flawed_builder'
|
5
|
+
autoload :ClassMethods, 'solargraph/parser/parser_gem/class_methods'
|
6
|
+
autoload :NodeMethods, 'solargraph/parser/parser_gem/node_methods'
|
7
|
+
autoload :NodeChainer, 'solargraph/parser/parser_gem/node_chainer'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'solargraph/parser/parser_gem/node_processors'
|
@@ -23,7 +23,7 @@ module Solargraph
|
|
23
23
|
|
24
24
|
# @param source [Source]
|
25
25
|
# @param namespace [String]
|
26
|
-
# @param scope [Symbol]
|
26
|
+
# @param scope [Symbol, nil]
|
27
27
|
# @param visibility [Symbol]
|
28
28
|
def initialize source: Solargraph::Source.load_string(''), closure: nil,
|
29
29
|
scope: nil, visibility: :public, lvars: []
|
data/lib/solargraph/parser.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
module Solargraph
|
2
2
|
module Parser
|
3
3
|
autoload :CommentRipper, 'solargraph/parser/comment_ripper'
|
4
|
-
autoload :
|
5
|
-
autoload :Rubyvm, 'solargraph/parser/rubyvm'
|
4
|
+
autoload :ParserGem, 'solargraph/parser/parser_gem'
|
6
5
|
autoload :Region, 'solargraph/parser/region'
|
7
6
|
autoload :NodeProcessor, 'solargraph/parser/node_processor'
|
8
7
|
autoload :Snippet, 'solargraph/parser/snippet'
|
@@ -10,17 +9,17 @@ module Solargraph
|
|
10
9
|
class SyntaxError < StandardError
|
11
10
|
end
|
12
11
|
|
13
|
-
# True if the parser can use RubyVM.
|
14
|
-
#
|
15
12
|
def self.rubyvm?
|
16
|
-
|
17
|
-
# false
|
13
|
+
false
|
18
14
|
end
|
19
15
|
|
20
|
-
|
21
|
-
|
22
|
-
extend selected::ClassMethods
|
16
|
+
# @deprecated
|
17
|
+
Legacy = ParserGem
|
23
18
|
|
24
|
-
|
19
|
+
ClassMethods = ParserGem::ClassMethods
|
20
|
+
|
21
|
+
extend ParserGem::ClassMethods
|
22
|
+
|
23
|
+
NodeMethods = ParserGem::NodeMethods
|
25
24
|
end
|
26
25
|
end
|
data/lib/solargraph/pin/base.rb
CHANGED
@@ -21,9 +21,11 @@ module Solargraph
|
|
21
21
|
# @return [String]
|
22
22
|
attr_reader :path
|
23
23
|
|
24
|
-
# @
|
25
|
-
|
26
|
-
|
24
|
+
# @return [::Symbol]
|
25
|
+
attr_accessor :source
|
26
|
+
|
27
|
+
# @param location [Solargraph::Location, nil]
|
28
|
+
# @param closure [Solargraph::Pin::Closure, nil]
|
27
29
|
# @param name [String]
|
28
30
|
# @param comments [String]
|
29
31
|
def initialize location: nil, closure: nil, name: '', comments: ''
|
@@ -38,6 +40,43 @@ module Solargraph
|
|
38
40
|
@comments ||= ''
|
39
41
|
end
|
40
42
|
|
43
|
+
# @param generics_to_resolve [Enumerable<String>]
|
44
|
+
# @param return_type_context [ComplexType, nil]
|
45
|
+
# @param context [ComplexType]
|
46
|
+
# @param resolved_generic_values [Hash{String => ComplexType}]
|
47
|
+
# @return [self]
|
48
|
+
def resolve_generics_from_context(generics_to_resolve, return_type_context = nil, resolved_generic_values: {})
|
49
|
+
proxy return_type.resolve_generics_from_context(generics_to_resolve,
|
50
|
+
return_type_context,
|
51
|
+
resolved_generic_values: resolved_generic_values)
|
52
|
+
end
|
53
|
+
|
54
|
+
# @yieldparam [ComplexType]
|
55
|
+
# @yieldreturn [ComplexType]
|
56
|
+
# @return [self]
|
57
|
+
def transform_types(&transform)
|
58
|
+
proxy return_type.transform(&transform)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Determine the concrete type for each of the generic type
|
62
|
+
# parameters used in this method based on the parameters passed
|
63
|
+
# into the its class and return a new method pin.
|
64
|
+
#
|
65
|
+
# @param definitions [Pin::Namespace] The module/class which uses generic types
|
66
|
+
# @param context_type [ComplexType] The receiver type
|
67
|
+
# @return [self]
|
68
|
+
def resolve_generics definitions, context_type
|
69
|
+
transformed = transform_types { |t| t.resolve_generics(definitions, context_type) if t }
|
70
|
+
transformed.erase_generics(definitions.generics)
|
71
|
+
end
|
72
|
+
|
73
|
+
# @param generics_to_erase [Enumerable<String>]
|
74
|
+
# @return [self]
|
75
|
+
def erase_generics(generics_to_erase)
|
76
|
+
return self if generics_to_erase.empty?
|
77
|
+
transform_types { |t| t.erase_generics(generics_to_erase) }
|
78
|
+
end
|
79
|
+
|
41
80
|
# @return [String, nil]
|
42
81
|
def filename
|
43
82
|
return nil if location.nil?
|
@@ -55,7 +94,7 @@ module Solargraph
|
|
55
94
|
end
|
56
95
|
|
57
96
|
def to_s
|
58
|
-
|
97
|
+
to_rbs
|
59
98
|
end
|
60
99
|
|
61
100
|
# @return [Boolean]
|
@@ -100,13 +139,13 @@ module Solargraph
|
|
100
139
|
@docstring ||= Solargraph::Source.parse_docstring('').to_docstring
|
101
140
|
end
|
102
141
|
|
103
|
-
# @return [Array<YARD::Tags::Directive>]
|
142
|
+
# @return [::Array<YARD::Tags::Directive>]
|
104
143
|
def directives
|
105
144
|
parse_comments unless defined?(@directives)
|
106
145
|
@directives
|
107
146
|
end
|
108
147
|
|
109
|
-
# @return [Array<YARD::Tags::MacroDirective>]
|
148
|
+
# @return [::Array<YARD::Tags::MacroDirective>]
|
110
149
|
def macros
|
111
150
|
@macros ||= collect_macros
|
112
151
|
end
|
@@ -213,12 +252,31 @@ module Solargraph
|
|
213
252
|
result
|
214
253
|
end
|
215
254
|
|
255
|
+
# @return [String]
|
216
256
|
def identity
|
217
|
-
@identity ||= "#{closure.
|
257
|
+
@identity ||= "#{closure.path}|#{name}"
|
258
|
+
end
|
259
|
+
|
260
|
+
# @return [String, nil]
|
261
|
+
def to_rbs
|
262
|
+
return_type.to_rbs
|
263
|
+
end
|
264
|
+
|
265
|
+
# @return [String, nil]
|
266
|
+
def desc
|
267
|
+
if path
|
268
|
+
if to_rbs
|
269
|
+
path + ' ' + to_rbs
|
270
|
+
else
|
271
|
+
path
|
272
|
+
end
|
273
|
+
else
|
274
|
+
to_rbs
|
275
|
+
end
|
218
276
|
end
|
219
277
|
|
220
278
|
def inspect
|
221
|
-
"#<#{self.class} `#{self.
|
279
|
+
"#<#{self.class} `#{self.desc}` at #{self.location.inspect}>"
|
222
280
|
end
|
223
281
|
|
224
282
|
protected
|
@@ -263,8 +321,8 @@ module Solargraph
|
|
263
321
|
true
|
264
322
|
end
|
265
323
|
|
266
|
-
# @param dir1 [Array<YARD::Tags::Directive>]
|
267
|
-
# @param dir2 [Array<YARD::Tags::Directive>]
|
324
|
+
# @param dir1 [::Array<YARD::Tags::Directive>]
|
325
|
+
# @param dir2 [::Array<YARD::Tags::Directive>]
|
268
326
|
# @return [Boolean]
|
269
327
|
def compare_directives dir1, dir2
|
270
328
|
return false if dir1.length != dir2.length
|
@@ -285,7 +343,7 @@ module Solargraph
|
|
285
343
|
tag1.types == tag2.types
|
286
344
|
end
|
287
345
|
|
288
|
-
# @return [Array<YARD::Tags::Handlers::Directive>]
|
346
|
+
# @return [::Array<YARD::Tags::Handlers::Directive>]
|
289
347
|
def collect_macros
|
290
348
|
return [] unless maybe_directives?
|
291
349
|
parse = Solargraph::Source.parse_docstring(comments)
|
@@ -39,7 +39,7 @@ module Solargraph
|
|
39
39
|
def probe api_map
|
40
40
|
return ComplexType::UNDEFINED if @assignment.nil?
|
41
41
|
types = []
|
42
|
-
|
42
|
+
value_position_nodes_only(@assignment).each do |node|
|
43
43
|
# Nil nodes may not have a location
|
44
44
|
if node.nil? || node.type == :NIL || node.type == :nil
|
45
45
|
types.push ComplexType::NIL
|
@@ -50,13 +50,13 @@ module Solargraph
|
|
50
50
|
clip = api_map.clip_at(location.filename, pos)
|
51
51
|
# Use the return node for inference. The clip might infer from the
|
52
52
|
# first node in a method call instead of the entire call.
|
53
|
-
chain = Parser.chain(node, nil,
|
54
|
-
result = chain.infer(api_map, closure, clip.locals)
|
53
|
+
chain = Parser.chain(node, nil, nil)
|
54
|
+
result = chain.infer(api_map, closure, clip.locals).self_to(closure.context.tag)
|
55
55
|
types.push result unless result.undefined?
|
56
56
|
end
|
57
57
|
end
|
58
58
|
return ComplexType::UNDEFINED if types.empty?
|
59
|
-
ComplexType.try_parse(*types.map(&:
|
59
|
+
ComplexType.try_parse(*types.map(&:to_s))
|
60
60
|
end
|
61
61
|
|
62
62
|
def == other
|
@@ -71,6 +71,10 @@ module Solargraph
|
|
71
71
|
true
|
72
72
|
end
|
73
73
|
|
74
|
+
def desc
|
75
|
+
"#{to_rbs} = #{assignment&.type.inspect}"
|
76
|
+
end
|
77
|
+
|
74
78
|
private
|
75
79
|
|
76
80
|
# @return [ComplexType]
|