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
@@ -1,85 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Solargraph
|
4
|
-
class SourceMap
|
5
|
-
# The processor classes used by SourceMap::Mapper to generate pins from
|
6
|
-
# parser nodes.
|
7
|
-
#
|
8
|
-
module NodeProcessor
|
9
|
-
autoload :Base, 'solargraph/source_map/node_processor/base'
|
10
|
-
autoload :BeginNode, 'solargraph/source_map/node_processor/begin_node'
|
11
|
-
autoload :DefNode, 'solargraph/source_map/node_processor/def_node'
|
12
|
-
autoload :DefsNode, 'solargraph/source_map/node_processor/defs_node'
|
13
|
-
autoload :SendNode, 'solargraph/source_map/node_processor/send_node'
|
14
|
-
autoload :NamespaceNode, 'solargraph/source_map/node_processor/namespace_node'
|
15
|
-
autoload :SclassNode, 'solargraph/source_map/node_processor/sclass_node'
|
16
|
-
autoload :ModuleNode, 'solargraph/source_map/node_processor/module_node'
|
17
|
-
autoload :IvasgnNode, 'solargraph/source_map/node_processor/ivasgn_node'
|
18
|
-
autoload :CvasgnNode, 'solargraph/source_map/node_processor/cvasgn_node'
|
19
|
-
autoload :LvasgnNode, 'solargraph/source_map/node_processor/lvasgn_node'
|
20
|
-
autoload :GvasgnNode, 'solargraph/source_map/node_processor/gvasgn_node'
|
21
|
-
autoload :CasgnNode, 'solargraph/source_map/node_processor/casgn_node'
|
22
|
-
autoload :AliasNode, 'solargraph/source_map/node_processor/alias_node'
|
23
|
-
autoload :ArgsNode, 'solargraph/source_map/node_processor/args_node'
|
24
|
-
autoload :BlockNode, 'solargraph/source_map/node_processor/block_node'
|
25
|
-
autoload :OrasgnNode, 'solargraph/source_map/node_processor/orasgn_node'
|
26
|
-
autoload :SymNode, 'solargraph/source_map/node_processor/sym_node'
|
27
|
-
autoload :ResbodyNode, 'solargraph/source_map/node_processor/resbody_node'
|
28
|
-
|
29
|
-
class << self
|
30
|
-
@@processors ||= {}
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
# Register a processor for a node type.
|
35
|
-
#
|
36
|
-
# @param type [Symbol]
|
37
|
-
# @param cls [Class<NodeProcessor::Base>]
|
38
|
-
# @return [Class<NodeProcessor::Base>]
|
39
|
-
def register type, cls
|
40
|
-
@@processors[type] = cls
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
register :source, BeginNode
|
45
|
-
register :begin, BeginNode
|
46
|
-
register :kwbegin, BeginNode
|
47
|
-
register :rescue, BeginNode
|
48
|
-
register :resbody, ResbodyNode
|
49
|
-
register :def, DefNode
|
50
|
-
register :defs, DefsNode
|
51
|
-
register :send, SendNode
|
52
|
-
register :class, NamespaceNode
|
53
|
-
register :module, NamespaceNode
|
54
|
-
register :sclass, SclassNode
|
55
|
-
register :ivasgn, IvasgnNode
|
56
|
-
register :cvasgn, CvasgnNode
|
57
|
-
register :lvasgn, LvasgnNode
|
58
|
-
register :gvasgn, GvasgnNode
|
59
|
-
register :casgn, CasgnNode
|
60
|
-
register :alias, AliasNode
|
61
|
-
register :args, ArgsNode
|
62
|
-
register :block, BlockNode
|
63
|
-
register :or_asgn, OrasgnNode
|
64
|
-
register :sym, SymNode
|
65
|
-
|
66
|
-
# @param node [Parser::AST::Node]
|
67
|
-
# @param region [Region]
|
68
|
-
# @param pins [Array<Pin::Base>]
|
69
|
-
# @return [Array(Array<Pin::Base>, Array<Pin::Base>)]
|
70
|
-
def self.process node, region = Region.new, pins = [], locals = []
|
71
|
-
if pins.empty?
|
72
|
-
pins.push Pin::Namespace.new(
|
73
|
-
location: region.source.location,
|
74
|
-
name: ''
|
75
|
-
)
|
76
|
-
end
|
77
|
-
return [pins, locals] unless node.is_a?(Parser::AST::Node)
|
78
|
-
klass = @@processors[node.type] || BeginNode
|
79
|
-
processor = klass.new(node, region, pins, locals)
|
80
|
-
processor.process
|
81
|
-
[processor.pins, processor.locals]
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Solargraph
|
4
|
-
class SourceMap
|
5
|
-
module NodeProcessor
|
6
|
-
class AliasNode < Base
|
7
|
-
def process
|
8
|
-
loc = get_node_location(node)
|
9
|
-
pins.push Solargraph::Pin::MethodAlias.new(
|
10
|
-
location: loc,
|
11
|
-
closure: region.closure,
|
12
|
-
name: node.children[0].children[0].to_s,
|
13
|
-
original: node.children[1].children[0].to_s,
|
14
|
-
scope: region.scope || :instance
|
15
|
-
)
|
16
|
-
process_children
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Solargraph
|
4
|
-
class SourceMap
|
5
|
-
module NodeProcessor
|
6
|
-
class ArgsNode < Base
|
7
|
-
def process
|
8
|
-
node.children.each do |u|
|
9
|
-
loc = get_node_location(u)
|
10
|
-
locals.push Solargraph::Pin::Parameter.new(
|
11
|
-
location: loc,
|
12
|
-
closure: region.closure,
|
13
|
-
comments: comments_for(node),
|
14
|
-
name: u.children[0].to_s,
|
15
|
-
assignment: u.children[1],
|
16
|
-
presence: region.closure.location.range
|
17
|
-
)
|
18
|
-
end
|
19
|
-
process_children
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,103 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Solargraph
|
4
|
-
class SourceMap
|
5
|
-
module NodeProcessor
|
6
|
-
class Base
|
7
|
-
include Solargraph::Source::NodeMethods
|
8
|
-
|
9
|
-
# @return [Parser::AST::Node]
|
10
|
-
attr_reader :node
|
11
|
-
|
12
|
-
# @return [Region]
|
13
|
-
attr_reader :region
|
14
|
-
|
15
|
-
# @return [Array<Pin::Base>]
|
16
|
-
attr_reader :pins
|
17
|
-
|
18
|
-
# @return [Array<Pin::Base>]
|
19
|
-
attr_reader :locals
|
20
|
-
|
21
|
-
# @param node [Parser::AST::Node]
|
22
|
-
# @param region [Region]
|
23
|
-
# @param pins [Array<Pin::Base>]
|
24
|
-
def initialize node, region, pins, locals
|
25
|
-
@node = node
|
26
|
-
@region = region
|
27
|
-
@pins = pins
|
28
|
-
@locals = locals
|
29
|
-
end
|
30
|
-
|
31
|
-
protected
|
32
|
-
|
33
|
-
# Subclasses should override this method to generate new pins.
|
34
|
-
#
|
35
|
-
# @return [void]
|
36
|
-
def process
|
37
|
-
raise NoMethodError, "#{self.class} does not implement the `process` method"
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
# @param subregion [Region]
|
43
|
-
# @return [void]
|
44
|
-
def process_children subregion = region
|
45
|
-
node.children.each do |child|
|
46
|
-
next unless child.is_a?(Parser::AST::Node)
|
47
|
-
NodeProcessor.process(child, subregion, pins, locals)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
# @param node [Parser::AST::Node]
|
52
|
-
# @return [Solargraph::Location]
|
53
|
-
def get_node_location(node)
|
54
|
-
st = Position.new(node.loc.line, node.loc.column)
|
55
|
-
en = Position.new(node.loc.last_line, node.loc.last_column)
|
56
|
-
range = Range.new(st, en)
|
57
|
-
Location.new(region.filename, range)
|
58
|
-
end
|
59
|
-
|
60
|
-
def comments_for(node)
|
61
|
-
region.source.comments_for(node)
|
62
|
-
end
|
63
|
-
|
64
|
-
def named_path_pin position
|
65
|
-
pins.select{|pin| pin.is_a?(Pin::Closure) && pin.path && !pin.path.empty? && pin.location.range.contain?(position)}.last
|
66
|
-
end
|
67
|
-
|
68
|
-
private
|
69
|
-
|
70
|
-
def method_args
|
71
|
-
return [] if node.nil?
|
72
|
-
list = nil
|
73
|
-
args = []
|
74
|
-
node.children.each { |c|
|
75
|
-
if c.is_a?(AST::Node) and c.type == :args
|
76
|
-
list = c
|
77
|
-
break
|
78
|
-
end
|
79
|
-
}
|
80
|
-
return args if list.nil?
|
81
|
-
list.children.each { |c|
|
82
|
-
if c.type == :arg
|
83
|
-
args.push c.children[0].to_s
|
84
|
-
elsif c.type == :restarg
|
85
|
-
args.push "*#{c.children[0]}"
|
86
|
-
elsif c.type == :optarg
|
87
|
-
args.push "#{c.children[0]} = #{region.code_for(c.children[1])}"
|
88
|
-
elsif c.type == :kwarg
|
89
|
-
args.push "#{c.children[0]}:"
|
90
|
-
elsif c.type == :kwoptarg
|
91
|
-
args.push "#{c.children[0]}: #{region.code_for(c.children[1])}"
|
92
|
-
elsif c.type == :kwrestarg
|
93
|
-
args.push "**#{c.children[0]}"
|
94
|
-
elsif c.type == :blockarg
|
95
|
-
args.push "&#{c.children[0]}"
|
96
|
-
end
|
97
|
-
}
|
98
|
-
args
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Solargraph
|
4
|
-
class SourceMap
|
5
|
-
module NodeProcessor
|
6
|
-
class BlockNode < Base
|
7
|
-
def process
|
8
|
-
pins.push Solargraph::Pin::Block.new(
|
9
|
-
location: get_node_location(node),
|
10
|
-
closure: region.closure,
|
11
|
-
receiver: node.children[0],
|
12
|
-
comments: comments_for(node),
|
13
|
-
scope: region.scope || region.closure.context.scope,
|
14
|
-
args: method_args
|
15
|
-
)
|
16
|
-
process_children region.update(closure: pins.last)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Solargraph
|
4
|
-
class SourceMap
|
5
|
-
module NodeProcessor
|
6
|
-
class CasgnNode < Base
|
7
|
-
def process
|
8
|
-
here = get_node_start_position(node)
|
9
|
-
pins.push Solargraph::Pin::Constant.new(
|
10
|
-
location: get_node_location(node),
|
11
|
-
closure: region.closure,
|
12
|
-
name: node.children[1].to_s,
|
13
|
-
comments: comments_for(node),
|
14
|
-
assignment: node.children[2]
|
15
|
-
)
|
16
|
-
process_children
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Solargraph
|
4
|
-
class SourceMap
|
5
|
-
module NodeProcessor
|
6
|
-
class CvasgnNode < Base
|
7
|
-
def process
|
8
|
-
loc = get_node_location(node)
|
9
|
-
pins.push Solargraph::Pin::ClassVariable.new(
|
10
|
-
location: loc,
|
11
|
-
closure: region.closure,
|
12
|
-
name: node.children[0].to_s,
|
13
|
-
comments: comments_for(node),
|
14
|
-
assignment: node.children[1]
|
15
|
-
)
|
16
|
-
process_children
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Solargraph
|
4
|
-
class SourceMap
|
5
|
-
module NodeProcessor
|
6
|
-
class DefNode < Base
|
7
|
-
def process
|
8
|
-
methpin = Solargraph::Pin::Method.new(
|
9
|
-
location: get_node_location(node),
|
10
|
-
closure: region.closure,
|
11
|
-
name: node.children[0].to_s,
|
12
|
-
comments: comments_for(node),
|
13
|
-
scope: region.scope || (region.closure.is_a?(Pin::Singleton) ? :class : :instance),
|
14
|
-
visibility: region.visibility,
|
15
|
-
args: method_args,
|
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
|
-
args: 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
|
-
args: 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
|
-
args: 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
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Solargraph
|
4
|
-
class SourceMap
|
5
|
-
module NodeProcessor
|
6
|
-
class DefsNode < DefNode
|
7
|
-
def process
|
8
|
-
s_visi = region.visibility
|
9
|
-
s_visi = :public if s_visi == :module_function || region.scope != :class
|
10
|
-
loc = get_node_location(node)
|
11
|
-
if node.children[0].is_a?(AST::Node) && node.children[0].type == :self
|
12
|
-
closure = region.closure
|
13
|
-
else
|
14
|
-
closure = Solargraph::Pin::Namespace.new(
|
15
|
-
name: unpack_name(node.children[0])
|
16
|
-
)
|
17
|
-
end
|
18
|
-
pins.push Solargraph::Pin::Method.new(
|
19
|
-
location: loc,
|
20
|
-
closure: closure,
|
21
|
-
name: node.children[1].to_s,
|
22
|
-
comments: comments_for(node),
|
23
|
-
scope: :class,
|
24
|
-
visibility: s_visi,
|
25
|
-
args: method_args,
|
26
|
-
node: node
|
27
|
-
)
|
28
|
-
process_children region.update(closure: pins.last, scope: :class)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Solargraph
|
4
|
-
class SourceMap
|
5
|
-
module NodeProcessor
|
6
|
-
class GvasgnNode < Base
|
7
|
-
def process
|
8
|
-
loc = get_node_location(node)
|
9
|
-
pins.push Solargraph::Pin::GlobalVariable.new(
|
10
|
-
location: loc,
|
11
|
-
closure: region.closure,
|
12
|
-
name: node.children[0].to_s,
|
13
|
-
comments: comments_for(node),
|
14
|
-
assignment: node.children[1]
|
15
|
-
)
|
16
|
-
process_children
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Solargraph
|
4
|
-
class SourceMap
|
5
|
-
module NodeProcessor
|
6
|
-
class IvasgnNode < Base
|
7
|
-
def process
|
8
|
-
loc = get_node_location(node)
|
9
|
-
pins.push Solargraph::Pin::InstanceVariable.new(
|
10
|
-
location: loc,
|
11
|
-
closure: region.closure,
|
12
|
-
name: node.children[0].to_s,
|
13
|
-
comments: comments_for(node),
|
14
|
-
assignment: node.children[1]
|
15
|
-
)
|
16
|
-
if region.visibility == :module_function
|
17
|
-
here = get_node_start_position(node)
|
18
|
-
named_path = named_path_pin(here)
|
19
|
-
if named_path.is_a?(Pin::BaseMethod)
|
20
|
-
pins.push Solargraph::Pin::InstanceVariable.new(
|
21
|
-
location: loc,
|
22
|
-
closure: Pin::Namespace.new(type: :module, closure: region.closure.closure, name: region.closure.name),
|
23
|
-
name: node.children[0].to_s,
|
24
|
-
comments: comments_for(node),
|
25
|
-
assignment: node.children[1]
|
26
|
-
)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
process_children
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|