solargraph 0.53.4 → 0.54.0
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/CHANGELOG.md +22 -0
- data/lib/solargraph/api_map/cache.rb +2 -12
- data/lib/solargraph/api_map/store.rb +11 -6
- data/lib/solargraph/api_map.rb +53 -17
- data/lib/solargraph/complex_type/type_methods.rb +62 -30
- data/lib/solargraph/complex_type/unique_type.rb +117 -66
- data/lib/solargraph/complex_type.rb +41 -25
- data/lib/solargraph/doc_map.rb +19 -3
- data/lib/solargraph/gem_pins.rb +9 -1
- data/lib/solargraph/language_server/host/dispatch.rb +8 -1
- data/lib/solargraph/language_server/host/sources.rb +1 -61
- data/lib/solargraph/language_server/host.rb +21 -68
- data/lib/solargraph/language_server/message/base.rb +1 -1
- data/lib/solargraph/language_server/message/initialize.rb +14 -0
- data/lib/solargraph/language_server/message/text_document/formatting.rb +1 -0
- data/lib/solargraph/language_server/progress.rb +118 -0
- data/lib/solargraph/language_server.rb +1 -0
- data/lib/solargraph/library.rb +136 -96
- data/lib/solargraph/parser/node_processor/base.rb +3 -2
- data/lib/solargraph/parser/node_processor.rb +1 -0
- data/lib/solargraph/parser/parser_gem/class_methods.rb +3 -7
- data/lib/solargraph/parser/parser_gem/node_methods.rb +0 -4
- data/lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb +47 -0
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +5 -3
- data/lib/solargraph/parser/parser_gem/node_processors.rb +2 -0
- data/lib/solargraph/pin/base_variable.rb +34 -5
- data/lib/solargraph/pin/block.rb +55 -0
- data/lib/solargraph/pin/delegated_method.rb +5 -1
- data/lib/solargraph/pin/documenting.rb +2 -0
- data/lib/solargraph/pin/method.rb +3 -1
- data/lib/solargraph/pin/parameter.rb +5 -28
- data/lib/solargraph/rbs_map/conversions.rb +10 -6
- data/lib/solargraph/rbs_map.rb +11 -3
- data/lib/solargraph/shell.rb +18 -13
- data/lib/solargraph/source/chain.rb +20 -0
- data/lib/solargraph/source/updater.rb +1 -0
- data/lib/solargraph/source.rb +0 -44
- data/lib/solargraph/source_map/mapper.rb +3 -2
- data/lib/solargraph/source_map.rb +10 -0
- data/lib/solargraph/type_checker.rb +43 -18
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +2 -1
- data/lib/solargraph/workspace.rb +13 -0
- metadata +4 -3
- data/lib/solargraph/language_server/host/cataloger.rb +0 -57
@@ -11,7 +11,7 @@ module Solargraph
|
|
11
11
|
autoload :TypeMethods, 'solargraph/complex_type/type_methods'
|
12
12
|
autoload :UniqueType, 'solargraph/complex_type/unique_type'
|
13
13
|
|
14
|
-
# @param types [Array<
|
14
|
+
# @param types [Array<UniqueType, ComplexType>]
|
15
15
|
def initialize types = [UniqueType::UNDEFINED]
|
16
16
|
# @todo @items here should not need an annotation
|
17
17
|
# @type [Array<UniqueType>]
|
@@ -86,6 +86,10 @@ module Solargraph
|
|
86
86
|
@items
|
87
87
|
end
|
88
88
|
|
89
|
+
def tags
|
90
|
+
@items.map(&:tag).join(', ')
|
91
|
+
end
|
92
|
+
|
89
93
|
# @param index [Integer]
|
90
94
|
# @return [UniqueType]
|
91
95
|
def [](index)
|
@@ -126,6 +130,10 @@ module Solargraph
|
|
126
130
|
map(&:tag).join(', ')
|
127
131
|
end
|
128
132
|
|
133
|
+
def rooted_tags
|
134
|
+
map(&:rooted_tag).join(', ')
|
135
|
+
end
|
136
|
+
|
129
137
|
def all? &block
|
130
138
|
@items.all? &block
|
131
139
|
end
|
@@ -147,15 +155,23 @@ module Solargraph
|
|
147
155
|
# @yieldreturn [UniqueType]
|
148
156
|
# @return [ComplexType]
|
149
157
|
def transform(new_name = nil, &transform_type)
|
158
|
+
raise "Please remove leading :: and set rooted with recreate() instead - #{new_name}" if new_name&.start_with?('::')
|
150
159
|
ComplexType.new(map { |ut| ut.transform(new_name, &transform_type) })
|
151
160
|
end
|
152
161
|
|
162
|
+
# @return [self]
|
163
|
+
def force_rooted
|
164
|
+
transform do |t|
|
165
|
+
t.recreate(make_rooted: true)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
153
169
|
# @param definitions [Pin::Namespace, Pin::Method]
|
154
170
|
# @param context_type [ComplexType]
|
155
171
|
# @return [ComplexType]
|
156
172
|
def resolve_generics definitions, context_type
|
157
173
|
result = @items.map { |i| i.resolve_generics(definitions, context_type) }
|
158
|
-
ComplexType.
|
174
|
+
ComplexType.try_parse(*result.map(&:tag))
|
159
175
|
end
|
160
176
|
|
161
177
|
# @param dst [String]
|
@@ -164,7 +180,7 @@ module Solargraph
|
|
164
180
|
return self unless selfy?
|
165
181
|
red = reduce_class(dst)
|
166
182
|
result = @items.map { |i| i.self_to red }
|
167
|
-
ComplexType.
|
183
|
+
ComplexType.try_parse(*result.map(&:tag))
|
168
184
|
end
|
169
185
|
|
170
186
|
def nullable?
|
@@ -190,21 +206,6 @@ module Solargraph
|
|
190
206
|
@items.all?(&:bot?)
|
191
207
|
end
|
192
208
|
|
193
|
-
private
|
194
|
-
|
195
|
-
# @todo This is a quick and dirty hack that forces `self` keywords
|
196
|
-
# to reference an instance of their class and never the class itself.
|
197
|
-
# This behavior may change depending on which result is expected
|
198
|
-
# from YARD conventions. See https://github.com/lsegal/yard/issues/1257
|
199
|
-
# @param dst [String]
|
200
|
-
# @return [String]
|
201
|
-
def reduce_class dst
|
202
|
-
while dst =~ /^(Class|Module)\<(.*?)\>$/
|
203
|
-
dst = dst.sub(/^(Class|Module)\</, '').sub(/\>$/, '')
|
204
|
-
end
|
205
|
-
dst
|
206
|
-
end
|
207
|
-
|
208
209
|
class << self
|
209
210
|
# Parse type strings into a ComplexType.
|
210
211
|
#
|
@@ -250,7 +251,7 @@ module Solargraph
|
|
250
251
|
elsif base.end_with?('=')
|
251
252
|
raise ComplexTypeError, "Invalid hash thing" unless key_types.nil?
|
252
253
|
# types.push ComplexType.new([UniqueType.new(base[0..-2].strip)])
|
253
|
-
types.push UniqueType.
|
254
|
+
types.push UniqueType.parse(base[0..-2].strip, subtype_string)
|
254
255
|
# @todo this should either expand key_type's type
|
255
256
|
# automatically or complain about not being
|
256
257
|
# compatible with key_type's type in type checking
|
@@ -281,7 +282,7 @@ module Solargraph
|
|
281
282
|
next
|
282
283
|
elsif char == ',' && point_stack == 0 && curly_stack == 0 && paren_stack == 0
|
283
284
|
# types.push ComplexType.new([UniqueType.new(base.strip, subtype_string.strip)])
|
284
|
-
types.push UniqueType.
|
285
|
+
types.push UniqueType.parse(base.strip, subtype_string.strip)
|
285
286
|
base.clear
|
286
287
|
subtype_string.clear
|
287
288
|
next
|
@@ -294,7 +295,7 @@ module Solargraph
|
|
294
295
|
end
|
295
296
|
raise ComplexTypeError, "Unclosed subtype in #{type_string}" if point_stack != 0 || curly_stack != 0 || paren_stack != 0
|
296
297
|
# types.push ComplexType.new([UniqueType.new(base, subtype_string)])
|
297
|
-
types.push UniqueType.
|
298
|
+
types.push UniqueType.parse(base.strip, subtype_string.strip)
|
298
299
|
end
|
299
300
|
unless key_types.nil?
|
300
301
|
raise ComplexTypeError, "Invalid use of key/value parameters" unless partial
|
@@ -311,18 +312,33 @@ module Solargraph
|
|
311
312
|
def try_parse *strings
|
312
313
|
parse *strings
|
313
314
|
rescue ComplexTypeError => e
|
314
|
-
Solargraph.logger.info "Error parsing complex type
|
315
|
+
Solargraph.logger.info "Error parsing complex type `#{strings.join(', ')}`: #{e.message}"
|
315
316
|
ComplexType::UNDEFINED
|
316
317
|
end
|
317
318
|
end
|
318
319
|
|
319
320
|
VOID = ComplexType.parse('void')
|
320
321
|
UNDEFINED = ComplexType.parse('undefined')
|
321
|
-
SYMBOL = ComplexType.parse('Symbol')
|
322
|
-
ROOT = ComplexType.parse('Class<>')
|
322
|
+
SYMBOL = ComplexType.parse('::Symbol')
|
323
|
+
ROOT = ComplexType.parse('::Class<>')
|
323
324
|
NIL = ComplexType.parse('nil')
|
324
325
|
SELF = ComplexType.parse('self')
|
325
|
-
BOOLEAN = ComplexType.parse('Boolean')
|
326
|
+
BOOLEAN = ComplexType.parse('::Boolean')
|
326
327
|
BOT = ComplexType.parse('bot')
|
328
|
+
|
329
|
+
private
|
330
|
+
|
331
|
+
# @todo This is a quick and dirty hack that forces `self` keywords
|
332
|
+
# to reference an instance of their class and never the class itself.
|
333
|
+
# This behavior may change depending on which result is expected
|
334
|
+
# from YARD conventions. See https://github.com/lsegal/yard/issues/1257
|
335
|
+
# @param dst [String]
|
336
|
+
# @return [String]
|
337
|
+
def reduce_class dst
|
338
|
+
while dst =~ /^(Class|Module)\<(.*?)\>$/
|
339
|
+
dst = dst.sub(/^(Class|Module)\</, '').sub(/\>$/, '')
|
340
|
+
end
|
341
|
+
dst
|
342
|
+
end
|
327
343
|
end
|
328
344
|
end
|
data/lib/solargraph/doc_map.rb
CHANGED
@@ -18,9 +18,11 @@ module Solargraph
|
|
18
18
|
|
19
19
|
# @param requires [Array<String>]
|
20
20
|
# @param preferences [Array<Gem::Specification>]
|
21
|
-
|
21
|
+
# @param rbs_path [String, Pathname, nil]
|
22
|
+
def initialize(requires, preferences, rbs_path = nil)
|
22
23
|
@requires = requires.compact
|
23
24
|
@preferences = preferences.compact
|
25
|
+
@rbs_path = rbs_path
|
24
26
|
generate
|
25
27
|
end
|
26
28
|
|
@@ -39,6 +41,7 @@ module Solargraph
|
|
39
41
|
@gems_in_memory ||= {}
|
40
42
|
end
|
41
43
|
|
44
|
+
# @return [Set<Gem::Specification>]
|
42
45
|
def dependencies
|
43
46
|
@dependencies ||= (gemspecs.flat_map { |spec| fetch_dependencies(spec) } - gemspecs).to_set
|
44
47
|
end
|
@@ -57,6 +60,7 @@ module Solargraph
|
|
57
60
|
end
|
58
61
|
end
|
59
62
|
dependencies.each { |dep| try_cache dep }
|
63
|
+
@uncached_gemspecs.uniq!
|
60
64
|
end
|
61
65
|
|
62
66
|
# @return [Hash{String => Gem::Specification, nil}]
|
@@ -75,7 +79,8 @@ module Solargraph
|
|
75
79
|
return if try_gem_in_memory(gemspec)
|
76
80
|
cache_file = File.join('gems', "#{gemspec.name}-#{gemspec.version}.ser")
|
77
81
|
if Cache.exist?(cache_file)
|
78
|
-
|
82
|
+
cached = Cache.load(cache_file)
|
83
|
+
gempins = update_from_collection(gemspec, cached)
|
79
84
|
self.class.gems_in_memory[gemspec] = gempins
|
80
85
|
@pins.concat gempins
|
81
86
|
else
|
@@ -93,7 +98,7 @@ module Solargraph
|
|
93
98
|
@pins.concat map.pins
|
94
99
|
else
|
95
100
|
# @todo Temporarily ignoring unresolved `require 'set'`
|
96
|
-
Solargraph.logger.
|
101
|
+
Solargraph.logger.debug "Require path #{path} could not be resolved" unless path == 'set'
|
97
102
|
end
|
98
103
|
end
|
99
104
|
|
@@ -107,6 +112,17 @@ module Solargraph
|
|
107
112
|
true
|
108
113
|
end
|
109
114
|
|
115
|
+
def update_from_collection gemspec, gempins
|
116
|
+
return gempins unless @rbs_path && File.directory?(@rbs_path)
|
117
|
+
return gempins if RbsMap.new(gemspec.name, gemspec.version).resolved?
|
118
|
+
|
119
|
+
rbs_map = RbsMap.new(gemspec.name, gemspec.version, directories: [@rbs_path])
|
120
|
+
return gempins unless rbs_map.resolved?
|
121
|
+
|
122
|
+
Solargraph.logger.info "Updating #{gemspec.name} #{gemspec.version} from collection"
|
123
|
+
GemPins.combine(gempins, rbs_map)
|
124
|
+
end
|
125
|
+
|
110
126
|
# @param path [String]
|
111
127
|
# @return [Gem::Specification, nil]
|
112
128
|
def resolve_path_to_gemspec path
|
data/lib/solargraph/gem_pins.rb
CHANGED
@@ -16,13 +16,21 @@ module Solargraph
|
|
16
16
|
def self.build(gemspec)
|
17
17
|
yard_pins = build_yard_pins(gemspec)
|
18
18
|
rbs_map = RbsMap.from_gemspec(gemspec)
|
19
|
+
combine yard_pins, rbs_map
|
20
|
+
end
|
21
|
+
|
22
|
+
# @param yard_pins [Array<Pin::Base>]
|
23
|
+
# @param rbs_map [RbsMap]
|
24
|
+
# @return [Array<Pin::Base>]
|
25
|
+
def self.combine(yard_pins, rbs_map)
|
19
26
|
in_yard = Set.new
|
20
27
|
combined = yard_pins.map do |yard|
|
21
28
|
in_yard.add yard.path
|
22
29
|
next yard unless yard.is_a?(Pin::Method)
|
30
|
+
|
23
31
|
rbs = rbs_map.path_pin(yard.path, Pin::Method)
|
24
32
|
next yard unless rbs
|
25
|
-
|
33
|
+
|
26
34
|
# @sg-ignore
|
27
35
|
yard.class.new(
|
28
36
|
location: yard.location,
|
@@ -34,7 +34,7 @@ module Solargraph
|
|
34
34
|
def update_libraries uri
|
35
35
|
src = sources.find(uri)
|
36
36
|
using = libraries.select { |lib| lib.contain?(src.filename) }
|
37
|
-
using.push
|
37
|
+
using.push library_for(uri) if using.empty?
|
38
38
|
using.each { |lib| lib.merge src }
|
39
39
|
diagnoser.schedule uri
|
40
40
|
end
|
@@ -114,6 +114,13 @@ module Solargraph
|
|
114
114
|
# @return [Library]
|
115
115
|
def generic_library
|
116
116
|
@generic_library ||= Solargraph::Library.new(Solargraph::Workspace.new('', nil, options), nil)
|
117
|
+
.tap { |lib| lib.add_observer self }
|
118
|
+
end
|
119
|
+
|
120
|
+
# @param library [Solargraph::Library]
|
121
|
+
# @return [void]
|
122
|
+
def update progress
|
123
|
+
progress&.send(self)
|
117
124
|
end
|
118
125
|
end
|
119
126
|
end
|
@@ -11,54 +11,10 @@ module Solargraph
|
|
11
11
|
include Observable
|
12
12
|
include UriHelpers
|
13
13
|
|
14
|
-
def initialize
|
15
|
-
@mutex = Mutex.new
|
16
|
-
@stopped = true
|
17
|
-
@has_uri = ConditionVariable.new
|
18
|
-
end
|
19
|
-
|
20
|
-
def stopped?
|
21
|
-
@stopped
|
22
|
-
end
|
23
|
-
|
24
|
-
# @return [void]
|
25
|
-
def start
|
26
|
-
return unless @stopped
|
27
|
-
@stopped = false
|
28
|
-
Thread.new do
|
29
|
-
tick until stopped?
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# @return [void]
|
34
|
-
def tick
|
35
|
-
uri = mutex.synchronize { next_uri }
|
36
|
-
|
37
|
-
return if queue.include?(uri)
|
38
|
-
mutex.synchronize do
|
39
|
-
nxt = open_source_hash[uri].finish_synchronize
|
40
|
-
open_source_hash[uri] = nxt
|
41
|
-
changed
|
42
|
-
notify_observers uri
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
14
|
# @param uri [String]
|
47
15
|
# @return [void]
|
48
16
|
def add_uri(uri)
|
49
17
|
queue.push(uri)
|
50
|
-
@has_uri.signal
|
51
|
-
end
|
52
|
-
|
53
|
-
# @return [String]
|
54
|
-
def next_uri
|
55
|
-
@has_uri.wait(mutex) if queue.empty?
|
56
|
-
queue.shift
|
57
|
-
end
|
58
|
-
|
59
|
-
# @return [void]
|
60
|
-
def stop
|
61
|
-
@stopped = true
|
62
18
|
end
|
63
19
|
|
64
20
|
# Open a source.
|
@@ -89,20 +45,7 @@ module Solargraph
|
|
89
45
|
# @return [void]
|
90
46
|
def update uri, updater
|
91
47
|
src = find(uri)
|
92
|
-
|
93
|
-
changed
|
94
|
-
notify_observers uri
|
95
|
-
end
|
96
|
-
|
97
|
-
# @param uri [String]
|
98
|
-
# @param updater [Source::Updater]
|
99
|
-
# @return [void]
|
100
|
-
def async_update uri, updater
|
101
|
-
src = find(uri)
|
102
|
-
mutex.synchronize do
|
103
|
-
open_source_hash[uri] = src.start_synchronize(updater)
|
104
|
-
add_uri(uri)
|
105
|
-
end
|
48
|
+
open_source_hash[uri] = src.synchronize(updater)
|
106
49
|
changed
|
107
50
|
notify_observers uri
|
108
51
|
end
|
@@ -144,9 +87,6 @@ module Solargraph
|
|
144
87
|
@open_source_hash ||= {}
|
145
88
|
end
|
146
89
|
|
147
|
-
# @return [Mutex]
|
148
|
-
attr_reader :mutex
|
149
|
-
|
150
90
|
# An array of source URIs that are waiting to finish synchronizing.
|
151
91
|
#
|
152
92
|
# @return [::Array<String>]
|
@@ -12,7 +12,6 @@ module Solargraph
|
|
12
12
|
#
|
13
13
|
class Host
|
14
14
|
autoload :Diagnoser, 'solargraph/language_server/host/diagnoser'
|
15
|
-
autoload :Cataloger, 'solargraph/language_server/host/cataloger'
|
16
15
|
autoload :Sources, 'solargraph/language_server/host/sources'
|
17
16
|
autoload :Dispatch, 'solargraph/language_server/host/dispatch'
|
18
17
|
autoload :MessageWorker, 'solargraph/language_server/host/message_worker'
|
@@ -43,8 +42,6 @@ module Solargraph
|
|
43
42
|
return unless stopped?
|
44
43
|
@stopped = false
|
45
44
|
diagnoser.start
|
46
|
-
cataloger.start
|
47
|
-
sources.start
|
48
45
|
message_worker.start
|
49
46
|
end
|
50
47
|
|
@@ -155,6 +152,7 @@ module Solargraph
|
|
155
152
|
def delete *uris
|
156
153
|
filenames = uris.map { |uri| uri_to_file(uri) }
|
157
154
|
libraries.each do |lib|
|
155
|
+
lib.delete_observer self
|
158
156
|
lib.delete(*filenames)
|
159
157
|
end
|
160
158
|
uris.each do |uri|
|
@@ -253,7 +251,7 @@ module Solargraph
|
|
253
251
|
# @return [void]
|
254
252
|
def change params
|
255
253
|
updater = generate_updater(params)
|
256
|
-
sources.
|
254
|
+
sources.update params['textDocument']['uri'], updater
|
257
255
|
diagnoser.schedule params['textDocument']['uri']
|
258
256
|
end
|
259
257
|
|
@@ -294,8 +292,9 @@ module Solargraph
|
|
294
292
|
begin
|
295
293
|
workspace = Solargraph::Workspace.new(path, nil, options)
|
296
294
|
lib = Solargraph::Library.new(workspace, name)
|
295
|
+
lib.add_observer self
|
297
296
|
libraries.push lib
|
298
|
-
|
297
|
+
library_map lib
|
299
298
|
rescue WorkspaceTooLargeError => e
|
300
299
|
send_notification 'window/showMessage', {
|
301
300
|
'type' => Solargraph::LanguageServer::MessageTypes::WARNING,
|
@@ -324,6 +323,7 @@ module Solargraph
|
|
324
323
|
# @param lib [Library]
|
325
324
|
libraries.delete_if do |lib|
|
326
325
|
next false if lib.workspace.directory != directory
|
326
|
+
lib.delete_observer self
|
327
327
|
true
|
328
328
|
end
|
329
329
|
end
|
@@ -458,9 +458,7 @@ module Solargraph
|
|
458
458
|
return if @stopped
|
459
459
|
@stopped = true
|
460
460
|
message_worker.stop
|
461
|
-
cataloger.stop
|
462
461
|
diagnoser.stop
|
463
|
-
sources.stop
|
464
462
|
changed
|
465
463
|
notify_observers
|
466
464
|
end
|
@@ -684,11 +682,15 @@ module Solargraph
|
|
684
682
|
libraries.each(&:catalog)
|
685
683
|
end
|
686
684
|
|
687
|
-
# @return [Hash{String =>
|
685
|
+
# @return [Hash{String => Hash{String => Boolean}}]
|
688
686
|
def client_capabilities
|
689
687
|
@client_capabilities ||= {}
|
690
688
|
end
|
691
689
|
|
690
|
+
def client_supports_progress?
|
691
|
+
client_capabilities['window'] && client_capabilities['window']['workDoneProgress']
|
692
|
+
end
|
693
|
+
|
692
694
|
private
|
693
695
|
|
694
696
|
# @return [MessageWorker]
|
@@ -701,11 +703,6 @@ module Solargraph
|
|
701
703
|
@diagnoser ||= Diagnoser.new(self)
|
702
704
|
end
|
703
705
|
|
704
|
-
# @return [Cataloger]
|
705
|
-
def cataloger
|
706
|
-
@cataloger ||= Cataloger.new(self)
|
707
|
-
end
|
708
|
-
|
709
706
|
# A hash of client requests by ID. The host uses this to keep track of
|
710
707
|
# pending responses.
|
711
708
|
#
|
@@ -835,72 +832,28 @@ module Solargraph
|
|
835
832
|
client_capabilities['rename'] && client_capabilities['rename']['prepareSupport']
|
836
833
|
end
|
837
834
|
|
838
|
-
def client_supports_progress?
|
839
|
-
client_capabilities['window'] && client_capabilities['window']['workDoneProgress']
|
840
|
-
end
|
841
|
-
|
842
835
|
# @param library [Library]
|
843
836
|
# @return [void]
|
844
|
-
def
|
837
|
+
def library_map library
|
845
838
|
return if library.mapped?
|
846
|
-
Thread.new
|
847
|
-
if client_supports_progress?
|
848
|
-
uuid = SecureRandom.uuid
|
849
|
-
send_request 'window/workDoneProgress/create', {
|
850
|
-
token: uuid
|
851
|
-
} do |response|
|
852
|
-
do_async_library_map library, response.nil? ? uuid : nil
|
853
|
-
end
|
854
|
-
else
|
855
|
-
do_async_library_map library
|
856
|
-
end
|
857
|
-
end
|
839
|
+
Thread.new { sync_library_map library }
|
858
840
|
end
|
859
841
|
|
860
842
|
# @param library [Library]
|
861
843
|
# @param uuid [String, nil]
|
862
844
|
# @return [void]
|
863
|
-
def
|
845
|
+
def sync_library_map library
|
864
846
|
total = library.workspace.sources.length
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
value: {
|
869
|
-
kind: 'begin',
|
870
|
-
title: "Mapping workspace",
|
871
|
-
message: "0/#{total} files",
|
872
|
-
cancellable: false,
|
873
|
-
percentage: 0
|
874
|
-
}
|
875
|
-
}
|
876
|
-
end
|
877
|
-
pct = 0
|
878
|
-
mod = 10
|
847
|
+
progress = Progress.new('Mapping workspace')
|
848
|
+
progress.begin "0/#{total} files", 0
|
849
|
+
progress.send self
|
879
850
|
while library.next_map
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
pct = cur
|
884
|
-
send_notification '$/progress', {
|
885
|
-
token: uuid,
|
886
|
-
value: {
|
887
|
-
kind: 'report',
|
888
|
-
cancellable: false,
|
889
|
-
message: "#{library.source_map_hash.keys.length}/#{total} files",
|
890
|
-
percentage: pct
|
891
|
-
}
|
892
|
-
}
|
893
|
-
end
|
894
|
-
end
|
895
|
-
if uuid
|
896
|
-
send_notification '$/progress', {
|
897
|
-
token: uuid,
|
898
|
-
value: {
|
899
|
-
kind: 'end',
|
900
|
-
message: 'Mapping complete'
|
901
|
-
}
|
902
|
-
}
|
851
|
+
pct = ((library.source_map_hash.keys.length.to_f / total) * 100).to_i
|
852
|
+
progress.report "#{library.source_map_hash.keys.length}/#{total} files", pct
|
853
|
+
progress.send self
|
903
854
|
end
|
855
|
+
progress.finish 'done'
|
856
|
+
progress.send self
|
904
857
|
end
|
905
858
|
end
|
906
859
|
end
|
@@ -47,6 +47,8 @@ module Solargraph
|
|
47
47
|
|
48
48
|
private
|
49
49
|
|
50
|
+
# @todo '?' methods should type like RBS 'boolish' rather than a strict true or false
|
51
|
+
# @sg-ignore
|
50
52
|
def support_workspace_folders?
|
51
53
|
params['capabilities'] &&
|
52
54
|
params['capabilities']['workspace'] &&
|
@@ -82,6 +84,7 @@ module Solargraph
|
|
82
84
|
}
|
83
85
|
end
|
84
86
|
|
87
|
+
# @return [Hash{Symbol => Hash{Symbol => String, Array<String>}}]
|
85
88
|
def static_on_type_formatting
|
86
89
|
{
|
87
90
|
documentOnTypeFormattingProvider: {
|
@@ -91,6 +94,7 @@ module Solargraph
|
|
91
94
|
}
|
92
95
|
end
|
93
96
|
|
97
|
+
# @return [Hash{Symbol => Boolean}]
|
94
98
|
def static_hover
|
95
99
|
return {} unless host.options['hover']
|
96
100
|
{
|
@@ -98,6 +102,7 @@ module Solargraph
|
|
98
102
|
}
|
99
103
|
end
|
100
104
|
|
105
|
+
# @return [Hash{Symbol => Boolean}]
|
101
106
|
def static_document_formatting
|
102
107
|
return {} unless host.options['formatting']
|
103
108
|
{
|
@@ -105,6 +110,7 @@ module Solargraph
|
|
105
110
|
}
|
106
111
|
end
|
107
112
|
|
113
|
+
# @return [Hash{Symbol => Boolean}]
|
108
114
|
def static_document_symbols
|
109
115
|
return {} unless host.options['symbols']
|
110
116
|
{
|
@@ -112,12 +118,14 @@ module Solargraph
|
|
112
118
|
}
|
113
119
|
end
|
114
120
|
|
121
|
+
# @return [Hash{Symbol => Boolean}]
|
115
122
|
def static_workspace_symbols
|
116
123
|
{
|
117
124
|
workspaceSymbolProvider: true
|
118
125
|
}
|
119
126
|
end
|
120
127
|
|
128
|
+
# @return [Hash{Symbol => Boolean}]
|
121
129
|
def static_definitions
|
122
130
|
return {} unless host.options['definitions']
|
123
131
|
{
|
@@ -125,6 +133,7 @@ module Solargraph
|
|
125
133
|
}
|
126
134
|
end
|
127
135
|
|
136
|
+
# @return [Hash{Symbol => Boolean}]
|
128
137
|
def static_type_definitions
|
129
138
|
return {} unless host.options['typeDefinitions']
|
130
139
|
{
|
@@ -132,12 +141,15 @@ module Solargraph
|
|
132
141
|
}
|
133
142
|
end
|
134
143
|
|
144
|
+
# @return [Hash{Symbol => Hash{Symbol => Boolean}}]
|
135
145
|
def static_rename
|
136
146
|
{
|
137
147
|
renameProvider: {prepareProvider: true}
|
138
148
|
}
|
139
149
|
end
|
140
150
|
|
151
|
+
|
152
|
+
# @return [Hash{Symbol => Boolean}]
|
141
153
|
def static_references
|
142
154
|
return {} unless host.options['references']
|
143
155
|
{
|
@@ -145,6 +157,7 @@ module Solargraph
|
|
145
157
|
}
|
146
158
|
end
|
147
159
|
|
160
|
+
# @return [Hash{Symbol => Boolean}]
|
148
161
|
def static_folding_range
|
149
162
|
return {} unless host.options['folding']
|
150
163
|
{
|
@@ -152,6 +165,7 @@ module Solargraph
|
|
152
165
|
}
|
153
166
|
end
|
154
167
|
|
168
|
+
# @return [Hash{Symbol => Boolean}]
|
155
169
|
def static_highlights
|
156
170
|
{
|
157
171
|
documentHighlightProvider: true
|