rucoa 0.11.0 → 0.13.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 +12 -3
- data/Gemfile.lock +3 -3
- data/README.md +6 -1
- data/images/document-highlight.gif +0 -0
- 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 +531 -0
- data/lib/rucoa/handlers/text_document_document_symbol_handler.rb +47 -76
- data/lib/rucoa/handlers/text_document_formatting_handler.rb +16 -24
- 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/modifier.rb +35 -0
- data/lib/rucoa/node_concerns/qualified_name.rb +5 -5
- data/lib/rucoa/node_concerns/rescue.rb +21 -0
- data/lib/rucoa/node_concerns/variable.rb +26 -0
- data/lib/rucoa/node_concerns.rb +3 -0
- data/lib/rucoa/node_inspector.rb +5 -5
- data/lib/rucoa/nodes/arg_node.rb +26 -0
- data/lib/rucoa/nodes/args_node.rb +14 -0
- data/lib/rucoa/nodes/base.rb +111 -47
- data/lib/rucoa/nodes/begin_node.rb +2 -0
- data/lib/rucoa/nodes/block_node.rb +38 -0
- data/lib/rucoa/nodes/case_node.rb +24 -0
- data/lib/rucoa/nodes/const_node.rb +26 -26
- data/lib/rucoa/nodes/cvar_node.rb +9 -0
- data/lib/rucoa/nodes/cvasgn_node.rb +9 -0
- data/lib/rucoa/nodes/def_node.rb +28 -13
- data/lib/rucoa/nodes/ensure_node.rb +19 -0
- data/lib/rucoa/nodes/for_node.rb +8 -0
- data/lib/rucoa/nodes/gvar_node.rb +9 -0
- data/lib/rucoa/nodes/gvasgn_node.rb +9 -0
- data/lib/rucoa/nodes/if_node.rb +34 -0
- data/lib/rucoa/nodes/ivar_node.rb +9 -0
- data/lib/rucoa/nodes/ivasgn_node.rb +9 -0
- data/lib/rucoa/nodes/lvar_node.rb +1 -18
- data/lib/rucoa/nodes/lvasgn_node.rb +9 -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 +9 -0
- data/lib/rucoa/nodes/when_node.rb +8 -0
- data/lib/rucoa/nodes/while_node.rb +9 -0
- data/lib/rucoa/nodes.rb +19 -1
- data/lib/rucoa/parser_builder.rb +26 -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 +6 -6
- 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
- data/lib/rucoa/yard/definitions_loader.rb +1 -1
- data/rucoa.gemspec +0 -1
- metadata +28 -4
- data/lib/rucoa/nodes/defs_node.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3829019e74a6fedcb5548ce3630b3c145c12ab40c0df99b63fd9747975f0a71d
|
4
|
+
data.tar.gz: 4cd7373ed7239adeb955caf7c373fe5da6d90ca0d92dc34801d2179db0387bbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3bbe0f9cb45652ab45706b3afa87853ba3e4d8e33b5894080772a054463bc3828db454da0a0af292982f4de9b8fa18a0353d1cf527e6961455d08c68eeeae63
|
7
|
+
data.tar.gz: 3b23e8f98a5a57a7f236f22ba7e8e606a43f477e789646740a99cdbb30f0bf5adb21779c1ea2e0f828112e32e4dd242eae28fde14120870d8163f0bc1adbc769
|
data/.rubocop.yml
CHANGED
@@ -8,6 +8,9 @@ AllCops:
|
|
8
8
|
NewCops: enable
|
9
9
|
TargetRubyVersion: 2.7
|
10
10
|
|
11
|
+
Gemspec/RequireMFA:
|
12
|
+
Enabled: false
|
13
|
+
|
11
14
|
Layout/LineLength:
|
12
15
|
Enabled: false
|
13
16
|
|
@@ -35,13 +38,19 @@ Security/MarshalLoad:
|
|
35
38
|
Sevencop/AutoloadOrdered:
|
36
39
|
Enabled: true
|
37
40
|
|
38
|
-
Sevencop/
|
41
|
+
Sevencop/HashElementOrdered:
|
42
|
+
Enabled: true
|
43
|
+
|
44
|
+
Sevencop/MethodDefinitionOrdered:
|
45
|
+
Enabled: true
|
46
|
+
|
47
|
+
Sevencop/MethodDefinitionArgumentsMultiline:
|
39
48
|
Enabled: true
|
40
49
|
|
41
|
-
Sevencop/
|
50
|
+
Sevencop/MethodDefinitionKeywordArgumentOrdered:
|
42
51
|
Enabled: true
|
43
52
|
|
44
|
-
Sevencop/
|
53
|
+
Sevencop/RequireOrdered:
|
45
54
|
Enabled: true
|
46
55
|
|
47
56
|
Style/Documentation:
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rucoa (0.
|
4
|
+
rucoa (0.13.0)
|
5
5
|
parser
|
6
6
|
rbs
|
7
7
|
rubocop
|
@@ -19,7 +19,7 @@ GEM
|
|
19
19
|
rainbow (3.1.1)
|
20
20
|
rake (13.0.6)
|
21
21
|
rbs (2.6.0)
|
22
|
-
regexp_parser (2.
|
22
|
+
regexp_parser (2.6.0)
|
23
23
|
rexml (3.2.5)
|
24
24
|
rspec (3.11.0)
|
25
25
|
rspec-core (~> 3.11.0)
|
@@ -54,7 +54,7 @@ GEM
|
|
54
54
|
rubocop-rspec (2.13.2)
|
55
55
|
rubocop (~> 1.33)
|
56
56
|
ruby-progressbar (1.11.0)
|
57
|
-
sevencop (0.
|
57
|
+
sevencop (0.16.0)
|
58
58
|
rubocop
|
59
59
|
unicode-display_width (2.3.0)
|
60
60
|
webrick (1.7.0)
|
data/README.md
CHANGED
@@ -35,6 +35,12 @@ Run "Format Document" command or enable "Format On Save" in the settings to auto
|
|
35
35
|
|
36
36
|

|
37
37
|
|
38
|
+
### Highlight
|
39
|
+
|
40
|
+
Highlights corresponding keywords.
|
41
|
+
|
42
|
+

|
43
|
+
|
38
44
|
### Selection
|
39
45
|
|
40
46
|
Run "Expand Selection" command to select appropriate ranges.
|
@@ -76,5 +82,4 @@ Shows method signature help when you start to type method arguments like `"100".
|
|
76
82
|
|
77
83
|
## Coming soon
|
78
84
|
|
79
|
-
- Highlight
|
80
85
|
- Semantic Tokens
|
Binary file
|
data/lib/rucoa/configuration.rb
CHANGED
@@ -36,6 +36,11 @@ module Rucoa
|
|
36
36
|
disable_feature('formatting')
|
37
37
|
end
|
38
38
|
|
39
|
+
# @return [void]
|
40
|
+
def disable_highlight
|
41
|
+
disable_feature('highlight')
|
42
|
+
end
|
43
|
+
|
39
44
|
# @return [void]
|
40
45
|
def disable_hover
|
41
46
|
disable_feature('hover')
|
@@ -58,18 +63,6 @@ module Rucoa
|
|
58
63
|
@settings['base']['debug'] = true
|
59
64
|
end
|
60
65
|
|
61
|
-
# @return [Boolean]
|
62
|
-
# @example returns false if the configuration is empty
|
63
|
-
# configuration = Rucoa::Configuration.new
|
64
|
-
# expect(configuration).not_to be_enables_debug
|
65
|
-
# @example returns true if the configuration enables debug
|
66
|
-
# configuration = Rucoa::Configuration.new
|
67
|
-
# configuration.update('base' => { 'debug' => true })
|
68
|
-
# expect(configuration).to be_enables_debug
|
69
|
-
def enables_debug?
|
70
|
-
fetch('base', 'debug', default: false)
|
71
|
-
end
|
72
|
-
|
73
66
|
# @return [Boolean]
|
74
67
|
# @example returns true if the configuration is empty
|
75
68
|
# configuration = Rucoa::Configuration.new
|
@@ -87,6 +80,18 @@ module Rucoa
|
|
87
80
|
enables_feature?('completion')
|
88
81
|
end
|
89
82
|
|
83
|
+
# @return [Boolean]
|
84
|
+
# @example returns false if the configuration is empty
|
85
|
+
# configuration = Rucoa::Configuration.new
|
86
|
+
# expect(configuration).not_to be_enables_debug
|
87
|
+
# @example returns true if the configuration enables debug
|
88
|
+
# configuration = Rucoa::Configuration.new
|
89
|
+
# configuration.update('base' => { 'debug' => true })
|
90
|
+
# expect(configuration).to be_enables_debug
|
91
|
+
def enables_debug?
|
92
|
+
fetch('base', 'debug', default: false)
|
93
|
+
end
|
94
|
+
|
90
95
|
# @return [Boolean]
|
91
96
|
def enables_definition?
|
92
97
|
enables_feature?('definition')
|
@@ -107,6 +112,11 @@ module Rucoa
|
|
107
112
|
enables_feature?('formatting')
|
108
113
|
end
|
109
114
|
|
115
|
+
# @return [Boolean]
|
116
|
+
def enables_highlight?
|
117
|
+
enables_feature?('highlight')
|
118
|
+
end
|
119
|
+
|
110
120
|
# @return [Boolean]
|
111
121
|
def enables_hover?
|
112
122
|
enables_feature?('hover')
|
@@ -7,11 +7,6 @@ module Rucoa
|
|
7
7
|
@qualified_names_by_uri = ::Hash.new { |hash, key| hash[key] = [] }
|
8
8
|
end
|
9
9
|
|
10
|
-
# @return [String]
|
11
|
-
def inspect
|
12
|
-
"#<#{self.class} definitions_count=#{@definition_by_qualified_name.count}>"
|
13
|
-
end
|
14
|
-
|
15
10
|
# @param definitions [Array<Rucoa::Definition::Base>]
|
16
11
|
# @return [void]
|
17
12
|
def bulk_add(definitions)
|
@@ -23,61 +18,12 @@ module Rucoa
|
|
23
18
|
end
|
24
19
|
end
|
25
20
|
|
26
|
-
# @param
|
27
|
-
# @return [
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
# module A
|
33
|
-
# class Foo
|
34
|
-
# end
|
35
|
-
# end
|
36
|
-
# RUBY
|
37
|
-
# uri: 'file:///path/to/a/foo.rb',
|
38
|
-
# )
|
39
|
-
# definition_store.update_from(foo)
|
40
|
-
# bar = Rucoa::Source.new(
|
41
|
-
# content: <<~RUBY,
|
42
|
-
# module A
|
43
|
-
# class Bar < Foo
|
44
|
-
# end
|
45
|
-
# end
|
46
|
-
# RUBY
|
47
|
-
# uri: 'file:///path/to/a/bar.rb',
|
48
|
-
# )
|
49
|
-
# definition_store.update_from(bar)
|
50
|
-
# definition = definition_store.find_definition_by_qualified_name('A::Bar')
|
51
|
-
# expect(definition.super_class_qualified_name).to eq('A::Foo')
|
52
|
-
# @example resolves included module names from definitions
|
53
|
-
# definition_store = Rucoa::DefinitionStore.new
|
54
|
-
# foo = Rucoa::Source.new(
|
55
|
-
# content: <<~RUBY,
|
56
|
-
# module A
|
57
|
-
# module Foo
|
58
|
-
# end
|
59
|
-
# end
|
60
|
-
# RUBY
|
61
|
-
# uri: 'file:///path/to/a/foo.rb',
|
62
|
-
# )
|
63
|
-
# definition_store.update_from(foo)
|
64
|
-
# bar = Rucoa::Source.new(
|
65
|
-
# content: <<~RUBY,
|
66
|
-
# module A
|
67
|
-
# class Bar
|
68
|
-
# include Foo
|
69
|
-
# end
|
70
|
-
# end
|
71
|
-
# RUBY
|
72
|
-
# uri: 'file:///path/to/a/bar.rb',
|
73
|
-
# )
|
74
|
-
# definition_store.update_from(bar)
|
75
|
-
# definition = definition_store.find_definition_by_qualified_name('A::Bar')
|
76
|
-
# expect(definition.included_module_qualified_names).to eq(%w[A::Foo])
|
77
|
-
def update_from(source)
|
78
|
-
delete_definitions_in(source)
|
79
|
-
add_definitions_in(source)
|
80
|
-
resolve_constants_in(source)
|
21
|
+
# @param namespace [String]
|
22
|
+
# @return [Array<Rucoa::Definitions::ConstantDefinition>] e.g. File::Separator, File::SEPARATOR, etc.
|
23
|
+
def constant_definitions_under(namespace)
|
24
|
+
constant_definitions.select do |constant_definition|
|
25
|
+
constant_definition.namespace == namespace
|
26
|
+
end
|
81
27
|
end
|
82
28
|
|
83
29
|
# @param qualified_name [String]
|
@@ -178,6 +124,11 @@ module Rucoa
|
|
178
124
|
end
|
179
125
|
end
|
180
126
|
|
127
|
+
# @return [String]
|
128
|
+
def inspect
|
129
|
+
"#<#{self.class} definitions_count=#{@definition_by_qualified_name.count}>"
|
130
|
+
end
|
131
|
+
|
181
132
|
# @param type [String]
|
182
133
|
# @return [Array<Rucoa::Definitions::MethodDefinition>]
|
183
134
|
# @example supports simple instance method
|
@@ -266,6 +217,19 @@ module Rucoa
|
|
266
217
|
end.uniq(&:method_name)
|
267
218
|
end
|
268
219
|
|
220
|
+
# @todo Search ancestors.
|
221
|
+
# @param unqualified_name [Rucoa::UnqualifiedName]
|
222
|
+
# @return [String]
|
223
|
+
def resolve_constant(unqualified_name)
|
224
|
+
(
|
225
|
+
unqualified_name.module_nesting.map do |prefix|
|
226
|
+
"#{prefix}::#{unqualified_name.chained_name}"
|
227
|
+
end + [unqualified_name.chained_name]
|
228
|
+
).find do |candidate|
|
229
|
+
find_definition_by_qualified_name(candidate)
|
230
|
+
end || unqualified_name.chained_name
|
231
|
+
end
|
232
|
+
|
269
233
|
# @param type [String]
|
270
234
|
# @return [Array<Rucoa::Definitions::MethodDefinition>]
|
271
235
|
# @example supports simple singleton method
|
@@ -340,42 +304,76 @@ module Rucoa
|
|
340
304
|
end.uniq(&:method_name)
|
341
305
|
end
|
342
306
|
|
343
|
-
# @param
|
344
|
-
# @return [
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
#
|
352
|
-
#
|
353
|
-
#
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
307
|
+
# @param source [Rucoa::Source]
|
308
|
+
# @return [void]
|
309
|
+
# @example resolves super class name from definitions
|
310
|
+
# definition_store = Rucoa::DefinitionStore.new
|
311
|
+
# foo = Rucoa::Source.new(
|
312
|
+
# content: <<~RUBY,
|
313
|
+
# module A
|
314
|
+
# class Foo
|
315
|
+
# end
|
316
|
+
# end
|
317
|
+
# RUBY
|
318
|
+
# uri: 'file:///path/to/a/foo.rb',
|
319
|
+
# )
|
320
|
+
# definition_store.update_from(foo)
|
321
|
+
# bar = Rucoa::Source.new(
|
322
|
+
# content: <<~RUBY,
|
323
|
+
# module A
|
324
|
+
# class Bar < Foo
|
325
|
+
# end
|
326
|
+
# end
|
327
|
+
# RUBY
|
328
|
+
# uri: 'file:///path/to/a/bar.rb',
|
329
|
+
# )
|
330
|
+
# definition_store.update_from(bar)
|
331
|
+
# definition = definition_store.find_definition_by_qualified_name('A::Bar')
|
332
|
+
# expect(definition.super_class_qualified_name).to eq('A::Foo')
|
333
|
+
# @example resolves included module names from definitions
|
334
|
+
# definition_store = Rucoa::DefinitionStore.new
|
335
|
+
# foo = Rucoa::Source.new(
|
336
|
+
# content: <<~RUBY,
|
337
|
+
# module A
|
338
|
+
# module Foo
|
339
|
+
# end
|
340
|
+
# end
|
341
|
+
# RUBY
|
342
|
+
# uri: 'file:///path/to/a/foo.rb',
|
343
|
+
# )
|
344
|
+
# definition_store.update_from(foo)
|
345
|
+
# bar = Rucoa::Source.new(
|
346
|
+
# content: <<~RUBY,
|
347
|
+
# module A
|
348
|
+
# class Bar
|
349
|
+
# include Foo
|
350
|
+
# end
|
351
|
+
# end
|
352
|
+
# RUBY
|
353
|
+
# uri: 'file:///path/to/a/bar.rb',
|
354
|
+
# )
|
355
|
+
# definition_store.update_from(bar)
|
356
|
+
# definition = definition_store.find_definition_by_qualified_name('A::Bar')
|
357
|
+
# expect(definition.included_module_qualified_names).to eq(%w[A::Foo])
|
358
|
+
def update_from(source)
|
359
|
+
delete_definitions_in(source)
|
360
|
+
add_definitions_in(source)
|
361
|
+
resolve_constants_in(source)
|
362
362
|
end
|
363
363
|
|
364
364
|
private
|
365
365
|
|
366
366
|
# @param source [Rucoa::Source]
|
367
367
|
# @return [void]
|
368
|
-
def
|
369
|
-
|
370
|
-
|
368
|
+
def add_definitions_in(source)
|
369
|
+
source.definitions.group_by do |definition|
|
370
|
+
definition.location.uri
|
371
|
+
end.each do |uri, definitions|
|
372
|
+
@qualified_names_by_uri[uri] += definitions.map(&:qualified_name)
|
373
|
+
definitions.each do |definition|
|
374
|
+
@definition_by_qualified_name[definition.qualified_name] = definition
|
375
|
+
end
|
371
376
|
end
|
372
|
-
@qualified_names_by_uri.delete(source.uri)
|
373
|
-
end
|
374
|
-
|
375
|
-
# @param type [String]
|
376
|
-
# @return [String, nil]
|
377
|
-
def singleton_class_name_from(type)
|
378
|
-
type[/singleton<([\w:]+)>/, 1]
|
379
377
|
end
|
380
378
|
|
381
379
|
# @param definition [Rucoa::Definitions::Class, Rucoa::Definitions::Module]
|
@@ -390,32 +388,9 @@ module Rucoa
|
|
390
388
|
end
|
391
389
|
end
|
392
390
|
|
393
|
-
# @
|
394
|
-
|
395
|
-
|
396
|
-
[
|
397
|
-
*definition.prepended_module_qualified_names.filter_map do |qualified_name|
|
398
|
-
find_definition_by_qualified_name(qualified_name)
|
399
|
-
end.reverse,
|
400
|
-
definition,
|
401
|
-
*definition.included_module_qualified_names.filter_map do |qualified_name|
|
402
|
-
find_definition_by_qualified_name(qualified_name)
|
403
|
-
end.reverse
|
404
|
-
]
|
405
|
-
end
|
406
|
-
|
407
|
-
# @param definition [Rucoa::Definitions::Class]
|
408
|
-
# @return [Array<Rucoa::Definitions::Class>] super "class"es (not including modules) in closest-first order
|
409
|
-
def super_class_definitions_of(definition)
|
410
|
-
result = []
|
411
|
-
while (super_class_qualified_name = definition.super_class_qualified_name)
|
412
|
-
super_definition = find_definition_by_qualified_name(super_class_qualified_name)
|
413
|
-
break unless super_definition
|
414
|
-
|
415
|
-
result << super_definition
|
416
|
-
definition = super_definition
|
417
|
-
end
|
418
|
-
result
|
391
|
+
# @return [Array<Rucoa::Definition::ConstantDefinition>]
|
392
|
+
def constant_definitions
|
393
|
+
definitions.grep(Definitions::ConstantDefinition)
|
419
394
|
end
|
420
395
|
|
421
396
|
# @return [Array<Rucoa::Definitions::Base>]
|
@@ -423,27 +398,32 @@ module Rucoa
|
|
423
398
|
@definition_by_qualified_name.values
|
424
399
|
end
|
425
400
|
|
401
|
+
# @param source [Rucoa::Source]
|
402
|
+
# @return [void]
|
403
|
+
def delete_definitions_in(source)
|
404
|
+
@qualified_names_by_uri[source.uri].each do |qualified_name|
|
405
|
+
@definition_by_qualified_name.delete(qualified_name)
|
406
|
+
end
|
407
|
+
@qualified_names_by_uri.delete(source.uri)
|
408
|
+
end
|
409
|
+
|
426
410
|
# @return [Array<Rucoa::Definition::MethodDefinition>]
|
427
411
|
def method_definitions
|
428
412
|
definitions.grep(Definitions::MethodDefinition)
|
429
413
|
end
|
430
414
|
|
431
|
-
# @
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
definitions.each do |definition|
|
444
|
-
@definition_by_qualified_name[definition.qualified_name] = definition
|
445
|
-
end
|
446
|
-
end
|
415
|
+
# @param definition [Rucoa::Definitions::Class, Rucoa::Definitions::Module]
|
416
|
+
# @return [Array<Rucoa::Definitions::Class, Rucoa::Definitions::Module>] An array of prepended, itself, and included definitions
|
417
|
+
def module_ancestors_of(definition)
|
418
|
+
[
|
419
|
+
*definition.prepended_module_qualified_names.filter_map do |qualified_name|
|
420
|
+
find_definition_by_qualified_name(qualified_name)
|
421
|
+
end.reverse,
|
422
|
+
definition,
|
423
|
+
*definition.included_module_qualified_names.filter_map do |qualified_name|
|
424
|
+
find_definition_by_qualified_name(qualified_name)
|
425
|
+
end.reverse
|
426
|
+
]
|
447
427
|
end
|
448
428
|
|
449
429
|
# @param source [Rucoa::Source]
|
@@ -471,5 +451,25 @@ module Rucoa
|
|
471
451
|
definition.prepended_module_unqualified_names = []
|
472
452
|
end
|
473
453
|
end
|
454
|
+
|
455
|
+
# @param type [String]
|
456
|
+
# @return [String, nil]
|
457
|
+
def singleton_class_name_from(type)
|
458
|
+
type[/singleton<([\w:]+)>/, 1]
|
459
|
+
end
|
460
|
+
|
461
|
+
# @param definition [Rucoa::Definitions::Class]
|
462
|
+
# @return [Array<Rucoa::Definitions::Class>] super "class"es (not including modules) in closest-first order
|
463
|
+
def super_class_definitions_of(definition)
|
464
|
+
result = []
|
465
|
+
while (super_class_qualified_name = definition.super_class_qualified_name)
|
466
|
+
super_definition = find_definition_by_qualified_name(super_class_qualified_name)
|
467
|
+
break unless super_definition
|
468
|
+
|
469
|
+
result << super_definition
|
470
|
+
definition = super_definition
|
471
|
+
end
|
472
|
+
result
|
473
|
+
end
|
474
474
|
end
|
475
475
|
end
|
@@ -30,6 +30,17 @@ module Rucoa
|
|
30
30
|
@types = types
|
31
31
|
end
|
32
32
|
|
33
|
+
# @return [Boolean]
|
34
|
+
def instance_method?
|
35
|
+
@kind == :instance
|
36
|
+
end
|
37
|
+
|
38
|
+
# @todo
|
39
|
+
# @return [Array<Rucoa::Definitions::MethodParameter>]
|
40
|
+
def parameters
|
41
|
+
[]
|
42
|
+
end
|
43
|
+
|
33
44
|
# @return [String]
|
34
45
|
# @example returns qualified name of method
|
35
46
|
# definition = Rucoa::Source.new(
|
@@ -52,12 +63,6 @@ module Rucoa
|
|
52
63
|
].join
|
53
64
|
end
|
54
65
|
|
55
|
-
# @todo
|
56
|
-
# @return [Array<Rucoa::Definitions::MethodParameter>]
|
57
|
-
def parameters
|
58
|
-
[]
|
59
|
-
end
|
60
|
-
|
61
66
|
# @return [Array<String>]
|
62
67
|
# @example returns return types
|
63
68
|
# definition = Rucoa::Source.new(
|
@@ -105,11 +110,6 @@ module Rucoa
|
|
105
110
|
end
|
106
111
|
end
|
107
112
|
|
108
|
-
# @return [Boolean]
|
109
|
-
def instance_method?
|
110
|
-
@kind == :instance
|
111
|
-
end
|
112
|
-
|
113
113
|
# @return [Boolean]
|
114
114
|
def singleton_method?
|
115
115
|
!instance_method?
|
@@ -7,6 +7,13 @@ module Rucoa
|
|
7
7
|
|
8
8
|
private
|
9
9
|
|
10
|
+
# @return [void]
|
11
|
+
def publish_diagnostics_on_each_source
|
12
|
+
source_store.each_uri do |uri|
|
13
|
+
publish_diagnostics_on(uri)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
10
17
|
# @return [void]
|
11
18
|
def request_workspace_configuration
|
12
19
|
write(
|
@@ -23,13 +30,6 @@ module Rucoa
|
|
23
30
|
publish_diagnostics_on_each_source
|
24
31
|
end
|
25
32
|
end
|
26
|
-
|
27
|
-
# @return [void]
|
28
|
-
def publish_diagnostics_on_each_source
|
29
|
-
source_store.each_uri do |uri|
|
30
|
-
publish_diagnostics_on(uri)
|
31
|
-
end
|
32
|
-
end
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -5,17 +5,6 @@ module Rucoa
|
|
5
5
|
module DiagnosticsPublishable
|
6
6
|
private
|
7
7
|
|
8
|
-
# @param uri [String]
|
9
|
-
# @return [Array<Hash>]
|
10
|
-
def diagnostics_on(uri)
|
11
|
-
return [] unless configuration.enables_diagnostics?
|
12
|
-
|
13
|
-
DiagnosticProvider.call(
|
14
|
-
source: source_store.get(uri),
|
15
|
-
uri: uri
|
16
|
-
)
|
17
|
-
end
|
18
|
-
|
19
8
|
# @param uri [String]
|
20
9
|
# @return [void]
|
21
10
|
def clear_diagnostics_on(uri)
|
@@ -28,6 +17,17 @@ module Rucoa
|
|
28
17
|
)
|
29
18
|
end
|
30
19
|
|
20
|
+
# @param uri [String]
|
21
|
+
# @return [Array<Hash>]
|
22
|
+
def diagnostics_on(uri)
|
23
|
+
return [] unless configuration.enables_diagnostics?
|
24
|
+
|
25
|
+
DiagnosticProvider.call(
|
26
|
+
source: source_store.get(uri),
|
27
|
+
uri: uri
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
31
|
# @param uri [String]
|
32
32
|
# @return [void]
|
33
33
|
def publish_diagnostics_on(uri)
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rucoa
|
4
|
+
module HandlerConcerns
|
5
|
+
module TextDocumentPositionParameters
|
6
|
+
private
|
7
|
+
|
8
|
+
# @return [Rucoa::Nodes::Base, nil]
|
9
|
+
def node
|
10
|
+
return unless position
|
11
|
+
return unless source
|
12
|
+
|
13
|
+
@node ||= source.node_at(position)
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [String, nil]
|
17
|
+
def parameter_position
|
18
|
+
@parameter_position ||= request.dig('params', 'position')
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [Rucoa::Position, nil]
|
22
|
+
def position
|
23
|
+
return unless parameter_position
|
24
|
+
|
25
|
+
@position ||= Position.from_vscode_position(parameter_position)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rucoa
|
4
|
+
module HandlerConcerns
|
5
|
+
module TextDocumentUriParameters
|
6
|
+
private
|
7
|
+
|
8
|
+
# @return [String, nil]
|
9
|
+
def parameter_uri
|
10
|
+
@parameter_uri ||= request.dig('params', 'textDocument', 'uri')
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [Rucoa::Source, nil]
|
14
|
+
def source
|
15
|
+
return unless parameter_uri
|
16
|
+
|
17
|
+
@source ||= source_store.get(parameter_uri)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -4,5 +4,7 @@ module Rucoa
|
|
4
4
|
module HandlerConcerns
|
5
5
|
autoload :ConfigurationRequestable, 'rucoa/handler_concerns/configuration_requestable'
|
6
6
|
autoload :DiagnosticsPublishable, 'rucoa/handler_concerns/diagnostics_publishable'
|
7
|
+
autoload :TextDocumentPositionParameters, 'rucoa/handler_concerns/text_document_position_parameters'
|
8
|
+
autoload :TextDocumentUriParameters, 'rucoa/handler_concerns/text_document_uri_parameters'
|
7
9
|
end
|
8
10
|
end
|
data/lib/rucoa/handlers/base.rb
CHANGED
@@ -41,15 +41,6 @@ module Rucoa
|
|
41
41
|
# @return [Rucoa::Server]
|
42
42
|
attr_reader :server
|
43
43
|
|
44
|
-
# @param message [Hash]
|
45
|
-
# @return [void]
|
46
|
-
def respond(message)
|
47
|
-
write(
|
48
|
-
id: request['id'],
|
49
|
-
result: message
|
50
|
-
)
|
51
|
-
end
|
52
|
-
|
53
44
|
# @return [Rucoa::Configuration]
|
54
45
|
def configuration
|
55
46
|
@server.configuration
|
@@ -60,6 +51,15 @@ module Rucoa
|
|
60
51
|
@server.definition_store
|
61
52
|
end
|
62
53
|
|
54
|
+
# @param message [Hash]
|
55
|
+
# @return [void]
|
56
|
+
def respond(message)
|
57
|
+
write(
|
58
|
+
id: request['id'],
|
59
|
+
result: message
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
63
|
# @return [Rucoa::SourceStore]
|
64
64
|
def source_store
|
65
65
|
@server.source_store
|