solargraph 0.25.0 → 0.25.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/solargraph.rb +1 -0
- data/lib/solargraph/api_map.rb +2 -0
- data/lib/solargraph/complex_type.rb +86 -14
- data/lib/solargraph/language_server/host.rb +12 -11
- data/lib/solargraph/pin/method.rb +7 -1
- data/lib/solargraph/source.rb +1 -0
- data/lib/solargraph/source/fragment.rb +5 -4
- data/lib/solargraph/source/mapper.rb +9 -1
- data/lib/solargraph/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bd332c0e24354eee990335169e5d861e470714cf3f3431b41c5d7e184f33035
|
4
|
+
data.tar.gz: a4ce050c8e2e9ef1990c9be69dc2a4a6457cf27bc9b7ba85168014c30da77480
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cd5cfb006e654069b88c596dea33d6be250bda7569a1193c834336345fa927d0b28b48fdfa5c37f68f3ce56ffc6cf6e647cda4e6184cbb566e8ad68ef3ac339
|
7
|
+
data.tar.gz: 9846d874b79d01132a0fdb8ad7dd6f0cf81682a1fb9e1f3d72602d8ca3330380fba455f9c4d7f9e624bb40b2dff21d39fcef42c4273832c549b296c4a98b4a24
|
data/lib/solargraph.rb
CHANGED
@@ -8,6 +8,7 @@ module Solargraph
|
|
8
8
|
class DiagnosticsError < RuntimeError; end
|
9
9
|
class FileNotFoundError < RuntimeError; end
|
10
10
|
class SourceNotAvailableError < StandardError; end
|
11
|
+
class ComplexTypeError < StandardError; end
|
11
12
|
class WorkspaceTooLargeError < RuntimeError
|
12
13
|
# @return [Integer]
|
13
14
|
attr_reader :size
|
data/lib/solargraph/api_map.rb
CHANGED
@@ -629,10 +629,12 @@ module Solargraph
|
|
629
629
|
@path_macros ||= {}
|
630
630
|
end
|
631
631
|
|
632
|
+
# @return [Array<Solargraph::Source>]
|
632
633
|
def current_workspace_sources
|
633
634
|
@sources - [@virtual_source]
|
634
635
|
end
|
635
636
|
|
637
|
+
# @return [String]
|
636
638
|
def inner_qualify name, root, skip
|
637
639
|
return nil if name.nil?
|
638
640
|
return nil if skip.include?(root)
|
@@ -21,10 +21,19 @@ module Solargraph
|
|
21
21
|
def initialize name, substring = ''
|
22
22
|
@name = name
|
23
23
|
@substring = substring
|
24
|
-
@tag = name
|
25
|
-
@
|
24
|
+
@tag = name + substring
|
25
|
+
@key_types = []
|
26
26
|
@subtypes = []
|
27
|
-
|
27
|
+
if parameters?
|
28
|
+
subs = ComplexType.parse(substring[1..-2])
|
29
|
+
if hash_parameters?
|
30
|
+
raise ComplexTypeError, "Bad hash type" unless subs.length == 2 and subs[0].is_a?(Array) and subs[1].is_a?(Array)
|
31
|
+
@key_types.concat subs[0]
|
32
|
+
@subtypes.concat subs[1]
|
33
|
+
else
|
34
|
+
@subtypes.concat subs
|
35
|
+
end
|
36
|
+
end
|
28
37
|
end
|
29
38
|
|
30
39
|
# @return [Boolean]
|
@@ -37,6 +46,36 @@ module Solargraph
|
|
37
46
|
@nil_type ||= (name.downcase == 'nil')
|
38
47
|
end
|
39
48
|
|
49
|
+
# @return [Boolean]
|
50
|
+
def parameters?
|
51
|
+
!substring.empty?
|
52
|
+
end
|
53
|
+
|
54
|
+
# @return [Boolean]
|
55
|
+
def list_parameters?
|
56
|
+
substring.start_with?('<')
|
57
|
+
end
|
58
|
+
|
59
|
+
# @return [Boolean]
|
60
|
+
def fixed_parameters?
|
61
|
+
substring.start_with?('(')
|
62
|
+
end
|
63
|
+
|
64
|
+
# @return [Boolean]
|
65
|
+
def hash_parameters?
|
66
|
+
substring.start_with?('{')
|
67
|
+
end
|
68
|
+
|
69
|
+
# @return [Array<ComplexType>]
|
70
|
+
def value_types
|
71
|
+
@subtypes
|
72
|
+
end
|
73
|
+
|
74
|
+
# @return [Array<ComplexType>]
|
75
|
+
def key_types
|
76
|
+
@key_types
|
77
|
+
end
|
78
|
+
|
40
79
|
# @return [String]
|
41
80
|
def namespace
|
42
81
|
@namespace ||= 'Object' if duck_type?
|
@@ -60,37 +99,70 @@ module Solargraph
|
|
60
99
|
# @return [Array<ComplexType>]
|
61
100
|
def parse *strings
|
62
101
|
types = []
|
102
|
+
key_types = nil
|
63
103
|
strings.each do |type_string|
|
64
104
|
point_stack = 0
|
65
105
|
curly_stack = 0
|
106
|
+
paren_stack = 0
|
66
107
|
base = ''
|
67
108
|
subtype_string = ''
|
68
109
|
type_string.each_char do |char|
|
69
|
-
if char == '
|
110
|
+
if char == '='
|
111
|
+
#raise ComplexTypeError, "Invalid = in type #{type_string}" unless curly_stack > 0
|
112
|
+
elsif char == '<'
|
70
113
|
point_stack += 1
|
71
|
-
next if point_stack == 1
|
72
114
|
elsif char == '>'
|
73
|
-
|
74
|
-
|
115
|
+
if subtype_string.end_with?('=') and curly_stack > 0
|
116
|
+
subtype_string += char
|
117
|
+
elsif base.end_with?('=')
|
118
|
+
raise ComplexTypeError, "Invalid hash thing" unless key_types.nil?
|
119
|
+
types.push ComplexType.new(base[0..-2].strip)
|
120
|
+
key_types = types
|
121
|
+
types = []
|
122
|
+
base = ''
|
123
|
+
subtype_string = ''
|
124
|
+
next
|
125
|
+
else
|
126
|
+
point_stack -= 1
|
127
|
+
subtype_string += char if point_stack == 0
|
128
|
+
raise ComplexTypeError, "Invalid close in type #{type_string}" if point_stack < 0
|
129
|
+
end
|
130
|
+
next
|
75
131
|
elsif char == '{'
|
76
|
-
|
77
|
-
|
78
|
-
|
132
|
+
curly_stack += 1
|
133
|
+
elsif char == '}'
|
134
|
+
curly_stack -= 1
|
135
|
+
subtype_string += char
|
136
|
+
raise ComplexTypeError, "Invalid close in type #{type_string}" if curly_stack < 0
|
137
|
+
# types.push ComplexType.parse(subtype_string[1..-2]) if curly_stack == 0
|
138
|
+
next
|
139
|
+
elsif char == '('
|
140
|
+
paren_stack += 1
|
141
|
+
elsif char == ')'
|
142
|
+
paren_stack -= 1
|
143
|
+
subtype_string += char if paren_stack == 0
|
144
|
+
raise ComplexTypeError, "Invalid close in type #{type_string}" if paren_stack < 0
|
145
|
+
next
|
146
|
+
elsif char == ',' and point_stack == 0 and curly_stack == 0 and paren_stack == 0
|
79
147
|
types.push ComplexType.new base.strip, subtype_string.strip
|
80
148
|
base = ''
|
81
149
|
subtype_string = ''
|
82
150
|
next
|
83
151
|
end
|
84
|
-
if point_stack == 0 and
|
152
|
+
if point_stack == 0 and curly_stack == 0 and paren_stack == 0
|
85
153
|
base += char
|
86
|
-
|
154
|
+
else
|
87
155
|
subtype_string += char
|
88
156
|
end
|
89
157
|
end
|
90
158
|
base.strip!
|
91
159
|
subtype_string.strip!
|
92
|
-
raise
|
93
|
-
types.push ComplexType.new
|
160
|
+
raise ComplexTypeError, "Unclosed subtype in #{type_string}" if point_stack != 0 or curly_stack != 0 or paren_stack != 0
|
161
|
+
types.push ComplexType.new(base, subtype_string)
|
162
|
+
end
|
163
|
+
unless key_types.nil?
|
164
|
+
return key_types if types.empty?
|
165
|
+
return [key_types, types]
|
94
166
|
end
|
95
167
|
types
|
96
168
|
end
|
@@ -492,17 +492,17 @@ module Solargraph
|
|
492
492
|
@diagnostics_queue.push change['textDocument']['uri']
|
493
493
|
changed = true
|
494
494
|
next true
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
495
|
+
elsif change['textDocument']['version'] == source.version + 1
|
496
|
+
# HACK: This condition fixes the fact that certain changes
|
497
|
+
# increment the version by one regardless of the number of
|
498
|
+
# changes
|
499
|
+
STDERR.puts "Warning: change applied to #{uri_to_file(change['textDocument']['uri'])} is possibly out of sync"
|
500
|
+
pending[change['textDocument']['uri']] -= 1
|
501
|
+
updater = generate_updater(change)
|
502
|
+
library.synchronize updater, pending[change['textDocument']['uri']] == 0
|
503
|
+
@diagnostics_queue.push change['textDocument']['uri']
|
504
|
+
changed = true
|
505
|
+
next true
|
506
506
|
elsif change['textDocument']['version'] <= source.version
|
507
507
|
# @todo Is deleting outdated changes correct behavior?
|
508
508
|
STDERR.puts "Warning: outdated change to #{change['textDocument']['uri']} was ignored"
|
@@ -510,6 +510,7 @@ module Solargraph
|
|
510
510
|
next true
|
511
511
|
else
|
512
512
|
# @todo Change is out of order. Save it for later
|
513
|
+
STDERR.puts "Skipping out of order change to #{change['textDocument']['uri']}"
|
513
514
|
next false
|
514
515
|
end
|
515
516
|
end
|
@@ -72,6 +72,7 @@ module Solargraph
|
|
72
72
|
|
73
73
|
private
|
74
74
|
|
75
|
+
# @return [Array<ComplexType>]
|
75
76
|
def generate_complex_types
|
76
77
|
tag = docstring.tag(:return)
|
77
78
|
if tag.nil?
|
@@ -79,7 +80,12 @@ module Solargraph
|
|
79
80
|
tag = ol.tag(:return) unless ol.nil?
|
80
81
|
end
|
81
82
|
return [] if tag.nil?
|
82
|
-
|
83
|
+
begin
|
84
|
+
ComplexType.parse *tag.types
|
85
|
+
rescue Solargraph::ComplexTypeError => e
|
86
|
+
STDERR.puts e.message
|
87
|
+
[]
|
88
|
+
end
|
83
89
|
end
|
84
90
|
end
|
85
91
|
end
|
data/lib/solargraph/source.rb
CHANGED
@@ -84,7 +84,7 @@ module Solargraph
|
|
84
84
|
#
|
85
85
|
# @return [String]
|
86
86
|
def signature
|
87
|
-
@signature ||= signature_data[1]
|
87
|
+
@signature ||= signature_data[1].to_s
|
88
88
|
end
|
89
89
|
|
90
90
|
def valid?
|
@@ -128,7 +128,7 @@ module Solargraph
|
|
128
128
|
|
129
129
|
# @return [String]
|
130
130
|
def chain
|
131
|
-
@chain ||= signature.split('.')[1..-1].join('.')
|
131
|
+
@chain ||= ( signature.empty? ? '' : signature.split('.')[1..-1].join('.') )
|
132
132
|
end
|
133
133
|
|
134
134
|
# @return [String]
|
@@ -393,7 +393,7 @@ module Solargraph
|
|
393
393
|
# @param index [Integer]
|
394
394
|
# @return [String]
|
395
395
|
def word_at index
|
396
|
-
@code[beginning_of_word_at(index)..index - 1]
|
396
|
+
@code[beginning_of_word_at(index)..index - 1].to_s
|
397
397
|
end
|
398
398
|
|
399
399
|
def beginning_of_word_at index
|
@@ -442,6 +442,7 @@ module Solargraph
|
|
442
442
|
Solargraph::Source::Range.from_to(start_pos[0], start_pos[1], end_pos[0], end_pos[1])
|
443
443
|
end
|
444
444
|
|
445
|
+
# @return [String]
|
445
446
|
def remainder_at index
|
446
447
|
cursor = index
|
447
448
|
while cursor < @code.length
|
@@ -450,7 +451,7 @@ module Solargraph
|
|
450
451
|
break unless char.match(/[a-z0-9_\?\!]/i)
|
451
452
|
cursor += 1
|
452
453
|
end
|
453
|
-
@code[index..cursor-1]
|
454
|
+
@code[index..cursor-1].to_s
|
454
455
|
end
|
455
456
|
|
456
457
|
def signature_position
|
@@ -50,9 +50,13 @@ module Solargraph
|
|
50
50
|
# @param node [Parser::AST::Node]
|
51
51
|
# @return [String]
|
52
52
|
def code_for node
|
53
|
+
# @todo Using node locations on code with converted EOLs seems
|
54
|
+
# slightly more efficient than calculating offsets.
|
53
55
|
b = node.location.expression.begin.begin_pos
|
54
56
|
e = node.location.expression.end.end_pos
|
55
|
-
|
57
|
+
# b = Source::Position.line_char_to_offset(@code, node.location.line - 1, node.location.column)
|
58
|
+
# e = Source::Position.line_char_to_offset(@code, node.location.last_line - 1, node.location.last_column)
|
59
|
+
frag = source_from_parser[b..e-1].to_s
|
56
60
|
frag.strip.gsub(/,$/, '')
|
57
61
|
end
|
58
62
|
|
@@ -406,6 +410,10 @@ module Solargraph
|
|
406
410
|
}
|
407
411
|
args
|
408
412
|
end
|
413
|
+
|
414
|
+
def source_from_parser
|
415
|
+
@source_from_parser ||= @code.gsub(/\r\n/, "\n")
|
416
|
+
end
|
409
417
|
end
|
410
418
|
end
|
411
419
|
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.25.
|
4
|
+
version: 0.25.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: 2018-08-
|
11
|
+
date: 2018-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|