rucoa 0.8.0 → 0.10.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 -0
- data/Gemfile.lock +8 -8
- data/data/definitions_ruby_3_1 +0 -0
- data/lib/rucoa/configuration.rb +4 -1
- data/lib/rucoa/definition_store.rb +268 -75
- data/lib/rucoa/definitions/base.rb +14 -3
- data/lib/rucoa/definitions/class_definition.rb +20 -4
- data/lib/rucoa/definitions/constant_definition.rb +31 -19
- data/lib/rucoa/definitions/method_definition.rb +44 -52
- data/lib/rucoa/definitions/method_parameter_definition.rb +4 -1
- data/lib/rucoa/definitions/module_definition.rb +39 -0
- data/lib/rucoa/handler_concerns/diagnostics_publishable.rb +14 -3
- data/lib/rucoa/handlers/base.rb +12 -3
- data/lib/rucoa/handlers/initialized_handler.rb +33 -5
- data/lib/rucoa/handlers/text_document_completion_handler.rb +1 -1
- data/lib/rucoa/handlers/text_document_definition_handler.rb +3 -99
- data/lib/rucoa/handlers/text_document_did_open_handler.rb +1 -4
- data/lib/rucoa/handlers/text_document_hover_handler.rb +21 -13
- data/lib/rucoa/handlers/text_document_selection_range_handler.rb +8 -2
- data/lib/rucoa/location.rb +37 -0
- data/lib/rucoa/node_concerns/body.rb +24 -0
- data/lib/rucoa/node_concerns/{name_full_qualifiable.rb → qualified_name.rb} +2 -2
- data/lib/rucoa/node_concerns.rb +2 -1
- data/lib/rucoa/node_inspector.rb +22 -26
- data/lib/rucoa/nodes/base.rb +51 -10
- data/lib/rucoa/nodes/begin_node.rb +8 -0
- data/lib/rucoa/nodes/casgn_node.rb +1 -1
- data/lib/rucoa/nodes/cbase_node.rb +8 -0
- data/lib/rucoa/nodes/class_node.rb +63 -1
- data/lib/rucoa/nodes/const_node.rb +64 -5
- data/lib/rucoa/nodes/def_node.rb +11 -9
- data/lib/rucoa/nodes/defs_node.rb +21 -0
- data/lib/rucoa/nodes/lvar_node.rb +2 -1
- data/lib/rucoa/nodes/module_node.rb +2 -1
- data/lib/rucoa/nodes/send_node.rb +14 -10
- data/lib/rucoa/nodes.rb +3 -1
- data/lib/rucoa/parse_result.rb +29 -0
- data/lib/rucoa/parser.rb +40 -8
- data/lib/rucoa/parser_builder.rb +7 -1
- data/lib/rucoa/position.rb +10 -1
- data/lib/rucoa/range.rb +11 -1
- data/lib/rucoa/rbs/class_definition_mapper.rb +13 -28
- data/lib/rucoa/rbs/constant_definition_mapper.rb +12 -6
- data/lib/rucoa/rbs/method_definition_mapper.rb +12 -6
- data/lib/rucoa/rbs/module_definition_mapper.rb +34 -6
- data/lib/rucoa/rubocop/autocorrector.rb +2 -2
- data/lib/rucoa/rubocop/investigator.rb +6 -3
- data/lib/rucoa/server.rb +9 -3
- data/lib/rucoa/source.rb +57 -27
- data/lib/rucoa/source_store.rb +0 -13
- data/lib/rucoa/unqualified_name.rb +9 -0
- data/lib/rucoa/version.rb +1 -1
- data/lib/rucoa/yard/definition_generators/attribute_reader_definition_generator.rb +60 -0
- data/lib/rucoa/yard/definition_generators/attribute_writer_definition_generator.rb +60 -0
- data/lib/rucoa/yard/definition_generators/base.rb +117 -0
- data/lib/rucoa/yard/definition_generators/class_definition_generator.rb +66 -0
- data/lib/rucoa/yard/definition_generators/constant_assignment_definition_generator.rb +29 -0
- data/lib/rucoa/yard/definition_generators/method_definition_generator.rb +47 -0
- data/lib/rucoa/yard/definition_generators/module_definition_generator.rb +62 -0
- data/lib/rucoa/yard/definition_generators.rb +15 -0
- data/lib/rucoa/yard/definitions_loader.rb +44 -65
- data/lib/rucoa/yard/type.rb +46 -0
- data/lib/rucoa/yard.rb +2 -1
- data/lib/rucoa.rb +4 -1
- metadata +18 -4
- data/lib/rucoa/yard/method_definition_mapper.rb +0 -215
@@ -0,0 +1,117 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rucoa
|
4
|
+
module Yard
|
5
|
+
module DefinitionGenerators
|
6
|
+
class Base
|
7
|
+
class << self
|
8
|
+
# @param comment [String]
|
9
|
+
# @param node [Rucoa::Nodes::Base]
|
10
|
+
# @return [Array<Rucoa::Definitions::Base>]
|
11
|
+
def call(
|
12
|
+
comment:,
|
13
|
+
node:
|
14
|
+
)
|
15
|
+
new(
|
16
|
+
comment: comment,
|
17
|
+
node: node
|
18
|
+
).call
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# @param comment [String]
|
23
|
+
# @param node [Rucoa::Nodes::Base]
|
24
|
+
def initialize(
|
25
|
+
comment:,
|
26
|
+
node:
|
27
|
+
)
|
28
|
+
@comment = comment
|
29
|
+
@node = node
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [Array<Rucoa::Definitions::Base>]
|
33
|
+
def call
|
34
|
+
raise ::NotImplementedError
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
# @return [String]
|
40
|
+
def description
|
41
|
+
docstring_parser.to_docstring.to_s
|
42
|
+
end
|
43
|
+
|
44
|
+
# @return [YARD::DocstringParser]
|
45
|
+
def docstring_parser
|
46
|
+
@docstring_parser ||= ::YARD::Logger.instance.enter_level(::Logger::FATAL) do
|
47
|
+
::YARD::Docstring.parser.parse(
|
48
|
+
@comment,
|
49
|
+
::YARD::CodeObjects::Base.new(:root, 'stub')
|
50
|
+
)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# @return [Rucoa::Location]
|
55
|
+
# @example returns source uri and entire range of target node
|
56
|
+
# definitions = Rucoa::Source.new(
|
57
|
+
# content: <<~RUBY,
|
58
|
+
# class Foo
|
59
|
+
# end
|
60
|
+
# RUBY
|
61
|
+
# uri: '/path/to/foo.rb'
|
62
|
+
# ).definitions
|
63
|
+
# expect(definitions[0].location).to eq(
|
64
|
+
# Rucoa::Location.new(
|
65
|
+
# range: Rucoa::Range.new(
|
66
|
+
# Rucoa::Position.new(
|
67
|
+
# column: 0,
|
68
|
+
# line: 1
|
69
|
+
# ),
|
70
|
+
# Rucoa::Position.new(
|
71
|
+
# column: 3,
|
72
|
+
# line: 2
|
73
|
+
# )
|
74
|
+
# ),
|
75
|
+
# uri: '/path/to/foo.rb'
|
76
|
+
# )
|
77
|
+
# )
|
78
|
+
def location
|
79
|
+
Location.from_rucoa_node(@node)
|
80
|
+
end
|
81
|
+
|
82
|
+
# @return [Array<String>]
|
83
|
+
# @example returns annotated return types if return tag is provided
|
84
|
+
# definitions = Rucoa::Source.new(
|
85
|
+
# content: <<~RUBY,
|
86
|
+
# # @return [String]
|
87
|
+
# def foo
|
88
|
+
# end
|
89
|
+
# RUBY
|
90
|
+
# uri: '/path/to/foo.rb'
|
91
|
+
# ).definitions
|
92
|
+
# expect(definitions[0].return_types).to eq(%w[String])
|
93
|
+
# @example returns Object if no return tag is provided
|
94
|
+
# definitions = Rucoa::Source.new(
|
95
|
+
# content: <<~RUBY,
|
96
|
+
# def foo
|
97
|
+
# end
|
98
|
+
# RUBY
|
99
|
+
# uri: '/path/to/foo.rb'
|
100
|
+
# ).definitions
|
101
|
+
# expect(definitions[0].return_types).to eq(%w[Object])
|
102
|
+
def return_types
|
103
|
+
types = docstring_parser.tags.select do |tag|
|
104
|
+
tag.tag_name == 'return'
|
105
|
+
end.flat_map(&:types).compact.map do |yard_type|
|
106
|
+
Type.new(yard_type).to_rucoa_type
|
107
|
+
end
|
108
|
+
if types.empty?
|
109
|
+
%w[Object]
|
110
|
+
else
|
111
|
+
types
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rucoa
|
4
|
+
module Yard
|
5
|
+
module DefinitionGenerators
|
6
|
+
class ClassDefinitionGenerator < ModuleDefinitionGenerator
|
7
|
+
# @example returns class definition for class node
|
8
|
+
# definitions = Rucoa::Source.new(
|
9
|
+
# content: <<~RUBY,
|
10
|
+
# class Foo
|
11
|
+
# end
|
12
|
+
# RUBY
|
13
|
+
# uri: '/path/to/foo.rb'
|
14
|
+
# ).definitions
|
15
|
+
# expect(definitions[0]).to be_a(Rucoa::Definitions::ClassDefinition)
|
16
|
+
# @example detects single-argument include
|
17
|
+
# definitions = Rucoa::Source.new(
|
18
|
+
# content: <<~RUBY,
|
19
|
+
# class Foo
|
20
|
+
# include Bar
|
21
|
+
# end
|
22
|
+
# RUBY
|
23
|
+
# uri: '/path/to/foo.rb'
|
24
|
+
# ).definitions
|
25
|
+
# expect(definitions[0].included_module_unqualified_names.map(&:chained_name)).to eq(%w[Bar])
|
26
|
+
# @example detects multi-arguments include
|
27
|
+
# definitions = Rucoa::Source.new(
|
28
|
+
# content: <<~RUBY,
|
29
|
+
# class Foo
|
30
|
+
# include Bar, Baz
|
31
|
+
# end
|
32
|
+
# RUBY
|
33
|
+
# uri: '/path/to/foo.rb'
|
34
|
+
# ).definitions
|
35
|
+
# expect(definitions[0].included_module_unqualified_names.map(&:chained_name)).to eq(%w[Bar Baz])
|
36
|
+
# @example ignores non-simple include
|
37
|
+
# definitions = Rucoa::Source.new(
|
38
|
+
# content: <<~RUBY,
|
39
|
+
# class Foo
|
40
|
+
# include foo
|
41
|
+
# end
|
42
|
+
# RUBY
|
43
|
+
# uri: '/path/to/foo.rb'
|
44
|
+
# ).definitions
|
45
|
+
# expect(definitions[0].included_module_unqualified_names.map(&:chained_name)).to eq([])
|
46
|
+
def call
|
47
|
+
return [] unless @node.is_a?(Nodes::ClassNode)
|
48
|
+
|
49
|
+
[
|
50
|
+
Definitions::ClassDefinition.new(
|
51
|
+
description: description,
|
52
|
+
included_module_unqualified_names: included_module_unqualified_names,
|
53
|
+
location: location,
|
54
|
+
prepended_module_unqualified_names: prepended_module_unqualified_names,
|
55
|
+
qualified_name: @node.qualified_name,
|
56
|
+
super_class_unqualified_name: UnqualifiedName.new(
|
57
|
+
chained_name: @node.super_class_chained_name,
|
58
|
+
module_nesting: @node.module_nesting
|
59
|
+
)
|
60
|
+
)
|
61
|
+
]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rucoa
|
4
|
+
module Yard
|
5
|
+
module DefinitionGenerators
|
6
|
+
class ConstantAssignmentDefinitionGenerator < Base
|
7
|
+
# @example returns constant definition for constant assignment node
|
8
|
+
# definitions = Rucoa::Source.new(
|
9
|
+
# content: <<~RUBY,
|
10
|
+
# Foo = 'foo'
|
11
|
+
# RUBY
|
12
|
+
# uri: '/path/to/foo.rb'
|
13
|
+
# ).definitions
|
14
|
+
# expect(definitions[0]).to be_a(Rucoa::Definitions::ConstantDefinition)
|
15
|
+
def call
|
16
|
+
return [] unless @node.is_a?(Nodes::CasgnNode)
|
17
|
+
|
18
|
+
[
|
19
|
+
Definitions::ConstantDefinition.new(
|
20
|
+
description: description,
|
21
|
+
location: location,
|
22
|
+
qualified_name: @node.qualified_name
|
23
|
+
)
|
24
|
+
]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rucoa
|
4
|
+
module Yard
|
5
|
+
module DefinitionGenerators
|
6
|
+
class MethodDefinitionGenerator < Base
|
7
|
+
# @example returns method definition for def node
|
8
|
+
# definitions = Rucoa::Source.new(
|
9
|
+
# content: <<~RUBY,
|
10
|
+
# def foo
|
11
|
+
# end
|
12
|
+
# RUBY
|
13
|
+
# uri: '/path/to/foo.rb'
|
14
|
+
# ).definitions
|
15
|
+
# expect(definitions[0]).to be_a(Rucoa::Definitions::MethodDefinition)
|
16
|
+
# @example returns method definition for defs node
|
17
|
+
# definitions = Rucoa::Source.new(
|
18
|
+
# content: <<~RUBY,
|
19
|
+
# def self.foo
|
20
|
+
# end
|
21
|
+
# RUBY
|
22
|
+
# uri: '/path/to/foo.rb'
|
23
|
+
# ).definitions
|
24
|
+
# expect(definitions[0]).to be_a(Rucoa::Definitions::MethodDefinition)
|
25
|
+
def call
|
26
|
+
return [] unless @node.is_a?(Nodes::DefNode) || @node.is_a?(Nodes::DefsNode)
|
27
|
+
|
28
|
+
[
|
29
|
+
Definitions::MethodDefinition.new(
|
30
|
+
description: description,
|
31
|
+
kind: @node.singleton? ? :singleton : :instance,
|
32
|
+
location: location,
|
33
|
+
method_name: @node.name,
|
34
|
+
namespace: @node.namespace,
|
35
|
+
types: return_types.map do |type|
|
36
|
+
Types::MethodType.new(
|
37
|
+
parameters_string: '', # TODO
|
38
|
+
return_type: type
|
39
|
+
)
|
40
|
+
end
|
41
|
+
)
|
42
|
+
]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rucoa
|
4
|
+
module Yard
|
5
|
+
module DefinitionGenerators
|
6
|
+
class ModuleDefinitionGenerator < Base
|
7
|
+
# @example returns module definition for module node
|
8
|
+
# definitions = Rucoa::Source.new(
|
9
|
+
# content: <<~RUBY,
|
10
|
+
# module Foo
|
11
|
+
# end
|
12
|
+
# RUBY
|
13
|
+
# uri: '/path/to/foo.rb'
|
14
|
+
# ).definitions
|
15
|
+
# expect(definitions[0]).to be_a(Rucoa::Definitions::ModuleDefinition)
|
16
|
+
def call
|
17
|
+
return [] unless @node.is_a?(Nodes::ModuleNode)
|
18
|
+
|
19
|
+
[
|
20
|
+
Definitions::ModuleDefinition.new(
|
21
|
+
description: description,
|
22
|
+
included_module_unqualified_names: included_module_unqualified_names,
|
23
|
+
location: location,
|
24
|
+
prepended_module_unqualified_names: prepended_module_unqualified_names,
|
25
|
+
qualified_name: @node.qualified_name
|
26
|
+
)
|
27
|
+
]
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
# @return [Array<Rucoa::UnqualifiedName>]
|
33
|
+
def included_module_unqualified_names
|
34
|
+
unqualified_names_for('include')
|
35
|
+
end
|
36
|
+
|
37
|
+
# @return [Array<Rucoa::UnqualifiedName>]
|
38
|
+
def prepended_module_unqualified_names
|
39
|
+
unqualified_names_for('prepend')
|
40
|
+
end
|
41
|
+
|
42
|
+
# @param method_name [String]
|
43
|
+
# @return [Array<Rucoa::UnqualifiedName>]
|
44
|
+
def unqualified_names_for(method_name)
|
45
|
+
@node.body_children.flat_map do |child|
|
46
|
+
next [] unless child.is_a?(Nodes::SendNode)
|
47
|
+
next [] unless child.name == method_name
|
48
|
+
|
49
|
+
child.arguments.filter_map do |argument|
|
50
|
+
next unless argument.is_a?(Nodes::ConstNode)
|
51
|
+
|
52
|
+
UnqualifiedName.new(
|
53
|
+
chained_name: argument.chained_name,
|
54
|
+
module_nesting: @node.module_nesting
|
55
|
+
)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rucoa
|
4
|
+
module Yard
|
5
|
+
module DefinitionGenerators
|
6
|
+
autoload :AttributeReaderDefinitionGenerator, 'rucoa/yard/definition_generators/attribute_reader_definition_generator'
|
7
|
+
autoload :AttributeWriterDefinitionGenerator, 'rucoa/yard/definition_generators/attribute_writer_definition_generator'
|
8
|
+
autoload :Base, 'rucoa/yard/definition_generators/base'
|
9
|
+
autoload :ClassDefinitionGenerator, 'rucoa/yard/definition_generators/class_definition_generator'
|
10
|
+
autoload :ConstantAssignmentDefinitionGenerator, 'rucoa/yard/definition_generators/constant_assignment_definition_generator'
|
11
|
+
autoload :MethodDefinitionGenerator, 'rucoa/yard/definition_generators/method_definition_generator'
|
12
|
+
autoload :ModuleDefinitionGenerator, 'rucoa/yard/definition_generators/module_definition_generator'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,84 +1,63 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'logger'
|
4
|
+
require 'set'
|
4
5
|
require 'yard'
|
5
6
|
|
6
7
|
module Rucoa
|
7
8
|
module Yard
|
8
9
|
class DefinitionsLoader
|
9
10
|
class << self
|
10
|
-
# @param
|
11
|
-
# @
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
# end
|
21
|
-
# end
|
22
|
-
# RUBY
|
23
|
-
# definitions = Rucoa::Yard::DefinitionsLoader.load_string(
|
24
|
-
# content: content,
|
25
|
-
# path: '/path/to/foo.rb'
|
26
|
-
# )
|
27
|
-
# expect(definitions.size).to eq(2)
|
28
|
-
# expect(definitions[1].full_qualified_name).to eq('Foo#foo')
|
29
|
-
# expect(definitions[1].source_path).to eq('/path/to/foo.rb')
|
30
|
-
# expect(definitions[1].description).to eq('Return given argument as an Integer.')
|
31
|
-
# expect(definitions[1].return_types).to eq(%w[Integer])
|
32
|
-
def load_string(content:, path:)
|
33
|
-
load(path: path) do
|
34
|
-
::YARD.parse_string(content)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# @param globs [String]
|
39
|
-
# @return [Array<Rucoa::Definitions::Base>]
|
40
|
-
def load_globs(globs:)
|
41
|
-
load do
|
42
|
-
::YARD.parse(globs)
|
43
|
-
end
|
11
|
+
# @param associations [Hash]
|
12
|
+
# @param root_node [Rucoa::Nodes::Base]
|
13
|
+
def call(
|
14
|
+
associations:,
|
15
|
+
root_node:
|
16
|
+
)
|
17
|
+
new(
|
18
|
+
associations: associations,
|
19
|
+
root_node: root_node
|
20
|
+
).call
|
44
21
|
end
|
22
|
+
end
|
45
23
|
|
46
|
-
|
24
|
+
# @param associations [Hash]
|
25
|
+
# @param root_node [Rucoa::Nodes::Base]
|
26
|
+
def initialize(
|
27
|
+
associations:,
|
28
|
+
root_node:
|
29
|
+
)
|
30
|
+
@associations = associations
|
31
|
+
@root_node = root_node
|
32
|
+
end
|
47
33
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
34
|
+
# @return [Array<Rucoa::Definition::Base>]
|
35
|
+
def call
|
36
|
+
[
|
37
|
+
@root_node,
|
38
|
+
*@root_node.descendants
|
39
|
+
].flat_map do |node|
|
40
|
+
[
|
41
|
+
DefinitionGenerators::ClassDefinitionGenerator,
|
42
|
+
DefinitionGenerators::ConstantAssignmentDefinitionGenerator,
|
43
|
+
DefinitionGenerators::MethodDefinitionGenerator,
|
44
|
+
DefinitionGenerators::ModuleDefinitionGenerator,
|
45
|
+
DefinitionGenerators::AttributeReaderDefinitionGenerator,
|
46
|
+
DefinitionGenerators::AttributeWriterDefinitionGenerator
|
47
|
+
].flat_map do |generator|
|
48
|
+
generator.call(
|
49
|
+
comment: comment_for(node),
|
50
|
+
node: node
|
58
51
|
)
|
59
|
-
when ::YARD::CodeObjects::ModuleObject
|
60
|
-
Definitions::ModuleDefinition.new(
|
61
|
-
full_qualified_name: code_object.path,
|
62
|
-
source_path: path || code_object.file
|
63
|
-
)
|
64
|
-
when ::YARD::CodeObjects::MethodObject
|
65
|
-
MethodDefinitionMapper.call(code_object, path: path)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
# @param path [String, nil]
|
70
|
-
# @return [Array<Rucoa::Definitions::Base>]
|
71
|
-
def load(path: nil, &block)
|
72
|
-
::YARD::Registry.clear
|
73
|
-
quietly(&block)
|
74
|
-
::YARD::Registry.all.filter_map do |code_object|
|
75
|
-
map(code_object, path: path)
|
76
52
|
end
|
77
53
|
end
|
54
|
+
end
|
78
55
|
|
79
|
-
|
80
|
-
|
81
|
-
|
56
|
+
# @return [String]
|
57
|
+
def comment_for(node)
|
58
|
+
@associations[node.location].map do |parser_comment|
|
59
|
+
parser_comment.text.gsub(/^#\s*/m, '')
|
60
|
+
end.join("\n")
|
82
61
|
end
|
83
62
|
end
|
84
63
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rucoa
|
4
|
+
module Yard
|
5
|
+
class Type
|
6
|
+
# @param value [String]
|
7
|
+
def initialize(value)
|
8
|
+
@value = value
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [String]
|
12
|
+
# @example scrubs "Array<String>" to "Array"
|
13
|
+
# yard_type = Rucoa::Yard::Type.new(
|
14
|
+
# 'Array<String>'
|
15
|
+
# )
|
16
|
+
# expect(yard_type.to_rucoa_type).to eq('Array')
|
17
|
+
# @example scrubs "Array(String, Integer)" to "Array"
|
18
|
+
# yard_type = Rucoa::Yard::Type.new(
|
19
|
+
# 'Array(String, Integer)'
|
20
|
+
# )
|
21
|
+
# expect(yard_type.to_rucoa_type).to eq('Array')
|
22
|
+
# @example scrubs "::Array" to "Array"
|
23
|
+
# yard_type = Rucoa::Yard::Type.new(
|
24
|
+
# '::Array'
|
25
|
+
# )
|
26
|
+
# expect(yard_type.to_rucoa_type).to eq('Array')
|
27
|
+
# @example scrubs "Hash{Symbol => Object}" to "Hash"
|
28
|
+
# yard_type = Rucoa::Yard::Type.new(
|
29
|
+
# 'Hash{Symbol => Object}'
|
30
|
+
# )
|
31
|
+
# expect(yard_type.to_rucoa_type).to eq('Hash')
|
32
|
+
# @example scrubs "Array<Array<Integer>>" to "Array"
|
33
|
+
# yard_type = Rucoa::Yard::Type.new(
|
34
|
+
# 'Array<Array<Integer>>'
|
35
|
+
# )
|
36
|
+
# expect(yard_type.to_rucoa_type).to eq('Array')
|
37
|
+
def to_rucoa_type
|
38
|
+
@value
|
39
|
+
.delete_prefix('::')
|
40
|
+
.gsub(/<.+>/, '')
|
41
|
+
.gsub(/\{.+\}/, '')
|
42
|
+
.gsub(/\(.+\)/, '')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/rucoa/yard.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
module Rucoa
|
4
4
|
module Yard
|
5
|
+
autoload :DefinitionGenerators, 'rucoa/yard/definition_generators'
|
5
6
|
autoload :DefinitionsLoader, 'rucoa/yard/definitions_loader'
|
6
|
-
autoload :
|
7
|
+
autoload :Type, 'rucoa/yard/type'
|
7
8
|
end
|
8
9
|
end
|
data/lib/rucoa.rb
CHANGED
@@ -6,16 +6,18 @@ module Rucoa
|
|
6
6
|
autoload :Cli, 'rucoa/cli'
|
7
7
|
autoload :Configuration, 'rucoa/configuration'
|
8
8
|
autoload :DefinitionArchiver, 'rucoa/definition_archiver'
|
9
|
-
autoload :Definitions, 'rucoa/definitions'
|
10
9
|
autoload :DefinitionStore, 'rucoa/definition_store'
|
10
|
+
autoload :Definitions, 'rucoa/definitions'
|
11
11
|
autoload :Errors, 'rucoa/errors'
|
12
12
|
autoload :HandlerConcerns, 'rucoa/handler_concerns'
|
13
13
|
autoload :Handlers, 'rucoa/handlers'
|
14
|
+
autoload :Location, 'rucoa/location'
|
14
15
|
autoload :MessageReader, 'rucoa/message_reader'
|
15
16
|
autoload :MessageWriter, 'rucoa/message_writer'
|
16
17
|
autoload :NodeConcerns, 'rucoa/node_concerns'
|
17
18
|
autoload :NodeInspector, 'rucoa/node_inspector'
|
18
19
|
autoload :Nodes, 'rucoa/nodes'
|
20
|
+
autoload :ParseResult, 'rucoa/parse_result'
|
19
21
|
autoload :Parser, 'rucoa/parser'
|
20
22
|
autoload :ParserBuilder, 'rucoa/parser_builder'
|
21
23
|
autoload :Position, 'rucoa/position'
|
@@ -26,5 +28,6 @@ module Rucoa
|
|
26
28
|
autoload :Source, 'rucoa/source'
|
27
29
|
autoload :SourceStore, 'rucoa/source_store'
|
28
30
|
autoload :Types, 'rucoa/types'
|
31
|
+
autoload :UnqualifiedName, 'rucoa/unqualified_name'
|
29
32
|
autoload :Yard, 'rucoa/yard'
|
30
33
|
end
|
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.
|
4
|
+
version: 0.10.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-
|
11
|
+
date: 2022-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -123,14 +123,18 @@ files:
|
|
123
123
|
- lib/rucoa/handlers/text_document_selection_range_handler.rb
|
124
124
|
- lib/rucoa/handlers/text_document_signature_help_handler.rb
|
125
125
|
- lib/rucoa/handlers/workspace_did_change_configuration_handler.rb
|
126
|
+
- lib/rucoa/location.rb
|
126
127
|
- lib/rucoa/message_reader.rb
|
127
128
|
- lib/rucoa/message_writer.rb
|
128
129
|
- lib/rucoa/node_concerns.rb
|
129
|
-
- lib/rucoa/node_concerns/
|
130
|
+
- lib/rucoa/node_concerns/body.rb
|
131
|
+
- lib/rucoa/node_concerns/qualified_name.rb
|
130
132
|
- lib/rucoa/node_inspector.rb
|
131
133
|
- lib/rucoa/nodes.rb
|
132
134
|
- lib/rucoa/nodes/base.rb
|
135
|
+
- lib/rucoa/nodes/begin_node.rb
|
133
136
|
- lib/rucoa/nodes/casgn_node.rb
|
137
|
+
- lib/rucoa/nodes/cbase_node.rb
|
134
138
|
- lib/rucoa/nodes/class_node.rb
|
135
139
|
- lib/rucoa/nodes/const_node.rb
|
136
140
|
- lib/rucoa/nodes/def_node.rb
|
@@ -141,6 +145,7 @@ files:
|
|
141
145
|
- lib/rucoa/nodes/send_node.rb
|
142
146
|
- lib/rucoa/nodes/str_node.rb
|
143
147
|
- lib/rucoa/nodes/sym_node.rb
|
148
|
+
- lib/rucoa/parse_result.rb
|
144
149
|
- lib/rucoa/parser.rb
|
145
150
|
- lib/rucoa/parser_builder.rb
|
146
151
|
- lib/rucoa/position.rb
|
@@ -160,10 +165,19 @@ files:
|
|
160
165
|
- lib/rucoa/source_store.rb
|
161
166
|
- lib/rucoa/types.rb
|
162
167
|
- lib/rucoa/types/method_type.rb
|
168
|
+
- lib/rucoa/unqualified_name.rb
|
163
169
|
- lib/rucoa/version.rb
|
164
170
|
- lib/rucoa/yard.rb
|
171
|
+
- lib/rucoa/yard/definition_generators.rb
|
172
|
+
- lib/rucoa/yard/definition_generators/attribute_reader_definition_generator.rb
|
173
|
+
- lib/rucoa/yard/definition_generators/attribute_writer_definition_generator.rb
|
174
|
+
- lib/rucoa/yard/definition_generators/base.rb
|
175
|
+
- lib/rucoa/yard/definition_generators/class_definition_generator.rb
|
176
|
+
- lib/rucoa/yard/definition_generators/constant_assignment_definition_generator.rb
|
177
|
+
- lib/rucoa/yard/definition_generators/method_definition_generator.rb
|
178
|
+
- lib/rucoa/yard/definition_generators/module_definition_generator.rb
|
165
179
|
- lib/rucoa/yard/definitions_loader.rb
|
166
|
-
- lib/rucoa/yard/
|
180
|
+
- lib/rucoa/yard/type.rb
|
167
181
|
- rucoa.gemspec
|
168
182
|
homepage: https://github.com/r7kamura/rucoa
|
169
183
|
licenses:
|