solargraph 0.38.6 → 0.39.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/SPONSORS.md +9 -0
- data/lib/solargraph.rb +1 -0
- data/lib/solargraph/api_map.rb +24 -13
- data/lib/solargraph/api_map/bundler_methods.rb +3 -0
- data/lib/solargraph/api_map/source_to_yard.rb +1 -6
- data/lib/solargraph/api_map/store.rb +19 -3
- data/lib/solargraph/complex_type/type_methods.rb +4 -4
- data/lib/solargraph/convention/base.rb +0 -5
- data/lib/solargraph/core_fills.rb +28 -2
- data/lib/solargraph/diagnostics/base.rb +1 -0
- data/lib/solargraph/diagnostics/type_check.rb +13 -13
- data/lib/solargraph/language_server/host.rb +11 -2
- data/lib/solargraph/language_server/host/sources.rb +20 -11
- data/lib/solargraph/language_server/message/text_document/formatting.rb +16 -11
- data/lib/solargraph/language_server/transport/data_reader.rb +2 -0
- data/lib/solargraph/library.rb +3 -3
- data/lib/solargraph/parser.rb +26 -0
- data/lib/solargraph/parser/comment_ripper.rb +52 -0
- data/lib/solargraph/parser/legacy.rb +12 -0
- data/lib/solargraph/parser/legacy/class_methods.rb +105 -0
- data/lib/solargraph/parser/legacy/flawed_builder.rb +16 -0
- data/lib/solargraph/parser/legacy/node_chainer.rb +115 -0
- data/lib/solargraph/parser/legacy/node_methods.rb +289 -0
- data/lib/solargraph/parser/legacy/node_processors.rb +54 -0
- data/lib/solargraph/parser/legacy/node_processors/alias_node.rb +23 -0
- data/lib/solargraph/parser/legacy/node_processors/args_node.rb +35 -0
- data/lib/solargraph/parser/legacy/node_processors/begin_node.rb +15 -0
- data/lib/solargraph/parser/legacy/node_processors/block_node.rb +22 -0
- data/lib/solargraph/parser/legacy/node_processors/casgn_node.rb +25 -0
- data/lib/solargraph/parser/legacy/node_processors/cvasgn_node.rb +23 -0
- data/lib/solargraph/parser/legacy/node_processors/def_node.rb +63 -0
- data/lib/solargraph/parser/legacy/node_processors/defs_node.rb +36 -0
- data/lib/solargraph/parser/legacy/node_processors/gvasgn_node.rb +23 -0
- data/lib/solargraph/parser/legacy/node_processors/ivasgn_node.rb +38 -0
- data/lib/solargraph/parser/legacy/node_processors/lvasgn_node.rb +28 -0
- data/lib/solargraph/parser/legacy/node_processors/namespace_node.rb +39 -0
- data/lib/solargraph/parser/legacy/node_processors/orasgn_node.rb +16 -0
- data/lib/solargraph/parser/legacy/node_processors/resbody_node.rb +36 -0
- data/lib/solargraph/parser/legacy/node_processors/sclass_node.rb +21 -0
- data/lib/solargraph/parser/legacy/node_processors/send_node.rb +232 -0
- data/lib/solargraph/parser/legacy/node_processors/sym_node.rb +18 -0
- data/lib/solargraph/parser/node_methods.rb +43 -0
- data/lib/solargraph/parser/node_processor.rb +43 -0
- data/lib/solargraph/parser/node_processor/base.rb +77 -0
- data/lib/solargraph/{source_map → parser}/region.rb +11 -6
- data/lib/solargraph/parser/rubyvm.rb +40 -0
- data/lib/solargraph/parser/rubyvm/class_methods.rb +146 -0
- data/lib/solargraph/parser/rubyvm/node_chainer.rb +133 -0
- data/lib/solargraph/parser/rubyvm/node_methods.rb +279 -0
- data/lib/solargraph/parser/rubyvm/node_processors.rb +60 -0
- data/lib/solargraph/parser/rubyvm/node_processors/alias_node.rb +23 -0
- data/lib/solargraph/parser/rubyvm/node_processors/args_node.rb +62 -0
- data/lib/solargraph/parser/rubyvm/node_processors/begin_node.rb +15 -0
- data/lib/solargraph/parser/rubyvm/node_processors/block_node.rb +22 -0
- data/lib/solargraph/parser/rubyvm/node_processors/casgn_node.rb +22 -0
- data/lib/solargraph/parser/rubyvm/node_processors/cvasgn_node.rb +23 -0
- data/lib/solargraph/parser/rubyvm/node_processors/def_node.rb +64 -0
- data/lib/solargraph/parser/rubyvm/node_processors/defs_node.rb +57 -0
- data/lib/solargraph/parser/rubyvm/node_processors/gvasgn_node.rb +23 -0
- data/lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb +38 -0
- data/lib/solargraph/parser/rubyvm/node_processors/kw_arg_node.rb +34 -0
- data/lib/solargraph/parser/rubyvm/node_processors/lit_node.rb +20 -0
- data/lib/solargraph/parser/rubyvm/node_processors/lvasgn_node.rb +27 -0
- data/lib/solargraph/parser/rubyvm/node_processors/namespace_node.rb +39 -0
- data/lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb +26 -0
- data/lib/solargraph/parser/rubyvm/node_processors/orasgn_node.rb +15 -0
- data/lib/solargraph/parser/rubyvm/node_processors/resbody_node.rb +45 -0
- data/lib/solargraph/parser/rubyvm/node_processors/sclass_node.rb +21 -0
- data/lib/solargraph/parser/rubyvm/node_processors/scope_node.rb +15 -0
- data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +292 -0
- data/lib/solargraph/parser/rubyvm/node_processors/sym_node.rb +18 -0
- data/lib/solargraph/parser/snippet.rb +13 -0
- data/lib/solargraph/pin/attribute.rb +8 -0
- data/lib/solargraph/pin/base.rb +1 -1
- data/lib/solargraph/pin/base_method.rb +26 -4
- data/lib/solargraph/pin/base_variable.rb +7 -8
- data/lib/solargraph/pin/block.rb +1 -1
- data/lib/solargraph/pin/constant.rb +16 -0
- data/lib/solargraph/pin/conversions.rb +2 -2
- data/lib/solargraph/pin/method.rb +26 -14
- data/lib/solargraph/pin/parameter.rb +56 -2
- data/lib/solargraph/pin/reference.rb +1 -0
- data/lib/solargraph/pin/reference/override.rb +2 -0
- data/lib/solargraph/pin/reference/prepend.rb +10 -0
- data/lib/solargraph/pin/yard_pin/constant.rb +2 -4
- data/lib/solargraph/pin/yard_pin/method.rb +34 -18
- data/lib/solargraph/pin/yard_pin/namespace.rb +3 -11
- data/lib/solargraph/pin/yard_pin/yard_mixin.rb +3 -12
- data/lib/solargraph/range.rb +8 -2
- data/lib/solargraph/shell.rb +17 -11
- data/lib/solargraph/source.rb +114 -135
- data/lib/solargraph/source/chain.rb +11 -3
- data/lib/solargraph/source/chain/call.rb +1 -2
- data/lib/solargraph/source/chain/constant.rb +44 -8
- data/lib/solargraph/source/chain/link.rb +1 -0
- data/lib/solargraph/source/cursor.rb +2 -28
- data/lib/solargraph/source/source_chainer.rb +12 -6
- data/lib/solargraph/source/updater.rb +2 -0
- data/lib/solargraph/source_map.rb +0 -2
- data/lib/solargraph/source_map/clip.rb +24 -17
- data/lib/solargraph/source_map/mapper.rb +34 -29
- data/lib/solargraph/type_checker.rb +367 -275
- data/lib/solargraph/type_checker/checks.rb +95 -0
- data/lib/solargraph/type_checker/param_def.rb +2 -17
- data/lib/solargraph/type_checker/rules.rb +53 -0
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/views/environment.erb +5 -3
- data/lib/solargraph/workspace.rb +17 -2
- data/lib/solargraph/workspace/config.rb +15 -7
- data/lib/solargraph/yard_map.rb +89 -49
- data/lib/solargraph/yard_map/core_docs.rb +1 -1
- data/solargraph.gemspec +2 -1
- metadata +88 -32
- data/OVERVIEW.md +0 -37
- data/lib/solargraph/source/flawed_builder.rb +0 -15
- data/lib/solargraph/source/node_chainer.rb +0 -111
- data/lib/solargraph/source/node_methods.rb +0 -240
- data/lib/solargraph/source_map/node_processor.rb +0 -85
- data/lib/solargraph/source_map/node_processor/alias_node.rb +0 -21
- data/lib/solargraph/source_map/node_processor/args_node.rb +0 -24
- data/lib/solargraph/source_map/node_processor/base.rb +0 -103
- data/lib/solargraph/source_map/node_processor/begin_node.rb +0 -13
- data/lib/solargraph/source_map/node_processor/block_node.rb +0 -21
- data/lib/solargraph/source_map/node_processor/casgn_node.rb +0 -21
- data/lib/solargraph/source_map/node_processor/cvasgn_node.rb +0 -21
- data/lib/solargraph/source_map/node_processor/def_node.rb +0 -62
- data/lib/solargraph/source_map/node_processor/defs_node.rb +0 -33
- data/lib/solargraph/source_map/node_processor/gvasgn_node.rb +0 -21
- data/lib/solargraph/source_map/node_processor/ivasgn_node.rb +0 -34
- data/lib/solargraph/source_map/node_processor/lvasgn_node.rb +0 -24
- data/lib/solargraph/source_map/node_processor/namespace_node.rb +0 -35
- data/lib/solargraph/source_map/node_processor/orasgn_node.rb +0 -14
- data/lib/solargraph/source_map/node_processor/resbody_node.rb +0 -32
- data/lib/solargraph/source_map/node_processor/sclass_node.rb +0 -19
- data/lib/solargraph/source_map/node_processor/send_node.rb +0 -217
- data/lib/solargraph/source_map/node_processor/sym_node.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71e5d6fa6baec1130d64df74ed6fcf49c6c41df2f1386cb5cd2760a7605a9e48
|
4
|
+
data.tar.gz: 91d9d6c695a63a0defab2c31967b2828907c800a94eb220c9210db9b672f2f27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b37f7a917d8c865063f14c62e185e919cb88f221219fdc611ef003aa0a17af99bdd762fd4d4fc36105f37c36b0bdd4017500abe17b3aa1506423df8b16ee55a
|
7
|
+
data.tar.gz: 60110bec4c847690cecdfa0d73d0495d09340a56ddf650dfbfc737e1f8b62682e1cce3de568edec7e52f4d4ff052e4c4746a2ec907c20320b6b133de610b6f3a
|
data/SPONSORS.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# Sponsors
|
2
|
+
|
3
|
+
Solargraph is developed and maintained by [Castwide Technologies](https://castwide.com).
|
4
|
+
|
5
|
+
The following people and organizations provide funding or other resources. [Become a sponsor](https://patreon.com/castwide)
|
6
|
+
|
7
|
+
## Named Sponsors
|
8
|
+
|
9
|
+
- Emily Strickland
|
data/lib/solargraph.rb
CHANGED
@@ -38,6 +38,7 @@ module Solargraph
|
|
38
38
|
autoload :Environ, 'solargraph/environ'
|
39
39
|
autoload :Convention, 'solargraph/convention'
|
40
40
|
autoload :Documentor, 'solargraph/documentor'
|
41
|
+
autoload :Parser, 'solargraph/parser'
|
41
42
|
|
42
43
|
dir = File.dirname(__FILE__)
|
43
44
|
YARDOC_PATH = File.realpath(File.join(dir, '..', 'yardoc'))
|
data/lib/solargraph/api_map.rb
CHANGED
@@ -149,7 +149,7 @@ module Solargraph
|
|
149
149
|
# @return [Source::Cursor]
|
150
150
|
def cursor_at filename, position
|
151
151
|
position = Position.normalize(position)
|
152
|
-
raise "File not found: #{filename}" unless source_map_hash.has_key?(filename)
|
152
|
+
raise FileNotFoundError, "File not found: #{filename}" unless source_map_hash.has_key?(filename)
|
153
153
|
source_map_hash[filename].cursor_at(position)
|
154
154
|
end
|
155
155
|
|
@@ -215,7 +215,7 @@ module Solargraph
|
|
215
215
|
contexts.push '' if contexts.empty?
|
216
216
|
cached = cache.get_constants(namespace, contexts)
|
217
217
|
return cached.clone unless cached.nil?
|
218
|
-
skip =
|
218
|
+
skip = Set.new
|
219
219
|
result = []
|
220
220
|
contexts.each do |context|
|
221
221
|
fqns = qualify(namespace, context)
|
@@ -238,9 +238,9 @@ module Solargraph
|
|
238
238
|
cached = cache.get_qualified_namespace(namespace, context)
|
239
239
|
return cached.clone unless cached.nil?
|
240
240
|
result = if namespace.start_with?('::')
|
241
|
-
inner_qualify(namespace[2..-1], '',
|
241
|
+
inner_qualify(namespace[2..-1], '', Set.new)
|
242
242
|
else
|
243
|
-
inner_qualify(namespace, context,
|
243
|
+
inner_qualify(namespace, context, Set.new)
|
244
244
|
end
|
245
245
|
cache.set_qualified_namespace(namespace, context, result)
|
246
246
|
result
|
@@ -295,7 +295,7 @@ module Solargraph
|
|
295
295
|
cached = cache.get_methods(fqns, scope, visibility, deep)
|
296
296
|
return cached.clone unless cached.nil?
|
297
297
|
result = []
|
298
|
-
skip =
|
298
|
+
skip = Set.new
|
299
299
|
if fqns == ''
|
300
300
|
# @todo Implement domains
|
301
301
|
implicit.domains.each do |domain|
|
@@ -308,6 +308,7 @@ module Solargraph
|
|
308
308
|
result.concat inner_get_methods('Kernel', :instance, visibility, deep, skip)
|
309
309
|
else
|
310
310
|
result.concat inner_get_methods(fqns, scope, visibility, deep, skip)
|
311
|
+
result.concat inner_get_methods('Kernel', :instance, [:public], deep, skip) if visibility.include?(:private)
|
311
312
|
end
|
312
313
|
resolved = resolve_method_aliases(result, visibility)
|
313
314
|
cache.set_methods(fqns, scope, visibility, deep, resolved)
|
@@ -551,15 +552,21 @@ module Solargraph
|
|
551
552
|
# @param scope [Symbol] :class or :instance
|
552
553
|
# @param visibility [Array<Symbol>] :public, :protected, and/or :private
|
553
554
|
# @param deep [Boolean]
|
554
|
-
# @param skip [
|
555
|
+
# @param skip [Set<String>]
|
555
556
|
# @param no_core [Boolean] Skip core classes if true
|
556
557
|
# @return [Array<Pin::Base>]
|
557
558
|
def inner_get_methods fqns, scope, visibility, deep, skip, no_core = false
|
558
559
|
return [] if no_core && fqns =~ /^(Object|BasicObject|Class|Module|Kernel)$/
|
559
560
|
reqstr = "#{fqns}|#{scope}|#{visibility.sort}|#{deep}"
|
560
561
|
return [] if skip.include?(reqstr)
|
561
|
-
skip.
|
562
|
+
skip.add reqstr
|
562
563
|
result = []
|
564
|
+
if deep && scope == :instance
|
565
|
+
store.get_prepends(fqns).reverse.each do |im|
|
566
|
+
fqim = qualify(im, fqns)
|
567
|
+
result.concat inner_get_methods(fqim, scope, visibility, deep, skip, true) unless fqim.nil?
|
568
|
+
end
|
569
|
+
end
|
563
570
|
result.concat store.get_methods(fqns, scope: scope, visibility: visibility).sort{ |a, b| a.name <=> b.name }
|
564
571
|
if deep
|
565
572
|
if scope == :instance
|
@@ -596,12 +603,16 @@ module Solargraph
|
|
596
603
|
|
597
604
|
# @param fqns [String]
|
598
605
|
# @param visibility [Array<Symbol>]
|
599
|
-
# @param skip [
|
606
|
+
# @param skip [Set<String>]
|
600
607
|
# @return [Array<Pin::Base>]
|
601
608
|
def inner_get_constants fqns, visibility, skip
|
602
609
|
return [] if fqns.nil? || skip.include?(fqns)
|
603
|
-
skip.
|
604
|
-
result =
|
610
|
+
skip.add fqns
|
611
|
+
result = []
|
612
|
+
store.get_prepends(fqns).each do |is|
|
613
|
+
result.concat inner_get_constants(qualify(is, fqns), [:public], skip)
|
614
|
+
end
|
615
|
+
result.concat store.get_constants(fqns, visibility)
|
605
616
|
.sort { |a, b| a.name <=> b.name }
|
606
617
|
store.get_includes(fqns).each do |is|
|
607
618
|
result.concat inner_get_constants(qualify(is, fqns), [:public], skip)
|
@@ -636,12 +647,12 @@ module Solargraph
|
|
636
647
|
|
637
648
|
# @param name [String]
|
638
649
|
# @param root [String]
|
639
|
-
# @param skip [
|
650
|
+
# @param skip [Set<String>]
|
640
651
|
# @return [String, nil]
|
641
652
|
def inner_qualify name, root, skip
|
642
653
|
return nil if name.nil?
|
643
654
|
return nil if skip.include?(root)
|
644
|
-
skip.
|
655
|
+
skip.add root
|
645
656
|
if name == ''
|
646
657
|
if root == ''
|
647
658
|
return ''
|
@@ -727,7 +738,7 @@ module Solargraph
|
|
727
738
|
comments: origin.comments,
|
728
739
|
scope: origin.scope,
|
729
740
|
visibility: origin.visibility,
|
730
|
-
|
741
|
+
parameters: origin.parameters
|
731
742
|
)
|
732
743
|
end
|
733
744
|
end
|
@@ -6,6 +6,8 @@ module Solargraph
|
|
6
6
|
module BundlerMethods
|
7
7
|
module_function
|
8
8
|
|
9
|
+
# @param directory [String]
|
10
|
+
# @return [Hash]
|
9
11
|
def require_from_bundle directory
|
10
12
|
@require_from_bundle ||= begin
|
11
13
|
Solargraph.logger.info "Loading gems for bundler/require"
|
@@ -16,6 +18,7 @@ module Solargraph
|
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
21
|
+
# @return [void]
|
19
22
|
def reset_require_from_bundle
|
20
23
|
@require_from_bundle = nil
|
21
24
|
end
|
@@ -60,12 +60,7 @@ module Solargraph
|
|
60
60
|
code_object_map[pin.path].docstring = pin.docstring
|
61
61
|
code_object_map[pin.path].visibility = pin.visibility || :public
|
62
62
|
code_object_map[pin.path].parameters = pin.parameters.map do |p|
|
63
|
-
|
64
|
-
v = nil
|
65
|
-
if p.length > n.length
|
66
|
-
v = p[n.length..-1].gsub(/^ = /, '')
|
67
|
-
end
|
68
|
-
[n, v]
|
63
|
+
[p.name, p.asgn_code]
|
69
64
|
end
|
70
65
|
end
|
71
66
|
end
|
@@ -19,7 +19,7 @@ module Solargraph
|
|
19
19
|
# @return [Array<Solargraph::Pin::Base>]
|
20
20
|
def get_constants fqns, visibility = [:public]
|
21
21
|
namespace_children(fqns).select { |pin|
|
22
|
-
!pin.name.empty?
|
22
|
+
!pin.name.empty? && (pin.is_a?(Pin::Namespace) || pin.is_a?(Pin::Constant)) && visibility.include?(pin.visibility)
|
23
23
|
}
|
24
24
|
end
|
25
25
|
|
@@ -34,7 +34,7 @@ module Solargraph
|
|
34
34
|
end
|
35
35
|
|
36
36
|
# @param fqns [String]
|
37
|
-
# @return [String]
|
37
|
+
# @return [String, nil]
|
38
38
|
def get_superclass fqns
|
39
39
|
return superclass_references[fqns].first if superclass_references.key?(fqns)
|
40
40
|
return 'Object' if fqns != 'BasicObject' && namespace_exists?(fqns)
|
@@ -48,6 +48,12 @@ module Solargraph
|
|
48
48
|
include_references[fqns] || []
|
49
49
|
end
|
50
50
|
|
51
|
+
# @param fqns [String]
|
52
|
+
# @return [Array<String>]
|
53
|
+
def get_prepends fqns
|
54
|
+
prepend_references[fqns] || []
|
55
|
+
end
|
56
|
+
|
51
57
|
# @param fqns [String]
|
52
58
|
# @return [Array<String>]
|
53
59
|
def get_extends fqns
|
@@ -172,6 +178,10 @@ module Solargraph
|
|
172
178
|
@include_references ||= {}
|
173
179
|
end
|
174
180
|
|
181
|
+
def prepend_references
|
182
|
+
@prepend_references ||= {}
|
183
|
+
end
|
184
|
+
|
175
185
|
def extend_references
|
176
186
|
@extend_references ||= {}
|
177
187
|
end
|
@@ -210,13 +220,16 @@ module Solargraph
|
|
210
220
|
pins.each do |pin|
|
211
221
|
namespace_map[pin.namespace] ||= []
|
212
222
|
namespace_map[pin.namespace].push pin
|
213
|
-
namespaces.add pin.path if pin.is_a?(Pin::Namespace)
|
223
|
+
namespaces.add pin.path if pin.is_a?(Pin::Namespace) && !pin.path.empty?
|
214
224
|
namespace_pins.push pin if pin.is_a?(Pin::Namespace)
|
215
225
|
method_pins.push pin if pin.is_a?(Pin::BaseMethod)
|
216
226
|
symbols.push pin if pin.is_a?(Pin::Symbol)
|
217
227
|
if pin.is_a?(Pin::Reference::Include)
|
218
228
|
include_references[pin.namespace] ||= []
|
219
229
|
include_references[pin.namespace].push pin.name
|
230
|
+
elsif pin.is_a?(Pin::Reference::Prepend)
|
231
|
+
prepend_references[pin.namespace] ||= []
|
232
|
+
prepend_references[pin.namespace].push pin.name
|
220
233
|
elsif pin.is_a?(Pin::Reference::Extend)
|
221
234
|
extend_references[pin.namespace] ||= []
|
222
235
|
extend_references[pin.namespace].push pin.name
|
@@ -245,6 +258,9 @@ module Solargraph
|
|
245
258
|
pin.docstring.add_tag(tag)
|
246
259
|
end
|
247
260
|
end
|
261
|
+
# @todo This is probably not the best place for these overrides
|
262
|
+
superclass_references['Integer'] = ['Numeric']
|
263
|
+
superclass_references['Float'] = ['Numeric']
|
248
264
|
end
|
249
265
|
end
|
250
266
|
end
|
@@ -113,13 +113,13 @@ module Solargraph
|
|
113
113
|
t.qualify api_map, context
|
114
114
|
end
|
115
115
|
if list_parameters?
|
116
|
-
Solargraph::ComplexType.parse("#{fqns}<#{rtypes.map(&:tag).join(', ')}>")
|
116
|
+
Solargraph::ComplexType.parse("#{fqns}<#{rtypes.map(&:tag).join(', ')}>")
|
117
117
|
elsif fixed_parameters?
|
118
|
-
Solargraph::ComplexType.parse("#{fqns}(#{rtypes.map(&:tag).join(', ')})")
|
118
|
+
Solargraph::ComplexType.parse("#{fqns}(#{rtypes.map(&:tag).join(', ')})")
|
119
119
|
elsif hash_parameters?
|
120
|
-
Solargraph::ComplexType.parse("#{fqns}{#{ltypes.map(&:tag).join(', ')} => #{rtypes.map(&:tag).join(', ')}}")
|
120
|
+
Solargraph::ComplexType.parse("#{fqns}{#{ltypes.map(&:tag).join(', ')} => #{rtypes.map(&:tag).join(', ')}}")
|
121
121
|
else
|
122
|
-
Solargraph::ComplexType.parse(fqns)
|
122
|
+
Solargraph::ComplexType.parse(fqns)
|
123
123
|
end
|
124
124
|
end
|
125
125
|
end
|
@@ -65,11 +65,13 @@ module Solargraph
|
|
65
65
|
@return [self]
|
66
66
|
@return_single_parameter
|
67
67
|
)),
|
68
|
+
Override.method_return('Array#uniq', 'self'),
|
68
69
|
|
69
70
|
Override.from_comment('BasicObject#==', %(
|
70
71
|
@param other [BasicObject]
|
71
72
|
@return [Boolean]
|
72
73
|
)),
|
74
|
+
Override.method_return('BasicObject#initialize', 'void'),
|
73
75
|
|
74
76
|
Override.method_return('Class#new', 'self'),
|
75
77
|
Override.method_return('Class.new', 'Class<Object>'),
|
@@ -84,6 +86,11 @@ module Solargraph
|
|
84
86
|
Override.method_return('File.extname', 'String'),
|
85
87
|
Override.method_return('File.join', 'String'),
|
86
88
|
|
89
|
+
Override.from_comment('Float#+', %(
|
90
|
+
@param y [Numeric]
|
91
|
+
@return [Numeric]
|
92
|
+
)),
|
93
|
+
|
87
94
|
Override.from_comment('Hash#[]', %(
|
88
95
|
@return_value_parameter
|
89
96
|
)),
|
@@ -94,9 +101,25 @@ module Solargraph
|
|
94
101
|
@param_tuple
|
95
102
|
)),
|
96
103
|
|
104
|
+
Override.from_comment('Integer#+', %(
|
105
|
+
@param y [Numeric]
|
106
|
+
@return [Numeric]
|
107
|
+
)),
|
108
|
+
|
109
|
+
Override.method_return('Kernel#puts', 'nil'),
|
110
|
+
|
111
|
+
# Override.method_return('Module#attr_reader', 'void'),
|
112
|
+
# Override.method_return('Module#attr_writer', 'void'),
|
113
|
+
# Override.method_return('Module#attr_accessor', 'void'),
|
114
|
+
|
115
|
+
Override.from_comment('Numeric#+', %(
|
116
|
+
@param y [Numeric]
|
117
|
+
@return [Numeric]
|
118
|
+
)),
|
119
|
+
|
97
120
|
Override.method_return('Object#!', 'Boolean'),
|
98
121
|
Override.method_return('Object#clone', 'self', delete: [:overload]),
|
99
|
-
Override.method_return('Object#dup', 'self'),
|
122
|
+
Override.method_return('Object#dup', 'self', delete: [:overload]),
|
100
123
|
Override.method_return('Object#freeze', 'self', delete: [:overload]),
|
101
124
|
Override.method_return('Object#inspect', 'String'),
|
102
125
|
Override.method_return('Object#taint', 'self'),
|
@@ -121,7 +144,10 @@ module Solargraph
|
|
121
144
|
|
122
145
|
Override.method_return('String#freeze', 'self'),
|
123
146
|
Override.method_return('String#split', 'Array<String>'),
|
124
|
-
Override.method_return('String#lines', 'Array<String>')
|
147
|
+
Override.method_return('String#lines', 'Array<String>'),
|
148
|
+
Override.from_comment('String#each_line', %(
|
149
|
+
@yieldparam [String]
|
150
|
+
))
|
125
151
|
].concat(
|
126
152
|
methods_with_yieldparam_subtypes.map do |path|
|
127
153
|
Override.from_comment(path, %(
|
@@ -8,19 +8,19 @@ module Solargraph
|
|
8
8
|
class TypeCheck < Base
|
9
9
|
def diagnose source, api_map
|
10
10
|
return [] unless args.include?('always') || api_map.workspaced?(source.filename)
|
11
|
-
severity =
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
11
|
+
severity = Diagnostics::Severities::ERROR
|
12
|
+
level = (args.reverse.find { |a| ['normal', 'typed', 'strict', 'strong'].include?(a) }) || :normal
|
13
|
+
checker = Solargraph::TypeChecker.new(source.filename, api_map: api_map, level: level.to_sym)
|
14
|
+
checker.problems
|
15
|
+
.sort { |a, b| a.location.range.start.line <=> b.location.range.start.line }
|
16
|
+
.map do |problem|
|
17
|
+
{
|
18
|
+
range: extract_first_line(problem.location, source),
|
19
|
+
severity: severity,
|
20
|
+
source: 'Typecheck',
|
21
|
+
message: problem.message
|
22
|
+
}
|
23
|
+
end
|
24
24
|
end
|
25
25
|
|
26
26
|
private
|
@@ -207,6 +207,15 @@ module Solargraph
|
|
207
207
|
type: LanguageServer::MessageTypes::ERROR,
|
208
208
|
message: "Error in diagnostics: #{e.message}"
|
209
209
|
}
|
210
|
+
rescue FileNotFoundError => e
|
211
|
+
# @todo This appears to happen when an external file is open and
|
212
|
+
# scheduled for diagnosis, but the file was closed (i.e., the
|
213
|
+
# editor moved to a different file) before diagnosis started
|
214
|
+
logger.warn "Unable to diagnose #{uri} : #{e.message}"
|
215
|
+
send_notification 'textDocument/publishDiagnostics', {
|
216
|
+
uri: uri,
|
217
|
+
diagnostics: []
|
218
|
+
}
|
210
219
|
end
|
211
220
|
else
|
212
221
|
logger.info "Deferring diagnosis of #{uri}"
|
@@ -245,7 +254,7 @@ module Solargraph
|
|
245
254
|
#
|
246
255
|
# @return [String] The most recent data or an empty string.
|
247
256
|
def flush
|
248
|
-
tmp =
|
257
|
+
tmp = ''
|
249
258
|
@buffer_semaphore.synchronize do
|
250
259
|
tmp = @buffer.clone
|
251
260
|
@buffer.clear
|
@@ -539,7 +548,7 @@ module Solargraph
|
|
539
548
|
end
|
540
549
|
|
541
550
|
# @param query [String]
|
542
|
-
# @return [
|
551
|
+
# @return [Array]
|
543
552
|
def document query
|
544
553
|
result = []
|
545
554
|
libraries.each { |lib| result.concat lib.document(query) }
|
@@ -12,7 +12,9 @@ module Solargraph
|
|
12
12
|
include UriHelpers
|
13
13
|
|
14
14
|
def initialize
|
15
|
+
@mutex = Mutex.new
|
15
16
|
@stopped = true
|
17
|
+
@has_uri = ConditionVariable.new
|
16
18
|
end
|
17
19
|
|
18
20
|
def stopped?
|
@@ -24,17 +26,14 @@ module Solargraph
|
|
24
26
|
return unless @stopped
|
25
27
|
@stopped = false
|
26
28
|
Thread.new do
|
27
|
-
until stopped?
|
28
|
-
tick
|
29
|
-
sleep 0.25 if queue.empty?
|
30
|
-
end
|
29
|
+
tick until stopped?
|
31
30
|
end
|
32
31
|
end
|
33
32
|
|
34
33
|
# @return [void]
|
35
34
|
def tick
|
36
|
-
|
37
|
-
|
35
|
+
uri = mutex.synchronize { next_uri }
|
36
|
+
|
38
37
|
return if queue.include?(uri)
|
39
38
|
mutex.synchronize do
|
40
39
|
nxt = open_source_hash[uri].finish_synchronize
|
@@ -44,6 +43,18 @@ module Solargraph
|
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
46
|
+
# @return [void]
|
47
|
+
def add_uri(uri)
|
48
|
+
queue.push(uri)
|
49
|
+
@has_uri.signal
|
50
|
+
end
|
51
|
+
|
52
|
+
# @return [String]
|
53
|
+
def next_uri
|
54
|
+
@has_uri.wait(mutex) if queue.empty?
|
55
|
+
queue.shift
|
56
|
+
end
|
57
|
+
|
47
58
|
# @return [void]
|
48
59
|
def stop
|
49
60
|
@stopped = true
|
@@ -87,7 +98,7 @@ module Solargraph
|
|
87
98
|
src = find(uri)
|
88
99
|
mutex.synchronize do
|
89
100
|
open_source_hash[uri] = src.start_synchronize(updater)
|
90
|
-
|
101
|
+
add_uri(uri)
|
91
102
|
end
|
92
103
|
changed
|
93
104
|
notify_observers uri
|
@@ -125,15 +136,13 @@ module Solargraph
|
|
125
136
|
|
126
137
|
private
|
127
138
|
|
128
|
-
# @return [
|
139
|
+
# @return [Hash]
|
129
140
|
def open_source_hash
|
130
141
|
@open_source_hash ||= {}
|
131
142
|
end
|
132
143
|
|
133
144
|
# @return [Mutex]
|
134
|
-
|
135
|
-
@mutex ||= Mutex.new
|
136
|
-
end
|
145
|
+
attr_reader :mutex
|
137
146
|
|
138
147
|
# An array of source URIs that are waiting to finish synchronizing.
|
139
148
|
#
|