yoda-language-server 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/yoda/parsing/location.rb +1 -1
- data/lib/yoda/store/objects/class_object.rb +6 -6
- data/lib/yoda/store/query/associators/associate_ancestors.rb +10 -2
- data/lib/yoda/store/query/associators/associate_methods.rb +10 -7
- data/lib/yoda/store/query/find_constant.rb +1 -2
- data/lib/yoda/store/query/find_method.rb +3 -23
- data/lib/yoda/store/registry.rb +1 -1
- data/lib/yoda/store/yard_importer.rb +16 -14
- data/lib/yoda/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 715586351d4d461d35dd89cd858dcc1f886508e7b8ed1f8ba82c071130ecb7d7
|
4
|
+
data.tar.gz: 932d126f234752431363cabdc461c8c2abfc7546293134074986e08678427914
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57e1304da036c27fc3f945c92cfe4bb7ac7d9c0d22f30cf4b6664bf647e833f62c6df31cb5618094c63824b58769648739bcd7771ffb7163310c017f9fbb9604
|
7
|
+
data.tar.gz: 6c76098551ddcd5be50d022ba649acc527bc0c173fbc49322add37914e91cc12fc479c928fabb43d7f2954dd94fab0c7d3660fdf2ce485f6d863fe9af7619ba5
|
@@ -2,7 +2,7 @@ module Yoda
|
|
2
2
|
module Store
|
3
3
|
module Objects
|
4
4
|
class ClassObject < NamespaceObject
|
5
|
-
# @return [
|
5
|
+
# @return [Path, nil]
|
6
6
|
attr_reader :superclass_path
|
7
7
|
|
8
8
|
# @return [Array<Symbol>]
|
@@ -15,7 +15,7 @@ module Yoda
|
|
15
15
|
def initialize(superclass_path: nil, **kwargs)
|
16
16
|
super(kwargs)
|
17
17
|
|
18
|
-
@superclass_path = Model::
|
18
|
+
@superclass_path = Model::Path.new(superclass_path) if superclass_path
|
19
19
|
end
|
20
20
|
|
21
21
|
def kind
|
@@ -23,7 +23,7 @@ module Yoda
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def to_h
|
26
|
-
super.merge(superclass_path: superclass_path&.
|
26
|
+
super.merge(superclass_path: superclass_path&.to_s)
|
27
27
|
end
|
28
28
|
|
29
29
|
private
|
@@ -32,14 +32,14 @@ module Yoda
|
|
32
32
|
# @return [Hash]
|
33
33
|
def merge_attributes(another)
|
34
34
|
super.merge(
|
35
|
-
superclass_path: select_superclass(another.superclass_path)&.
|
35
|
+
superclass_path: select_superclass(another.superclass_path)&.to_s,
|
36
36
|
)
|
37
37
|
end
|
38
38
|
|
39
39
|
# @param another [ScopedPath]
|
40
|
-
# @return [
|
40
|
+
# @return [Path]
|
41
41
|
def select_superclass(another)
|
42
|
-
if %w(Object Exception).include?(another&.
|
42
|
+
if %w(Object Exception).include?(another&.to_s)
|
43
43
|
superclass_path || another
|
44
44
|
else
|
45
45
|
another || superclass_path
|
@@ -5,7 +5,12 @@ module Yoda
|
|
5
5
|
module Query
|
6
6
|
module Associators
|
7
7
|
class AssociateAncestors
|
8
|
-
class CircularReferenceError < StandardError
|
8
|
+
class CircularReferenceError < StandardError
|
9
|
+
# @param circular_scope [Objects::NamespaceObject, nil]
|
10
|
+
def initialize(circular_scope)
|
11
|
+
super("#{circular_scope&.path} appears twice")
|
12
|
+
end
|
13
|
+
end
|
9
14
|
|
10
15
|
# @return [Registry]
|
11
16
|
attr_reader :registry
|
@@ -16,11 +21,14 @@ module Yoda
|
|
16
21
|
end
|
17
22
|
|
18
23
|
# @param obj [Objects::Base]
|
24
|
+
# @return [Enumerator<Objects::NamespaceObject>]
|
19
25
|
def associate(obj)
|
20
26
|
if obj.is_a?(Objects::NamespaceObject)
|
21
|
-
|
27
|
+
Enumerator.new do |yielder|
|
22
28
|
Processor.new(registry).process(obj).each { |klass| yielder << klass }
|
23
29
|
end
|
30
|
+
else
|
31
|
+
[]
|
24
32
|
end
|
25
33
|
end
|
26
34
|
|
@@ -12,23 +12,26 @@ module Yoda
|
|
12
12
|
end
|
13
13
|
|
14
14
|
# @param obj [Object::Base]
|
15
|
+
# @return [Enumerator<Objects::MethodObject>]
|
15
16
|
def associate(obj)
|
16
17
|
if obj.is_a?(Objects::NamespaceObject)
|
17
|
-
|
18
|
-
obj.methods = Enumerator.new do |yielder|
|
18
|
+
Enumerator.new do |yielder|
|
19
19
|
name_set = Set.new
|
20
20
|
|
21
|
-
obj.
|
21
|
+
AssociateAncestors.new(registry).associate(obj).each do |ancestor|
|
22
22
|
ancestor.instance_method_addresses.each do |method_address|
|
23
23
|
method_name = Objects::MethodObject.name_of_path(method_address)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
if !name_set.member?(method_name)
|
25
|
+
name_set.add(method_name)
|
26
|
+
if el = registry.find(method_address)
|
27
|
+
yielder << el
|
28
|
+
end
|
28
29
|
end
|
29
30
|
end
|
30
31
|
end
|
31
32
|
end
|
33
|
+
else
|
34
|
+
[]
|
32
35
|
end
|
33
36
|
end
|
34
37
|
end
|
@@ -78,8 +78,7 @@ module Yoda
|
|
78
78
|
Enumerator.new do |yielder|
|
79
79
|
met = Set.new
|
80
80
|
|
81
|
-
Associators::AssociateAncestors.new(registry).associate(scope)
|
82
|
-
scope.ancestors.each do |ancestor|
|
81
|
+
Associators::AssociateAncestors.new(registry).associate(scope).each do |ancestor|
|
83
82
|
select_child_constants(ancestor, name).each do |obj|
|
84
83
|
next if met.include?(obj.name)
|
85
84
|
met.add(obj.name)
|
@@ -27,29 +27,9 @@ module Yoda
|
|
27
27
|
def lazy_select(namespace, expected, visibility: nil)
|
28
28
|
visibility ||= %i(public private protected)
|
29
29
|
Enumerator.new do |yielder|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
name = Objects::MethodObject.name_of_path(address)
|
34
|
-
if match_name?(name, expected)
|
35
|
-
next if met.include?(name)
|
36
|
-
if el = registry.find(address)
|
37
|
-
met.add(name)
|
38
|
-
yielder << el if visibility.include?(el.visibility)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
# @param namespace [Objects::Namespace]
|
46
|
-
# @return [Enumerator<Objects::MethodObject>]
|
47
|
-
def all_method_addresses(namespace)
|
48
|
-
Enumerator.new do |yielder|
|
49
|
-
Associators::AssociateAncestors.new(registry).associate(namespace)
|
50
|
-
namespace.ancestors.each do |ancestor|
|
51
|
-
ancestor.instance_method_addresses.each do |address|
|
52
|
-
yielder << address
|
30
|
+
Associators::AssociateMethods.new(registry).associate(namespace).each do |method|
|
31
|
+
if match_name?(method.name, expected) && visibility.include?(method.visibility)
|
32
|
+
yielder << method
|
53
33
|
end
|
54
34
|
end
|
55
35
|
end
|
data/lib/yoda/store/registry.rb
CHANGED
@@ -39,7 +39,7 @@ module Yoda
|
|
39
39
|
def register(code_object)
|
40
40
|
return if @registered.member?(code_object.path)
|
41
41
|
@registered.add(code_object.path)
|
42
|
-
register(code_object.parent) if code_object.parent
|
42
|
+
register(code_object.parent) if code_object.parent
|
43
43
|
|
44
44
|
new_objects = begin
|
45
45
|
case code_object.type
|
@@ -64,7 +64,9 @@ module Yoda
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
|
67
|
+
# In YARD, proxy module is undetermined its absolute path and its defined namespace is undetermined.
|
68
|
+
# In Yoda, proxy module is assumed to be defined directory under parent namespace.
|
69
|
+
register_to_parent(code_object) if code_object.parent && (code_object.type == :proxy || code_object.parent.type == :proxy)
|
68
70
|
[new_objects].flatten.compact.each { |new_object| patch.register(new_object) }
|
69
71
|
end
|
70
72
|
|
@@ -79,7 +81,7 @@ module Yoda
|
|
79
81
|
tag_list: code_object.tags.map { |tag| convert_tag(tag, '') },
|
80
82
|
sources: code_object.files.map(&method(:convert_source)),
|
81
83
|
primary_source: code_object[:current_file_has_comments] ? convert_source(code_object.files.first) : nil,
|
82
|
-
instance_method_addresses: code_object.meths(included: false, scope: :instance).map(
|
84
|
+
instance_method_addresses: code_object.meths(included: false, scope: :instance).map { |meth| path_to_store(meth) },
|
83
85
|
mixin_addresses: code_object.instance_mixins.map { |mixin| path_to_store(mixin) },
|
84
86
|
constant_addresses: (code_object.children.select{ |child| %i(constant module class).include?(child.type) }.map { |constant| constant.path } + ['Object']).uniq,
|
85
87
|
)
|
@@ -87,7 +89,7 @@ module Yoda
|
|
87
89
|
path: path_to_store(code_object),
|
88
90
|
sources: code_object.files.map(&method(:convert_source)),
|
89
91
|
primary_source: code_object[:current_file_has_comments] ? convert_source(code_object.files.first) : nil,
|
90
|
-
instance_method_addresses: code_object.meths(included: false, scope: :class).map(
|
92
|
+
instance_method_addresses: code_object.meths(included: false, scope: :class).map { |meth| path_to_store(meth) },
|
91
93
|
mixin_addresses: code_object.instance_mixins.map { |mixin| path_to_store(mixin) },
|
92
94
|
)
|
93
95
|
[object_class, object_meta_class]
|
@@ -149,7 +151,7 @@ module Yoda
|
|
149
151
|
tag_list: code_object.tags.map { |tag| convert_tag(tag, path_to_store(code_object)) },
|
150
152
|
sources: code_object.files.map(&method(:convert_source)),
|
151
153
|
primary_source: code_object[:current_file_has_comments] ? convert_source(code_object.files.first) : nil,
|
152
|
-
instance_method_addresses: code_object.meths(included: false, scope: :instance).map(
|
154
|
+
instance_method_addresses: code_object.meths(included: false, scope: :instance).map { |meth| path_to_store(meth) },
|
153
155
|
mixin_addresses: code_object.instance_mixins.map { |mixin| path_to_store(mixin) },
|
154
156
|
constant_addresses: code_object.children.select{ |child| %i(constant module class).include?(child.type) }.map { |constant| constant.path },
|
155
157
|
)
|
@@ -158,7 +160,7 @@ module Yoda
|
|
158
160
|
path: path_to_store(code_object),
|
159
161
|
sources: code_object.files.map(&method(:convert_source)),
|
160
162
|
primary_source: code_object[:current_file_has_comments] ? convert_source(code_object.files.first) : nil,
|
161
|
-
instance_method_addresses: code_object.meths(included: false, scope: :class).map(
|
163
|
+
instance_method_addresses: code_object.meths(included: false, scope: :class).map { |meth| path_to_store(meth) },
|
162
164
|
mixin_addresses: code_object.instance_mixins.map { |mixin| path_to_store(mixin) },
|
163
165
|
)
|
164
166
|
|
@@ -174,7 +176,7 @@ module Yoda
|
|
174
176
|
tag_list: code_object.tags.map { |tag| convert_tag(tag, path_to_store(code_object)) },
|
175
177
|
sources: code_object.files.map(&method(:convert_source)),
|
176
178
|
primary_source: code_object[:current_file_has_comments] ? convert_source(code_object.files.first) : nil,
|
177
|
-
instance_method_addresses: code_object.meths(included: false, scope: :instance).map(
|
179
|
+
instance_method_addresses: code_object.meths(included: false, scope: :instance).map { |meth| path_to_store(meth) },
|
178
180
|
mixin_addresses: code_object.instance_mixins.map { |mixin| path_to_store(mixin) },
|
179
181
|
constant_addresses: code_object.children.select{ |child| %i(constant module class).include?(child.type) }.map { |constant| path_to_store(constant) },
|
180
182
|
superclass_path: !code_object.superclass || code_object.superclass&.path == 'Qnil' ? nil : path_to_store(code_object.superclass),
|
@@ -184,7 +186,7 @@ module Yoda
|
|
184
186
|
path: path_to_store(code_object),
|
185
187
|
sources: code_object.files.map(&method(:convert_source)),
|
186
188
|
primary_source: code_object[:current_file_has_comments] ? convert_source(code_object.files.first) : nil,
|
187
|
-
instance_method_addresses: code_object.meths(included: false, scope: :class).map(
|
189
|
+
instance_method_addresses: code_object.meths(included: false, scope: :class).map { |meth| path_to_store(meth) },
|
188
190
|
mixin_addresses: code_object.class_mixins.map { |mixin| path_to_store(mixin) },
|
189
191
|
)
|
190
192
|
|
@@ -250,10 +252,10 @@ module Yoda
|
|
250
252
|
|
251
253
|
# @param code_object [::YARD::CodeObjects::Base]
|
252
254
|
# @return [vaid]
|
253
|
-
def
|
254
|
-
|
255
|
-
|
256
|
-
|
255
|
+
def register_to_parent(code_object)
|
256
|
+
parent_module = patch.find(path_to_store(code_object.parent))
|
257
|
+
parent_module.instance_method_addresses.push(path_to_store(code_object)) if code_object.type == :method
|
258
|
+
parent_module.constant_addresses.push(path_to_store(code_object)) if [:class, :module, :proxy].include?(code_object.type)
|
257
259
|
end
|
258
260
|
|
259
261
|
# @param source [(String, Integer)]
|
@@ -271,13 +273,13 @@ module Yoda
|
|
271
273
|
end
|
272
274
|
|
273
275
|
# @param code_object [::YARD::CodeObjects::Base]
|
274
|
-
# @return [String]
|
276
|
+
# @return [String] absolute object path to store.
|
275
277
|
def calc_path_to_store(object)
|
276
278
|
return 'Object' if object.root?
|
277
279
|
parent_path = path_to_store(object.parent)
|
278
280
|
|
279
281
|
if object.type == :proxy || object.is_a?(YARD::CodeObjects::Proxy)
|
280
|
-
# For now, we suppose the proxy object exists directly under its
|
282
|
+
# For now, we suppose the proxy object exists directly under its namespace.
|
281
283
|
[path_to_store(object.parent), object.name].join('::')
|
282
284
|
elsif object.parent.path == path_to_store(object.parent)
|
283
285
|
object.path
|
data/lib/yoda/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yoda-language-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomoya Chiba
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yard
|