solargraph 0.12.0 → 0.12.1
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 +11 -10
- data/lib/solargraph/api_map/cache.rb +5 -0
- data/lib/solargraph/api_map/cvar_pin.rb +6 -5
- data/lib/solargraph/api_map/ivar_pin.rb +6 -5
- data/lib/solargraph/code_map.rb +41 -25
- data/lib/solargraph/node_methods.rb +2 -0
- data/lib/solargraph/suggestion.rb +1 -1
- data/lib/solargraph/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12ba7fd6f2f9b2393c21aba8249cd43e7c69062f
|
4
|
+
data.tar.gz: c102835081a9b19b74180c1f75b7ebaea695e5f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bd7974b55a00ec8a914e77dffe352af321bbe9e27d1a1c19c74417015bc6d7886077017313e3526489e6a12e2b0933dc586cae2252e31afb0332da75f5a9f76
|
7
|
+
data.tar.gz: cdc14d195c758dc1acd151e22155c41390026bb89e9a74756b9b28e24cd68f53fde8c1e8ce20f4c8a3bb1244f0bfa12f034fda91e0438a9c534483e8a61aed01
|
data/lib/solargraph/api_map.rb
CHANGED
@@ -23,7 +23,7 @@ module Solargraph
|
|
23
23
|
].freeze
|
24
24
|
|
25
25
|
MAPPABLE_NODES = [
|
26
|
-
:array, :hash, :str, :dstr, :int, :float, :block, :class, :sclass,
|
26
|
+
:array, :hash, :str, :dstr, :int, :float, :sym, :block, :class, :sclass,
|
27
27
|
:module, :def, :defs, :ivasgn, :gvasgn, :lvasgn, :cvasgn, :casgn,
|
28
28
|
:or_asgn, :const, :lvar, :args, :kwargs
|
29
29
|
].freeze
|
@@ -35,7 +35,7 @@ module Solargraph
|
|
35
35
|
|
36
36
|
METHODS_RETURNING_SELF = [
|
37
37
|
'clone', 'dup', 'freeze', 'taint', 'untaint'
|
38
|
-
]
|
38
|
+
].freeze
|
39
39
|
|
40
40
|
include NodeMethods
|
41
41
|
include YardMethods
|
@@ -202,7 +202,7 @@ module Solargraph
|
|
202
202
|
ip = @ivar_pins[namespace]
|
203
203
|
unless ip.nil?
|
204
204
|
ip.select{ |pin| pin.scope == scope }.each do |pin|
|
205
|
-
result.push pin.suggestion
|
205
|
+
result.push pin.suggestion
|
206
206
|
end
|
207
207
|
end
|
208
208
|
result
|
@@ -214,7 +214,7 @@ module Solargraph
|
|
214
214
|
ip = @cvar_pins[namespace]
|
215
215
|
unless ip.nil?
|
216
216
|
ip.each do |pin|
|
217
|
-
result.push pin.suggestion
|
217
|
+
result.push pin.suggestion
|
218
218
|
end
|
219
219
|
end
|
220
220
|
result
|
@@ -532,15 +532,16 @@ module Solargraph
|
|
532
532
|
@namespace_map = {}
|
533
533
|
@namespace_tree = {}
|
534
534
|
@required = []
|
535
|
+
end
|
536
|
+
|
537
|
+
def process_maps
|
538
|
+
cache.clear
|
535
539
|
@ivar_pins = {}
|
536
540
|
@cvar_pins = {}
|
537
541
|
@method_pins = {}
|
538
542
|
@attr_nodes = {}
|
539
543
|
@namespace_includes = {}
|
540
544
|
@superclasses = {}
|
541
|
-
end
|
542
|
-
|
543
|
-
def process_maps
|
544
545
|
@parent_stack = {}
|
545
546
|
@namespace_map = {}
|
546
547
|
@namespace_tree = {}
|
@@ -840,7 +841,7 @@ module Solargraph
|
|
840
841
|
# TODO: The api_map should ignore local variables.
|
841
842
|
type = node.children[0].type
|
842
843
|
children.push node.children[0].children[0], node.children[1]
|
843
|
-
elsif [:array, :hash, :str, :dstr, :int, :float].include?(node.type)
|
844
|
+
elsif [:array, :hash, :str, :dstr, :int, :float, :sym].include?(node.type)
|
844
845
|
# @todo Do we really care about the details?
|
845
846
|
end
|
846
847
|
result = node.updated(type, children)
|
@@ -896,10 +897,10 @@ module Solargraph
|
|
896
897
|
if c.kind_of?(AST::Node)
|
897
898
|
if c.type == :ivasgn
|
898
899
|
@ivar_pins[fqn] ||= []
|
899
|
-
@ivar_pins[fqn].push IvarPin.new(c, fqn, local_scope, get_comment_for(c))
|
900
|
+
@ivar_pins[fqn].push IvarPin.new(self, c, fqn, local_scope, get_comment_for(c))
|
900
901
|
elsif c.type == :cvasgn
|
901
902
|
@cvar_pins[fqn] ||= []
|
902
|
-
@cvar_pins[fqn].push CvarPin.new(c, fqn, get_comment_for(c))
|
903
|
+
@cvar_pins[fqn].push CvarPin.new(self, c, fqn, get_comment_for(c))
|
903
904
|
else
|
904
905
|
unless fqn.nil? or in_yardoc
|
905
906
|
if c.kind_of?(AST::Node)
|
@@ -5,20 +5,21 @@ module Solargraph
|
|
5
5
|
attr_reader :namespace
|
6
6
|
attr_reader :docstring
|
7
7
|
|
8
|
-
def initialize node, namespace, docstring
|
8
|
+
def initialize api_map, node, namespace, docstring
|
9
|
+
@api_map = api_map
|
9
10
|
@node = node
|
10
11
|
@namespace = namespace
|
11
12
|
@docstring = docstring
|
12
13
|
end
|
13
14
|
|
14
|
-
def suggestion
|
15
|
-
@suggestion ||= generate_suggestion
|
15
|
+
def suggestion
|
16
|
+
@suggestion ||= generate_suggestion
|
16
17
|
end
|
17
18
|
|
18
19
|
private
|
19
20
|
|
20
|
-
def generate_suggestion
|
21
|
-
type = api_map.infer_assignment_node_type(node, namespace)
|
21
|
+
def generate_suggestion
|
22
|
+
type = @api_map.infer_assignment_node_type(node, namespace)
|
22
23
|
Suggestion.new(node.children[0], kind: Suggestion::VARIABLE, documentation: docstring, return_type: type)
|
23
24
|
end
|
24
25
|
end
|
@@ -6,21 +6,22 @@ module Solargraph
|
|
6
6
|
attr_reader :scope
|
7
7
|
attr_reader :docstring
|
8
8
|
|
9
|
-
def initialize node, namespace, scope, docstring
|
9
|
+
def initialize api_map, node, namespace, scope, docstring
|
10
|
+
@api_map = api_map
|
10
11
|
@node = node
|
11
12
|
@namespace = namespace
|
12
13
|
@scope = scope
|
13
14
|
@docstring = docstring
|
14
15
|
end
|
15
16
|
|
16
|
-
def suggestion
|
17
|
-
@suggestion ||= generate_suggestion
|
17
|
+
def suggestion
|
18
|
+
@suggestion ||= generate_suggestion
|
18
19
|
end
|
19
20
|
|
20
21
|
private
|
21
22
|
|
22
|
-
def generate_suggestion
|
23
|
-
type = api_map.infer_assignment_node_type(node, namespace)
|
23
|
+
def generate_suggestion
|
24
|
+
type = @api_map.infer_assignment_node_type(node, namespace)
|
24
25
|
Suggestion.new(node.children[0], kind: Suggestion::VARIABLE, documentation: docstring, return_type: type)
|
25
26
|
end
|
26
27
|
end
|
data/lib/solargraph/code_map.rb
CHANGED
@@ -98,6 +98,8 @@ module Solargraph
|
|
98
98
|
# @return [Solargraph::ApiMap]
|
99
99
|
def api_map
|
100
100
|
@api_map ||= ApiMap.new(workspace)
|
101
|
+
@api_map.refresh
|
102
|
+
@api_map
|
101
103
|
end
|
102
104
|
|
103
105
|
# Get the offset of the specified line and column.
|
@@ -395,7 +397,11 @@ module Solargraph
|
|
395
397
|
literal = node_at(index - 1)
|
396
398
|
else
|
397
399
|
beg_sig = get_signature_index_at(index)
|
398
|
-
|
400
|
+
if @code[beg_sig] == '.'
|
401
|
+
literal = node_at(beg_sig - 1)
|
402
|
+
else
|
403
|
+
literal = node_at(1 + beg_sig)
|
404
|
+
end
|
399
405
|
end
|
400
406
|
type = infer_literal_node_type(literal)
|
401
407
|
if type.nil?
|
@@ -431,11 +437,19 @@ module Solargraph
|
|
431
437
|
end
|
432
438
|
end
|
433
439
|
else
|
434
|
-
if signature.empty?
|
440
|
+
if signature.empty? or signature == '[].'
|
435
441
|
result = type
|
436
442
|
else
|
437
443
|
cursed = get_signature_index_at(index)
|
438
|
-
|
444
|
+
if signature.start_with?('[].')
|
445
|
+
rest = signature[3..-1]
|
446
|
+
else
|
447
|
+
if signature.start_with?('.')
|
448
|
+
rest = signature[literal.loc.expression.end_pos+(cursed-literal.loc.expression.end_pos)..-1]
|
449
|
+
else
|
450
|
+
rest = signature
|
451
|
+
end
|
452
|
+
end
|
439
453
|
return type if rest.nil?
|
440
454
|
lit_code = @code[literal.loc.expression.begin_pos..literal.loc.expression.end_pos]
|
441
455
|
rest = rest[lit_code.length..-1] if rest.start_with?(lit_code)
|
@@ -541,28 +555,30 @@ module Solargraph
|
|
541
555
|
signature = ''
|
542
556
|
index -=1
|
543
557
|
while index >= 0
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
558
|
+
unless string_at?(index)
|
559
|
+
break if brackets > 0 or parens > 0 or squares > 0
|
560
|
+
char = @code[index, 1]
|
561
|
+
if char == ')'
|
562
|
+
parens -=1
|
563
|
+
elsif char == ']'
|
564
|
+
squares -=1
|
565
|
+
elsif char == '}'
|
566
|
+
brackets -= 1
|
567
|
+
elsif char == '('
|
568
|
+
parens += 1
|
569
|
+
elsif char == '{'
|
570
|
+
brackets += 1
|
571
|
+
elsif char == '['
|
572
|
+
squares += 1
|
573
|
+
signature = ".[]#{signature}" if squares == 0 and @code[index-2] != '%'
|
574
|
+
end
|
575
|
+
if brackets == 0 and parens == 0 and squares == 0
|
576
|
+
break if ['"', "'", ',', ' ', "\t", "\n", ';', '%'].include?(char)
|
577
|
+
signature = char + signature if char.match(/[a-z0-9:\._@]/i) and @code[index - 1] != '%'
|
578
|
+
if char == '@'
|
579
|
+
signature = "@#{signature}" if @code[index-1, 1] == '@'
|
580
|
+
break
|
581
|
+
end
|
566
582
|
end
|
567
583
|
end
|
568
584
|
index -= 1
|
@@ -93,7 +93,7 @@ module Solargraph
|
|
93
93
|
arguments: @arguments,
|
94
94
|
params: params,
|
95
95
|
return_type: return_type,
|
96
|
-
documentation: @helper.html_markup_rdoc(documentation
|
96
|
+
documentation: documentation.nil? ? nil : @helper.html_markup_rdoc(documentation)
|
97
97
|
}
|
98
98
|
obj.to_json(args)
|
99
99
|
end
|
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.12.
|
4
|
+
version: 0.12.1
|
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-09-
|
11
|
+
date: 2017-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|