solargraph 0.5.3 → 0.5.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 34392923b4d66bd6306a6216e363aca3a504ff3b
4
- data.tar.gz: 8025196be58e10a71a5d61bfe79d629598e3543f
3
+ metadata.gz: bd8da15d1c0d25c8c95d4da12a4cba4c4b312ed0
4
+ data.tar.gz: 0cb4e3d5705c8b6339db2b2d144748068aec4d96
5
5
  SHA512:
6
- metadata.gz: 701214492f652110bff2a97f08a3fcc832600f3d8aac88f8d8d71cdb258b17c4fc32340ac7cc0c011856180d8698a8a67fa0ce705a81adb8b753e536a975e8e1
7
- data.tar.gz: 8ece31aa4ee0e7918c32ef96df4d98cb4e2354035170eb65671003e0fcbdafb60509b6c71fc64ae58d22c1ea6385469430efb988e71f21000d70b2f375d0653a
6
+ metadata.gz: 0e785fbea311d6778f7452897fdacb3cd9d7a5e5038db0bc12c3d30e51bf0f99d816f73308e7b379c856e6a8f434a6bc402f6786e849b7dfd93c745e5454f2f5
7
+ data.tar.gz: d24ac0e448bc7796cf8c92f63727699a3ea8c5cb1f0de50069f787de68ec9b0576fa2362666c1a74d2a82d6f5437e8d9dc04f6ccb66978c632ff376eb380dd96
@@ -24,10 +24,10 @@ module Solargraph
24
24
  attr_reader :required
25
25
 
26
26
  def initialize workspace = nil
27
- @workspace = workspace
27
+ @workspace = workspace.gsub(/\\/, '/') unless workspace.nil?
28
28
  clear
29
29
  unless @workspace.nil?
30
- extra = File.join(workspace, '.solargraph')
30
+ extra = File.join(@workspace, '.solargraph')
31
31
  if File.exist?(extra)
32
32
  append_file(extra)
33
33
  end
@@ -252,7 +252,10 @@ module Solargraph
252
252
  if @yardoc_files.nil?
253
253
  @yardoc_files = []
254
254
  yard_options[:include].each { |glob|
255
- @yardoc_files.concat Dir[File.join workspace, glob]
255
+ #@yardoc_files.concat Dir[File.join workspace, glob]
256
+ Dir[File.join workspace, glob].each { |f|
257
+ @yardoc_files.push File.absolute_path(f)
258
+ }
256
259
  }
257
260
  end
258
261
  @yardoc_files.include?(file)
@@ -351,10 +354,8 @@ module Solargraph
351
354
  meths.delete_if{ |m| m.insert != p }
352
355
  return nil if meths.empty?
353
356
  type = nil
354
- unless meths[0].documentation.nil?
355
- match = meths[0].documentation.all.match(/@return \[([a-z0-9:_]*)/i)
356
- type = find_fully_qualified_namespace(match[1]) unless match.nil?
357
- end
357
+ match = meths[0].return_type
358
+ type = find_fully_qualified_namespace(match) unless match.nil?
358
359
  end
359
360
  scope = :instance
360
361
  top = false
@@ -362,15 +363,6 @@ module Solargraph
362
363
  type
363
364
  end
364
365
 
365
- def get_method_return_value namespace, root, method, scope = :instance
366
- meths = get_methods(namespace, root).delete_if{ |m| m.insert != method }
367
- meths.each { |m|
368
- r = get_return_tag(m)
369
- return r unless r.nil?
370
- }
371
- nil
372
- end
373
-
374
366
  def get_namespace_type namespace, root = ''
375
367
  type = nil
376
368
  fqns = find_fully_qualified_namespace(namespace, root)
@@ -411,6 +403,8 @@ module Solargraph
411
403
  list.children.each { |c|
412
404
  if c.type == :arg
413
405
  args.push c.children[0]
406
+ elsif c.type == :kwoptarg
407
+ args.push "#{c.children[0]}:"
414
408
  end
415
409
  }
416
410
  args
@@ -430,12 +424,6 @@ module Solargraph
430
424
  elsif type == :module
431
425
  meths += yard_map.get_instance_methods('Module')
432
426
  end
433
- # TODO: Look out for repeats. Consider not doing this at all.
434
- #sc = get_superclass(namespace, root)
435
- #until sc.nil?
436
- # meths += yard.get_instance_methods(sc, root)
437
- # sc = get_superclass(sc)
438
- #end
439
427
  end
440
428
  meths
441
429
  end
@@ -529,6 +517,7 @@ module Solargraph
529
517
  skip.push fqns
530
518
  nodes = get_namespace_nodes(fqns)
531
519
  nodes.each { |n|
520
+ f = get_filename_for(n)
532
521
  unless yardoc_has_file?(get_filename_for(n))
533
522
  if n.kind_of?(AST::Node)
534
523
  if n.type == :class and !n.children[1].nil?
@@ -221,7 +221,8 @@ module Solargraph
221
221
  fqns = @api_map.find_fully_qualified_namespace(signature, ns_here)
222
222
  if fqns.nil?
223
223
  # It's a method call
224
- type = @api_map.infer_signature_type(signature, ns_here, scope: :class)
224
+ sig_scope = (scope.type == :def ? :instance : :class)
225
+ type = @api_map.infer_signature_type(signature, ns_here, scope: sig_scope)
225
226
  result.concat @api_map.get_instance_methods(type) unless type.nil?
226
227
  else
227
228
  if fqns == ns_here
@@ -271,24 +272,6 @@ module Solargraph
271
272
  obj
272
273
  end
273
274
 
274
- # @todo Candidate for deprecation
275
- def get_instance_method_return_value namespace, root, method
276
- meths = @api_map.get_instance_methods(namespace, root).delete_if{ |m| m.insert != method }
277
- meths.each { |m|
278
- r = get_return_tag(m)
279
- return r unless r.nil?
280
- }
281
- nil
282
- end
283
-
284
- def get_return_tag suggestion
285
- unless suggestion.documentation.nil?
286
- match = suggestion.documentation.all.match(/@return \[([a-z0-9:_]*)/i)
287
- return match[1]
288
- end
289
- nil
290
- end
291
-
292
275
  def get_signature_at index
293
276
  brackets = 0
294
277
  squares = 0
@@ -30,6 +30,22 @@ module Solargraph
30
30
  label
31
31
  end
32
32
 
33
+ def return_type
34
+ if code_object.nil?
35
+ unless documentation.nil?
36
+ match = documentation.all.match(/@return \[([a-z0-9:_]*)/i)
37
+ return match[1]
38
+ end
39
+ else
40
+ o = code_object.tag(:overload)
41
+ unless o.nil?
42
+ r = o.tag(:return)
43
+ return r.types[0] unless r.nil?
44
+ end
45
+ end
46
+ nil
47
+ end
48
+
33
49
  def to_json args={}
34
50
  obj = {
35
51
  label: @label,
@@ -1,3 +1,3 @@
1
1
  module Solargraph
2
- VERSION = '0.5.3'
2
+ VERSION = '0.5.4'
3
3
  end
@@ -57,12 +57,7 @@ module Solargraph
57
57
  yard = YARD::Registry.load! y
58
58
  unless yard.nil?
59
59
  obj = yard.at query
60
- #found.push YARD::Templates::Engine.render(format: :html, object: obj) unless obj.nil?
61
- unless obj.nil?
62
- # HACK: Fix return tags in core documentation
63
- fix_return! obj if obj.kind_of?(YARD::CodeObjects::MethodObject) and y.include?('.solargraph')
64
- found.push obj
65
- end
60
+ found.push obj unless obj.nil?
66
61
  end
67
62
  }
68
63
  found
@@ -126,15 +121,9 @@ module Solargraph
126
121
  yard = YARD::Registry.load! y
127
122
  unless yard.nil?
128
123
  ns = nil
129
- #if scope == ''
130
- # ns = yard.at(namespace)
131
- #else
132
- ns = find_first_resolved_namespace(yard, namespace, scope)
133
- #end
124
+ ns = find_first_resolved_namespace(yard, namespace, scope)
134
125
  unless ns.nil? or !ns.kind_of?(YARD::CodeObjects::NamespaceObject)
135
126
  ns.meths(scope: :class, visibility: visibility).each { |m|
136
- # HACK: Fix return tags in core documentation
137
- fix_return! m if y.include?('.solargraph')
138
127
  n = m.to_s.split(/[\.#]/).last
139
128
  label = "#{n}"
140
129
  args = get_method_args(m)
@@ -160,15 +149,9 @@ module Solargraph
160
149
  yard = YARD::Registry.load! y
161
150
  unless yard.nil?
162
151
  ns = nil
163
- #if scope == ''
164
- # ns = yard.at(namespace)
165
- #else
166
- ns = find_first_resolved_namespace(yard, namespace, scope)
167
- #end
152
+ ns = find_first_resolved_namespace(yard, namespace, scope)
168
153
  unless ns.nil?
169
154
  ns.meths(scope: :instance, visibility: visibility).each { |m|
170
- # HACK: Fix return tags in core documentation
171
- fix_return! m if y.include?('.solargraph')
172
155
  n = m.to_s.split(/[\.#]/).last
173
156
  if n.to_s.match(/^[a-z]/i) and (namespace == 'Kernel' or !m.to_s.start_with?('Kernel#')) and !m.docstring.to_s.include?(':nodoc:')
174
157
  label = "#{n}"
@@ -206,25 +189,14 @@ module Solargraph
206
189
  def get_method_args meth
207
190
  args = []
208
191
  meth.parameters.each { |a|
209
- args.push a[0]
210
- }
211
- args
212
- end
213
-
214
- def fix_return! meth
215
- return unless meth.tag(:return).nil?
216
- return unless meth.docstring.all.include?('@return')
217
- text = ''
218
- meth.docstring.all.lines.each { |line|
219
- if line.strip.start_with?('@return')
220
- text += line.strip
221
- else
222
- text += line
192
+ p = a[0]
193
+ unless a[1].nil?
194
+ p += ' =' unless p.end_with?(':')
195
+ p += " #{a[1]}"
223
196
  end
224
- text += "\n"
197
+ args.push p
225
198
  }
226
- doc = YARD::Docstring.new(text, meth)
227
- meth.docstring = doc
199
+ args
228
200
  end
229
201
 
230
202
  def find_first_resolved_namespace yard, namespace, scope
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.5.3
4
+ version: 0.5.4
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-19 00:00:00.000000000 Z
11
+ date: 2017-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -92,6 +92,20 @@ dependencies:
92
92
  - - ">="
93
93
  - !ruby/object:Gem::Version
94
94
  version: 3.5.0
95
+ - !ruby/object:Gem::Dependency
96
+ name: rack-test
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
95
109
  - !ruby/object:Gem::Dependency
96
110
  name: codeclimate-test-reporter
97
111
  requirement: !ruby/object:Gem::Requirement