solargraph 0.5.5 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/solargraph/api_map.rb +2 -2
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/yard_map.rb +32 -5
- data/lib/solargraph/yard_map/cache.rb +33 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6777382978fc47bc58e60e5dba335340528371e5
|
4
|
+
data.tar.gz: eab7012670ddc8c018cac7d8a9eb2f65da37c7da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e81fd6a61cc46763f3b12ac2130ad54dd1f3637632f9dd7fdc03c5b9313a2555b4ef06672c72193ff8a0ac7624a8106394250771782be24d40af1f9c0b5a5b4b
|
7
|
+
data.tar.gz: 91137dda081bb75b40e500966684c354c7ab9c4583cd56602d7d8e1cebec20cf9adb5ff7a4ae913100e5f801552a1afb940e0588a9a023ffb669831aee3f5067
|
data/lib/solargraph/api_map.rb
CHANGED
@@ -493,7 +493,7 @@ module Solargraph
|
|
493
493
|
label = "#{c.children[1]}"
|
494
494
|
args = get_method_args(c)
|
495
495
|
label += " #{args.join(', ')}" unless args.empty?
|
496
|
-
meths.push Suggestion.new(label, insert: c.children[1].to_s, kind: Suggestion::METHOD, detail: 'Method', documentation: docstring) if c.children[1].to_s[0].match(/[a-z_]/i) and c.children[1] != :def
|
496
|
+
meths.push Suggestion.new(label, insert: c.children[1].to_s.gsub(/=/, ' = '), kind: Suggestion::METHOD, detail: 'Method', documentation: docstring) if c.children[1].to_s[0].match(/[a-z_]/i) and c.children[1] != :def
|
497
497
|
elsif c.type == :send and c.children[1] == :include
|
498
498
|
# TODO: This might not be right. Should we be getting singleton methods
|
499
499
|
# from an include, or only from an extend?
|
@@ -536,7 +536,7 @@ module Solargraph
|
|
536
536
|
label = "#{c.children[0]}"
|
537
537
|
args = get_method_args(c)
|
538
538
|
label += " #{args.join(', ')}" unless args.empty?
|
539
|
-
meths.push Suggestion.new(label, insert: c.children[0].to_s, kind: Suggestion::METHOD, documentation: cmnt, detail: fqns) if c.children[0].to_s[0].match(/[a-z]/i)
|
539
|
+
meths.push Suggestion.new(label, insert: c.children[0].to_s.gsub(/=/, ' = '), kind: Suggestion::METHOD, documentation: cmnt, detail: fqns) if c.children[0].to_s[0].match(/[a-z]/i)
|
540
540
|
elsif c.kind_of?(AST::Node) and c.type == :send and c.children[1] == :attr_reader
|
541
541
|
c.children[2..-1].each { |x|
|
542
542
|
meths.push Suggestion.new(x.children[0], kind: Suggestion::METHOD) if x.type == :sym
|
data/lib/solargraph/version.rb
CHANGED
data/lib/solargraph/yard_map.rb
CHANGED
@@ -5,6 +5,8 @@ require 'yard'
|
|
5
5
|
module Solargraph
|
6
6
|
|
7
7
|
class YardMap
|
8
|
+
autoload :Cache, 'solargraph/yard_map/cache'
|
9
|
+
|
8
10
|
def initialize required: [], workspace: nil
|
9
11
|
unless workspace.nil?
|
10
12
|
wsy = File.join(workspace, '.yardoc')
|
@@ -32,6 +34,7 @@ module Solargraph
|
|
32
34
|
yardocs.push File.join(Dir.home, '.solargraph', 'cache', '2.0.0', 'yardoc')
|
33
35
|
#yardocs.push File.join(Dir.home, '.solargraph', 'cache', '2.0.0', 'yardoc-stdlib')
|
34
36
|
yardocs.uniq!
|
37
|
+
cache_core
|
35
38
|
end
|
36
39
|
|
37
40
|
def yardocs
|
@@ -63,7 +66,10 @@ module Solargraph
|
|
63
66
|
found
|
64
67
|
end
|
65
68
|
|
69
|
+
# @return [Array<Suggestion>]
|
66
70
|
def get_constants namespace, scope = ''
|
71
|
+
cached = cache.get_constants(namespace, scope)
|
72
|
+
return cached unless cached.nil?
|
67
73
|
consts = []
|
68
74
|
result = []
|
69
75
|
yardocs.each { |y|
|
@@ -90,6 +96,7 @@ module Solargraph
|
|
90
96
|
end
|
91
97
|
result.push Suggestion.new(c.to_s.split('::').last, detail: detail, kind: kind)
|
92
98
|
}
|
99
|
+
cache.set_constants(namespace, scope, result)
|
93
100
|
result
|
94
101
|
end
|
95
102
|
|
@@ -115,20 +122,23 @@ module Solargraph
|
|
115
122
|
nil
|
116
123
|
end
|
117
124
|
|
125
|
+
# @return [Array<Suggestion>]
|
118
126
|
def get_methods namespace, scope = '', visibility: [:public]
|
127
|
+
cached = cache.get_methods(namespace, scope, visibility)
|
128
|
+
return cached unless cached.nil?
|
119
129
|
meths = []
|
120
130
|
yardocs.each { |y|
|
121
131
|
yard = YARD::Registry.load! y
|
122
132
|
unless yard.nil?
|
123
133
|
ns = nil
|
124
134
|
ns = find_first_resolved_namespace(yard, namespace, scope)
|
125
|
-
unless ns.nil?
|
135
|
+
unless ns.nil?
|
126
136
|
ns.meths(scope: :class, visibility: visibility).each { |m|
|
127
|
-
n = m.to_s.split(/[\.#]/).last
|
137
|
+
n = m.to_s.split(/[\.#]/).last.gsub(/=/, ' = ')
|
128
138
|
label = "#{n}"
|
129
139
|
args = get_method_args(m)
|
130
140
|
label += " #{args.join(', ')}" unless args.empty?
|
131
|
-
meths.push Suggestion.new(label, insert: "#{n}", kind: Suggestion::METHOD, documentation: m.docstring, code_object: m, detail: "#{ns}", location: "#{m.file}:#{m.line}")
|
141
|
+
meths.push Suggestion.new(label, insert: "#{n.gsub(/=/, ' = ')}", kind: Suggestion::METHOD, documentation: m.docstring, code_object: m, detail: "#{ns}", location: "#{m.file}:#{m.line}")
|
132
142
|
}
|
133
143
|
# Collect superclass methods
|
134
144
|
if ns.kind_of?(YARD::CodeObjects::ClassObject) and !ns.superclass.nil?
|
@@ -140,10 +150,14 @@ module Solargraph
|
|
140
150
|
end
|
141
151
|
end
|
142
152
|
}
|
153
|
+
cache.set_methods(namespace, scope, visibility, meths)
|
143
154
|
meths
|
144
155
|
end
|
145
156
|
|
157
|
+
# @return [Array<Suggestion>]
|
146
158
|
def get_instance_methods namespace, scope = '', visibility: [:public]
|
159
|
+
cached = cache.get_instance_methods(namespace, scope, visibility)
|
160
|
+
return cached unless cached.nil?
|
147
161
|
meths = []
|
148
162
|
yardocs.each { |y|
|
149
163
|
yard = YARD::Registry.load! y
|
@@ -157,7 +171,7 @@ module Solargraph
|
|
157
171
|
label = "#{n}"
|
158
172
|
args = get_method_args(m)
|
159
173
|
label += " #{args.join(', ')}" unless args.empty?
|
160
|
-
meths.push Suggestion.new(label, insert: "#{n}", kind: Suggestion::METHOD, documentation: m.docstring, code_object: m, detail: "#{ns}", location: "#{m.file}:#{m.line}")
|
174
|
+
meths.push Suggestion.new(label, insert: "#{n.gsub(/=/, ' = ')}", kind: Suggestion::METHOD, documentation: m.docstring, code_object: m, detail: "#{ns}", location: "#{m.file}:#{m.line}")
|
161
175
|
end
|
162
176
|
}
|
163
177
|
if ns.kind_of?(YARD::CodeObjects::ClassObject) and namespace != 'Object'
|
@@ -166,6 +180,7 @@ module Solargraph
|
|
166
180
|
end
|
167
181
|
end
|
168
182
|
}
|
183
|
+
cache.set_instance_methods(namespace, scope, visibility, meths)
|
169
184
|
meths
|
170
185
|
end
|
171
186
|
|
@@ -178,7 +193,7 @@ module Solargraph
|
|
178
193
|
yard = YARD::Registry.load! y
|
179
194
|
unless yard.nil?
|
180
195
|
obj = find_first_resolved_namespace(yard, namespace, scope)
|
181
|
-
return obj.path unless obj.nil?
|
196
|
+
return obj.path unless obj.nil? or !obj.kind_of?(YARD::CodeObjects::NamespaceObject)
|
182
197
|
end
|
183
198
|
}
|
184
199
|
nil
|
@@ -186,6 +201,10 @@ module Solargraph
|
|
186
201
|
|
187
202
|
private
|
188
203
|
|
204
|
+
def cache
|
205
|
+
@cache ||= Cache.new
|
206
|
+
end
|
207
|
+
|
189
208
|
def get_method_args meth
|
190
209
|
args = []
|
191
210
|
meth.parameters.each { |a|
|
@@ -208,6 +227,14 @@ module Solargraph
|
|
208
227
|
end
|
209
228
|
yard.at(namespace)
|
210
229
|
end
|
230
|
+
|
231
|
+
def cache_core
|
232
|
+
c = get_constants '', ''
|
233
|
+
c.each { |n|
|
234
|
+
get_methods 'n', visibility: :public
|
235
|
+
get_instance_methods 'n', visibility: :public
|
236
|
+
}
|
237
|
+
end
|
211
238
|
end
|
212
239
|
|
213
240
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Solargraph
|
2
|
+
class YardMap::Cache
|
3
|
+
def initialize
|
4
|
+
@constants = {}
|
5
|
+
@methods = {}
|
6
|
+
@instance_methods = {}
|
7
|
+
end
|
8
|
+
|
9
|
+
def set_constants namespace, scope, suggestions
|
10
|
+
@constants[[namespace, scope]] = suggestions
|
11
|
+
end
|
12
|
+
|
13
|
+
def set_methods namespace, scope, visibility, suggestions
|
14
|
+
@methods[[namespace, scope, visibility]] = suggestions
|
15
|
+
end
|
16
|
+
|
17
|
+
def set_instance_methods namespace, scope, visibility, suggestions
|
18
|
+
@instance_methods[[namespace, scope, visibility]] = suggestions
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_methods namespace, scope, visibility
|
22
|
+
@methods[[namespace, scope, visibility]]
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_instance_methods namespace, scope, visibility
|
26
|
+
@instance_methods[[namespace, scope, visibility]]
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_constants namespace, scope
|
30
|
+
@constants[[namespace, scope]]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solargraph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -96,14 +96,14 @@ dependencies:
|
|
96
96
|
name: rack-test
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
|
-
- - "
|
99
|
+
- - "~>"
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '0'
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
|
-
- - "
|
106
|
+
- - "~>"
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '0'
|
109
109
|
- !ruby/object:Gem::Dependency
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- lib/solargraph/views/layout.erb
|
150
150
|
- lib/solargraph/views/search.erb
|
151
151
|
- lib/solargraph/yard_map.rb
|
152
|
+
- lib/solargraph/yard_map/cache.rb
|
152
153
|
- yardoc/2.0.0.tar.gz
|
153
154
|
homepage: http://castwide.com
|
154
155
|
licenses:
|