solargraph 0.17.1 → 0.17.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e75af30aa57a99e118082d7c337d889f7aa6151
4
- data.tar.gz: 2937ed78501b758858b304127987eb822540163f
3
+ metadata.gz: 70caa0a1b8b30a5d8c276ef9ec3dd54e36df6786
4
+ data.tar.gz: 346775f0ce4f6b0dd62f2240ab0ad523c845075a
5
5
  SHA512:
6
- metadata.gz: 110b41dcd353afc575f30a096e9e83d311ff8d664e37847097d4618ab8bfe76f7d4825ff730838f971ba3af503015cde7b156e7a1d8afef504dfa3b1515dc13e
7
- data.tar.gz: 5e0bc35e2d8c06a73e452451ddb3167f06f00fc8e52add97f9ea4152387e14ea366d4e2b715491697f65194d601feb0d04d23c2b09d5bef31ec5136d29dc3b50
6
+ metadata.gz: 415327acf2fc2f9779aa53a01a0a5bd4dd9e14f39cdc879f4ce51fdd9533eb3786a4c129fc0e365e080ddf8f4a2e5de0cb8464c7443ca2cbc1bb4d8a0fb4a6cf
7
+ data.tar.gz: 77954b8598a0b098d50b4080169f952dbdb008381c7471bebcd97fe6ebd4a737d23a768e5f5cb6bda05689dd6e3a6543cf62146590c01c53431151d62b68b324
@@ -216,8 +216,8 @@ module Solargraph
216
216
  while parts.length > 0
217
217
  resolved = find_namespace_pins(parts.join('::'))
218
218
  resolved.each do |pin|
219
- visi = :public
220
- visi = :private if namespace == '' and root != '' and pin.path == fqns
219
+ visi = [:public]
220
+ visi.push :private if namespace == '' and root != '' and pin.path == fqns
221
221
  result.concat inner_get_constants(pin.path, skip, true, visi)
222
222
  end
223
223
  parts.pop
@@ -967,24 +967,24 @@ module Solargraph
967
967
  cp = @const_pins[here]
968
968
  unless cp.nil?
969
969
  cp.each do |pin|
970
- result.push pin_to_suggestion(pin) if pin.visibility == :public or visibility == :private
970
+ result.push pin_to_suggestion(pin) if pin.visibility == :public or visibility.include?(:private)
971
971
  end
972
972
  end
973
973
  np = @namespace_pins[here]
974
974
  unless np.nil?
975
975
  np.each do |pin|
976
- if pin.visibility == :public || visibility == :private
976
+ if pin.visibility == :public || visibility.include?(:private)
977
977
  result.push pin_to_suggestion(pin)
978
978
  if deep
979
979
  get_include_strings_from(pin.node).each do |i|
980
- result.concat inner_get_constants(i, skip, false, :public)
980
+ result.concat inner_get_constants(i, skip, false, [:public])
981
981
  end
982
982
  end
983
983
  end
984
984
  end
985
985
  end
986
986
  get_include_strings_from(*get_namespace_nodes(here)).each do |i|
987
- result.concat inner_get_constants(i, skip, false, :public)
987
+ result.concat inner_get_constants(i, skip, false, [:public])
988
988
  end
989
989
  result
990
990
  end
@@ -102,11 +102,17 @@ module Solargraph
102
102
  #
103
103
  # @return [Boolean]
104
104
  def comment_at?(index)
105
+ return false if string_at?(index)
105
106
  line, col = Solargraph::ApiMap::Source.get_position_at(source.code, index)
106
107
  return false if source.stubbed_lines.include?(line)
107
108
  @comments.each do |c|
108
109
  return true if index > c.location.expression.begin_pos and index <= c.location.expression.end_pos
109
110
  end
111
+ # Extra test due to some comments not getting tracked
112
+ while (index > 0 and @code[index] != "\n")
113
+ return true if @code[index] == '#'
114
+ index -= 1
115
+ end
110
116
  false
111
117
  end
112
118
 
@@ -540,6 +546,7 @@ module Solargraph
540
546
  index -=1
541
547
  in_whitespace = false
542
548
  while index >= 0
549
+ break if index > 0 and comment_at?(index - 1)
543
550
  unless !in_whitespace and string_at?(index)
544
551
  break if brackets > 0 or parens > 0 or squares > 0
545
552
  char = @code[index, 1]
@@ -19,5 +19,9 @@ module Solargraph
19
19
  METHODS_WITH_YIELDPARAM_SUBTYPES = %w{
20
20
  Array#each Hash#each_pair Array#map
21
21
  }.freeze
22
+
23
+ CUSTOM_RETURN_TYPES = {
24
+ 'String#split' => 'Array<String>'
25
+ }.freeze
22
26
  end
23
27
  end
@@ -22,7 +22,6 @@ module Solargraph
22
22
 
23
23
  post '/prepare' do
24
24
  content_type :json
25
- STDERR.puts "Preparing #{params['workspace']}"
26
25
  begin
27
26
  Server.prepare_workspace params['workspace']
28
27
  { "status" => "ok"}.to_json
@@ -99,7 +98,7 @@ module Solargraph
99
98
  sugg = []
100
99
  workspace = find_local_workspace(params['filename'], params['workspace'])
101
100
  api_map = get_api_map(workspace)
102
- code_map = CodeMap.new(code: params['text'], filename: params['filename'], api_map: @@api_hash[workspace], cursor: [params['line'].to_i, params['column'].to_i])
101
+ code_map = CodeMap.new(code: params['text'], filename: params['filename'], api_map: api_map, cursor: [params['line'].to_i, params['column'].to_i])
103
102
  offset = code_map.get_offset(params['line'].to_i, params['column'].to_i)
104
103
  sugg = code_map.define_symbol_at(offset)
105
104
  { "status" => "ok", "suggestions" => sugg }.to_json
@@ -174,6 +173,7 @@ module Solargraph
174
173
  end
175
174
 
176
175
  def find_local_workspace file, workspace
176
+ return nil if workspace.nil? or workspace.empty?
177
177
  workspace.gsub!(/\\/, '/') unless workspace.nil?
178
178
  unless file.nil? or workspace.nil?
179
179
  file.gsub!(/\\/, '/') unless file.nil?
@@ -190,8 +190,9 @@ module Solargraph
190
190
  class << self
191
191
  def prepare_workspace directory
192
192
  return if directory.nil?
193
- Thread.new do
194
- directory.gsub!(/\\/, '/') unless directory.nil?
193
+ #Thread.new do
194
+ directory.gsub!(/\\/, '/')
195
+ STDERR.puts "Preparing #{directory}"
195
196
  configs = Dir[File.join(directory, '**', '.solargraph.yml')]
196
197
  resolved = []
197
198
  configs.each do |cf|
@@ -200,12 +201,11 @@ module Solargraph
200
201
  resolved.push dir
201
202
  end
202
203
  generate_api_map directory unless resolved.include?(directory)
203
- end
204
+ #end
204
205
  end
205
206
 
206
207
  def generate_api_map(directory)
207
208
  api_map = Solargraph::ApiMap.new(directory)
208
- api_map.yard_map
209
209
  @@semaphore.synchronize do
210
210
  @@api_hash[directory] = api_map
211
211
  end
@@ -1,3 +1,3 @@
1
1
  module Solargraph
2
- VERSION = '0.17.1'
2
+ VERSION = '0.17.2'
3
3
  end
@@ -24,15 +24,6 @@ module Solargraph
24
24
  @namespace_yardocs = {}
25
25
  @gem_paths = {}
26
26
  process_gem_paths
27
- if !workspace.nil? and File.exist?(File.join workspace, 'Gemfile')
28
- Bundler.with_clean_env do
29
- Bundler.environment.chdir(workspace) do
30
- process_requires
31
- end
32
- end
33
- else
34
- process_requires
35
- end
36
27
  yardocs.push CoreDocs.yardoc_file
37
28
  yardocs.uniq!
38
29
  yardocs.each do |y|
@@ -45,11 +36,6 @@ module Solargraph
45
36
  cache_core
46
37
  end
47
38
 
48
- # @return [Solargraph::LiveMap]
49
- def live_map
50
- @live_map ||= Solargraph::LiveMap.new
51
- end
52
-
53
39
  # @return [Array<String>]
54
40
  def yardocs
55
41
  @yardocs ||= []
@@ -131,7 +117,7 @@ module Solargraph
131
117
  else
132
118
  next
133
119
  end
134
- result.push Suggestion.new(c.to_s.split('::').last, detail: c.to_s, kind: kind, docstring: c.docstring, return_type: return_type)
120
+ result.push Suggestion.new(c.to_s.split('::').last, detail: c.to_s, kind: kind, docstring: c.docstring, return_type: return_type, location: object_location(c))
135
121
  }
136
122
  cache.set_constants(namespace, scope, result)
137
123
  result
@@ -199,7 +185,11 @@ module Solargraph
199
185
  label = "#{n}"
200
186
  args = get_method_args(m)
201
187
  kind = (m.is_attribute? ? Suggestion::FIELD : Suggestion::METHOD)
202
- meths.push Suggestion.new(label, insert: "#{n.gsub(/=$/, ' = ')}", kind: kind, docstring: m.docstring, code_object: m, detail: m.namespace, location: object_location(m), arguments: args)
188
+ rt = nil
189
+ if Solargraph::CoreFills::CUSTOM_RETURN_TYPES.has_key?(m.path)
190
+ rt = Solargraph::CoreFills::CUSTOM_RETURN_TYPES[m.path]
191
+ end
192
+ meths.push Suggestion.new(label, insert: "#{n.gsub(/=$/, ' = ')}", kind: kind, docstring: m.docstring, code_object: m, detail: m.namespace, location: object_location(m), arguments: args, return_type: rt)
203
193
  end
204
194
  }
205
195
  if ns.kind_of?(YARD::CodeObjects::ClassObject) and namespace != 'Object'
@@ -218,10 +208,6 @@ module Solargraph
218
208
  meths
219
209
  end
220
210
 
221
- def gem_names
222
- Gem::Specification.map{ |s| s.name }.uniq
223
- end
224
-
225
211
  def find_fully_qualified_namespace namespace, scope
226
212
  unless scope.nil? or scope.empty?
227
213
  parts = scope.split('::')
@@ -280,38 +266,6 @@ module Solargraph
280
266
  nil
281
267
  end
282
268
 
283
- def bundled_gem_yardocs
284
- result = []
285
- unless workspace.nil?
286
- Bundler.with_clean_env do
287
- Bundler.environment.chdir(workspace) do
288
- glfn = File.join(workspace, 'Gemfile.lock')
289
- spec_versions = {}
290
- if File.file?(glfn)
291
- lockfile = Bundler::LockfileParser.new(Bundler.read_file(glfn))
292
- lockfile.specs.each do |s|
293
- spec_versions[s.name] = s.version.to_s
294
- end
295
- end
296
- Bundler.environment.dependencies.each do |s|
297
- if s.type == :runtime
298
- ver = spec_versions[s.name]
299
- y = YARD::Registry.yardoc_file_for_gem(s.name, ver)
300
- if y.nil?
301
- STDERR.puts "Bundled gem not found: #{s.name}, #{ver}"
302
- else
303
- #STDERR.puts "Adding #{y}"
304
- result.push y
305
- add_gem_dependencies(s.name)
306
- end
307
- end
308
- end
309
- end
310
- end
311
- end
312
- result.uniq
313
- end
314
-
315
269
  private
316
270
 
317
271
  def cache
@@ -359,86 +313,41 @@ module Solargraph
359
313
  end
360
314
  end
361
315
 
362
- def process_requires
363
- used = []
364
- @required.each do |r|
365
- if workspace.nil? or !File.exist?(File.join workspace, 'lib', "#{r}.rb")
366
- unless used.include?(r)
367
- used.push r
368
- result = find_yardoc(r)
369
- if result.nil?
370
- STDERR.puts "Required path not found: #{r}"
371
- else
372
- yardocs.unshift result unless yardocs.include?(result)
373
- end
374
- end
375
- end
376
- end
377
- end
378
-
379
316
  def process_gem_paths
380
317
  if !has_bundle?
381
- required.each do |r|
382
- spec = Gem::Specification.find_by_path(r)
383
- if spec.nil?
384
- STDERR.puts "Required path not found: #{r}"
385
- else
386
- @gem_paths[spec.name] = spec.full_gem_path
387
- end
388
- end
318
+ process_requires
389
319
  else
390
320
  Bundler.with_clean_env do
391
321
  Bundler.environment.chdir(workspace) do
392
- Bundler.environment.gems.to_a.each do |g|
393
- @gem_paths[g.name] = g.full_gem_path
394
- end
322
+ #Bundler.environment.gems.to_a.each do |g|
323
+ # @gem_paths[g.name] = g.full_gem_path
324
+ #end
325
+ process_requires
395
326
  end
396
- #Bundler.environment.chdir(workspace) do
397
- # required.each do |r|
398
- # spec = Bundler.rubygems.gem_from_path(r)
399
- # if spec.nil?
400
- # STDERR.puts "Required path not found: #{r}"
401
- # else
402
- # @gem_paths[spec.name] = spec.full_gem_path
403
- # end
404
- # end
405
- #end
406
327
  end
407
328
  end
408
329
  end
409
330
 
410
- def find_yardoc path
411
- result = nil
412
- spec = Gem::Specification.find_by_path(path)
413
- result = YARD::Registry.yardoc_file_for_gem(spec.name) unless spec.nil?
414
- if result.nil?
415
- $LOAD_PATH.each do |base|
416
- source_file = File.join(base, "#{path}.rb")
417
- if File.exist?(source_file)
418
- if base.start_with?(Bundler.bundle_path.to_s)
419
- match = File.dirname(base).split('/').last.match(/^([a-z0-9\-_]*?)-([0-9]+\.[0-9]+\.[0-9]+)/i)
420
- unless match.nil? or match[1].nil?
421
- result = YARD::Registry.yardoc_file_for_gem(match[1])
422
- add_gem_dependencies match[1]
423
- break
424
- end
425
- end
426
- yp = File.join(File.dirname(base), '.yardoc')
427
- if File.exist?(yp)
428
- result = yp
429
- break
430
- else
431
- # @todo Keep trying?
432
- end
433
- break
434
- end
331
+ def process_requires
332
+ required.each do |r|
333
+ spec = Gem::Specification.find_by_path(r)
334
+ begin
335
+ spec = Gem::Specification.find_by_name(r) if spec.nil?
336
+ rescue Gem::MissingSpecError => e
337
+ # @todo How to handle this?
338
+ end
339
+ if spec.nil?
340
+ STDERR.puts "Required path not found (pgp): #{r}"
341
+ else
342
+ @gem_paths[spec.name] = spec.full_gem_path
343
+ add_gem_dependencies spec
344
+ result = YARD::Registry.yardoc_file_for_gem(spec.name)
345
+ yardocs.unshift result unless result.nil? or yardocs.include?(result)
435
346
  end
436
347
  end
437
- result
438
348
  end
439
349
 
440
- def add_gem_dependencies gem_name
441
- spec = Gem::Specification.find_by_name(gem_name)
350
+ def add_gem_dependencies spec
442
351
  (spec.dependencies - spec.development_dependencies).each do |dep|
443
352
  gy = YARD::Registry.yardoc_file_for_gem(dep.name)
444
353
  if gy.nil?
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.17.1
4
+ version: 0.17.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-05 00:00:00.000000000 Z
11
+ date: 2018-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser