solargraph 0.32.5 → 0.33.0
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 +1 -0
- data/README.md +2 -11
- data/lib/solargraph.rb +1 -2
- data/lib/solargraph/api_map.rb +93 -63
- data/lib/solargraph/api_map/cache.rb +16 -1
- data/lib/solargraph/api_map/source_to_yard.rb +16 -7
- data/lib/solargraph/api_map/store.rb +55 -12
- data/lib/solargraph/complex_type.rb +58 -14
- data/lib/solargraph/complex_type/type_methods.rb +2 -2
- data/lib/solargraph/complex_type/unique_type.rb +33 -4
- data/lib/solargraph/core_fills.rb +40 -12
- data/lib/solargraph/diagnostics.rb +4 -3
- data/lib/solargraph/diagnostics/base.rb +6 -0
- data/lib/solargraph/diagnostics/require_not_found.rb +17 -10
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +2 -0
- data/lib/solargraph/diagnostics/type_check.rb +51 -0
- data/lib/solargraph/diagnostics/update_errors.rb +1 -0
- data/lib/solargraph/language_server/host.rb +55 -25
- data/lib/solargraph/language_server/host/diagnoser.rb +1 -2
- data/lib/solargraph/language_server/host/dispatch.rb +4 -8
- data/lib/solargraph/language_server/host/sources.rb +1 -1
- data/lib/solargraph/language_server/message.rb +1 -0
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +4 -2
- data/lib/solargraph/language_server/message/initialize.rb +9 -0
- data/lib/solargraph/language_server/message/initialized.rb +1 -0
- data/lib/solargraph/language_server/message/text_document.rb +1 -0
- data/lib/solargraph/language_server/message/text_document/code_action.rb +15 -0
- data/lib/solargraph/language_server/message/text_document/completion.rb +1 -1
- data/lib/solargraph/language_server/message/text_document/definition.rb +25 -5
- data/lib/solargraph/language_server/message/text_document/hover.rb +1 -1
- data/lib/solargraph/language_server/message/text_document/signature_help.rb +4 -0
- data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +8 -4
- data/lib/solargraph/language_server/transport/adapter.rb +12 -15
- data/lib/solargraph/library.rb +23 -6
- data/lib/solargraph/location.rb +4 -0
- data/lib/solargraph/pin.rb +7 -3
- data/lib/solargraph/pin/attribute.rb +14 -13
- data/lib/solargraph/pin/base.rb +56 -43
- data/lib/solargraph/pin/base_method.rb +41 -18
- data/lib/solargraph/pin/base_variable.rb +17 -15
- data/lib/solargraph/pin/block.rb +22 -4
- data/lib/solargraph/pin/closure.rb +28 -0
- data/lib/solargraph/pin/common.rb +59 -0
- data/lib/solargraph/pin/constant.rb +4 -4
- data/lib/solargraph/pin/conversions.rb +8 -8
- data/lib/solargraph/pin/duck_method.rb +3 -3
- data/lib/solargraph/pin/instance_variable.rb +30 -0
- data/lib/solargraph/pin/keyword.rb +1 -1
- data/lib/solargraph/pin/local_variable.rb +3 -3
- data/lib/solargraph/pin/localized.rb +9 -5
- data/lib/solargraph/pin/method.rb +26 -40
- data/lib/solargraph/pin/method_alias.rb +9 -6
- data/lib/solargraph/pin/namespace.rb +33 -10
- data/lib/solargraph/pin/parameter.rb +150 -0
- data/lib/solargraph/pin/proxy_type.rb +8 -8
- data/lib/solargraph/pin/reference.rb +1 -12
- data/lib/solargraph/pin/reference/override.rb +18 -0
- data/lib/solargraph/pin/reference/require.rb +2 -1
- data/lib/solargraph/pin/singleton.rb +9 -0
- data/lib/solargraph/pin/symbol.rb +9 -4
- data/lib/solargraph/pin/yard_pin/constant.rb +12 -3
- data/lib/solargraph/pin/yard_pin/method.rb +18 -6
- data/lib/solargraph/pin/yard_pin/namespace.rb +13 -1
- data/lib/solargraph/position.rb +1 -1
- data/lib/solargraph/range.rb +4 -0
- data/lib/solargraph/shell.rb +83 -4
- data/lib/solargraph/source.rb +32 -12
- data/lib/solargraph/source/chain.rb +48 -28
- data/lib/solargraph/source/chain/call.rb +37 -38
- data/lib/solargraph/source/chain/constant.rb +1 -1
- data/lib/solargraph/source/chain/head.rb +2 -8
- data/lib/solargraph/source/chain/instance_variable.rb +1 -1
- data/lib/solargraph/source/chain/link.rb +2 -0
- data/lib/solargraph/source/cursor.rb +59 -24
- data/lib/solargraph/source/node_chainer.rb +0 -2
- data/lib/solargraph/source/node_methods.rb +12 -6
- data/lib/solargraph/source/source_chainer.rb +38 -44
- data/lib/solargraph/source_map.rb +11 -18
- data/lib/solargraph/source_map/clip.rb +13 -15
- data/lib/solargraph/source_map/mapper.rb +37 -26
- data/lib/solargraph/source_map/node_processor.rb +13 -8
- data/lib/solargraph/source_map/node_processor/alias_node.rb +8 -8
- data/lib/solargraph/source_map/node_processor/args_node.rb +10 -16
- data/lib/solargraph/source_map/node_processor/base.rb +47 -4
- data/lib/solargraph/source_map/node_processor/block_node.rb +9 -4
- data/lib/solargraph/source_map/node_processor/casgn_node.rb +7 -2
- data/lib/solargraph/source_map/node_processor/cvasgn_node.rb +8 -3
- data/lib/solargraph/source_map/node_processor/def_node.rb +45 -38
- data/lib/solargraph/source_map/node_processor/defs_node.rb +16 -6
- data/lib/solargraph/source_map/node_processor/gvasgn_node.rb +8 -1
- data/lib/solargraph/source_map/node_processor/ivasgn_node.rb +20 -6
- data/lib/solargraph/source_map/node_processor/lvasgn_node.rb +10 -4
- data/lib/solargraph/source_map/node_processor/namespace_node.rb +18 -12
- data/lib/solargraph/source_map/node_processor/orasgn_node.rb +1 -1
- data/lib/solargraph/source_map/node_processor/resbody_node.rb +30 -0
- data/lib/solargraph/source_map/node_processor/sclass_node.rb +7 -1
- data/lib/solargraph/source_map/node_processor/send_node.rb +102 -52
- data/lib/solargraph/source_map/node_processor/sym_node.rb +4 -1
- data/lib/solargraph/source_map/region.rb +9 -8
- data/lib/solargraph/type_checker.rb +282 -0
- data/lib/solargraph/type_checker/param_def.rb +47 -0
- data/lib/solargraph/type_checker/problem.rb +25 -0
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/views/environment.erb +1 -1
- data/lib/solargraph/workspace.rb +2 -2
- data/lib/solargraph/workspace/config.rb +0 -8
- data/lib/solargraph/yard_map.rb +25 -69
- data/lib/solargraph/yard_map/core_docs.rb +8 -3
- data/lib/solargraph/yard_map/core_gen.rb +1 -3
- data/lib/solargraph/yard_map/mapper.rb +85 -0
- data/lib/yard-solargraph.rb +2 -0
- metadata +14 -14
- data/lib/solargraph/diagnostics/type_not_defined.rb +0 -108
- data/lib/solargraph/live_map.rb +0 -126
- data/lib/solargraph/live_map/cache.rb +0 -38
- data/lib/solargraph/pin/block_parameter.rb +0 -103
- data/lib/solargraph/pin/method_parameter.rb +0 -40
- data/lib/solargraph/pin/plugin/method.rb +0 -25
- data/lib/solargraph/plugin.rb +0 -8
- data/lib/solargraph/plugin/base.rb +0 -41
- data/lib/solargraph/plugin/canceler.rb +0 -11
- data/lib/solargraph/plugin/process.rb +0 -172
- data/lib/solargraph/plugin/runtime.rb +0 -134
- data/lib/yard-coregen.rb +0 -16
@@ -4,8 +4,13 @@ module Solargraph
|
|
4
4
|
class CasgnNode < Base
|
5
5
|
def process
|
6
6
|
here = get_node_start_position(node)
|
7
|
-
|
8
|
-
|
7
|
+
pins.push Solargraph::Pin::Constant.new(
|
8
|
+
location: get_node_location(node),
|
9
|
+
closure: region.closure,
|
10
|
+
name: node.children[1].to_s,
|
11
|
+
comments: comments_for(node),
|
12
|
+
assignment: node.children[2]
|
13
|
+
)
|
9
14
|
process_children
|
10
15
|
end
|
11
16
|
end
|
@@ -3,9 +3,14 @@ module Solargraph
|
|
3
3
|
module NodeProcessor
|
4
4
|
class CvasgnNode < Base
|
5
5
|
def process
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
loc = get_node_location(node)
|
7
|
+
pins.push Solargraph::Pin::ClassVariable.new(
|
8
|
+
location: loc,
|
9
|
+
closure: region.closure,
|
10
|
+
name: node.children[0].to_s,
|
11
|
+
comments: comments_for(node),
|
12
|
+
assignment: node.children[1]
|
13
|
+
)
|
9
14
|
process_children
|
10
15
|
end
|
11
16
|
end
|
@@ -3,50 +3,57 @@ module Solargraph
|
|
3
3
|
module NodeProcessor
|
4
4
|
class DefNode < Base
|
5
5
|
def process
|
6
|
-
|
6
|
+
loc = get_node_location(node)
|
7
|
+
methpin = Solargraph::Pin::Method.new(
|
8
|
+
location: get_node_location(node),
|
9
|
+
closure: region.closure,
|
10
|
+
name: node.children[0].to_s,
|
11
|
+
comments: comments_for(node),
|
12
|
+
scope: region.scope || (region.closure.is_a?(Pin::Singleton) ? :class : :instance),
|
13
|
+
visibility: region.visibility,
|
14
|
+
args: method_args,
|
15
|
+
node: node
|
16
|
+
)
|
7
17
|
if methpin.name == 'initialize' and methpin.scope == :instance
|
8
|
-
pins.push Solargraph::Pin::Method.new(
|
18
|
+
pins.push Solargraph::Pin::Method.new(
|
19
|
+
location: methpin.location,
|
20
|
+
closure: methpin.closure,
|
21
|
+
name: 'new',
|
22
|
+
comments: methpin.comments,
|
23
|
+
scope: :class,
|
24
|
+
args: methpin.parameters
|
25
|
+
)
|
9
26
|
# @todo Smelly instance variable access.
|
10
|
-
pins.last.instance_variable_set(:@
|
11
|
-
pins.push
|
27
|
+
pins.last.instance_variable_set(:@return_type, ComplexType::SELF)
|
28
|
+
pins.push methpin
|
29
|
+
# @todo Smelly instance variable access.
|
30
|
+
methpin.instance_variable_set(:@visibility, :private)
|
31
|
+
methpin.instance_variable_set(:@return_type, ComplexType::VOID)
|
12
32
|
elsif region.visibility == :module_function
|
13
|
-
pins.push Solargraph::Pin::Method.new(
|
14
|
-
|
33
|
+
pins.push Solargraph::Pin::Method.new(
|
34
|
+
location: methpin.location,
|
35
|
+
closure: methpin.closure,
|
36
|
+
name: methpin.name,
|
37
|
+
comments: methpin.comments,
|
38
|
+
scope: :class,
|
39
|
+
visibility: :public,
|
40
|
+
args: methpin.parameters,
|
41
|
+
node: methpin.node
|
42
|
+
)
|
43
|
+
pins.push Solargraph::Pin::Method.new(
|
44
|
+
location: methpin.location,
|
45
|
+
closure: methpin.closure,
|
46
|
+
name: methpin.name,
|
47
|
+
comments: methpin.comments,
|
48
|
+
scope: :instance,
|
49
|
+
visibility: :private,
|
50
|
+
args: methpin.parameters,
|
51
|
+
node: methpin.node
|
52
|
+
)
|
15
53
|
else
|
16
54
|
pins.push methpin
|
17
55
|
end
|
18
|
-
process_children
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def method_args
|
24
|
-
return [] if node.nil?
|
25
|
-
list = nil
|
26
|
-
args = []
|
27
|
-
node.children.each { |c|
|
28
|
-
if c.kind_of?(AST::Node) and c.type == :args
|
29
|
-
list = c
|
30
|
-
break
|
31
|
-
end
|
32
|
-
}
|
33
|
-
return args if list.nil?
|
34
|
-
list.children.each { |c|
|
35
|
-
if c.type == :arg
|
36
|
-
args.push c.children[0].to_s
|
37
|
-
elsif c.type == :restarg
|
38
|
-
args.push "*#{c.children[0]}"
|
39
|
-
elsif c.type == :optarg
|
40
|
-
args.push "#{c.children[0]} = #{region.code_for(c.children[1])}"
|
41
|
-
elsif c.type == :kwarg
|
42
|
-
args.push "#{c.children[0]}:"
|
43
|
-
elsif c.type == :kwoptarg
|
44
|
-
args.push "#{c.children[0]}: #{region.code_for(c.children[1])}"
|
45
|
-
elsif c.type == :blockarg
|
46
|
-
args.push "&#{c.children[0]}"
|
47
|
-
end
|
48
|
-
}
|
49
|
-
args
|
56
|
+
process_children region.update(closure: methpin, scope: methpin.scope)
|
50
57
|
end
|
51
58
|
end
|
52
59
|
end
|
@@ -5,15 +5,25 @@ module Solargraph
|
|
5
5
|
def process
|
6
6
|
s_visi = region.visibility
|
7
7
|
s_visi = :public if s_visi == :module_function || region.scope != :class
|
8
|
+
loc = get_node_location(node)
|
8
9
|
if node.children[0].is_a?(AST::Node) && node.children[0].type == :self
|
9
|
-
|
10
|
+
closure = region.closure
|
10
11
|
else
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
pins.push Solargraph::Pin::Method.new(get_node_location(node), dfqn, "#{node.children[1]}", comments_for(node), :class, s_visi, method_args, node)
|
15
|
-
process_children region.update(namespace: dfqn)
|
12
|
+
closure = Solargraph::Pin::Namespace.new(
|
13
|
+
name: unpack_name(node.children[0])
|
14
|
+
)
|
16
15
|
end
|
16
|
+
pins.push Solargraph::Pin::Method.new(
|
17
|
+
location: loc,
|
18
|
+
closure: closure,
|
19
|
+
name: node.children[1].to_s,
|
20
|
+
comments: comments_for(node),
|
21
|
+
scope: :class,
|
22
|
+
visibility: s_visi,
|
23
|
+
args: method_args,
|
24
|
+
node: node
|
25
|
+
)
|
26
|
+
process_children region.update(closure: pins.last, scope: :class)
|
17
27
|
end
|
18
28
|
end
|
19
29
|
end
|
@@ -3,7 +3,14 @@ module Solargraph
|
|
3
3
|
module NodeProcessor
|
4
4
|
class GvasgnNode < Base
|
5
5
|
def process
|
6
|
-
|
6
|
+
loc = get_node_location(node)
|
7
|
+
pins.push Solargraph::Pin::GlobalVariable.new(
|
8
|
+
location: loc,
|
9
|
+
closure: region.closure,
|
10
|
+
name: node.children[0].to_s,
|
11
|
+
comments: comments_for(node),
|
12
|
+
assignment: node.children[1]
|
13
|
+
)
|
7
14
|
process_children
|
8
15
|
end
|
9
16
|
end
|
@@ -3,12 +3,26 @@ module Solargraph
|
|
3
3
|
module NodeProcessor
|
4
4
|
class IvasgnNode < Base
|
5
5
|
def process
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
loc = get_node_location(node)
|
7
|
+
pins.push Solargraph::Pin::InstanceVariable.new(
|
8
|
+
location: loc,
|
9
|
+
closure: region.closure,
|
10
|
+
name: node.children[0].to_s,
|
11
|
+
comments: comments_for(node),
|
12
|
+
assignment: node.children[1]
|
13
|
+
)
|
14
|
+
if region.visibility == :module_function
|
15
|
+
here = get_node_start_position(node)
|
16
|
+
named_path = named_path_pin(here)
|
17
|
+
if named_path.kind == Pin::METHOD
|
18
|
+
pins.push Solargraph::Pin::InstanceVariable.new(
|
19
|
+
location: loc,
|
20
|
+
closure: Pin::Namespace.new(type: :module, closure: region.closure.closure, name: region.closure.name),
|
21
|
+
name: node.children[0].to_s,
|
22
|
+
comments: comments_for(node),
|
23
|
+
assignment: node.children[1]
|
24
|
+
)
|
25
|
+
end
|
12
26
|
end
|
13
27
|
process_children
|
14
28
|
end
|
@@ -4,10 +4,16 @@ module Solargraph
|
|
4
4
|
class LvasgnNode < Base
|
5
5
|
def process
|
6
6
|
here = get_node_start_position(node)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
presence = Range.new(here, region.closure.location.range.ending)
|
8
|
+
loc = get_node_location(node)
|
9
|
+
locals.push Solargraph::Pin::LocalVariable.new(
|
10
|
+
location: loc,
|
11
|
+
closure: region.closure,
|
12
|
+
name: node.children[0].to_s,
|
13
|
+
assignment: node.children[1],
|
14
|
+
comments: comments_for(node),
|
15
|
+
presence: presence
|
16
|
+
)
|
11
17
|
process_children
|
12
18
|
end
|
13
19
|
end
|
@@ -3,22 +3,28 @@ module Solargraph
|
|
3
3
|
module NodeProcessor
|
4
4
|
class NamespaceNode < Base
|
5
5
|
def process
|
6
|
-
visibility = :public
|
7
|
-
if node.children[0].kind_of?(AST::Node) and node.children[0].children[0].kind_of?(AST::Node) and node.children[0].children[0].type == :cbase
|
8
|
-
tree = pack_name(node.children[0])
|
9
|
-
tree.shift if tree.first.empty?
|
10
|
-
else
|
11
|
-
tree = region.namespace.empty? ? [] : [region.namespace]
|
12
|
-
tree.concat pack_name(node.children[0])
|
13
|
-
end
|
14
|
-
fqn = tree.join('::')
|
15
6
|
sc = nil
|
16
7
|
if node.type == :class and !node.children[1].nil?
|
17
8
|
sc = unpack_name(node.children[1])
|
18
9
|
end
|
19
|
-
|
20
|
-
|
21
|
-
|
10
|
+
loc = get_node_location(node)
|
11
|
+
nspin = Solargraph::Pin::Namespace.new(
|
12
|
+
type: node.type,
|
13
|
+
location: loc,
|
14
|
+
closure: region.closure,
|
15
|
+
name: unpack_name(node.children[0]),
|
16
|
+
comments: comments_for(node),
|
17
|
+
visibility: :public
|
18
|
+
)
|
19
|
+
pins.push nspin
|
20
|
+
unless sc.nil?
|
21
|
+
pins.push Pin::Reference::Superclass.new(
|
22
|
+
location: loc,
|
23
|
+
closure: pins.last,
|
24
|
+
name: sc
|
25
|
+
)
|
26
|
+
end
|
27
|
+
process_children region.update(closure: nspin, visibility: :public)
|
22
28
|
end
|
23
29
|
end
|
24
30
|
end
|
@@ -4,7 +4,7 @@ module Solargraph
|
|
4
4
|
class OrasgnNode < Base
|
5
5
|
def process
|
6
6
|
new_node = node.updated(node.children[0].type, node.children[0].children + [node.children[1]])
|
7
|
-
NodeProcessor.process(new_node, region, pins)
|
7
|
+
NodeProcessor.process(new_node, region, pins, locals)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Solargraph
|
2
|
+
class SourceMap
|
3
|
+
module NodeProcessor
|
4
|
+
class ResbodyNode < Base
|
5
|
+
def process
|
6
|
+
if node.children[1]
|
7
|
+
here = get_node_start_position(node.children[1])
|
8
|
+
presence = Range.new(here, region.closure.location.range.ending)
|
9
|
+
loc = get_node_location(node.children[1])
|
10
|
+
types = if node.children[0].nil?
|
11
|
+
['Exception']
|
12
|
+
else
|
13
|
+
node.children[0].children.map do |child|
|
14
|
+
unpack_name(child)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
locals.push Solargraph::Pin::LocalVariable.new(
|
18
|
+
location: loc,
|
19
|
+
closure: region.closure,
|
20
|
+
name: node.children[1].children[0].to_s,
|
21
|
+
comments: "@type [#{types.join(',')}]",
|
22
|
+
presence: presence
|
23
|
+
)
|
24
|
+
end
|
25
|
+
NodeProcessor.process(node.children[2], region, pins, locals)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -3,7 +3,13 @@ module Solargraph
|
|
3
3
|
module NodeProcessor
|
4
4
|
class SclassNode < Base
|
5
5
|
def process
|
6
|
-
|
6
|
+
# @todo Temporarily skipping remote metaclasses
|
7
|
+
return unless node.children[0].is_a?(AST::Node) && node.children[0].type == :self
|
8
|
+
pins.push Solargraph::Pin::Singleton.new(
|
9
|
+
location: get_node_location(node),
|
10
|
+
closure: region.closure
|
11
|
+
)
|
12
|
+
process_children region.update(visibility: :public, scope: :class, closure: pins.last)
|
7
13
|
end
|
8
14
|
end
|
9
15
|
end
|
@@ -9,7 +9,7 @@ module Solargraph
|
|
9
9
|
node.children[2..-1].each do |child|
|
10
10
|
next unless child.is_a?(AST::Node) && (child.type == :sym || child.type == :str)
|
11
11
|
name = child.children[0].to_s
|
12
|
-
matches = pins.select{ |pin| [Pin::METHOD, Pin::ATTRIBUTE].include?(pin.kind) && pin.name == name && pin.namespace == region.namespace && pin.context.scope == region.scope }
|
12
|
+
matches = pins.select{ |pin| [Pin::METHOD, Pin::ATTRIBUTE].include?(pin.kind) && pin.name == name && pin.namespace == region.closure.full_context.namespace && pin.context.scope == (region.scope || :instance)}
|
13
13
|
matches.each do |pin|
|
14
14
|
# @todo Smelly instance variable access
|
15
15
|
pin.instance_variable_set(:@visibility, node.children[1])
|
@@ -27,7 +27,7 @@ module Solargraph
|
|
27
27
|
process_include
|
28
28
|
elsif node.children[1] == :extend
|
29
29
|
process_extend
|
30
|
-
elsif node.children[1] == :require
|
30
|
+
elsif node.children[1] == :require
|
31
31
|
process_require
|
32
32
|
elsif node.children[1] == :private_constant
|
33
33
|
process_private_constant
|
@@ -43,113 +43,163 @@ module Solargraph
|
|
43
43
|
|
44
44
|
private
|
45
45
|
|
46
|
+
# @return [void]
|
46
47
|
def process_attribute
|
47
48
|
node.children[2..-1].each do |a|
|
49
|
+
loc = get_node_location(node)
|
50
|
+
clos = region.closure
|
51
|
+
cmnt = comments_for(node)
|
48
52
|
if node.children[1] == :attr_reader || node.children[1] == :attr_accessor
|
49
|
-
pins.push Solargraph::Pin::Attribute.new(
|
53
|
+
pins.push Solargraph::Pin::Attribute.new(
|
54
|
+
location: loc,
|
55
|
+
closure: clos,
|
56
|
+
name: a.children[0].to_s,
|
57
|
+
comments: cmnt,
|
58
|
+
access: :reader,
|
59
|
+
scope: region.scope || :instance,
|
60
|
+
visibility: region.visibility
|
61
|
+
)
|
50
62
|
end
|
51
63
|
if node.children[1] == :attr_writer || node.children[1] == :attr_accessor
|
52
|
-
pins.push Solargraph::Pin::Attribute.new(
|
64
|
+
pins.push Solargraph::Pin::Attribute.new(
|
65
|
+
location: loc,
|
66
|
+
closure: clos,
|
67
|
+
name: "#{a.children[0]}=",
|
68
|
+
comments: cmnt,
|
69
|
+
access: :writer,
|
70
|
+
scope: region.scope || :instance,
|
71
|
+
visibility: region.visibility
|
72
|
+
)
|
53
73
|
end
|
54
74
|
end
|
55
75
|
end
|
56
76
|
|
77
|
+
# @return [void]
|
57
78
|
def process_include
|
58
79
|
if node.children[2].kind_of?(AST::Node) && node.children[2].type == :const
|
80
|
+
cp = region.closure
|
59
81
|
node.children[2..-1].each do |i|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
82
|
+
pins.push Pin::Reference::Include.new(
|
83
|
+
location: get_node_location(i),
|
84
|
+
closure: cp,
|
85
|
+
name: unpack_name(i)
|
86
|
+
)
|
64
87
|
end
|
65
88
|
end
|
66
89
|
end
|
67
90
|
|
91
|
+
# @return [void]
|
68
92
|
def process_extend
|
69
93
|
node.children[2..-1].each do |i|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
pins.push
|
94
|
+
loc = get_node_location(node)
|
95
|
+
if i.type == :self
|
96
|
+
pins.push Pin::Reference::Extend.new(
|
97
|
+
location: loc,
|
98
|
+
closure: region.closure,
|
99
|
+
name: region.closure.full_context.namespace
|
100
|
+
)
|
101
|
+
else
|
102
|
+
pins.push Pin::Reference::Extend.new(
|
103
|
+
location: loc,
|
104
|
+
closure: region.closure,
|
105
|
+
name: unpack_name(i)
|
106
|
+
)
|
79
107
|
end
|
80
108
|
end
|
81
109
|
end
|
82
110
|
|
111
|
+
# @return [void]
|
83
112
|
def process_require
|
84
113
|
if node.children[2].kind_of?(AST::Node) && node.children[2].type == :str
|
85
114
|
pins.push Pin::Reference::Require.new(get_node_location(node), node.children[2].children[0].to_s)
|
86
115
|
end
|
87
116
|
end
|
88
117
|
|
118
|
+
# @return [void]
|
89
119
|
def process_module_function
|
90
120
|
if node.children[2].nil?
|
91
121
|
# @todo Smelly instance variable access
|
92
122
|
region.instance_variable_set(:@visibility, :module_function)
|
93
123
|
elsif node.children[2].type == :sym || node.children[2].type == :str
|
94
|
-
# @todo What to do about references?
|
95
124
|
node.children[2..-1].each do |x|
|
96
125
|
cn = x.children[0].to_s
|
97
|
-
ref = pins.select{|p| [Solargraph::Pin::Method, Solargraph::Pin::Attribute].include?(p.class) && p.namespace == region.namespace && p.name == cn}.first
|
126
|
+
ref = pins.select{|p| [Solargraph::Pin::Method, Solargraph::Pin::Attribute].include?(p.class) && p.namespace == region.closure.full_context.namespace && p.name == cn}.first
|
98
127
|
unless ref.nil?
|
99
128
|
pins.delete ref
|
100
|
-
mm = Solargraph::Pin::Method.new(
|
101
|
-
|
129
|
+
mm = Solargraph::Pin::Method.new(
|
130
|
+
location: ref.location,
|
131
|
+
closure: ref.closure,
|
132
|
+
name: ref.name,
|
133
|
+
comments: ref.comments,
|
134
|
+
scope: :class,
|
135
|
+
visibility: :public,
|
136
|
+
args: ref.parameters,
|
137
|
+
node: ref.node
|
138
|
+
)
|
139
|
+
cm = Solargraph::Pin::Method.new(
|
140
|
+
location: ref.location,
|
141
|
+
closure: ref.closure,
|
142
|
+
name: ref.name,
|
143
|
+
comments: ref.comments,
|
144
|
+
scope: :instance,
|
145
|
+
visibility: :private,
|
146
|
+
args: ref.parameters,
|
147
|
+
node: ref.node)
|
102
148
|
pins.push mm, cm
|
103
|
-
pins.select{|pin| pin.kind == Pin::INSTANCE_VARIABLE
|
149
|
+
pins.select{|pin| pin.kind == Pin::INSTANCE_VARIABLE && pin.closure.path == ref.path}.each do |ivar|
|
104
150
|
pins.delete ivar
|
105
|
-
pins.push Solargraph::Pin::InstanceVariable.new(
|
106
|
-
|
151
|
+
pins.push Solargraph::Pin::InstanceVariable.new(
|
152
|
+
location: ivar.location,
|
153
|
+
closure: cm,
|
154
|
+
name: ivar.name,
|
155
|
+
comments: ivar.comments,
|
156
|
+
assignment: ivar.assignment
|
157
|
+
# scope: :instance
|
158
|
+
)
|
159
|
+
pins.push Solargraph::Pin::InstanceVariable.new(
|
160
|
+
location: ivar.location,
|
161
|
+
closure: mm,
|
162
|
+
name: ivar.name,
|
163
|
+
comments: ivar.comments,
|
164
|
+
assignment: ivar.assignment
|
165
|
+
# scope: :class
|
166
|
+
)
|
107
167
|
end
|
108
168
|
end
|
109
169
|
end
|
110
170
|
elsif node.children[2].type == :def
|
111
|
-
NodeProcessor.process node.children[2], region.update(visibility: :module_function), pins
|
171
|
+
NodeProcessor.process node.children[2], region.update(visibility: :module_function), pins, locals
|
112
172
|
end
|
113
173
|
end
|
114
174
|
|
175
|
+
# @return [void]
|
115
176
|
def process_private_constant
|
116
177
|
if node.children[2] && (node.children[2].type == :sym || node.children[2].type == :str)
|
117
|
-
# @todo What to do about references?
|
118
178
|
cn = node.children[2].children[0].to_s
|
119
|
-
ref = pins.select{|p| [Solargraph::Pin::Namespace, Solargraph::Pin::Constant].include?(p.class) && p.namespace == region.namespace && p.name == cn}.first
|
120
|
-
|
121
|
-
|
122
|
-
# Might be either a namespace or constant
|
123
|
-
if ref.kind == Pin::CONSTANT
|
124
|
-
pins.push ref.class.new(ref.location, ref.namespace, ref.name, ref.comments, ref.signature, ref.return_type, ref.context, :private)
|
125
|
-
else
|
126
|
-
# pins.push ref.class.new(ref.location, ref.namespace, ref.name, ref.comments, ref.type, :private, (ref.superclass_reference.nil? ? nil : ref.superclass_reference.name))
|
127
|
-
pins.push ref.class.new(ref.location, ref.namespace, ref.name, ref.comments, ref.type, :private)
|
128
|
-
end
|
129
|
-
end
|
179
|
+
ref = pins.select{|p| [Solargraph::Pin::Namespace, Solargraph::Pin::Constant].include?(p.class) && p.namespace == region.closure.full_context.namespace && p.name == cn}.first
|
180
|
+
# HACK: Smelly instance variable access
|
181
|
+
ref.instance_variable_set(:@visibility, :private) unless ref.nil?
|
130
182
|
end
|
131
183
|
end
|
132
184
|
|
185
|
+
# @return [void]
|
133
186
|
def process_alias_method
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
end
|
143
|
-
end
|
187
|
+
loc = get_node_location(node)
|
188
|
+
pins.push Solargraph::Pin::MethodAlias.new(
|
189
|
+
location: get_node_location(node),
|
190
|
+
closure: region.closure,
|
191
|
+
name: node.children[2].children[0].to_s,
|
192
|
+
original: node.children[3].children[0].to_s,
|
193
|
+
scope: region.scope || :instance
|
194
|
+
)
|
144
195
|
end
|
145
196
|
|
197
|
+
# @return [Boolean]
|
146
198
|
def process_private_class_method
|
147
199
|
if node.children[2].type == :sym || node.children[2].type == :str
|
148
|
-
ref = pins.select{|p| [Solargraph::Pin::Method, Solargraph::Pin::Attribute].include?(p.class) && p.namespace == region.namespace && p.name == node.children[2].children[0].to_s}.first
|
149
|
-
|
150
|
-
|
151
|
-
ref.instance_variable_set(:@visibility, :private)
|
152
|
-
end
|
200
|
+
ref = pins.select{|p| [Solargraph::Pin::Method, Solargraph::Pin::Attribute].include?(p.class) && p.namespace == region.closure.full_context.namespace && p.name == node.children[2].children[0].to_s}.first
|
201
|
+
# HACK: Smelly instance variable access
|
202
|
+
ref.instance_variable_set(:@visibility, :private) unless ref.nil?
|
153
203
|
false
|
154
204
|
else
|
155
205
|
process_children region.update(scope: :class, visibility: :private)
|