rucoa 0.11.0 → 0.12.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/.rubocop.yml +6 -3
- data/Gemfile.lock +3 -3
- data/README.md +4 -1
- data/lib/rucoa/configuration.rb +22 -12
- data/lib/rucoa/definition_store.rb +131 -131
- data/lib/rucoa/definitions/method_definition.rb +11 -11
- data/lib/rucoa/handler_concerns/configuration_requestable.rb +7 -7
- data/lib/rucoa/handler_concerns/diagnostics_publishable.rb +11 -11
- data/lib/rucoa/handler_concerns/text_document_position_parameters.rb +29 -0
- data/lib/rucoa/handler_concerns/text_document_uri_parameters.rb +21 -0
- data/lib/rucoa/handler_concerns.rb +2 -0
- data/lib/rucoa/handlers/base.rb +9 -9
- data/lib/rucoa/handlers/initialize_handler.rb +1 -0
- data/lib/rucoa/handlers/initialized_handler.rb +16 -16
- data/lib/rucoa/handlers/text_document_code_action_handler.rb +12 -12
- data/lib/rucoa/handlers/text_document_completion_handler.rb +85 -99
- data/lib/rucoa/handlers/text_document_definition_handler.rb +11 -30
- data/lib/rucoa/handlers/text_document_did_close_handler.rb +2 -8
- data/lib/rucoa/handlers/text_document_did_open_handler.rb +3 -7
- data/lib/rucoa/handlers/text_document_document_highlight_handler.rb +256 -0
- data/lib/rucoa/handlers/text_document_document_symbol_handler.rb +47 -76
- data/lib/rucoa/handlers/text_document_formatting_handler.rb +15 -23
- data/lib/rucoa/handlers/text_document_hover_handler.rb +24 -43
- data/lib/rucoa/handlers/text_document_range_formatting_handler.rb +17 -25
- data/lib/rucoa/handlers/text_document_selection_range_handler.rb +11 -19
- data/lib/rucoa/handlers/text_document_signature_help_handler.rb +17 -36
- data/lib/rucoa/handlers.rb +1 -0
- data/lib/rucoa/node_concerns/body.rb +1 -1
- data/lib/rucoa/node_concerns/qualified_name.rb +5 -5
- data/lib/rucoa/node_concerns/rescue.rb +21 -0
- data/lib/rucoa/node_concerns.rb +1 -0
- data/lib/rucoa/node_inspector.rb +5 -5
- data/lib/rucoa/nodes/base.rb +48 -48
- data/lib/rucoa/nodes/begin_node.rb +2 -0
- data/lib/rucoa/nodes/block_node.rb +24 -0
- data/lib/rucoa/nodes/case_node.rb +24 -0
- data/lib/rucoa/nodes/const_node.rb +26 -26
- data/lib/rucoa/nodes/def_node.rb +14 -13
- data/lib/rucoa/nodes/ensure_node.rb +19 -0
- data/lib/rucoa/nodes/for_node.rb +8 -0
- data/lib/rucoa/nodes/if_node.rb +32 -0
- data/lib/rucoa/nodes/resbody_node.rb +8 -0
- data/lib/rucoa/nodes/rescue_node.rb +17 -0
- data/lib/rucoa/nodes/send_node.rb +40 -0
- data/lib/rucoa/nodes/until_node.rb +8 -0
- data/lib/rucoa/nodes/when_node.rb +8 -0
- data/lib/rucoa/nodes/while_node.rb +8 -0
- data/lib/rucoa/nodes.rb +10 -1
- data/lib/rucoa/parser_builder.rb +16 -2
- data/lib/rucoa/range.rb +9 -3
- data/lib/rucoa/rbs/constant_definition_mapper.rb +5 -5
- data/lib/rucoa/rbs/method_definition_mapper.rb +18 -18
- data/lib/rucoa/rbs/module_definition_mapper.rb +13 -13
- data/lib/rucoa/rbs/ruby_definitions_loader.rb +5 -5
- data/lib/rucoa/rubocop/configuration_checker.rb +7 -7
- data/lib/rucoa/server.rb +24 -23
- data/lib/rucoa/source.rb +5 -5
- data/lib/rucoa/source_store.rb +8 -8
- data/lib/rucoa/version.rb +1 -1
- data/lib/rucoa/yard/definition_generators/method_definition_generator.rb +1 -1
- metadata +16 -3
- data/lib/rucoa/nodes/defs_node.rb +0 -33
data/lib/rucoa/nodes/base.rb
CHANGED
@@ -14,16 +14,6 @@ module Rucoa
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
# @return [Rucoa::Nodes::Base, nil]
|
18
|
-
def parent
|
19
|
-
@mutable_attributes[:parent]
|
20
|
-
end
|
21
|
-
|
22
|
-
# @param node [Rucoa::Nodes::Base]
|
23
|
-
def parent=(node)
|
24
|
-
@mutable_attributes[:parent] = node
|
25
|
-
end
|
26
|
-
|
27
17
|
# @return [Array<Rucoa::Nodes::Base>]
|
28
18
|
def ancestors
|
29
19
|
each_ancestor.to_a
|
@@ -73,23 +63,6 @@ module Rucoa
|
|
73
63
|
self
|
74
64
|
end
|
75
65
|
|
76
|
-
# @note Override.
|
77
|
-
# Some nodes change their type depending on the context.
|
78
|
-
# For example, `const` node can be `casgn` node.
|
79
|
-
# @return [Rucoa::Nodes::Base]
|
80
|
-
def updated(
|
81
|
-
type = nil,
|
82
|
-
children = nil,
|
83
|
-
properties = {}
|
84
|
-
)
|
85
|
-
properties[:location] ||= @location
|
86
|
-
ParserBuilder.node_class_for(type || @type).new(
|
87
|
-
type || @type,
|
88
|
-
children || @children,
|
89
|
-
properties
|
90
|
-
)
|
91
|
-
end
|
92
|
-
|
93
66
|
# @param position [Rucoa::Position]
|
94
67
|
# @return [Boolean]
|
95
68
|
def include_position?(position)
|
@@ -98,6 +71,29 @@ module Rucoa
|
|
98
71
|
Range.from_parser_range(location.expression).include?(position)
|
99
72
|
end
|
100
73
|
|
74
|
+
# @return [Array<String>]
|
75
|
+
# @example return ["Bar::Foo", "Foo"] for class Foo::Bar::Baz
|
76
|
+
# node = Rucoa::Source.new(
|
77
|
+
# content: <<~RUBY,
|
78
|
+
# module Foo
|
79
|
+
# module Bar
|
80
|
+
# module Baz
|
81
|
+
# end
|
82
|
+
# end
|
83
|
+
# end
|
84
|
+
# RUBY
|
85
|
+
# uri: 'file:///path/to/foo/bar/baz.rb'
|
86
|
+
# ).node_at(
|
87
|
+
# Rucoa::Position.new(
|
88
|
+
# column: 4,
|
89
|
+
# line: 3
|
90
|
+
# )
|
91
|
+
# )
|
92
|
+
# expect(node.module_nesting).to eq(['Foo::Bar', 'Foo'])
|
93
|
+
def module_nesting
|
94
|
+
each_ancestor(:class, :module).map(&:qualified_name)
|
95
|
+
end
|
96
|
+
|
101
97
|
# @note namespace is a String representation of `Module.nesting`.
|
102
98
|
# @return [String]
|
103
99
|
# @example returns namespace
|
@@ -130,27 +126,31 @@ module Rucoa
|
|
130
126
|
module_nesting.first || 'Object'
|
131
127
|
end
|
132
128
|
|
133
|
-
# @return [
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
#
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
#
|
144
|
-
#
|
145
|
-
#
|
146
|
-
#
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
129
|
+
# @return [Rucoa::Nodes::Base, nil]
|
130
|
+
def parent
|
131
|
+
@mutable_attributes[:parent]
|
132
|
+
end
|
133
|
+
|
134
|
+
# @param node [Rucoa::Nodes::Base]
|
135
|
+
def parent=(node)
|
136
|
+
@mutable_attributes[:parent] = node
|
137
|
+
end
|
138
|
+
|
139
|
+
# @note Override.
|
140
|
+
# Some nodes change their type depending on the context.
|
141
|
+
# For example, `const` node can be `casgn` node.
|
142
|
+
# @return [Rucoa::Nodes::Base]
|
143
|
+
def updated(
|
144
|
+
type = nil,
|
145
|
+
children = nil,
|
146
|
+
properties = {}
|
147
|
+
)
|
148
|
+
properties[:location] ||= @location
|
149
|
+
ParserBuilder.node_class_for(type || @type).new(
|
150
|
+
type || @type,
|
151
|
+
children || @children,
|
152
|
+
properties
|
153
|
+
)
|
154
154
|
end
|
155
155
|
|
156
156
|
protected
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rucoa
|
4
|
+
module Nodes
|
5
|
+
class BlockNode < Base
|
6
|
+
include NodeConcerns::Body
|
7
|
+
include NodeConcerns::Rescue
|
8
|
+
|
9
|
+
# @return [Rucoa::Nodes::SendNode]
|
10
|
+
# @example returns send node
|
11
|
+
# node = Rucoa::Source.new(
|
12
|
+
# content: <<~RUBY,
|
13
|
+
# foo do
|
14
|
+
# end
|
15
|
+
# RUBY
|
16
|
+
# uri: 'file:///foo.rb'
|
17
|
+
# ).root_node
|
18
|
+
# expect(node.send_node.name).to eq('foo')
|
19
|
+
def send_node
|
20
|
+
children[0]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rucoa
|
4
|
+
module Nodes
|
5
|
+
class CaseNode < Base
|
6
|
+
# @return [Array<Rucoa::Nodes::Base>]
|
7
|
+
# @example returns when nodes
|
8
|
+
# node = Rucoa::Source.new(
|
9
|
+
# content: <<~RUBY,
|
10
|
+
# case foo
|
11
|
+
# when 1
|
12
|
+
# when 2
|
13
|
+
# else
|
14
|
+
# end
|
15
|
+
# RUBY
|
16
|
+
# uri: 'file:///foo.rb'
|
17
|
+
# ).root_node
|
18
|
+
# expect(node.whens.length).to eq(2)
|
19
|
+
def whens
|
20
|
+
children[1...-1]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -3,32 +3,6 @@
|
|
3
3
|
module Rucoa
|
4
4
|
module Nodes
|
5
5
|
class ConstNode < Base
|
6
|
-
# @return [String]
|
7
|
-
# @example returns "A" for "A"
|
8
|
-
# node = Rucoa::Source.new(
|
9
|
-
# content: <<~RUBY,
|
10
|
-
# A
|
11
|
-
# RUBY
|
12
|
-
# uri: 'file:///path/to/a.rb'
|
13
|
-
# ).root_node
|
14
|
-
# expect(node.name).to eq('A')
|
15
|
-
# @example returns "B" for "A::B"
|
16
|
-
# node = Rucoa::Source.new(
|
17
|
-
# content: <<~RUBY,
|
18
|
-
# A::B
|
19
|
-
# RUBY
|
20
|
-
# uri: 'file:///path/to/a.rb'
|
21
|
-
# ).node_at(
|
22
|
-
# Rucoa::Position.new(
|
23
|
-
# column: 4,
|
24
|
-
# line: 1
|
25
|
-
# )
|
26
|
-
# )
|
27
|
-
# expect(node.name).to eq('B')
|
28
|
-
def name
|
29
|
-
children[1].to_s
|
30
|
-
end
|
31
|
-
|
32
6
|
# @return [String]
|
33
7
|
# @example returns "A" for "A"
|
34
8
|
# node = Rucoa::Source.new(
|
@@ -91,6 +65,32 @@ module Rucoa
|
|
91
65
|
each_ancestor(:class, :module).map(&:qualified_name)
|
92
66
|
end
|
93
67
|
|
68
|
+
# @return [String]
|
69
|
+
# @example returns "A" for "A"
|
70
|
+
# node = Rucoa::Source.new(
|
71
|
+
# content: <<~RUBY,
|
72
|
+
# A
|
73
|
+
# RUBY
|
74
|
+
# uri: 'file:///path/to/a.rb'
|
75
|
+
# ).root_node
|
76
|
+
# expect(node.name).to eq('A')
|
77
|
+
# @example returns "B" for "A::B"
|
78
|
+
# node = Rucoa::Source.new(
|
79
|
+
# content: <<~RUBY,
|
80
|
+
# A::B
|
81
|
+
# RUBY
|
82
|
+
# uri: 'file:///path/to/a.rb'
|
83
|
+
# ).node_at(
|
84
|
+
# Rucoa::Position.new(
|
85
|
+
# column: 4,
|
86
|
+
# line: 1
|
87
|
+
# )
|
88
|
+
# )
|
89
|
+
# expect(node.name).to eq('B')
|
90
|
+
def name
|
91
|
+
children[1].to_s
|
92
|
+
end
|
93
|
+
|
94
94
|
private
|
95
95
|
|
96
96
|
# @return [Rucoa::Nodes::Base, nil]
|
data/lib/rucoa/nodes/def_node.rb
CHANGED
@@ -3,6 +3,18 @@
|
|
3
3
|
module Rucoa
|
4
4
|
module Nodes
|
5
5
|
class DefNode < Base
|
6
|
+
include NodeConcerns::Body
|
7
|
+
include NodeConcerns::Rescue
|
8
|
+
|
9
|
+
# @return [String]
|
10
|
+
def method_marker
|
11
|
+
if singleton?
|
12
|
+
'.'
|
13
|
+
else
|
14
|
+
'#'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
6
18
|
# @return [String]
|
7
19
|
# @example returns method name
|
8
20
|
# node = Rucoa::Source.new(
|
@@ -23,7 +35,7 @@ module Rucoa
|
|
23
35
|
# )
|
24
36
|
# expect(node.name).to eq('baz')
|
25
37
|
def name
|
26
|
-
children[
|
38
|
+
children[-3].to_s
|
27
39
|
end
|
28
40
|
|
29
41
|
# @return [String]
|
@@ -55,18 +67,7 @@ module Rucoa
|
|
55
67
|
|
56
68
|
# @return [Boolean]
|
57
69
|
def singleton?
|
58
|
-
each_ancestor(:sclass).any?
|
59
|
-
end
|
60
|
-
|
61
|
-
private
|
62
|
-
|
63
|
-
# @return [String]
|
64
|
-
def method_marker
|
65
|
-
if singleton?
|
66
|
-
'.'
|
67
|
-
else
|
68
|
-
'#'
|
69
|
-
end
|
70
|
+
type == :defs || each_ancestor(:sclass).any?
|
70
71
|
end
|
71
72
|
end
|
72
73
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rucoa
|
4
|
+
module Nodes
|
5
|
+
class EnsureNode < Base
|
6
|
+
# @return [Rucoa::Nodes::Base, nil]
|
7
|
+
def body
|
8
|
+
children[0]
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [Rucoa::Nodes::RescueNode, nil]
|
12
|
+
def rescue
|
13
|
+
return unless body.is_a?(Nodes::RescueNode)
|
14
|
+
|
15
|
+
body
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rucoa
|
4
|
+
module Nodes
|
5
|
+
class IfNode < Base
|
6
|
+
# @return [Rucoa::Nodes::Base, nil]
|
7
|
+
def branch_else
|
8
|
+
children[2]
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [Rucoa::Nodes::Base, nil]
|
12
|
+
def branch_if
|
13
|
+
children[1]
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [Rucoa::Nodes::Base]
|
17
|
+
def condition
|
18
|
+
children[0]
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [Rucoa::Nodes::IfNode, nil]
|
22
|
+
def elsif
|
23
|
+
branch_else if branch_else.is_a?(Nodes::IfNode)
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [Boolean]
|
27
|
+
def elsif?
|
28
|
+
parent.is_a?(Nodes::IfNode) && eql?(parent.elsif)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rucoa
|
4
|
+
module Nodes
|
5
|
+
class RescueNode < Base
|
6
|
+
# @return [Rucoa::Nodes::Base, nil]
|
7
|
+
def body
|
8
|
+
children[0]
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [Array<Rucoa::Nodes::Resbody>]
|
12
|
+
def resbodies
|
13
|
+
children[1..-2]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -21,6 +21,39 @@ module Rucoa
|
|
21
21
|
children[2..]
|
22
22
|
end
|
23
23
|
|
24
|
+
# @return [Rucoa::Nodes::BlockNode, nil]
|
25
|
+
# @example returns nil for method call without block
|
26
|
+
# node = Rucoa::Source.new(
|
27
|
+
# content: <<~RUBY,
|
28
|
+
# foo
|
29
|
+
# RUBY
|
30
|
+
# uri: 'file:///path/to/example.rb'
|
31
|
+
# ).node_at(
|
32
|
+
# Rucoa::Position.new(
|
33
|
+
# column: 0,
|
34
|
+
# line: 1
|
35
|
+
# )
|
36
|
+
# )
|
37
|
+
# expect(node.block).to be_nil
|
38
|
+
# @example returns block
|
39
|
+
# node = Rucoa::Source.new(
|
40
|
+
# content: <<~RUBY,
|
41
|
+
# foo do
|
42
|
+
# bar
|
43
|
+
# end
|
44
|
+
# RUBY
|
45
|
+
# uri: 'file:///path/to/example.rb'
|
46
|
+
# ).node_at(
|
47
|
+
# Rucoa::Position.new(
|
48
|
+
# column: 0,
|
49
|
+
# line: 1
|
50
|
+
# )
|
51
|
+
# )
|
52
|
+
# expect(node.block).to be_a(Rucoa::Nodes::BlockNode)
|
53
|
+
def block
|
54
|
+
parent if called_with_block?
|
55
|
+
end
|
56
|
+
|
24
57
|
# @return [String]
|
25
58
|
# @example returns method name
|
26
59
|
# node = Rucoa::Source.new(
|
@@ -59,6 +92,13 @@ module Rucoa
|
|
59
92
|
def receiver
|
60
93
|
children[0]
|
61
94
|
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
# @return [Boolean]
|
99
|
+
def called_with_block?
|
100
|
+
parent.is_a?(Nodes::BlockNode) && eql?(parent.send_node)
|
101
|
+
end
|
62
102
|
end
|
63
103
|
end
|
64
104
|
end
|
data/lib/rucoa/nodes.rb
CHANGED
@@ -4,17 +4,26 @@ module Rucoa
|
|
4
4
|
module Nodes
|
5
5
|
autoload :Base, 'rucoa/nodes/base'
|
6
6
|
autoload :BeginNode, 'rucoa/nodes/begin_node'
|
7
|
+
autoload :BlockNode, 'rucoa/nodes/block_node'
|
8
|
+
autoload :CaseNode, 'rucoa/nodes/case_node'
|
7
9
|
autoload :CasgnNode, 'rucoa/nodes/casgn_node'
|
8
10
|
autoload :CbaseNode, 'rucoa/nodes/cbase_node'
|
9
11
|
autoload :ClassNode, 'rucoa/nodes/class_node'
|
10
12
|
autoload :ConstNode, 'rucoa/nodes/const_node'
|
11
13
|
autoload :DefNode, 'rucoa/nodes/def_node'
|
12
|
-
autoload :
|
14
|
+
autoload :EnsureNode, 'rucoa/nodes/ensure_node'
|
15
|
+
autoload :ForNode, 'rucoa/nodes/for_node'
|
16
|
+
autoload :IfNode, 'rucoa/nodes/if_node'
|
13
17
|
autoload :LvarNode, 'rucoa/nodes/lvar_node'
|
14
18
|
autoload :ModuleNode, 'rucoa/nodes/module_node'
|
19
|
+
autoload :ResbodyNode, 'rucoa/nodes/resbody_node'
|
20
|
+
autoload :RescueNode, 'rucoa/nodes/rescue_node'
|
15
21
|
autoload :SclassNode, 'rucoa/nodes/sclass_node'
|
16
22
|
autoload :SendNode, 'rucoa/nodes/send_node'
|
17
23
|
autoload :StrNode, 'rucoa/nodes/str_node'
|
18
24
|
autoload :SymNode, 'rucoa/nodes/sym_node'
|
25
|
+
autoload :UntilNode, 'rucoa/nodes/until_node'
|
26
|
+
autoload :WhenNode, 'rucoa/nodes/when_node'
|
27
|
+
autoload :WhileNode, 'rucoa/nodes/while_node'
|
19
28
|
end
|
20
29
|
end
|
data/lib/rucoa/parser_builder.rb
CHANGED
@@ -6,18 +6,32 @@ module Rucoa
|
|
6
6
|
class ParserBuilder < ::Parser::Builders::Default
|
7
7
|
NODE_CLASS_BY_TYPE = {
|
8
8
|
begin: Nodes::BeginNode,
|
9
|
+
block: Nodes::BlockNode,
|
10
|
+
case: Nodes::CaseNode,
|
9
11
|
casgn: Nodes::CasgnNode,
|
10
12
|
cbase: Nodes::CbaseNode,
|
11
13
|
class: Nodes::ClassNode,
|
12
14
|
const: Nodes::ConstNode,
|
15
|
+
csend: Nodes::SendNode,
|
13
16
|
def: Nodes::DefNode,
|
14
|
-
defs: Nodes::
|
17
|
+
defs: Nodes::DefNode,
|
18
|
+
ensure: Nodes::EnsureNode,
|
19
|
+
for: Nodes::ForNode,
|
20
|
+
if: Nodes::IfNode,
|
21
|
+
kwbegin: Nodes::BeginNode,
|
15
22
|
lvar: Nodes::LvarNode,
|
16
23
|
module: Nodes::ModuleNode,
|
24
|
+
resbody: Nodes::ResbodyNode,
|
25
|
+
rescue: Nodes::RescueNode,
|
17
26
|
sclass: Nodes::SclassNode,
|
18
27
|
send: Nodes::SendNode,
|
19
28
|
str: Nodes::StrNode,
|
20
|
-
|
29
|
+
super: Nodes::SendNode,
|
30
|
+
sym: Nodes::SymNode,
|
31
|
+
until: Nodes::UntilNode,
|
32
|
+
when: Nodes::WhenNode,
|
33
|
+
while: Nodes::WhileNode,
|
34
|
+
zsuper: Nodes::SendNode
|
21
35
|
}.freeze
|
22
36
|
|
23
37
|
class << self
|
data/lib/rucoa/range.rb
CHANGED
@@ -103,6 +103,12 @@ module Rucoa
|
|
103
103
|
# )
|
104
104
|
# expect(range).to include(
|
105
105
|
# Rucoa::Position.new(
|
106
|
+
# column: 1,
|
107
|
+
# line: 1
|
108
|
+
# )
|
109
|
+
# )
|
110
|
+
# expect(range).to include(
|
111
|
+
# Rucoa::Position.new(
|
106
112
|
# column: 0,
|
107
113
|
# line: 2
|
108
114
|
# )
|
@@ -116,9 +122,9 @@ module Rucoa
|
|
116
122
|
def include?(position)
|
117
123
|
return false if position.line > @ending.line
|
118
124
|
return false if position.line < @beginning.line
|
119
|
-
return false if position.column < @beginning.column
|
120
|
-
return false if position.column > @ending.column
|
121
|
-
return false if position.column == @ending.column && !@including_ending
|
125
|
+
return false if position.line == @beginning.line && position.column < @beginning.column
|
126
|
+
return false if position.line == @ending.line && position.column > @ending.column
|
127
|
+
return false if position.line == @ending.line && position.column == @ending.column && !@including_ending
|
122
128
|
|
123
129
|
true
|
124
130
|
end
|
@@ -32,15 +32,15 @@ module Rucoa
|
|
32
32
|
@declaration.comment&.string&.sub(/\A\s*<!--.*-->\s*/m, '')
|
33
33
|
end
|
34
34
|
|
35
|
-
# @return [String]
|
36
|
-
def qualified_name
|
37
|
-
@declaration.name.to_s.delete_prefix('::')
|
38
|
-
end
|
39
|
-
|
40
35
|
# @return [Rucoa::Location]
|
41
36
|
def location
|
42
37
|
Location.from_rbs_location(@declaration.location)
|
43
38
|
end
|
39
|
+
|
40
|
+
# @return [String]
|
41
|
+
def qualified_name
|
42
|
+
@declaration.name.to_s.delete_prefix('::')
|
43
|
+
end
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -42,23 +42,19 @@ module Rucoa
|
|
42
42
|
|
43
43
|
private
|
44
44
|
|
45
|
-
# @return [Array<Rucoa::Types::MethodType>]
|
46
|
-
def types
|
47
|
-
@method_definition.types.map do |method_type|
|
48
|
-
MethodTypeMapper.call(
|
49
|
-
method_type: method_type
|
50
|
-
)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
45
|
# @return [String, nil]
|
55
46
|
def description
|
56
47
|
@method_definition.comment&.string&.sub(/\A\s*<!--.*-->\s*/m, '')
|
57
48
|
end
|
58
49
|
|
59
|
-
# @return [
|
60
|
-
def
|
61
|
-
@
|
50
|
+
# @return [Symbol]
|
51
|
+
def kind
|
52
|
+
@method_definition.kind
|
53
|
+
end
|
54
|
+
|
55
|
+
# @return [Rucoa::Location]
|
56
|
+
def location
|
57
|
+
Location.from_rbs_location(@method_definition.location)
|
62
58
|
end
|
63
59
|
|
64
60
|
# @return [String]
|
@@ -66,14 +62,18 @@ module Rucoa
|
|
66
62
|
@method_definition.name.to_s
|
67
63
|
end
|
68
64
|
|
69
|
-
# @return [
|
70
|
-
def
|
71
|
-
@
|
65
|
+
# @return [String]
|
66
|
+
def namespace
|
67
|
+
@declaration.name.to_s.delete_prefix('::')
|
72
68
|
end
|
73
69
|
|
74
|
-
# @return [Rucoa::
|
75
|
-
def
|
76
|
-
|
70
|
+
# @return [Array<Rucoa::Types::MethodType>]
|
71
|
+
def types
|
72
|
+
@method_definition.types.map do |method_type|
|
73
|
+
MethodTypeMapper.call(
|
74
|
+
method_type: method_type
|
75
|
+
)
|
76
|
+
end
|
77
77
|
end
|
78
78
|
|
79
79
|
class MethodTypeMapper
|
@@ -35,16 +35,6 @@ module Rucoa
|
|
35
35
|
@declaration.comment&.string&.sub(/\A\s*<!--.*-->\s*/m, '')
|
36
36
|
end
|
37
37
|
|
38
|
-
# @return [String]
|
39
|
-
def qualified_name
|
40
|
-
@declaration.name.to_s.delete_prefix('::')
|
41
|
-
end
|
42
|
-
|
43
|
-
# @return [Rucoa::Location]
|
44
|
-
def location
|
45
|
-
Location.from_rbs_location(@declaration.location)
|
46
|
-
end
|
47
|
-
|
48
38
|
# @return [Array<String>]
|
49
39
|
def extended_module_qualified_names
|
50
40
|
module_qualified_names_for(::RBS::AST::Members::Extend)
|
@@ -55,9 +45,9 @@ module Rucoa
|
|
55
45
|
module_qualified_names_for(::RBS::AST::Members::Include)
|
56
46
|
end
|
57
47
|
|
58
|
-
# @return [
|
59
|
-
def
|
60
|
-
|
48
|
+
# @return [Rucoa::Location]
|
49
|
+
def location
|
50
|
+
Location.from_rbs_location(@declaration.location)
|
61
51
|
end
|
62
52
|
|
63
53
|
def module_qualified_names_for(member_class)
|
@@ -68,6 +58,16 @@ module Rucoa
|
|
68
58
|
end
|
69
59
|
end
|
70
60
|
end
|
61
|
+
|
62
|
+
# @return [Array<String>]
|
63
|
+
def prepended_module_qualified_names
|
64
|
+
module_qualified_names_for(::RBS::AST::Members::Prepend)
|
65
|
+
end
|
66
|
+
|
67
|
+
# @return [String]
|
68
|
+
def qualified_name
|
69
|
+
@declaration.name.to_s.delete_prefix('::')
|
70
|
+
end
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|