rucoa 0.6.0 → 0.8.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/Gemfile.lock +1 -1
- data/README.md +4 -1
- data/data/definitions_ruby_3_1 +0 -0
- data/lib/rucoa/configuration.rb +10 -0
- data/lib/rucoa/definition_store.rb +113 -6
- data/lib/rucoa/definitions/class_definition.rb +16 -0
- data/lib/rucoa/definitions/method_definition.rb +14 -2
- data/lib/rucoa/definitions/module_definition.rb +8 -0
- data/lib/rucoa/definitions.rb +2 -0
- data/lib/rucoa/handler_concerns/diagnostics_publishable.rb +14 -2
- data/lib/rucoa/handlers/initialize_handler.rb +1 -0
- data/lib/rucoa/handlers/initialized_handler.rb +1 -1
- data/lib/rucoa/handlers/text_document_completion_handler.rb +9 -2
- data/lib/rucoa/handlers/text_document_definition_handler.rb +155 -0
- data/lib/rucoa/handlers/text_document_did_close_handler.rb +20 -0
- data/lib/rucoa/handlers/text_document_formatting_handler.rb +2 -2
- data/lib/rucoa/handlers/text_document_hover_handler.rb +3 -4
- data/lib/rucoa/handlers/text_document_range_formatting_handler.rb +2 -2
- data/lib/rucoa/handlers.rb +2 -0
- data/lib/rucoa/node_inspector.rb +48 -15
- data/lib/rucoa/nodes/base.rb +2 -2
- data/lib/rucoa/nodes/const_node.rb +31 -0
- data/lib/rucoa/position.rb +1 -1
- data/lib/rucoa/rbs/class_definition_mapper.rb +46 -0
- data/lib/rucoa/{definition_builders/rbs_constant_definition_builder.rb → rbs/constant_definition_mapper.rb} +4 -8
- data/lib/rucoa/{definition_builders/rbs_method_definition_builder.rb → rbs/method_definition_mapper.rb} +4 -7
- data/lib/rucoa/rbs/module_definition_mapper.rb +40 -0
- data/lib/rucoa/rbs/ruby_definitions_loader.rb +82 -0
- data/lib/rucoa/rbs.rb +11 -0
- data/lib/rucoa/rubocop/autocorrector.rb +51 -0
- data/lib/rucoa/rubocop/configuration_checker.rb +44 -0
- data/lib/rucoa/rubocop/investigator.rb +59 -0
- data/lib/rucoa/rubocop.rb +9 -0
- data/lib/rucoa/server.rb +2 -0
- data/lib/rucoa/source.rb +11 -3
- data/lib/rucoa/version.rb +1 -1
- data/lib/rucoa/yard/definitions_loader.rb +85 -0
- data/lib/rucoa/{definition_builders/yard_method_definition_builder.rb → yard/method_definition_mapper.rb} +22 -25
- data/lib/rucoa/yard.rb +8 -0
- data/lib/rucoa.rb +3 -7
- metadata +19 -12
- data/lib/rucoa/definition_builders.rb +0 -9
- data/lib/rucoa/rbs_document_loader.rb +0 -43
- data/lib/rucoa/rubocop_autocorrector.rb +0 -38
- data/lib/rucoa/rubocop_configuration_checker.rb +0 -42
- data/lib/rucoa/rubocop_investigator.rb +0 -48
- data/lib/rucoa/yard_glob_document_loader.rb +0 -47
- data/lib/rucoa/yard_string_document_loader.rb +0 -70
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26c4a8d526acb34d3722fc4b78e4c8fa0a1bac7bfc11d72af4b5962afdbc01c9
|
4
|
+
data.tar.gz: b49e5bdca272898e10870fbad7f99b2ba5cf63e0d1acef074d3af1928b69058b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4de0736efd9d7b44d7756bfe5aedf6fc60d0b3a9ce9ab55cb0e3c6b83ca0525017e0ddb629d612ec4c05a8cae97f1d902bf33a3090c00570765c344821393bf6
|
7
|
+
data.tar.gz: 8228a81e3b4408274d2e51f2c339e724e4c4615f4af2a311bad68c48b74d32a09773cf5a0caaa780135780d7510b95aa64579ec6d009bf7fe711cb590660bde8
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -62,6 +62,10 @@ This extension supports the folowiing types of symbols:
|
|
62
62
|
|
63
63
|
Provides completion items for constant names and method names.
|
64
64
|
|
65
|
+
### Definition
|
66
|
+
|
67
|
+
Provides "Go to Definition" command to jump to the definition.
|
68
|
+
|
65
69
|
### Hover
|
66
70
|
|
67
71
|
Shows documentation for the symbol under the cursor.
|
@@ -72,6 +76,5 @@ Shows method signature help when you start to type method arguments like `"100".
|
|
72
76
|
|
73
77
|
## Coming soon
|
74
78
|
|
75
|
-
- Go to Definition
|
76
79
|
- Highlight
|
77
80
|
- Semantic Tokens
|
data/data/definitions_ruby_3_1
CHANGED
Binary file
|
data/lib/rucoa/configuration.rb
CHANGED
@@ -16,6 +16,11 @@ module Rucoa
|
|
16
16
|
disable_feature('completion')
|
17
17
|
end
|
18
18
|
|
19
|
+
# @return [void]
|
20
|
+
def disable_definition
|
21
|
+
disable_feature('definition')
|
22
|
+
end
|
23
|
+
|
19
24
|
# @return [void]
|
20
25
|
def disable_diagnostics
|
21
26
|
disable_feature('diagnostics')
|
@@ -82,6 +87,11 @@ module Rucoa
|
|
82
87
|
enables_feature?('completion')
|
83
88
|
end
|
84
89
|
|
90
|
+
# @return [Boolean]
|
91
|
+
def enables_definition?
|
92
|
+
enables_feature?('definition')
|
93
|
+
end
|
94
|
+
|
85
95
|
# @return [Boolean]
|
86
96
|
def enables_diagnostics?
|
87
97
|
enables_feature?('diagnostics')
|
@@ -24,14 +24,86 @@ module Rucoa
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
# @param method_name [String]
|
27
28
|
# @param namespace [String]
|
29
|
+
# @param singleton [Boolean]
|
30
|
+
# @return [Rucoa::Definition::MethodDefinition, nil]
|
31
|
+
# @example has the ability to find `IO.write` from `File.write`
|
32
|
+
# definition_store = Rucoa::DefinitionStore.new
|
33
|
+
# definition_store.definitions += Rucoa::DefinitionArchiver.load
|
34
|
+
# subject = definition_store.find_method_definition_by(
|
35
|
+
# method_name: 'write',
|
36
|
+
# namespace: 'File',
|
37
|
+
# singleton: true
|
38
|
+
# )
|
39
|
+
# expect(subject.full_qualified_name).to eq('IO.write')
|
40
|
+
def find_method_definition_by(method_name:, namespace:, singleton: false)
|
41
|
+
if singleton
|
42
|
+
singleton_method_definitions_of(namespace)
|
43
|
+
else
|
44
|
+
instance_method_definitions_of(namespace)
|
45
|
+
end.find do |method_definition|
|
46
|
+
method_definition.method_name == method_name
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# @param type [String]
|
51
|
+
# @return [Array<Rucoa::Definitions::MethodDefinition>]
|
52
|
+
# @example includes ancestors' methods
|
53
|
+
# definition_store = Rucoa::DefinitionStore.new
|
54
|
+
# definition_store.definitions += Rucoa::DefinitionArchiver.load
|
55
|
+
# subject = definition_store.instance_method_definitions_of('File')
|
56
|
+
# expect(subject.map(&:full_qualified_name)).to include('IO#raw')
|
57
|
+
# @example responds to `singleton<File>`
|
58
|
+
# definition_store = Rucoa::DefinitionStore.new
|
59
|
+
# definition_store.definitions += Rucoa::DefinitionArchiver.load
|
60
|
+
# subject = definition_store.instance_method_definitions_of('singleton<File>')
|
61
|
+
# expect(subject.map(&:full_qualified_name)).to include('IO.write')
|
62
|
+
def instance_method_definitions_of(type)
|
63
|
+
singleton_class_name = singleton_class_name_from(type)
|
64
|
+
return singleton_method_definitions_of(singleton_class_name) if singleton_class_name
|
65
|
+
|
66
|
+
class_or_module_definition = find_class_or_module_definition(type)
|
67
|
+
return [] unless class_or_module_definition
|
68
|
+
|
69
|
+
definitions = instance_method_definitions
|
70
|
+
[
|
71
|
+
class_or_module_definition,
|
72
|
+
*ancestor_definitions_of(class_or_module_definition)
|
73
|
+
].map(&:full_qualified_name).flat_map do |full_qualified_type_name|
|
74
|
+
definitions.select do |definition|
|
75
|
+
definition.namespace == full_qualified_type_name
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# @param type [String]
|
28
81
|
# @return [Array<Rucoa::Definitions::MethodDefinition>]
|
29
|
-
|
30
|
-
|
31
|
-
|
82
|
+
# @example returns singleton method definitions of File
|
83
|
+
# definition_store = Rucoa::DefinitionStore.new
|
84
|
+
# definition_store.definitions += Rucoa::DefinitionArchiver.load
|
85
|
+
# subject = definition_store.singleton_method_definitions_of('File')
|
86
|
+
# expect(subject.map(&:full_qualified_name)).to include('IO.write')
|
87
|
+
def singleton_method_definitions_of(type)
|
88
|
+
class_or_module_definition = find_class_or_module_definition(type)
|
89
|
+
return [] unless class_or_module_definition
|
90
|
+
|
91
|
+
definitions = singleton_method_definitions
|
92
|
+
[
|
93
|
+
class_or_module_definition,
|
94
|
+
*ancestor_definitions_of(class_or_module_definition)
|
95
|
+
].map(&:full_qualified_name).flat_map do |full_qualified_type_name|
|
96
|
+
definitions.select do |definition|
|
97
|
+
definition.namespace == full_qualified_type_name
|
98
|
+
end
|
32
99
|
end
|
33
100
|
end
|
34
101
|
|
102
|
+
# @return [Array<Rucoa::Definition::ConstantDefinition>]
|
103
|
+
def constant_definitions
|
104
|
+
@definitions.grep(Definitions::ConstantDefinition)
|
105
|
+
end
|
106
|
+
|
35
107
|
# @param namespace [String]
|
36
108
|
# @return [Array<Rucoa::Definitions::ConstantDefinition>] e.g. File::Separator, File::SEPARATOR, etc.
|
37
109
|
def constant_definitions_under(namespace)
|
@@ -42,9 +114,34 @@ module Rucoa
|
|
42
114
|
|
43
115
|
private
|
44
116
|
|
45
|
-
# @
|
46
|
-
|
47
|
-
|
117
|
+
# @param type [String]
|
118
|
+
# @return [String, nil]
|
119
|
+
def singleton_class_name_from(type)
|
120
|
+
type[/singleton<(\w+)>/, 1]
|
121
|
+
end
|
122
|
+
|
123
|
+
# @param class_or_module_definition [Rucoa::Definitions::Class, Rucoa::Definitions::Module]
|
124
|
+
# @return [Array<Rucoa::Definitions::Class>]
|
125
|
+
def ancestor_definitions_of(class_or_module_definition)
|
126
|
+
return [] unless class_or_module_definition.is_a?(Definitions::ClassDefinition)
|
127
|
+
|
128
|
+
result = []
|
129
|
+
class_definition = class_or_module_definition
|
130
|
+
while (super_class_name = class_definition.super_class_name)
|
131
|
+
class_definition = find_class_or_module_definition(super_class_name)
|
132
|
+
break unless class_definition
|
133
|
+
|
134
|
+
result << class_definition
|
135
|
+
end
|
136
|
+
result
|
137
|
+
end
|
138
|
+
|
139
|
+
# @param type [String]
|
140
|
+
# @return [Rucoa::Definitions::Class, Rucoa::Definitions::Module, nil]
|
141
|
+
def find_class_or_module_definition(type)
|
142
|
+
@definitions.find do |definition|
|
143
|
+
definition.full_qualified_name == type
|
144
|
+
end
|
48
145
|
end
|
49
146
|
|
50
147
|
# @return [Array<Rucoa::Definition::MethodDefinition>]
|
@@ -52,6 +149,16 @@ module Rucoa
|
|
52
149
|
@definitions.grep(Definitions::MethodDefinition)
|
53
150
|
end
|
54
151
|
|
152
|
+
# @return [Array<Rucoa::Definition::MethodDefinition>]
|
153
|
+
def instance_method_definitions
|
154
|
+
method_definitions.select(&:instance_method?)
|
155
|
+
end
|
156
|
+
|
157
|
+
# @return [Array<Rucoa::Definition::MethodDefinition>]
|
158
|
+
def singleton_method_definitions
|
159
|
+
method_definitions.select(&:singleton_method?)
|
160
|
+
end
|
161
|
+
|
55
162
|
# @param source_path [String]
|
56
163
|
# @return [Array<Rucoa::Definition::Base>]
|
57
164
|
def delete_definitions_defined_in(source_path)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rucoa
|
4
|
+
module Definitions
|
5
|
+
class ClassDefinition < ModuleDefinition
|
6
|
+
# @return [String, nil]
|
7
|
+
attr_reader :super_class_name
|
8
|
+
|
9
|
+
# @param super_class_name [String, nil]
|
10
|
+
def initialize(super_class_name:, **keyword_arguments)
|
11
|
+
super(**keyword_arguments)
|
12
|
+
@super_class_name = super_class_name
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -6,6 +6,9 @@ module Rucoa
|
|
6
6
|
# @return [String, nil]
|
7
7
|
attr_reader :description
|
8
8
|
|
9
|
+
# @return [Symbol]
|
10
|
+
attr_reader :kind
|
11
|
+
|
9
12
|
# @return [String]
|
10
13
|
attr_reader :method_name
|
11
14
|
|
@@ -110,12 +113,21 @@ module Rucoa
|
|
110
113
|
end
|
111
114
|
end
|
112
115
|
|
116
|
+
# @return [Boolean]
|
117
|
+
def instance_method?
|
118
|
+
@kind == :instance
|
119
|
+
end
|
120
|
+
|
121
|
+
# @return [Boolean]
|
122
|
+
def singleton_method?
|
123
|
+
!instance_method?
|
124
|
+
end
|
125
|
+
|
113
126
|
private
|
114
127
|
|
115
128
|
# @return [String]
|
116
129
|
def method_kind_symbol
|
117
|
-
|
118
|
-
when :instance
|
130
|
+
if instance_method?
|
119
131
|
'#'
|
120
132
|
else
|
121
133
|
'.'
|
data/lib/rucoa/definitions.rb
CHANGED
@@ -3,7 +3,9 @@
|
|
3
3
|
module Rucoa
|
4
4
|
module Definitions
|
5
5
|
autoload :Base, 'rucoa/definitions/base'
|
6
|
+
autoload :ClassDefinition, 'rucoa/definitions/class_definition'
|
6
7
|
autoload :ConstantDefinition, 'rucoa/definitions/constant_definition'
|
7
8
|
autoload :MethodDefinition, 'rucoa/definitions/method_definition'
|
9
|
+
autoload :ModuleDefinition, 'rucoa/definitions/module_definition'
|
8
10
|
end
|
9
11
|
end
|
@@ -16,6 +16,18 @@ module Rucoa
|
|
16
16
|
)
|
17
17
|
end
|
18
18
|
|
19
|
+
# @param uri [String]
|
20
|
+
# @return [void]
|
21
|
+
def clear_diagnostics_on(uri)
|
22
|
+
write(
|
23
|
+
method: 'textDocument/publishDiagnostics',
|
24
|
+
params: {
|
25
|
+
diagnostics: [],
|
26
|
+
uri: uri
|
27
|
+
}
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
19
31
|
# @param uri [String]
|
20
32
|
# @return [void]
|
21
33
|
def publish_diagnostics_on(uri)
|
@@ -48,7 +60,7 @@ module Rucoa
|
|
48
60
|
|
49
61
|
# @return [Array<Hash>]
|
50
62
|
def call
|
51
|
-
return [] unless
|
63
|
+
return [] unless Rubocop::ConfigurationChecker.call
|
52
64
|
|
53
65
|
offenses.map do |offense|
|
54
66
|
OffenseToDiagnosticMapper.call(
|
@@ -63,7 +75,7 @@ module Rucoa
|
|
63
75
|
|
64
76
|
# @return [Array<RuboCop::Cop::Offense>]
|
65
77
|
def offenses
|
66
|
-
|
78
|
+
Rubocop::Investigator.call(source: @source)
|
67
79
|
end
|
68
80
|
|
69
81
|
class OffenseToDiagnosticMapper
|
@@ -148,7 +148,7 @@ module Rucoa
|
|
148
148
|
# @return [Array<String>]
|
149
149
|
def callable_method_definitions
|
150
150
|
receiver_types.flat_map do |type|
|
151
|
-
definition_store.
|
151
|
+
definition_store.instance_method_definitions_of(type)
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
@@ -208,7 +208,14 @@ module Rucoa
|
|
208
208
|
if @repaired
|
209
209
|
position.to_range
|
210
210
|
else
|
211
|
-
Range.from_parser_range(
|
211
|
+
Range.from_parser_range(
|
212
|
+
case node
|
213
|
+
when Nodes::SendNode
|
214
|
+
node.location.selector
|
215
|
+
else
|
216
|
+
node.location.expression
|
217
|
+
end
|
218
|
+
)
|
212
219
|
end
|
213
220
|
end
|
214
221
|
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rucoa
|
4
|
+
module Handlers
|
5
|
+
class TextDocumentDefinitionHandler < Base
|
6
|
+
def call
|
7
|
+
respond(location)
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
# @return [Hash, nil]
|
13
|
+
def location
|
14
|
+
return unless reponsible?
|
15
|
+
|
16
|
+
{
|
17
|
+
range: location_range.to_vscode_range,
|
18
|
+
uri: location_uri
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Boolean]
|
23
|
+
def reponsible?
|
24
|
+
configuration.enables_definition? &&
|
25
|
+
!location_uri.nil? &&
|
26
|
+
!location_source.nil?
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [Rucoa::Range]
|
30
|
+
def location_range
|
31
|
+
return Range.from_parser_range(location_node.location.expression) if location_node
|
32
|
+
|
33
|
+
Position.new.to_range
|
34
|
+
end
|
35
|
+
|
36
|
+
# @return [String, nil]
|
37
|
+
def location_uri
|
38
|
+
return unless definition
|
39
|
+
|
40
|
+
if definition.source_path.start_with?('Untitled-')
|
41
|
+
"untitled:#{definition.source_path}"
|
42
|
+
else
|
43
|
+
"file://#{definition.source_path}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [Rucoa::Nodes::Base, nil]
|
48
|
+
def location_node
|
49
|
+
@location_node ||=
|
50
|
+
case definition
|
51
|
+
when Definitions::ClassDefinition
|
52
|
+
find_class_node
|
53
|
+
when Definitions::ModuleDefinition
|
54
|
+
find_module_node
|
55
|
+
when Definitions::MethodDefinition
|
56
|
+
find_method_node
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# @return [Rucoa::Source, nil]
|
61
|
+
def location_source
|
62
|
+
source_store.get(location_uri)
|
63
|
+
end
|
64
|
+
|
65
|
+
# @return [Rucoa::Position]
|
66
|
+
def position
|
67
|
+
Position.from_vscode_position(
|
68
|
+
request.dig('params', 'position')
|
69
|
+
)
|
70
|
+
end
|
71
|
+
|
72
|
+
# @return [String]
|
73
|
+
def uri
|
74
|
+
request.dig('params', 'textDocument', 'uri')
|
75
|
+
end
|
76
|
+
|
77
|
+
# @return [Rucoa::Source, nil]
|
78
|
+
def source
|
79
|
+
source_store.get(uri)
|
80
|
+
end
|
81
|
+
|
82
|
+
# @return [Rucoa::Nodes::Base]
|
83
|
+
def node
|
84
|
+
source&.node_at(position)
|
85
|
+
end
|
86
|
+
|
87
|
+
# @return [Rucoa::Definitions::Base, nil]
|
88
|
+
def definition
|
89
|
+
@definition ||= NodeInspector.new(
|
90
|
+
definition_store: definition_store,
|
91
|
+
node: node
|
92
|
+
).definitions.first
|
93
|
+
end
|
94
|
+
|
95
|
+
# @return [Rucoa::Nodes::ClassNode, nil]
|
96
|
+
def find_class_node
|
97
|
+
find_by_full_qualified_name(
|
98
|
+
full_qualified_name: definition.full_qualified_name,
|
99
|
+
klass: Nodes::ClassNode
|
100
|
+
) || find_by_name(
|
101
|
+
klass: Nodes::ClassNode,
|
102
|
+
name: definition.name
|
103
|
+
)
|
104
|
+
end
|
105
|
+
|
106
|
+
# @return [Rucoa::Nodes::ModuleNode, nil]
|
107
|
+
def find_module_node
|
108
|
+
find_by_full_qualified_name(
|
109
|
+
full_qualified_name: definition.full_qualified_name,
|
110
|
+
klass: Nodes::ModuleNode
|
111
|
+
) || find_by_name(
|
112
|
+
klass: Nodes::ModuleNode,
|
113
|
+
name: definition.name
|
114
|
+
)
|
115
|
+
end
|
116
|
+
|
117
|
+
# @return [Rucoa::Nodes::MethodNode, nil]
|
118
|
+
def find_method_node
|
119
|
+
location_root_or_descendant_nodes.reverse.find do |node|
|
120
|
+
node.is_a?(Nodes::DefNode) &&
|
121
|
+
node.name == definition.method_name &&
|
122
|
+
node.namespace == definition.namespace
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# @param full_qualified_name [String]
|
127
|
+
# @param klass [Class]
|
128
|
+
# @return [Rucoa::Nodes::Base, nil]
|
129
|
+
def find_by_full_qualified_name(full_qualified_name:, klass:)
|
130
|
+
location_root_or_descendant_nodes.reverse.find do |node|
|
131
|
+
node.is_a?(klass) &&
|
132
|
+
node.full_qualified_name == full_qualified_name
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
# @param name [String]
|
137
|
+
# @param klass [Class]
|
138
|
+
# @return [Rucoa::Nodes::Base, nil]
|
139
|
+
def find_by_name(klass:, name:)
|
140
|
+
location_root_or_descendant_nodes.reverse.find do |node|
|
141
|
+
node.is_a?(klass) &&
|
142
|
+
node.name == name
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# @return [Array<Rucoa::Nodes::Base>]
|
147
|
+
def location_root_or_descendant_nodes
|
148
|
+
@location_root_or_descendant_nodes ||= [
|
149
|
+
location_source.root_node,
|
150
|
+
*location_source.root_node.descendants
|
151
|
+
]
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rucoa
|
4
|
+
module Handlers
|
5
|
+
class TextDocumentDidCloseHandler < Base
|
6
|
+
include HandlerConcerns::DiagnosticsPublishable
|
7
|
+
|
8
|
+
def call
|
9
|
+
clear_diagnostics_on(uri)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
# @return [String]
|
15
|
+
def uri
|
16
|
+
request.dig('params', 'textDocument', 'uri')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -13,7 +13,7 @@ module Rucoa
|
|
13
13
|
def formattable?
|
14
14
|
configuration.enables_formatting? &&
|
15
15
|
source &&
|
16
|
-
|
16
|
+
Rubocop::ConfigurationChecker.call
|
17
17
|
end
|
18
18
|
|
19
19
|
# @return [Array<Hash>]
|
@@ -43,7 +43,7 @@ module Rucoa
|
|
43
43
|
|
44
44
|
# @return [String]
|
45
45
|
def new_text
|
46
|
-
|
46
|
+
Rubocop::Autocorrector.call(source: source)
|
47
47
|
end
|
48
48
|
|
49
49
|
# @return [Hash]
|
@@ -23,14 +23,13 @@ module Rucoa
|
|
23
23
|
def responsible?
|
24
24
|
configuration.enables_hover? &&
|
25
25
|
!source.nil? &&
|
26
|
-
!node.nil?
|
26
|
+
!node.nil? &&
|
27
|
+
!method_definitions.empty?
|
27
28
|
end
|
28
29
|
|
29
30
|
# @return [String, nil]
|
30
31
|
def contents
|
31
32
|
method_definition = method_definitions.first
|
32
|
-
return unless method_definition
|
33
|
-
|
34
33
|
[
|
35
34
|
method_definition.signatures.join("\n"),
|
36
35
|
method_definition.description
|
@@ -66,7 +65,7 @@ module Rucoa
|
|
66
65
|
|
67
66
|
# @return [Array<Rucoa::Definitions::MethodDefinition>]
|
68
67
|
def method_definitions
|
69
|
-
NodeInspector.new(
|
68
|
+
@method_definitions ||= NodeInspector.new(
|
70
69
|
definition_store: definition_store,
|
71
70
|
node: node
|
72
71
|
).method_definitions
|
@@ -25,7 +25,7 @@ module Rucoa
|
|
25
25
|
def formattable?
|
26
26
|
configuration.enables_formatting? &&
|
27
27
|
source &&
|
28
|
-
|
28
|
+
Rubocop::ConfigurationChecker.call
|
29
29
|
end
|
30
30
|
|
31
31
|
# @return [Rucoa::Source]
|
@@ -59,7 +59,7 @@ module Rucoa
|
|
59
59
|
|
60
60
|
# @return [Array<RuboCop::Cop::Offense>]
|
61
61
|
def offenses
|
62
|
-
|
62
|
+
Rubocop::Investigator.call(source: source)
|
63
63
|
end
|
64
64
|
|
65
65
|
# @return [Array(Rucoa::Range, String)]
|
data/lib/rucoa/handlers.rb
CHANGED
@@ -9,7 +9,9 @@ module Rucoa
|
|
9
9
|
autoload :ShutdownHandler, 'rucoa/handlers/shutdown_handler'
|
10
10
|
autoload :TextDocumentCodeActionHandler, 'rucoa/handlers/text_document_code_action_handler'
|
11
11
|
autoload :TextDocumentCompletionHandler, 'rucoa/handlers/text_document_completion_handler'
|
12
|
+
autoload :TextDocumentDefinitionHandler, 'rucoa/handlers/text_document_definition_handler'
|
12
13
|
autoload :TextDocumentDidChangeHandler, 'rucoa/handlers/text_document_did_change_handler'
|
14
|
+
autoload :TextDocumentDidCloseHandler, 'rucoa/handlers/text_document_did_close_handler'
|
13
15
|
autoload :TextDocumentDidOpenHandler, 'rucoa/handlers/text_document_did_open_handler'
|
14
16
|
autoload :TextDocumentDocumentSymbolHandler, 'rucoa/handlers/text_document_document_symbol_handler'
|
15
17
|
autoload :TextDocumentFormattingHandler, 'rucoa/handlers/text_document_formatting_handler'
|