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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -3
  3. data/Gemfile.lock +3 -3
  4. data/README.md +4 -1
  5. data/lib/rucoa/configuration.rb +22 -12
  6. data/lib/rucoa/definition_store.rb +131 -131
  7. data/lib/rucoa/definitions/method_definition.rb +11 -11
  8. data/lib/rucoa/handler_concerns/configuration_requestable.rb +7 -7
  9. data/lib/rucoa/handler_concerns/diagnostics_publishable.rb +11 -11
  10. data/lib/rucoa/handler_concerns/text_document_position_parameters.rb +29 -0
  11. data/lib/rucoa/handler_concerns/text_document_uri_parameters.rb +21 -0
  12. data/lib/rucoa/handler_concerns.rb +2 -0
  13. data/lib/rucoa/handlers/base.rb +9 -9
  14. data/lib/rucoa/handlers/initialize_handler.rb +1 -0
  15. data/lib/rucoa/handlers/initialized_handler.rb +16 -16
  16. data/lib/rucoa/handlers/text_document_code_action_handler.rb +12 -12
  17. data/lib/rucoa/handlers/text_document_completion_handler.rb +85 -99
  18. data/lib/rucoa/handlers/text_document_definition_handler.rb +11 -30
  19. data/lib/rucoa/handlers/text_document_did_close_handler.rb +2 -8
  20. data/lib/rucoa/handlers/text_document_did_open_handler.rb +3 -7
  21. data/lib/rucoa/handlers/text_document_document_highlight_handler.rb +256 -0
  22. data/lib/rucoa/handlers/text_document_document_symbol_handler.rb +47 -76
  23. data/lib/rucoa/handlers/text_document_formatting_handler.rb +15 -23
  24. data/lib/rucoa/handlers/text_document_hover_handler.rb +24 -43
  25. data/lib/rucoa/handlers/text_document_range_formatting_handler.rb +17 -25
  26. data/lib/rucoa/handlers/text_document_selection_range_handler.rb +11 -19
  27. data/lib/rucoa/handlers/text_document_signature_help_handler.rb +17 -36
  28. data/lib/rucoa/handlers.rb +1 -0
  29. data/lib/rucoa/node_concerns/body.rb +1 -1
  30. data/lib/rucoa/node_concerns/qualified_name.rb +5 -5
  31. data/lib/rucoa/node_concerns/rescue.rb +21 -0
  32. data/lib/rucoa/node_concerns.rb +1 -0
  33. data/lib/rucoa/node_inspector.rb +5 -5
  34. data/lib/rucoa/nodes/base.rb +48 -48
  35. data/lib/rucoa/nodes/begin_node.rb +2 -0
  36. data/lib/rucoa/nodes/block_node.rb +24 -0
  37. data/lib/rucoa/nodes/case_node.rb +24 -0
  38. data/lib/rucoa/nodes/const_node.rb +26 -26
  39. data/lib/rucoa/nodes/def_node.rb +14 -13
  40. data/lib/rucoa/nodes/ensure_node.rb +19 -0
  41. data/lib/rucoa/nodes/for_node.rb +8 -0
  42. data/lib/rucoa/nodes/if_node.rb +32 -0
  43. data/lib/rucoa/nodes/resbody_node.rb +8 -0
  44. data/lib/rucoa/nodes/rescue_node.rb +17 -0
  45. data/lib/rucoa/nodes/send_node.rb +40 -0
  46. data/lib/rucoa/nodes/until_node.rb +8 -0
  47. data/lib/rucoa/nodes/when_node.rb +8 -0
  48. data/lib/rucoa/nodes/while_node.rb +8 -0
  49. data/lib/rucoa/nodes.rb +10 -1
  50. data/lib/rucoa/parser_builder.rb +16 -2
  51. data/lib/rucoa/range.rb +9 -3
  52. data/lib/rucoa/rbs/constant_definition_mapper.rb +5 -5
  53. data/lib/rucoa/rbs/method_definition_mapper.rb +18 -18
  54. data/lib/rucoa/rbs/module_definition_mapper.rb +13 -13
  55. data/lib/rucoa/rbs/ruby_definitions_loader.rb +5 -5
  56. data/lib/rucoa/rubocop/configuration_checker.rb +7 -7
  57. data/lib/rucoa/server.rb +24 -23
  58. data/lib/rucoa/source.rb +5 -5
  59. data/lib/rucoa/source_store.rb +8 -8
  60. data/lib/rucoa/version.rb +1 -1
  61. data/lib/rucoa/yard/definition_generators/method_definition_generator.rb +1 -1
  62. metadata +16 -3
  63. data/lib/rucoa/nodes/defs_node.rb +0 -33
@@ -43,11 +43,6 @@ module Rucoa
43
43
 
44
44
  private
45
45
 
46
- # @return [Array<RBS::AST::Declarations::Base>]
47
- def declarations
48
- class_declarations + constant_declarations
49
- end
50
-
51
46
  # @return [Array<RBS::AST::Declarations::Class>]
52
47
  def class_declarations
53
48
  environment.class_decls.values.flat_map do |multi_entry|
@@ -60,6 +55,11 @@ module Rucoa
60
55
  environment.constant_decls.values.map(&:decl)
61
56
  end
62
57
 
58
+ # @return [Array<RBS::AST::Declarations::Base>]
59
+ def declarations
60
+ class_declarations + constant_declarations
61
+ end
62
+
63
63
  # @return [RBS::Environment]
64
64
  def environment
65
65
  @environment ||= ::RBS::Environment.from_loader(
@@ -19,13 +19,6 @@ module Rucoa
19
19
 
20
20
  private
21
21
 
22
- # @return [Boolean]
23
- def rubocop_configured_for_current_directory?
24
- each_current_and_ancestor_pathname.any? do |pathname|
25
- pathname.join('.rubocop.yml').exist?
26
- end
27
- end
28
-
29
22
  # @return [Enumerable<Pathname>]
30
23
  def each_current_and_ancestor_pathname
31
24
  return to_enum(__method__) unless block_given?
@@ -39,6 +32,13 @@ module Rucoa
39
32
  end
40
33
  self
41
34
  end
35
+
36
+ # @return [Boolean]
37
+ def rubocop_configured_for_current_directory?
38
+ each_current_and_ancestor_pathname.any? do |pathname|
39
+ pathname.join('.rubocop.yml').exist?
40
+ end
41
+ end
42
42
  end
43
43
  end
44
44
  end
data/lib/rucoa/server.rb CHANGED
@@ -17,6 +17,7 @@ module Rucoa
17
17
  'textDocument/didChange' => Handlers::TextDocumentDidChangeHandler,
18
18
  'textDocument/didClose' => Handlers::TextDocumentDidCloseHandler,
19
19
  'textDocument/didOpen' => Handlers::TextDocumentDidOpenHandler,
20
+ 'textDocument/documentHighlight' => Handlers::TextDocumentDocumentHighlightHandler,
20
21
  'textDocument/documentSymbol' => Handlers::TextDocumentDocumentSymbolHandler,
21
22
  'textDocument/formatting' => Handlers::TextDocumentFormattingHandler,
22
23
  'textDocument/hover' => Handlers::TextDocumentHoverHandler,
@@ -62,6 +63,19 @@ module Rucoa
62
63
  @definition_store.bulk_add(DefinitionArchiver.load)
63
64
  end
64
65
 
66
+ # @return [void]
67
+ def finish
68
+ exit(0)
69
+ end
70
+
71
+ # @note This method is for testing.
72
+ # @return [Array<Hash>]
73
+ def responses
74
+ io = @writer.io
75
+ io.rewind
76
+ MessageReader.new(io).read.to_a
77
+ end
78
+
65
79
  # @return [void]
66
80
  def start
67
81
  @reader.read do |message|
@@ -75,11 +89,6 @@ module Rucoa
75
89
  end
76
90
  end
77
91
 
78
- # @return [void]
79
- def finish
80
- exit(0)
81
- end
82
-
83
92
  # @yieldparam response [Hash]
84
93
  # @param message [Hash]
85
94
  # @return [void]
@@ -94,15 +103,18 @@ module Rucoa
94
103
  end
95
104
  end
96
105
 
97
- # @note This method is for testing.
98
- # @return [Array<Hash>]
99
- def responses
100
- io = @writer.io
101
- io.rewind
102
- MessageReader.new(io).read.to_a
106
+ private
107
+
108
+ # @yieldparam log [String]
109
+ def debug(&block)
110
+ @logger.debug(&block) if configuration.enables_debug?
103
111
  end
104
112
 
105
- private
113
+ # @param request_method [String]
114
+ # @return [Class, nil]
115
+ def find_client_request_handler(request_method)
116
+ METHOD_TO_HANDLER_MAP[request_method]
117
+ end
106
118
 
107
119
  # @param request [Hash]
108
120
  # @return [void]
@@ -114,11 +126,6 @@ module Rucoa
114
126
  end
115
127
  end
116
128
 
117
- # @yieldparam log [String]
118
- def debug(&block)
119
- @logger.debug(&block) if configuration.enables_debug?
120
- end
121
-
122
129
  # @param request [Hash]
123
130
  # @return [void]
124
131
  def handle_client_request(request)
@@ -134,12 +141,6 @@ module Rucoa
134
141
  @client_response_handlers.delete(response['id'])&.call(response)
135
142
  end
136
143
 
137
- # @param request_method [String]
138
- # @return [Class, nil]
139
- def find_client_request_handler(request_method)
140
- METHOD_TO_HANDLER_MAP[request_method]
141
- end
142
-
143
144
  # @param message [Hash]
144
145
  # @return [void]
145
146
  def write_server_request(
data/lib/rucoa/source.rb CHANGED
@@ -62,6 +62,11 @@ module Rucoa
62
62
  end
63
63
  end
64
64
 
65
+ # @return [Boolean]
66
+ def failed_to_parse?
67
+ parse_result.failed?
68
+ end
69
+
65
70
  # @return [String, nil]
66
71
  # @example returns path for file URI
67
72
  # source = Rucoa::Source.new(
@@ -96,11 +101,6 @@ module Rucoa
96
101
  parse_result.root_node
97
102
  end
98
103
 
99
- # @return [Boolean]
100
- def failed_to_parse?
101
- parse_result.failed?
102
- end
103
-
104
104
  # @return [Boolean]
105
105
  def untitled?
106
106
  uri_object.scheme == 'untitled'
@@ -6,10 +6,10 @@ module Rucoa
6
6
  @data = {}
7
7
  end
8
8
 
9
- # @param source [Rucoa::Source]
10
- # @return [void]
11
- def update(source)
12
- @data[source.uri] = source
9
+ # @yieldparam uri [String]
10
+ # @return [Enumerable<String>]
11
+ def each_uri(&block)
12
+ @data.each_key(&block)
13
13
  end
14
14
 
15
15
  # @param uri [String]
@@ -18,10 +18,10 @@ module Rucoa
18
18
  @data[uri]
19
19
  end
20
20
 
21
- # @yieldparam uri [String]
22
- # @return [Enumerable<String>]
23
- def each_uri(&block)
24
- @data.each_key(&block)
21
+ # @param source [Rucoa::Source]
22
+ # @return [void]
23
+ def update(source)
24
+ @data[source.uri] = source
25
25
  end
26
26
  end
27
27
  end
data/lib/rucoa/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rucoa
4
- VERSION = '0.11.0'
4
+ VERSION = '0.12.0'
5
5
  end
@@ -36,7 +36,7 @@ module Rucoa
36
36
  # ).definitions
37
37
  # expect(definitions[1].qualified_name).to eq('Foo.bar')
38
38
  def call
39
- return [] unless @node.is_a?(Nodes::DefNode) || @node.is_a?(Nodes::DefsNode)
39
+ return [] unless @node.is_a?(Nodes::DefNode)
40
40
 
41
41
  [
42
42
  Definitions::MethodDefinition.new(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rucoa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-26 00:00:00.000000000 Z
11
+ date: 2022-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -104,6 +104,8 @@ files:
104
104
  - lib/rucoa/handler_concerns.rb
105
105
  - lib/rucoa/handler_concerns/configuration_requestable.rb
106
106
  - lib/rucoa/handler_concerns/diagnostics_publishable.rb
107
+ - lib/rucoa/handler_concerns/text_document_position_parameters.rb
108
+ - lib/rucoa/handler_concerns/text_document_uri_parameters.rb
107
109
  - lib/rucoa/handlers.rb
108
110
  - lib/rucoa/handlers/base.rb
109
111
  - lib/rucoa/handlers/exit_handler.rb
@@ -116,6 +118,7 @@ files:
116
118
  - lib/rucoa/handlers/text_document_did_change_handler.rb
117
119
  - lib/rucoa/handlers/text_document_did_close_handler.rb
118
120
  - lib/rucoa/handlers/text_document_did_open_handler.rb
121
+ - lib/rucoa/handlers/text_document_document_highlight_handler.rb
119
122
  - lib/rucoa/handlers/text_document_document_symbol_handler.rb
120
123
  - lib/rucoa/handlers/text_document_formatting_handler.rb
121
124
  - lib/rucoa/handlers/text_document_hover_handler.rb
@@ -129,22 +132,32 @@ files:
129
132
  - lib/rucoa/node_concerns.rb
130
133
  - lib/rucoa/node_concerns/body.rb
131
134
  - lib/rucoa/node_concerns/qualified_name.rb
135
+ - lib/rucoa/node_concerns/rescue.rb
132
136
  - lib/rucoa/node_inspector.rb
133
137
  - lib/rucoa/nodes.rb
134
138
  - lib/rucoa/nodes/base.rb
135
139
  - lib/rucoa/nodes/begin_node.rb
140
+ - lib/rucoa/nodes/block_node.rb
141
+ - lib/rucoa/nodes/case_node.rb
136
142
  - lib/rucoa/nodes/casgn_node.rb
137
143
  - lib/rucoa/nodes/cbase_node.rb
138
144
  - lib/rucoa/nodes/class_node.rb
139
145
  - lib/rucoa/nodes/const_node.rb
140
146
  - lib/rucoa/nodes/def_node.rb
141
- - lib/rucoa/nodes/defs_node.rb
147
+ - lib/rucoa/nodes/ensure_node.rb
148
+ - lib/rucoa/nodes/for_node.rb
149
+ - lib/rucoa/nodes/if_node.rb
142
150
  - lib/rucoa/nodes/lvar_node.rb
143
151
  - lib/rucoa/nodes/module_node.rb
152
+ - lib/rucoa/nodes/resbody_node.rb
153
+ - lib/rucoa/nodes/rescue_node.rb
144
154
  - lib/rucoa/nodes/sclass_node.rb
145
155
  - lib/rucoa/nodes/send_node.rb
146
156
  - lib/rucoa/nodes/str_node.rb
147
157
  - lib/rucoa/nodes/sym_node.rb
158
+ - lib/rucoa/nodes/until_node.rb
159
+ - lib/rucoa/nodes/when_node.rb
160
+ - lib/rucoa/nodes/while_node.rb
148
161
  - lib/rucoa/parse_result.rb
149
162
  - lib/rucoa/parser.rb
150
163
  - lib/rucoa/parser_builder.rb
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Rucoa
4
- module Nodes
5
- class DefsNode < Base
6
- # @return [String]
7
- def qualified_name
8
- [
9
- namespace,
10
- method_marker,
11
- name
12
- ].join
13
- end
14
-
15
- # @return [String]
16
- def name
17
- children[1].to_s
18
- end
19
-
20
- # @return [Boolean]
21
- def singleton?
22
- true
23
- end
24
-
25
- private
26
-
27
- # @return [String]
28
- def method_marker
29
- '.'
30
- end
31
- end
32
- end
33
- end