solargraph 0.38.6 → 0.39.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/SPONSORS.md +9 -0
- data/lib/solargraph.rb +1 -0
- data/lib/solargraph/api_map.rb +24 -13
- data/lib/solargraph/api_map/bundler_methods.rb +3 -0
- data/lib/solargraph/api_map/source_to_yard.rb +1 -6
- data/lib/solargraph/api_map/store.rb +19 -3
- data/lib/solargraph/complex_type/type_methods.rb +4 -4
- data/lib/solargraph/convention/base.rb +0 -5
- data/lib/solargraph/core_fills.rb +28 -2
- data/lib/solargraph/diagnostics/base.rb +1 -0
- data/lib/solargraph/diagnostics/type_check.rb +13 -13
- data/lib/solargraph/language_server/host.rb +11 -2
- data/lib/solargraph/language_server/host/sources.rb +20 -11
- data/lib/solargraph/language_server/message/text_document/formatting.rb +16 -11
- data/lib/solargraph/language_server/transport/data_reader.rb +2 -0
- data/lib/solargraph/library.rb +3 -3
- data/lib/solargraph/parser.rb +26 -0
- data/lib/solargraph/parser/comment_ripper.rb +52 -0
- data/lib/solargraph/parser/legacy.rb +12 -0
- data/lib/solargraph/parser/legacy/class_methods.rb +105 -0
- data/lib/solargraph/parser/legacy/flawed_builder.rb +16 -0
- data/lib/solargraph/parser/legacy/node_chainer.rb +115 -0
- data/lib/solargraph/parser/legacy/node_methods.rb +289 -0
- data/lib/solargraph/parser/legacy/node_processors.rb +54 -0
- data/lib/solargraph/parser/legacy/node_processors/alias_node.rb +23 -0
- data/lib/solargraph/parser/legacy/node_processors/args_node.rb +35 -0
- data/lib/solargraph/parser/legacy/node_processors/begin_node.rb +15 -0
- data/lib/solargraph/parser/legacy/node_processors/block_node.rb +22 -0
- data/lib/solargraph/parser/legacy/node_processors/casgn_node.rb +25 -0
- data/lib/solargraph/parser/legacy/node_processors/cvasgn_node.rb +23 -0
- data/lib/solargraph/parser/legacy/node_processors/def_node.rb +63 -0
- data/lib/solargraph/parser/legacy/node_processors/defs_node.rb +36 -0
- data/lib/solargraph/parser/legacy/node_processors/gvasgn_node.rb +23 -0
- data/lib/solargraph/parser/legacy/node_processors/ivasgn_node.rb +38 -0
- data/lib/solargraph/parser/legacy/node_processors/lvasgn_node.rb +28 -0
- data/lib/solargraph/parser/legacy/node_processors/namespace_node.rb +39 -0
- data/lib/solargraph/parser/legacy/node_processors/orasgn_node.rb +16 -0
- data/lib/solargraph/parser/legacy/node_processors/resbody_node.rb +36 -0
- data/lib/solargraph/parser/legacy/node_processors/sclass_node.rb +21 -0
- data/lib/solargraph/parser/legacy/node_processors/send_node.rb +232 -0
- data/lib/solargraph/parser/legacy/node_processors/sym_node.rb +18 -0
- data/lib/solargraph/parser/node_methods.rb +43 -0
- data/lib/solargraph/parser/node_processor.rb +43 -0
- data/lib/solargraph/parser/node_processor/base.rb +77 -0
- data/lib/solargraph/{source_map → parser}/region.rb +11 -6
- data/lib/solargraph/parser/rubyvm.rb +40 -0
- data/lib/solargraph/parser/rubyvm/class_methods.rb +146 -0
- data/lib/solargraph/parser/rubyvm/node_chainer.rb +133 -0
- data/lib/solargraph/parser/rubyvm/node_methods.rb +279 -0
- data/lib/solargraph/parser/rubyvm/node_processors.rb +60 -0
- data/lib/solargraph/parser/rubyvm/node_processors/alias_node.rb +23 -0
- data/lib/solargraph/parser/rubyvm/node_processors/args_node.rb +62 -0
- data/lib/solargraph/parser/rubyvm/node_processors/begin_node.rb +15 -0
- data/lib/solargraph/parser/rubyvm/node_processors/block_node.rb +22 -0
- data/lib/solargraph/parser/rubyvm/node_processors/casgn_node.rb +22 -0
- data/lib/solargraph/parser/rubyvm/node_processors/cvasgn_node.rb +23 -0
- data/lib/solargraph/parser/rubyvm/node_processors/def_node.rb +64 -0
- data/lib/solargraph/parser/rubyvm/node_processors/defs_node.rb +57 -0
- data/lib/solargraph/parser/rubyvm/node_processors/gvasgn_node.rb +23 -0
- data/lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb +38 -0
- data/lib/solargraph/parser/rubyvm/node_processors/kw_arg_node.rb +34 -0
- data/lib/solargraph/parser/rubyvm/node_processors/lit_node.rb +20 -0
- data/lib/solargraph/parser/rubyvm/node_processors/lvasgn_node.rb +27 -0
- data/lib/solargraph/parser/rubyvm/node_processors/namespace_node.rb +39 -0
- data/lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb +26 -0
- data/lib/solargraph/parser/rubyvm/node_processors/orasgn_node.rb +15 -0
- data/lib/solargraph/parser/rubyvm/node_processors/resbody_node.rb +45 -0
- data/lib/solargraph/parser/rubyvm/node_processors/sclass_node.rb +21 -0
- data/lib/solargraph/parser/rubyvm/node_processors/scope_node.rb +15 -0
- data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +292 -0
- data/lib/solargraph/parser/rubyvm/node_processors/sym_node.rb +18 -0
- data/lib/solargraph/parser/snippet.rb +13 -0
- data/lib/solargraph/pin/attribute.rb +8 -0
- data/lib/solargraph/pin/base.rb +1 -1
- data/lib/solargraph/pin/base_method.rb +26 -4
- data/lib/solargraph/pin/base_variable.rb +7 -8
- data/lib/solargraph/pin/block.rb +1 -1
- data/lib/solargraph/pin/constant.rb +16 -0
- data/lib/solargraph/pin/conversions.rb +2 -2
- data/lib/solargraph/pin/method.rb +26 -14
- data/lib/solargraph/pin/parameter.rb +56 -2
- data/lib/solargraph/pin/reference.rb +1 -0
- data/lib/solargraph/pin/reference/override.rb +2 -0
- data/lib/solargraph/pin/reference/prepend.rb +10 -0
- data/lib/solargraph/pin/yard_pin/constant.rb +2 -4
- data/lib/solargraph/pin/yard_pin/method.rb +34 -18
- data/lib/solargraph/pin/yard_pin/namespace.rb +3 -11
- data/lib/solargraph/pin/yard_pin/yard_mixin.rb +3 -12
- data/lib/solargraph/range.rb +8 -2
- data/lib/solargraph/shell.rb +17 -11
- data/lib/solargraph/source.rb +114 -135
- data/lib/solargraph/source/chain.rb +11 -3
- data/lib/solargraph/source/chain/call.rb +1 -2
- data/lib/solargraph/source/chain/constant.rb +44 -8
- data/lib/solargraph/source/chain/link.rb +1 -0
- data/lib/solargraph/source/cursor.rb +2 -28
- data/lib/solargraph/source/source_chainer.rb +12 -6
- data/lib/solargraph/source/updater.rb +2 -0
- data/lib/solargraph/source_map.rb +0 -2
- data/lib/solargraph/source_map/clip.rb +24 -17
- data/lib/solargraph/source_map/mapper.rb +34 -29
- data/lib/solargraph/type_checker.rb +367 -275
- data/lib/solargraph/type_checker/checks.rb +95 -0
- data/lib/solargraph/type_checker/param_def.rb +2 -17
- data/lib/solargraph/type_checker/rules.rb +53 -0
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/views/environment.erb +5 -3
- data/lib/solargraph/workspace.rb +17 -2
- data/lib/solargraph/workspace/config.rb +15 -7
- data/lib/solargraph/yard_map.rb +89 -49
- data/lib/solargraph/yard_map/core_docs.rb +1 -1
- data/solargraph.gemspec +2 -1
- metadata +88 -32
- data/OVERVIEW.md +0 -37
- data/lib/solargraph/source/flawed_builder.rb +0 -15
- data/lib/solargraph/source/node_chainer.rb +0 -111
- data/lib/solargraph/source/node_methods.rb +0 -240
- data/lib/solargraph/source_map/node_processor.rb +0 -85
- data/lib/solargraph/source_map/node_processor/alias_node.rb +0 -21
- data/lib/solargraph/source_map/node_processor/args_node.rb +0 -24
- data/lib/solargraph/source_map/node_processor/base.rb +0 -103
- data/lib/solargraph/source_map/node_processor/begin_node.rb +0 -13
- data/lib/solargraph/source_map/node_processor/block_node.rb +0 -21
- data/lib/solargraph/source_map/node_processor/casgn_node.rb +0 -21
- data/lib/solargraph/source_map/node_processor/cvasgn_node.rb +0 -21
- data/lib/solargraph/source_map/node_processor/def_node.rb +0 -62
- data/lib/solargraph/source_map/node_processor/defs_node.rb +0 -33
- data/lib/solargraph/source_map/node_processor/gvasgn_node.rb +0 -21
- data/lib/solargraph/source_map/node_processor/ivasgn_node.rb +0 -34
- data/lib/solargraph/source_map/node_processor/lvasgn_node.rb +0 -24
- data/lib/solargraph/source_map/node_processor/namespace_node.rb +0 -35
- data/lib/solargraph/source_map/node_processor/orasgn_node.rb +0 -14
- data/lib/solargraph/source_map/node_processor/resbody_node.rb +0 -32
- data/lib/solargraph/source_map/node_processor/sclass_node.rb +0 -19
- data/lib/solargraph/source_map/node_processor/send_node.rb +0 -217
- data/lib/solargraph/source_map/node_processor/sym_node.rb +0 -16
@@ -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 Legacy
|
8
|
+
module NodeProcessors
|
9
|
+
autoload :BeginNode, 'solargraph/parser/legacy/node_processors/begin_node'
|
10
|
+
autoload :DefNode, 'solargraph/parser/legacy/node_processors/def_node'
|
11
|
+
autoload :DefsNode, 'solargraph/parser/legacy/node_processors/defs_node'
|
12
|
+
autoload :SendNode, 'solargraph/parser/legacy/node_processors/send_node'
|
13
|
+
autoload :NamespaceNode, 'solargraph/parser/legacy/node_processors/namespace_node'
|
14
|
+
autoload :SclassNode, 'solargraph/parser/legacy/node_processors/sclass_node'
|
15
|
+
autoload :ModuleNode, 'solargraph/parser/legacy/node_processors/module_node'
|
16
|
+
autoload :IvasgnNode, 'solargraph/parser/legacy/node_processors/ivasgn_node'
|
17
|
+
autoload :CvasgnNode, 'solargraph/parser/legacy/node_processors/cvasgn_node'
|
18
|
+
autoload :LvasgnNode, 'solargraph/parser/legacy/node_processors/lvasgn_node'
|
19
|
+
autoload :GvasgnNode, 'solargraph/parser/legacy/node_processors/gvasgn_node'
|
20
|
+
autoload :CasgnNode, 'solargraph/parser/legacy/node_processors/casgn_node'
|
21
|
+
autoload :AliasNode, 'solargraph/parser/legacy/node_processors/alias_node'
|
22
|
+
autoload :ArgsNode, 'solargraph/parser/legacy/node_processors/args_node'
|
23
|
+
autoload :BlockNode, 'solargraph/parser/legacy/node_processors/block_node'
|
24
|
+
autoload :OrasgnNode, 'solargraph/parser/legacy/node_processors/orasgn_node'
|
25
|
+
autoload :SymNode, 'solargraph/parser/legacy/node_processors/sym_node'
|
26
|
+
autoload :ResbodyNode, 'solargraph/parser/legacy/node_processors/resbody_node'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
module NodeProcessor
|
31
|
+
register :source, Legacy::NodeProcessors::BeginNode
|
32
|
+
register :begin, Legacy::NodeProcessors::BeginNode
|
33
|
+
register :kwbegin, Legacy::NodeProcessors::BeginNode
|
34
|
+
register :rescue, Legacy::NodeProcessors::BeginNode
|
35
|
+
register :resbody, Legacy::NodeProcessors::ResbodyNode
|
36
|
+
register :def, Legacy::NodeProcessors::DefNode
|
37
|
+
register :defs, Legacy::NodeProcessors::DefsNode
|
38
|
+
register :send, Legacy::NodeProcessors::SendNode
|
39
|
+
register :class, Legacy::NodeProcessors::NamespaceNode
|
40
|
+
register :module, Legacy::NodeProcessors::NamespaceNode
|
41
|
+
register :sclass, Legacy::NodeProcessors::SclassNode
|
42
|
+
register :ivasgn, Legacy::NodeProcessors::IvasgnNode
|
43
|
+
register :cvasgn, Legacy::NodeProcessors::CvasgnNode
|
44
|
+
register :lvasgn, Legacy::NodeProcessors::LvasgnNode
|
45
|
+
register :gvasgn, Legacy::NodeProcessors::GvasgnNode
|
46
|
+
register :casgn, Legacy::NodeProcessors::CasgnNode
|
47
|
+
register :alias, Legacy::NodeProcessors::AliasNode
|
48
|
+
register :args, Legacy::NodeProcessors::ArgsNode
|
49
|
+
register :block, Legacy::NodeProcessors::BlockNode
|
50
|
+
register :or_asgn, Legacy::NodeProcessors::OrasgnNode
|
51
|
+
register :sym, Legacy::NodeProcessors::SymNode
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Solargraph
|
4
|
+
module Parser
|
5
|
+
module Legacy
|
6
|
+
module NodeProcessors
|
7
|
+
class AliasNode < Parser::NodeProcessor::Base
|
8
|
+
def process
|
9
|
+
loc = get_node_location(node)
|
10
|
+
pins.push Solargraph::Pin::MethodAlias.new(
|
11
|
+
location: loc,
|
12
|
+
closure: region.closure,
|
13
|
+
name: node.children[0].children[0].to_s,
|
14
|
+
original: node.children[1].children[0].to_s,
|
15
|
+
scope: region.scope || :instance
|
16
|
+
)
|
17
|
+
process_children
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Solargraph
|
4
|
+
module Parser
|
5
|
+
module Legacy
|
6
|
+
module NodeProcessors
|
7
|
+
class ArgsNode < Parser::NodeProcessor::Base
|
8
|
+
def process
|
9
|
+
node.children.each do |u|
|
10
|
+
loc = get_node_location(u)
|
11
|
+
locals.push Solargraph::Pin::Parameter.new(
|
12
|
+
location: loc,
|
13
|
+
closure: region.closure,
|
14
|
+
comments: comments_for(node),
|
15
|
+
name: u.children[0].to_s,
|
16
|
+
assignment: u.children[1],
|
17
|
+
asgn_code: u.children[1] ? region.code_for(u.children[1]) : nil,
|
18
|
+
presence: region.closure.location.range,
|
19
|
+
decl: get_decl(u)
|
20
|
+
)
|
21
|
+
region.closure.parameters.push locals.last
|
22
|
+
end
|
23
|
+
process_children
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def get_decl node
|
29
|
+
node.type
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Solargraph
|
4
|
+
module Parser
|
5
|
+
module Legacy
|
6
|
+
module NodeProcessors
|
7
|
+
class BlockNode < Parser::NodeProcessor::Base
|
8
|
+
def process
|
9
|
+
pins.push Solargraph::Pin::Block.new(
|
10
|
+
location: get_node_location(node),
|
11
|
+
closure: region.closure,
|
12
|
+
receiver: node.children[0],
|
13
|
+
comments: comments_for(node),
|
14
|
+
scope: region.scope || region.closure.context.scope
|
15
|
+
)
|
16
|
+
process_children region.update(closure: pins.last)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Solargraph
|
4
|
+
module Parser
|
5
|
+
module Legacy
|
6
|
+
module NodeProcessors
|
7
|
+
class CasgnNode < Parser::NodeProcessor::Base
|
8
|
+
include Legacy::NodeMethods
|
9
|
+
|
10
|
+
def process
|
11
|
+
here = get_node_start_position(node)
|
12
|
+
pins.push Solargraph::Pin::Constant.new(
|
13
|
+
location: get_node_location(node),
|
14
|
+
closure: region.closure,
|
15
|
+
name: node.children[1].to_s,
|
16
|
+
comments: comments_for(node),
|
17
|
+
assignment: node.children[2]
|
18
|
+
)
|
19
|
+
process_children
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Solargraph
|
4
|
+
module Parser
|
5
|
+
module Legacy
|
6
|
+
module NodeProcessors
|
7
|
+
class CvasgnNode < Parser::NodeProcessor::Base
|
8
|
+
def process
|
9
|
+
loc = get_node_location(node)
|
10
|
+
pins.push Solargraph::Pin::ClassVariable.new(
|
11
|
+
location: loc,
|
12
|
+
closure: region.closure,
|
13
|
+
name: node.children[0].to_s,
|
14
|
+
comments: comments_for(node),
|
15
|
+
assignment: node.children[1]
|
16
|
+
)
|
17
|
+
process_children
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Solargraph
|
4
|
+
module Parser
|
5
|
+
module Legacy
|
6
|
+
module NodeProcessors
|
7
|
+
class DefNode < Parser::NodeProcessor::Base
|
8
|
+
def process
|
9
|
+
methpin = Solargraph::Pin::Method.new(
|
10
|
+
location: get_node_location(node),
|
11
|
+
closure: region.closure,
|
12
|
+
name: node.children[0].to_s,
|
13
|
+
comments: comments_for(node),
|
14
|
+
scope: region.scope || (region.closure.is_a?(Pin::Singleton) ? :class : :instance),
|
15
|
+
visibility: region.visibility,
|
16
|
+
node: node
|
17
|
+
)
|
18
|
+
if methpin.name == 'initialize' and methpin.scope == :instance
|
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
|
34
|
+
pins.push Solargraph::Pin::Method.new(
|
35
|
+
location: methpin.location,
|
36
|
+
closure: methpin.closure,
|
37
|
+
name: methpin.name,
|
38
|
+
comments: methpin.comments,
|
39
|
+
scope: :class,
|
40
|
+
visibility: :public,
|
41
|
+
parameters: methpin.parameters,
|
42
|
+
node: methpin.node
|
43
|
+
)
|
44
|
+
pins.push Solargraph::Pin::Method.new(
|
45
|
+
location: methpin.location,
|
46
|
+
closure: methpin.closure,
|
47
|
+
name: methpin.name,
|
48
|
+
comments: methpin.comments,
|
49
|
+
scope: :instance,
|
50
|
+
visibility: :private,
|
51
|
+
parameters: methpin.parameters,
|
52
|
+
node: methpin.node
|
53
|
+
)
|
54
|
+
else
|
55
|
+
pins.push methpin
|
56
|
+
end
|
57
|
+
process_children region.update(closure: methpin, scope: methpin.scope)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Solargraph
|
4
|
+
module Parser
|
5
|
+
module Legacy
|
6
|
+
module NodeProcessors
|
7
|
+
class DefsNode < DefNode
|
8
|
+
include Legacy::NodeMethods
|
9
|
+
|
10
|
+
def process
|
11
|
+
s_visi = region.visibility
|
12
|
+
s_visi = :public if s_visi == :module_function || region.scope != :class
|
13
|
+
loc = get_node_location(node)
|
14
|
+
if node.children[0].is_a?(AST::Node) && node.children[0].type == :self
|
15
|
+
closure = region.closure
|
16
|
+
else
|
17
|
+
closure = Solargraph::Pin::Namespace.new(
|
18
|
+
name: unpack_name(node.children[0])
|
19
|
+
)
|
20
|
+
end
|
21
|
+
pins.push Solargraph::Pin::Method.new(
|
22
|
+
location: loc,
|
23
|
+
closure: closure,
|
24
|
+
name: node.children[1].to_s,
|
25
|
+
comments: comments_for(node),
|
26
|
+
scope: :class,
|
27
|
+
visibility: s_visi,
|
28
|
+
node: node
|
29
|
+
)
|
30
|
+
process_children region.update(closure: pins.last, scope: :class)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Solargraph
|
4
|
+
module Parser
|
5
|
+
module Legacy
|
6
|
+
module NodeProcessors
|
7
|
+
class GvasgnNode < Parser::NodeProcessor::Base
|
8
|
+
def process
|
9
|
+
loc = get_node_location(node)
|
10
|
+
pins.push Solargraph::Pin::GlobalVariable.new(
|
11
|
+
location: loc,
|
12
|
+
closure: region.closure,
|
13
|
+
name: node.children[0].to_s,
|
14
|
+
comments: comments_for(node),
|
15
|
+
assignment: node.children[1]
|
16
|
+
)
|
17
|
+
process_children
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Solargraph
|
4
|
+
module Parser
|
5
|
+
module Legacy
|
6
|
+
module NodeProcessors
|
7
|
+
class IvasgnNode < Parser::NodeProcessor::Base
|
8
|
+
include Legacy::NodeMethods
|
9
|
+
|
10
|
+
def process
|
11
|
+
loc = get_node_location(node)
|
12
|
+
pins.push Solargraph::Pin::InstanceVariable.new(
|
13
|
+
location: loc,
|
14
|
+
closure: region.closure,
|
15
|
+
name: node.children[0].to_s,
|
16
|
+
comments: comments_for(node),
|
17
|
+
assignment: node.children[1]
|
18
|
+
)
|
19
|
+
if region.visibility == :module_function
|
20
|
+
here = get_node_start_position(node)
|
21
|
+
named_path = named_path_pin(here)
|
22
|
+
if named_path.is_a?(Pin::BaseMethod)
|
23
|
+
pins.push Solargraph::Pin::InstanceVariable.new(
|
24
|
+
location: loc,
|
25
|
+
closure: Pin::Namespace.new(type: :module, closure: region.closure.closure, name: region.closure.name),
|
26
|
+
name: node.children[0].to_s,
|
27
|
+
comments: comments_for(node),
|
28
|
+
assignment: node.children[1]
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
process_children
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Solargraph
|
4
|
+
module Parser
|
5
|
+
module Legacy
|
6
|
+
module NodeProcessors
|
7
|
+
class LvasgnNode < Parser::NodeProcessor::Base
|
8
|
+
include Legacy::NodeMethods
|
9
|
+
|
10
|
+
def process
|
11
|
+
here = get_node_start_position(node)
|
12
|
+
presence = Range.new(here, region.closure.location.range.ending)
|
13
|
+
loc = get_node_location(node)
|
14
|
+
locals.push Solargraph::Pin::LocalVariable.new(
|
15
|
+
location: loc,
|
16
|
+
closure: region.closure,
|
17
|
+
name: node.children[0].to_s,
|
18
|
+
assignment: node.children[1],
|
19
|
+
comments: comments_for(node),
|
20
|
+
presence: presence
|
21
|
+
)
|
22
|
+
process_children
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Solargraph
|
4
|
+
module Parser
|
5
|
+
module Legacy
|
6
|
+
module NodeProcessors
|
7
|
+
class NamespaceNode < Parser::NodeProcessor::Base
|
8
|
+
include Legacy::NodeMethods
|
9
|
+
|
10
|
+
def process
|
11
|
+
sc = nil
|
12
|
+
if node.type == :class and !node.children[1].nil?
|
13
|
+
sc = unpack_name(node.children[1])
|
14
|
+
end
|
15
|
+
loc = get_node_location(node)
|
16
|
+
nspin = Solargraph::Pin::Namespace.new(
|
17
|
+
type: node.type,
|
18
|
+
location: loc,
|
19
|
+
closure: region.closure,
|
20
|
+
name: unpack_name(node.children[0]),
|
21
|
+
comments: comments_for(node),
|
22
|
+
visibility: :public,
|
23
|
+
gates: region.closure.gates.freeze
|
24
|
+
)
|
25
|
+
pins.push nspin
|
26
|
+
unless sc.nil?
|
27
|
+
pins.push Pin::Reference::Superclass.new(
|
28
|
+
location: loc,
|
29
|
+
closure: pins.last,
|
30
|
+
name: sc
|
31
|
+
)
|
32
|
+
end
|
33
|
+
process_children region.update(closure: nspin, visibility: :public)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Solargraph
|
4
|
+
module Parser
|
5
|
+
module Legacy
|
6
|
+
module NodeProcessors
|
7
|
+
class OrasgnNode < Parser::NodeProcessor::Base
|
8
|
+
def process
|
9
|
+
new_node = node.updated(node.children[0].type, node.children[0].children + [node.children[1]])
|
10
|
+
NodeProcessor.process(new_node, region, pins, locals)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|