solargraph 0.11.1 → 0.11.2
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/lib/solargraph/api_map.rb +29 -17
- data/lib/solargraph/code_map.rb +83 -23
- data/lib/solargraph/server.rb +2 -4
- data/lib/solargraph/version.rb +1 -1
- metadata +32 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fd196523191df8e781673c9b4f4ec9680132b60
|
4
|
+
data.tar.gz: c341f7ecf19bb780648b125234d411891d6048e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22635ccfb51ffcff3638ec6cac95dc550824060a74e41aedf4f11e67e2da45b320e801c789fa5d1634614e8f7838a2a4260a24711bd3ee290b2d80365ba6f2b1
|
7
|
+
data.tar.gz: 6767110f8eccb4268f21b73a06f2854fc2b957da3caf3067e9ae0433a4251eb9d252e9d937c27d6926a416777e287911475a97bb8c10a5791954535022749dff
|
data/lib/solargraph/api_map.rb
CHANGED
@@ -495,15 +495,13 @@ module Solargraph
|
|
495
495
|
if workspace.nil?
|
496
496
|
STDERR.puts "No workspace specified for yardoc update."
|
497
497
|
else
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
STDERR.puts "There was an error processing the workspace yardoc."
|
506
|
-
end
|
498
|
+
Dir.chdir(workspace) do
|
499
|
+
STDERR.puts "Updating the yardoc for #{workspace}..."
|
500
|
+
cmd = "yardoc -e #{Solargraph::YARD_EXTENSION_FILE}"
|
501
|
+
STDERR.puts "Update yardoc with #{cmd}"
|
502
|
+
STDERR.puts `#{cmd}`
|
503
|
+
unless $?.success?
|
504
|
+
STDERR.puts "There was an error processing the workspace yardoc."
|
507
505
|
end
|
508
506
|
end
|
509
507
|
end
|
@@ -635,7 +633,7 @@ module Solargraph
|
|
635
633
|
n.children.each { |c|
|
636
634
|
if c.kind_of?(AST::Node) and c.type == :send and [:public, :protected, :private].include?(c.children[1])
|
637
635
|
current_scope = c.children[1]
|
638
|
-
elsif c.kind_of?(AST::Node) and c.type == :send and c.children[1] == :include
|
636
|
+
elsif c.kind_of?(AST::Node) and c.type == :send and c.children[1] == :include and n.type == :class
|
639
637
|
fqmod = find_fully_qualified_namespace(const_from(c.children[2]), root)
|
640
638
|
meths += get_instance_methods(fqmod) unless fqmod.nil? or skip.include?(fqmod)
|
641
639
|
else
|
@@ -665,9 +663,11 @@ module Solargraph
|
|
665
663
|
end
|
666
664
|
end
|
667
665
|
# This is necessary to get included modules from workspace definitions
|
668
|
-
|
669
|
-
|
670
|
-
|
666
|
+
if n.type == :class
|
667
|
+
get_include_strings_from(n).each { |i|
|
668
|
+
meths += inner_get_instance_methods(i, fqns, skip, visibility)
|
669
|
+
}
|
670
|
+
end
|
671
671
|
}
|
672
672
|
meths.uniq
|
673
673
|
end
|
@@ -715,10 +715,14 @@ module Solargraph
|
|
715
715
|
def get_constant_nodes(node, fqns)
|
716
716
|
result = []
|
717
717
|
node.children.each do |n|
|
718
|
-
if n.kind_of?(AST::Node)
|
719
|
-
|
720
|
-
|
721
|
-
|
718
|
+
if n.kind_of?(AST::Node)
|
719
|
+
if n.type == :casgn
|
720
|
+
cmnt = get_comment_for(n)
|
721
|
+
type = infer_assignment_node_type(n, fqns)
|
722
|
+
result.push Suggestion.new(n.children[1].to_s, kind: Suggestion::CONSTANT, documentation: cmnt, return_type: type)
|
723
|
+
else
|
724
|
+
result.concat get_constant_nodes(n, fqns) unless n.type == :class or n.type == :module
|
725
|
+
end
|
722
726
|
end
|
723
727
|
end
|
724
728
|
result
|
@@ -763,6 +767,7 @@ module Solargraph
|
|
763
767
|
# @return [String] The fully qualified namespace for the signature's type
|
764
768
|
# or nil if a type could not be determined
|
765
769
|
def inner_infer_signature_type signature, namespace, scope: :instance
|
770
|
+
orig = namespace
|
766
771
|
namespace = clean_namespace_string(namespace)
|
767
772
|
return nil if signature.nil?
|
768
773
|
signature.gsub!(/\.$/, '')
|
@@ -808,6 +813,13 @@ module Solargraph
|
|
808
813
|
sub = infer_signature_type(parts.join('.'), type, scope: :instance)
|
809
814
|
return sub unless sub.to_s == ''
|
810
815
|
end
|
816
|
+
if top and scope == :instance and p == '[]' and !orig.nil?
|
817
|
+
if orig.start_with?('Array<')
|
818
|
+
match = orig.match(/Array<([a-z0-9:_]*)/i)[1]
|
819
|
+
type = match
|
820
|
+
next
|
821
|
+
end
|
822
|
+
end
|
811
823
|
unless p == 'new' and scope != :instance
|
812
824
|
if scope == :instance
|
813
825
|
visibility = [:public]
|
data/lib/solargraph/code_map.rb
CHANGED
@@ -266,12 +266,21 @@ module Solargraph
|
|
266
266
|
phrase = phrase_at(index)
|
267
267
|
signature = get_signature_at(index)
|
268
268
|
namespace = namespace_at(index)
|
269
|
-
if signature.include?('.')
|
269
|
+
if signature.include?('.') or @code[index - signature.length - 1] == '.'
|
270
270
|
# Check for literals first
|
271
|
-
|
271
|
+
nearest = @code[0, index].rindex('.')
|
272
|
+
revised = signature[0..nearest-index-1]
|
273
|
+
revised = revised[2..-1] if revised.start_with?('[]')
|
274
|
+
cursed = get_signature_index_at(index)
|
275
|
+
frag = @code[cursed..index]
|
276
|
+
literal = nil
|
277
|
+
if frag.start_with?('.')
|
278
|
+
literal = node_at(cursed - 1)
|
279
|
+
else
|
280
|
+
literal = node_at(cursed + 1)
|
281
|
+
end
|
282
|
+
type = infer_literal_node_type(literal)
|
272
283
|
if type.nil?
|
273
|
-
nearest = @code[0, index].rindex('.')
|
274
|
-
revised = signature[0..nearest-index-1]
|
275
284
|
type = infer_signature_at(nearest) unless revised.empty?
|
276
285
|
if !type.nil?
|
277
286
|
result.concat api_map.get_instance_methods(type) unless type.nil?
|
@@ -280,7 +289,14 @@ module Solargraph
|
|
280
289
|
result.concat api_map.get_methods(fqns) unless fqns.nil?
|
281
290
|
end
|
282
291
|
else
|
283
|
-
|
292
|
+
rest = revised
|
293
|
+
rest = rest[1..-1] if rest.start_with?('.')
|
294
|
+
if rest.nil? or rest.empty?
|
295
|
+
result.concat api_map.get_instance_methods(type)
|
296
|
+
else
|
297
|
+
intype = api_map.infer_signature_type(rest, type, scope: :instance)
|
298
|
+
result.concat api_map.get_instance_methods(intype)
|
299
|
+
end
|
284
300
|
end
|
285
301
|
elsif signature.start_with?('@@')
|
286
302
|
result.concat get_class_variables_at(index)
|
@@ -298,18 +314,23 @@ module Solargraph
|
|
298
314
|
result = api_map.namespaces_in(ns, namespace)
|
299
315
|
end
|
300
316
|
else
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
317
|
+
type = infer_literal_node_type(node_at(index - 2))
|
318
|
+
if type.nil?
|
319
|
+
current_namespace = namespace_at(index)
|
320
|
+
parts = current_namespace.to_s.split('::')
|
321
|
+
result += get_snippets_at(index) if with_snippets
|
322
|
+
result += get_local_variables_and_methods_at(index)
|
323
|
+
result += ApiMap.get_keywords
|
324
|
+
while parts.length > 0
|
325
|
+
ns = parts.join('::')
|
326
|
+
result += api_map.namespaces_in(ns, namespace)
|
327
|
+
parts.pop
|
328
|
+
end
|
329
|
+
result += api_map.namespaces_in('')
|
330
|
+
result += api_map.get_instance_methods('Kernel')
|
331
|
+
else
|
332
|
+
result.concat api_map.get_instance_methods(type)
|
310
333
|
end
|
311
|
-
result += api_map.namespaces_in('')
|
312
|
-
result += api_map.get_instance_methods('Kernel')
|
313
334
|
end
|
314
335
|
result = reduce_starting_with(result, word_at(index)) if filtered
|
315
336
|
result.uniq{|s| s.path}.sort{|a,b| a.label <=> b.label}
|
@@ -478,11 +499,9 @@ module Solargraph
|
|
478
499
|
# A signature is a method call that can start with a constant, method, or
|
479
500
|
# variable and does not include any method arguments. Examples:
|
480
501
|
#
|
481
|
-
#
|
482
|
-
#
|
483
|
-
#
|
484
|
-
# @x.bar @x.bar
|
485
|
-
# y.split(', ').length y.split.length
|
502
|
+
# * String.new -> String.new
|
503
|
+
# * @x.bar -> @x.bar
|
504
|
+
# * y.split(', ').length -> y.split.length
|
486
505
|
#
|
487
506
|
# @param index [Integer]
|
488
507
|
# @return [String]
|
@@ -507,10 +526,11 @@ module Solargraph
|
|
507
526
|
brackets += 1
|
508
527
|
elsif char == '['
|
509
528
|
squares += 1
|
529
|
+
signature = ".[]#{signature}" if squares == 0 and @code[index-2] != '%'
|
510
530
|
end
|
511
531
|
if brackets == 0 and parens == 0 and squares == 0
|
512
|
-
break if ['"', "'", ',', ' ', "\t", "\n"].include?(char)
|
513
|
-
signature = char + signature if char.match(/[a-z0-9:\._@]/i)
|
532
|
+
break if ['"', "'", ',', ' ', "\t", "\n", ';', '%'].include?(char)
|
533
|
+
signature = char + signature if char.match(/[a-z0-9:\._@]/i) and @code[index - 1] != '%'
|
514
534
|
if char == '@'
|
515
535
|
signature = "@#{signature}" if @code[index-1, 1] == '@'
|
516
536
|
break
|
@@ -518,9 +538,49 @@ module Solargraph
|
|
518
538
|
end
|
519
539
|
index -= 1
|
520
540
|
end
|
541
|
+
signature = signature[1..-1] if signature.start_with?('.')
|
542
|
+
#signature = signature[2..-1] if signature.start_with?('[]')
|
521
543
|
signature
|
522
544
|
end
|
523
545
|
|
546
|
+
def get_signature_index_at index
|
547
|
+
brackets = 0
|
548
|
+
squares = 0
|
549
|
+
parens = 0
|
550
|
+
signature = ''
|
551
|
+
index -=1
|
552
|
+
while index >= 0
|
553
|
+
break if brackets > 0 or parens > 0 or squares > 0
|
554
|
+
char = @code[index, 1]
|
555
|
+
if char == ')'
|
556
|
+
parens -=1
|
557
|
+
elsif char == ']'
|
558
|
+
squares -=1
|
559
|
+
elsif char == '}'
|
560
|
+
brackets -= 1
|
561
|
+
elsif char == '('
|
562
|
+
parens += 1
|
563
|
+
elsif char == '{'
|
564
|
+
brackets += 1
|
565
|
+
elsif char == '['
|
566
|
+
squares += 1
|
567
|
+
signature = ".[]#{signature}" if squares == 0
|
568
|
+
end
|
569
|
+
if brackets == 0 and parens == 0 and squares == 0
|
570
|
+
break if ['"', "'", ',', ' ', "\t", "\n", ';'].include?(char)
|
571
|
+
signature = char + signature if char.match(/[a-z0-9:\._@]/i)
|
572
|
+
if char == '@'
|
573
|
+
signature = "@#{signature}" if @code[index-1, 1] == '@'
|
574
|
+
break
|
575
|
+
end
|
576
|
+
end
|
577
|
+
index -= 1
|
578
|
+
end
|
579
|
+
signature = signature[1..-1] if signature.start_with?('.')
|
580
|
+
signature = signature[2..-1] if signature.start_with?('[]')
|
581
|
+
index + 1
|
582
|
+
end
|
583
|
+
|
524
584
|
def get_snippets_at(index)
|
525
585
|
result = []
|
526
586
|
Snippets.definitions.each_pair { |name, detail|
|
data/lib/solargraph/server.rb
CHANGED
@@ -25,7 +25,7 @@ module Solargraph
|
|
25
25
|
begin
|
26
26
|
sugg = []
|
27
27
|
workspace = params['workspace']
|
28
|
-
Server.prepare_workspace workspace unless @@api_hash.has_key?(workspace)
|
28
|
+
#Server.prepare_workspace workspace unless @@api_hash.has_key?(workspace)
|
29
29
|
@@semaphore.synchronize {
|
30
30
|
code_map = CodeMap.new(code: params['text'], filename: params['filename'], api_map: @@api_hash[workspace], cursor: [params['line'].to_i, params['column'].to_i])
|
31
31
|
offset = code_map.get_offset(params['line'].to_i, params['column'].to_i)
|
@@ -122,12 +122,10 @@ module Solargraph
|
|
122
122
|
|
123
123
|
def prepare_workspace directory
|
124
124
|
api_map = Solargraph::ApiMap.new(directory)
|
125
|
+
api_map.update_yardoc
|
125
126
|
@@semaphore.synchronize {
|
126
127
|
@@api_hash[directory] = api_map
|
127
128
|
}
|
128
|
-
Thread.new {
|
129
|
-
api_map.update_yardoc
|
130
|
-
}
|
131
129
|
end
|
132
130
|
end
|
133
131
|
|
data/lib/solargraph/version.rb
CHANGED
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.11.
|
4
|
+
version: 0.11.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: 2017-
|
11
|
+
date: 2017-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -120,7 +120,35 @@ dependencies:
|
|
120
120
|
- - "~>"
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: '0.14'
|
123
|
-
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
name: debase
|
125
|
+
requirement: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
type: :development
|
131
|
+
prerelease: false
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: ruby-debug-ide
|
139
|
+
requirement: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
type: :development
|
145
|
+
prerelease: false
|
146
|
+
version_requirements: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
description: IDE tools for code completion and inline documentation
|
124
152
|
email: admin@castwide.com
|
125
153
|
executables:
|
126
154
|
- solargraph
|
@@ -149,7 +177,7 @@ files:
|
|
149
177
|
- lib/solargraph/yard_methods.rb
|
150
178
|
- lib/yard-solargraph.rb
|
151
179
|
- yardoc/2.0.0.tar.gz
|
152
|
-
homepage: http://
|
180
|
+
homepage: http://solargraph.org
|
153
181
|
licenses:
|
154
182
|
- MIT
|
155
183
|
metadata: {}
|