rucoa 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -0
  3. data/Gemfile.lock +8 -8
  4. data/data/definitions_ruby_3_1 +0 -0
  5. data/lib/rucoa/configuration.rb +4 -1
  6. data/lib/rucoa/definition_store.rb +216 -83
  7. data/lib/rucoa/definitions/base.rb +14 -3
  8. data/lib/rucoa/definitions/class_definition.rb +14 -64
  9. data/lib/rucoa/definitions/constant_definition.rb +31 -19
  10. data/lib/rucoa/definitions/method_definition.rb +44 -52
  11. data/lib/rucoa/definitions/method_parameter_definition.rb +4 -1
  12. data/lib/rucoa/definitions/module_definition.rb +39 -0
  13. data/lib/rucoa/handler_concerns/diagnostics_publishable.rb +14 -3
  14. data/lib/rucoa/handlers/base.rb +12 -3
  15. data/lib/rucoa/handlers/text_document_definition_handler.rb +3 -99
  16. data/lib/rucoa/handlers/text_document_hover_handler.rb +21 -13
  17. data/lib/rucoa/handlers/text_document_selection_range_handler.rb +8 -2
  18. data/lib/rucoa/location.rb +37 -0
  19. data/lib/rucoa/node_concerns/body.rb +24 -0
  20. data/lib/rucoa/node_concerns/{name_fully_qualifiable.rb → qualified_name.rb} +2 -2
  21. data/lib/rucoa/node_concerns.rb +2 -1
  22. data/lib/rucoa/node_inspector.rb +17 -22
  23. data/lib/rucoa/nodes/base.rb +22 -6
  24. data/lib/rucoa/nodes/begin_node.rb +8 -0
  25. data/lib/rucoa/nodes/casgn_node.rb +1 -1
  26. data/lib/rucoa/nodes/class_node.rb +2 -1
  27. data/lib/rucoa/nodes/const_node.rb +33 -15
  28. data/lib/rucoa/nodes/def_node.rb +2 -2
  29. data/lib/rucoa/nodes/defs_node.rb +1 -1
  30. data/lib/rucoa/nodes/module_node.rb +2 -1
  31. data/lib/rucoa/nodes.rb +2 -1
  32. data/lib/rucoa/parser.rb +14 -14
  33. data/lib/rucoa/parser_builder.rb +6 -1
  34. data/lib/rucoa/position.rb +10 -1
  35. data/lib/rucoa/range.rb +11 -1
  36. data/lib/rucoa/rbs/class_definition_mapper.rb +13 -28
  37. data/lib/rucoa/rbs/constant_definition_mapper.rb +12 -6
  38. data/lib/rucoa/rbs/method_definition_mapper.rb +12 -6
  39. data/lib/rucoa/rbs/module_definition_mapper.rb +34 -6
  40. data/lib/rucoa/rubocop/investigator.rb +4 -1
  41. data/lib/rucoa/server.rb +8 -2
  42. data/lib/rucoa/source.rb +19 -4
  43. data/lib/rucoa/unqualified_name.rb +9 -0
  44. data/lib/rucoa/version.rb +1 -1
  45. data/lib/rucoa/yard/definition_generators/attribute_reader_definition_generator.rb +60 -0
  46. data/lib/rucoa/yard/definition_generators/attribute_writer_definition_generator.rb +60 -0
  47. data/lib/rucoa/yard/definition_generators/base.rb +117 -0
  48. data/lib/rucoa/yard/definition_generators/class_definition_generator.rb +66 -0
  49. data/lib/rucoa/yard/definition_generators/constant_assignment_definition_generator.rb +29 -0
  50. data/lib/rucoa/yard/definition_generators/method_definition_generator.rb +47 -0
  51. data/lib/rucoa/yard/definition_generators/module_definition_generator.rb +62 -0
  52. data/lib/rucoa/yard/definition_generators.rb +15 -0
  53. data/lib/rucoa/yard/definitions_loader.rb +1 -271
  54. data/lib/rucoa/yard.rb +1 -0
  55. data/lib/rucoa.rb +4 -2
  56. metadata +15 -3
@@ -4,7 +4,10 @@ module Rucoa
4
4
  class NodeInspector
5
5
  # @param definition_store [Rucoa::DefinitionStore]
6
6
  # @param node [Rucoa::Node]
7
- def initialize(definition_store:, node:)
7
+ def initialize(
8
+ definition_store:,
9
+ node:
10
+ )
8
11
  @definition_store = definition_store
9
12
  @node = node
10
13
  end
@@ -90,22 +93,14 @@ module Rucoa
90
93
  def constant_definition
91
94
  return unless @node.is_a?(Nodes::ConstNode)
92
95
 
93
- module_nesting = @node.module_nesting
94
- candidate_fully_qualified_names = module_nesting.flat_map do |module_nesting_fully_qualified_name|
95
- [
96
- module_nesting_fully_qualified_name
97
- # TODO: *ancestors_of(module_nesting_fully_qualified_name)
98
- ].map do |fully_qualified_name|
99
- [
100
- fully_qualified_name,
101
- @node.chained_name
102
- ].join('::')
103
- end
104
- end + [@node.chained_name]
105
- candidate_fully_qualified_names.find do |candidate_fully_qualified_name|
106
- definition = @definition_store.find_definition_by_fully_qualified_name(candidate_fully_qualified_name)
107
- break definition if definition
108
- end
96
+ @definition_store.find_definition_by_qualified_name(
97
+ @definition_store.resolve_constant(
98
+ UnqualifiedName.new(
99
+ chained_name: @node.chained_name,
100
+ module_nesting: @node.module_nesting
101
+ )
102
+ )
103
+ )
109
104
  end
110
105
 
111
106
  # @return [Boolean]
@@ -114,16 +109,16 @@ module Rucoa
114
109
  end
115
110
 
116
111
  # @return [String, nil]
117
- def nearest_def_fully_qualified_name
118
- @node.each_ancestor(:def).first&.fully_qualified_name
112
+ def nearest_def_qualified_name
113
+ @node.each_ancestor(:def).first&.qualified_name
119
114
  end
120
115
 
121
116
  # @return [Array<String>]
122
117
  def return_types_for_lvar
123
- fully_qualified_name = nearest_def_fully_qualified_name
124
- return [] unless fully_qualified_name
118
+ qualified_name = nearest_def_qualified_name
119
+ return [] unless qualified_name
125
120
 
126
- definition = @definition_store.find_definition_by_fully_qualified_name(fully_qualified_name)
121
+ definition = @definition_store.find_definition_by_qualified_name(qualified_name)
127
122
  return [] unless definition
128
123
 
129
124
  definition.parameters.select do |parameter|
@@ -37,7 +37,10 @@ module Rucoa
37
37
  # @param types [Array<Symbol>]
38
38
  # @return [Rucoa::Nodes::Base] if a block is given
39
39
  # @return [Enumerator] if no block is given
40
- def each_ancestor(*types, &block)
40
+ def each_ancestor(
41
+ *types,
42
+ &block
43
+ )
41
44
  return to_enum(__method__, *types) unless block
42
45
 
43
46
  visit_ancestors(types, &block)
@@ -47,7 +50,10 @@ module Rucoa
47
50
  # @param types [Array<Symbol>]
48
51
  # @return [Rucoa::Nodes::Base] if a block is given
49
52
  # @return [Enumerator] if no block is given
50
- def each_child_node(*types, &block)
53
+ def each_child_node(
54
+ *types,
55
+ &block
56
+ )
51
57
  return to_enum(__method__, *types) unless block
52
58
 
53
59
  visit_child_node(types, &block)
@@ -57,7 +63,10 @@ module Rucoa
57
63
  # @param types [Array<Symbol>]
58
64
  # @return [Rucoa::Nodes::Base] if a block is given
59
65
  # @return [Enumerator] if no block is given
60
- def each_descendant(*types, &block)
66
+ def each_descendant(
67
+ *types,
68
+ &block
69
+ )
61
70
  return to_enum(__method__, *types) unless block
62
71
 
63
72
  visit_descendants(types, &block)
@@ -68,7 +77,11 @@ module Rucoa
68
77
  # Some nodes change their type depending on the context.
69
78
  # For example, `const` node can be `casgn` node.
70
79
  # @return [Rucoa::Nodes::Base]
71
- def updated(type = nil, children = nil, properties = {})
80
+ def updated(
81
+ type = nil,
82
+ children = nil,
83
+ properties = {}
84
+ )
72
85
  properties[:location] ||= @location
73
86
  ParserBuilder.node_class_for(type || @type).new(
74
87
  type || @type,
@@ -137,7 +150,7 @@ module Rucoa
137
150
  # )
138
151
  # expect(node.module_nesting).to eq(['Foo::Bar', 'Foo'])
139
152
  def module_nesting
140
- each_ancestor(:class, :module).map(&:fully_qualified_name)
153
+ each_ancestor(:class, :module).map(&:qualified_name)
141
154
  end
142
155
 
143
156
  protected
@@ -145,7 +158,10 @@ module Rucoa
145
158
  # Visit all descendants.
146
159
  # @param types [Array<Symbol>]
147
160
  # @return [void]
148
- def visit_descendants(types, &block)
161
+ def visit_descendants(
162
+ types,
163
+ &block
164
+ )
149
165
  each_child_node do |child|
150
166
  yield(child) if types.empty? || types.include?(child.type)
151
167
  child.visit_descendants(types, &block)
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rucoa
4
+ module Nodes
5
+ class BeginNode < Base
6
+ end
7
+ end
8
+ end
@@ -3,7 +3,7 @@
3
3
  module Rucoa
4
4
  module Nodes
5
5
  class CasgnNode < Base
6
- include NodeConcerns::NameFullyQualifiable
6
+ include NodeConcerns::QualifiedName
7
7
 
8
8
  # @return [String]
9
9
  def name
@@ -3,7 +3,8 @@
3
3
  module Rucoa
4
4
  module Nodes
5
5
  class ClassNode < Base
6
- include NodeConcerns::NameFullyQualifiable
6
+ include NodeConcerns::Body
7
+ include NodeConcerns::QualifiedName
7
8
 
8
9
  # @return [String]
9
10
  def name
@@ -5,16 +5,25 @@ module Rucoa
5
5
  class ConstNode < Base
6
6
  # @return [String]
7
7
  # @example returns "A" for "A"
8
- # node = Rucoa::Parser.call(
9
- # path: '/path/to/example.rb',
10
- # text: 'A'
8
+ # node = Rucoa::Source.new(
9
+ # content: <<~RUBY,
10
+ # A
11
+ # RUBY
12
+ # uri: 'file:///path/to/a.rb'
11
13
  # ).root_node
12
14
  # expect(node.name).to eq('A')
13
15
  # @example returns "B" for "A::B"
14
- # node = Rucoa::Parser.call(
15
- # path: '/path/to/example.rb',
16
- # text: 'A::B'
17
- # ).root_node
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
+ # )
18
27
  # expect(node.name).to eq('B')
19
28
  def name
20
29
  children[1].to_s
@@ -22,16 +31,25 @@ module Rucoa
22
31
 
23
32
  # @return [String]
24
33
  # @example returns "A" for "A"
25
- # node = Rucoa::Parser.call(
26
- # path: '/path/to/example.rb',
27
- # text: 'A'
34
+ # node = Rucoa::Source.new(
35
+ # content: <<~RUBY,
36
+ # A
37
+ # RUBY
38
+ # uri: 'file:///path/to/a.rb'
28
39
  # ).root_node
29
40
  # expect(node.chained_name).to eq('A')
30
41
  # @example returns "A::B" for "A::B"
31
- # node = Rucoa::Parser.call(
32
- # path: '/path/to/example.rb',
33
- # text: 'A::B'
34
- # ).root_node
42
+ # node = Rucoa::Source.new(
43
+ # content: <<~RUBY,
44
+ # A::B
45
+ # RUBY
46
+ # uri: 'file:///path/to/a.rb'
47
+ # ).node_at(
48
+ # Rucoa::Position.new(
49
+ # column: 4,
50
+ # line: 1
51
+ # )
52
+ # )
35
53
  # expect(node.chained_name).to eq('A::B')
36
54
  def chained_name
37
55
  case receiver
@@ -70,7 +88,7 @@ module Rucoa
70
88
  # )
71
89
  # expect(node.module_nesting).to eq(['Foo::Bar', 'Foo'])
72
90
  def module_nesting
73
- each_ancestor(:class, :module).map(&:fully_qualified_name)
91
+ each_ancestor(:class, :module).map(&:qualified_name)
74
92
  end
75
93
 
76
94
  private
@@ -44,8 +44,8 @@ module Rucoa
44
44
  # line: 3
45
45
  # )
46
46
  # )
47
- # expect(node.fully_qualified_name).to eq('Foo::Bar#baz')
48
- def fully_qualified_name
47
+ # expect(node.qualified_name).to eq('Foo::Bar#baz')
48
+ def qualified_name
49
49
  [
50
50
  namespace,
51
51
  method_marker,
@@ -4,7 +4,7 @@ module Rucoa
4
4
  module Nodes
5
5
  class DefsNode < Base
6
6
  # @return [String]
7
- def fully_qualified_name
7
+ def qualified_name
8
8
  [
9
9
  namespace,
10
10
  method_marker,
@@ -3,7 +3,8 @@
3
3
  module Rucoa
4
4
  module Nodes
5
5
  class ModuleNode < Base
6
- include NodeConcerns::NameFullyQualifiable
6
+ include NodeConcerns::Body
7
+ include NodeConcerns::QualifiedName
7
8
 
8
9
  # @return [String]
9
10
  def name
data/lib/rucoa/nodes.rb CHANGED
@@ -3,9 +3,10 @@
3
3
  module Rucoa
4
4
  module Nodes
5
5
  autoload :Base, 'rucoa/nodes/base'
6
+ autoload :BeginNode, 'rucoa/nodes/begin_node'
7
+ autoload :CasgnNode, 'rucoa/nodes/casgn_node'
6
8
  autoload :CbaseNode, 'rucoa/nodes/cbase_node'
7
9
  autoload :ClassNode, 'rucoa/nodes/class_node'
8
- autoload :CasgnNode, 'rucoa/nodes/casgn_node'
9
10
  autoload :ConstNode, 'rucoa/nodes/const_node'
10
11
  autoload :DefNode, 'rucoa/nodes/def_node'
11
12
  autoload :DefsNode, 'rucoa/nodes/defs_node'
data/lib/rucoa/parser.rb CHANGED
@@ -5,47 +5,47 @@ require 'parser/current'
5
5
  module Rucoa
6
6
  class Parser
7
7
  class << self
8
- # @param path [String]
9
8
  # @param text [String]
9
+ # @param uri [String]
10
10
  # @return [Rucoa::ParseResult]
11
11
  # @example returns non-failed parse result for valid Ruby source
12
12
  # result = Rucoa::Parser.call(
13
- # path: '/path/to/foo.rb',
14
- # text: 'foo'
13
+ # text: 'foo',
14
+ # uri: 'file:///path/to/foo.rb'
15
15
  # )
16
16
  # expect(result).not_to be_failed
17
17
  # @example returns failed parse result for invalid Ruby source
18
18
  # result = Rucoa::Parser.call(
19
- # path: '/path/to/foo.rb',
20
- # text: 'foo('
19
+ # text: 'foo(',
20
+ # uri: 'file:///path/to/foo.rb'
21
21
  # )
22
22
  # expect(result).to be_failed
23
23
  def call(
24
- path:,
25
- text:
24
+ text:,
25
+ uri:
26
26
  )
27
27
  new(
28
- path: path,
29
- text: text
28
+ text: text,
29
+ uri: uri
30
30
  ).call
31
31
  end
32
32
  end
33
33
 
34
- # @param path [String]
35
34
  # @param text [String]
35
+ # @param uri [String]
36
36
  def initialize(
37
- path:,
38
- text:
37
+ text:,
38
+ uri:
39
39
  )
40
- @path = path
41
40
  @text = text
41
+ @uri = uri
42
42
  end
43
43
 
44
44
  # @return [Rucoa::ParseResult]
45
45
  def call
46
46
  root_node, comments = parser.parse_with_comments(
47
47
  ::Parser::Source::Buffer.new(
48
- @path,
48
+ @uri,
49
49
  source: @text
50
50
  )
51
51
  )
@@ -5,6 +5,7 @@ require 'parser/current'
5
5
  module Rucoa
6
6
  class ParserBuilder < ::Parser::Builders::Default
7
7
  NODE_CLASS_BY_TYPE = {
8
+ begin: Nodes::BeginNode,
8
9
  casgn: Nodes::CasgnNode,
9
10
  cbase: Nodes::CbaseNode,
10
11
  class: Nodes::ClassNode,
@@ -28,7 +29,11 @@ module Rucoa
28
29
  end
29
30
 
30
31
  # @note Override.
31
- def n(type, children, source_map)
32
+ def n(
33
+ type,
34
+ children,
35
+ source_map
36
+ )
32
37
  self.class.node_class_for(type).new(
33
38
  type,
34
39
  children,
@@ -39,11 +39,20 @@ module Rucoa
39
39
 
40
40
  # @param column [Integer] 0-origin column number
41
41
  # @param line [Integer] 1-origin line number
42
- def initialize(column: 0, line: 1)
42
+ def initialize(
43
+ column: 0,
44
+ line: 1
45
+ )
43
46
  @column = column
44
47
  @line = line
45
48
  end
46
49
 
50
+ # @param other [Rucoa::Position]
51
+ # @return [Boolean]
52
+ def ==(other)
53
+ column == other.column && line == other.line
54
+ end
55
+
47
56
  # @param text [String]
48
57
  # @return [Integer]
49
58
  def to_index_of(text)
data/lib/rucoa/range.rb CHANGED
@@ -31,12 +31,22 @@ module Rucoa
31
31
  # @param beginning [Rucoa::Position]
32
32
  # @param ending [Ruoca::Position]
33
33
  # @param including_ending [Boolean]
34
- def initialize(beginning, ending, including_ending: true)
34
+ def initialize(
35
+ beginning,
36
+ ending,
37
+ including_ending: true
38
+ )
35
39
  @beginning = beginning
36
40
  @ending = ending
37
41
  @including_ending = including_ending
38
42
  end
39
43
 
44
+ # @param other [Rucoa::Range]
45
+ # @return [Boolean]
46
+ def ==(other)
47
+ beginning == other.beginning && ending == other.ending
48
+ end
49
+
40
50
  # @param range [Rucoa::Range]
41
51
  # @return [Boolean]
42
52
  # @example returns true when the range is contained in self
@@ -2,43 +2,28 @@
2
2
 
3
3
  module Rucoa
4
4
  module Rbs
5
- class ClassDefinitionMapper
6
- class << self
7
- # @param declaration [RBS::AST::Declarations::Class]
8
- # @return [Rucoa::Definitions::ClassDefinition]
9
- def call(declaration:)
10
- new(declaration: declaration).call
11
- end
12
- end
13
-
14
- # @param declaration [RBS::AST::Declarations::Class]
15
- def initialize(declaration:)
16
- @declaration = declaration
17
- end
18
-
5
+ class ClassDefinitionMapper < ModuleDefinitionMapper
19
6
  # @return [Rucoa::Definitions::ClassDefinition]
7
+ # @example supports `include`
8
+ # definition_store = Rucoa::DefinitionStore.new
9
+ # definition_store.bulk_add(Rucoa::DefinitionArchiver.load)
10
+ # subject = definition_store.find_definition_by_qualified_name('Array')
11
+ # expect(subject.included_module_qualified_names).to include('Enumerable')
20
12
  def call
21
13
  Definitions::ClassDefinition.new(
22
- fully_qualified_name: fully_qualified_name,
23
- source_path: source_path,
24
- super_class_fully_qualified_name: super_class_fully_qualified_name
14
+ description: description,
15
+ included_module_qualified_names: included_module_qualified_names,
16
+ location: location,
17
+ prepended_module_qualified_names: prepended_module_qualified_names,
18
+ qualified_name: qualified_name,
19
+ super_class_qualified_name: super_class_qualified_name
25
20
  )
26
21
  end
27
22
 
28
23
  private
29
24
 
30
- # @return [String]
31
- def fully_qualified_name
32
- @declaration.name.to_s.delete_prefix('::')
33
- end
34
-
35
- # @return [String]
36
- def source_path
37
- @declaration.location.name
38
- end
39
-
40
25
  # @return [String, nil]
41
- def super_class_fully_qualified_name
26
+ def super_class_qualified_name
42
27
  @declaration.super_class&.name&.to_s&.delete_prefix('::')
43
28
  end
44
29
  end
@@ -19,21 +19,27 @@ module Rucoa
19
19
  # @return [Rucoa::Definitions::ConstantDefinition]
20
20
  def call
21
21
  Definitions::ConstantDefinition.new(
22
- fully_qualified_name: fully_qualified_name,
23
- source_path: source_path
22
+ description: description,
23
+ location: location,
24
+ qualified_name: qualified_name
24
25
  )
25
26
  end
26
27
 
27
28
  private
28
29
 
30
+ # @return [String, nil]
31
+ def description
32
+ @declaration.comment&.string&.sub(/\A\s*<!--.*-->\s*/m, '')
33
+ end
34
+
29
35
  # @return [String]
30
- def fully_qualified_name
36
+ def qualified_name
31
37
  @declaration.name.to_s.delete_prefix('::')
32
38
  end
33
39
 
34
- # @return [String]
35
- def source_path
36
- @declaration.location.name
40
+ # @return [Rucoa::Location]
41
+ def location
42
+ Location.from_rbs_location(@declaration.location)
37
43
  end
38
44
  end
39
45
  end
@@ -7,7 +7,10 @@ module Rucoa
7
7
  # @param declaration [RBS::AST::Declarations::Class, RBS::AST::Declarations::Module]
8
8
  # @param method_definition [RBS::AST::Members::MethodDefinition]
9
9
  # @return [Rucoa::Definitions::MethodDefinition]
10
- def call(declaration:, method_definition:)
10
+ def call(
11
+ declaration:,
12
+ method_definition:
13
+ )
11
14
  new(
12
15
  declaration: declaration,
13
16
  method_definition: method_definition
@@ -17,7 +20,10 @@ module Rucoa
17
20
 
18
21
  # @param declaration [RBS::AST::Declarations::Class, RBS::AST::Declarations::Module]
19
22
  # @param method_definition [RBS::AST::Members::MethodDefinition]
20
- def initialize(declaration:, method_definition:)
23
+ def initialize(
24
+ declaration:,
25
+ method_definition:
26
+ )
21
27
  @declaration = declaration
22
28
  @method_definition = method_definition
23
29
  end
@@ -27,9 +33,9 @@ module Rucoa
27
33
  Definitions::MethodDefinition.new(
28
34
  description: description,
29
35
  kind: kind,
36
+ location: location,
30
37
  method_name: method_name,
31
38
  namespace: namespace,
32
- source_path: source_path,
33
39
  types: types
34
40
  )
35
41
  end
@@ -65,9 +71,9 @@ module Rucoa
65
71
  @method_definition.kind
66
72
  end
67
73
 
68
- # @return [String]
69
- def source_path
70
- @declaration.location.name
74
+ # @return [Rucoa::Location]
75
+ def location
76
+ Location.from_rbs_location(@method_definition.location)
71
77
  end
72
78
 
73
79
  class MethodTypeMapper
@@ -19,21 +19,49 @@ module Rucoa
19
19
  # @return [Rucoa::Definitions::ModuleDefinition]
20
20
  def call
21
21
  Definitions::ModuleDefinition.new(
22
- fully_qualified_name: fully_qualified_name,
23
- source_path: source_path
22
+ description: description,
23
+ included_module_qualified_names: included_module_qualified_names,
24
+ location: location,
25
+ prepended_module_qualified_names: prepended_module_qualified_names,
26
+ qualified_name: qualified_name
24
27
  )
25
28
  end
26
29
 
27
30
  private
28
31
 
32
+ # @return [String, nil]
33
+ def description
34
+ @declaration.comment&.string&.sub(/\A\s*<!--.*-->\s*/m, '')
35
+ end
36
+
29
37
  # @return [String]
30
- def fully_qualified_name
38
+ def qualified_name
31
39
  @declaration.name.to_s.delete_prefix('::')
32
40
  end
33
41
 
34
- # @return [String]
35
- def source_path
36
- @declaration.location.name
42
+ # @return [Rucoa::Location]
43
+ def location
44
+ Location.from_rbs_location(@declaration.location)
45
+ end
46
+
47
+ # @return [Array<String>]
48
+ def included_module_qualified_names
49
+ @declaration.members.filter_map do |member|
50
+ case member
51
+ when ::RBS::AST::Members::Include
52
+ member.name.to_s.delete_prefix('::')
53
+ end
54
+ end
55
+ end
56
+
57
+ # @return [Array<String>]
58
+ def prepended_module_qualified_names
59
+ @declaration.members.filter_map do |member|
60
+ case member
61
+ when ::RBS::AST::Members::Prepend
62
+ member.name.to_s.delete_prefix('::')
63
+ end
64
+ end
37
65
  end
38
66
  end
39
67
  end
@@ -41,7 +41,10 @@ module Rucoa
41
41
  # @param file [String]
42
42
  # @param offenses [Array<RuboCop::Cop::Offense>]
43
43
  # @return [void]
44
- def file_finished(file, offenses)
44
+ def file_finished(
45
+ file,
46
+ offenses
47
+ )
45
48
  @offenses = offenses
46
49
  super
47
50
  end
data/lib/rucoa/server.rb CHANGED
@@ -83,7 +83,10 @@ module Rucoa
83
83
  # @yieldparam response [Hash]
84
84
  # @param message [Hash]
85
85
  # @return [void]
86
- def write(message, &block)
86
+ def write(
87
+ message,
88
+ &block
89
+ )
87
90
  if block
88
91
  write_server_request(message, &block)
89
92
  else
@@ -139,7 +142,10 @@ module Rucoa
139
142
 
140
143
  # @param message [Hash]
141
144
  # @return [void]
142
- def write_server_request(message, &block)
145
+ def write_server_request(
146
+ message,
147
+ &block
148
+ )
143
149
  message = message.merge('id' => @server_request_id)
144
150
  debug do
145
151
  {