solargraph 0.55.3 → 0.56.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/.github/workflows/plugins.yml +2 -0
- data/.github/workflows/typecheck.yml +3 -1
- data/.gitignore +2 -0
- data/CHANGELOG.md +26 -1
- data/README.md +13 -3
- data/lib/solargraph/api_map/index.rb +23 -15
- data/lib/solargraph/api_map/store.rb +8 -4
- data/lib/solargraph/api_map.rb +150 -57
- data/lib/solargraph/complex_type/type_methods.rb +6 -1
- data/lib/solargraph/complex_type/unique_type.rb +10 -2
- data/lib/solargraph/convention/base.rb +3 -3
- data/lib/solargraph/convention.rb +3 -3
- data/lib/solargraph/doc_map.rb +209 -49
- data/lib/solargraph/gem_pins.rb +53 -37
- data/lib/solargraph/language_server/host.rb +11 -2
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +2 -0
- data/lib/solargraph/language_server/message/extended/document.rb +5 -2
- data/lib/solargraph/language_server/message/extended/document_gems.rb +3 -3
- data/lib/solargraph/library.rb +43 -16
- data/lib/solargraph/location.rb +13 -0
- data/lib/solargraph/logging.rb +1 -0
- data/lib/solargraph/parser/comment_ripper.rb +1 -0
- data/lib/solargraph/parser/flow_sensitive_typing.rb +2 -1
- data/lib/solargraph/parser/node_processor.rb +3 -1
- data/lib/solargraph/parser/parser_gem/class_methods.rb +5 -8
- data/lib/solargraph/parser/parser_gem/node_methods.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_processors/alias_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +4 -2
- data/lib/solargraph/parser/parser_gem/node_processors/block_node.rb +4 -2
- data/lib/solargraph/parser/parser_gem/node_processors/casgn_node.rb +4 -3
- data/lib/solargraph/parser/parser_gem/node_processors/cvasgn_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/def_node.rb +6 -3
- data/lib/solargraph/parser/parser_gem/node_processors/defs_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/gvasgn_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/ivasgn_node.rb +4 -2
- data/lib/solargraph/parser/parser_gem/node_processors/lvasgn_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/namespace_node.rb +6 -4
- data/lib/solargraph/parser/parser_gem/node_processors/resbody_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb +4 -3
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +28 -16
- data/lib/solargraph/parser/parser_gem/node_processors/sym_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/until_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors/while_node.rb +1 -0
- data/lib/solargraph/parser/region.rb +1 -1
- data/lib/solargraph/pin/base.rb +295 -28
- data/lib/solargraph/pin/base_variable.rb +9 -8
- data/lib/solargraph/pin/callable.rb +74 -3
- data/lib/solargraph/pin/closure.rb +18 -1
- data/lib/solargraph/pin/common.rb +5 -0
- data/lib/solargraph/pin/delegated_method.rb +2 -0
- data/lib/solargraph/pin/documenting.rb +16 -0
- data/lib/solargraph/pin/keyword.rb +7 -2
- data/lib/solargraph/pin/local_variable.rb +8 -5
- data/lib/solargraph/pin/method.rb +147 -25
- data/lib/solargraph/pin/namespace.rb +7 -2
- data/lib/solargraph/pin/parameter.rb +47 -6
- data/lib/solargraph/pin/proxy_type.rb +3 -3
- data/lib/solargraph/pin/reference/override.rb +10 -6
- data/lib/solargraph/pin/reference/require.rb +2 -2
- data/lib/solargraph/pin/signature.rb +42 -0
- data/lib/solargraph/pin/singleton.rb +1 -1
- data/lib/solargraph/pin/symbol.rb +3 -2
- data/lib/solargraph/pin.rb +1 -1
- data/lib/solargraph/pin_cache.rb +185 -0
- data/lib/solargraph/position.rb +9 -0
- data/lib/solargraph/range.rb +9 -0
- data/lib/solargraph/rbs_map/conversions.rb +183 -56
- data/lib/solargraph/rbs_map/core_fills.rb +24 -15
- data/lib/solargraph/rbs_map/core_map.rb +34 -11
- data/lib/solargraph/rbs_map/stdlib_map.rb +15 -5
- data/lib/solargraph/rbs_map.rb +74 -17
- data/lib/solargraph/shell.rb +17 -18
- data/lib/solargraph/source/chain/array.rb +7 -4
- data/lib/solargraph/source/chain/block_symbol.rb +1 -1
- data/lib/solargraph/source/chain/block_variable.rb +1 -1
- data/lib/solargraph/source/chain/call.rb +8 -7
- data/lib/solargraph/source/chain/hash.rb +1 -1
- data/lib/solargraph/source/chain/head.rb +1 -1
- data/lib/solargraph/source/chain/if.rb +1 -1
- data/lib/solargraph/source/chain/literal.rb +2 -2
- data/lib/solargraph/source/chain/or.rb +1 -1
- data/lib/solargraph/source/chain.rb +2 -2
- data/lib/solargraph/source_map/mapper.rb +9 -5
- data/lib/solargraph/source_map.rb +0 -17
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/views/_method.erb +10 -10
- data/lib/solargraph/views/_namespace.erb +3 -3
- data/lib/solargraph/views/document.erb +10 -10
- data/lib/solargraph/workspace.rb +23 -5
- data/lib/solargraph/yard_map/mapper/to_constant.rb +4 -2
- data/lib/solargraph/yard_map/mapper/to_method.rb +14 -1
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +4 -2
- data/lib/solargraph/yard_map/mapper.rb +4 -3
- data/lib/solargraph/yard_map/to_method.rb +4 -2
- data/lib/solargraph/yardoc.rb +7 -8
- data/lib/solargraph.rb +18 -1
- data/rbs/fills/tuple.rbs +150 -0
- data/rbs_collection.yaml +19 -0
- data/solargraph.gemspec +2 -1
- metadata +22 -9
- data/lib/solargraph/cache.rb +0 -77
data/lib/solargraph/workspace.rb
CHANGED
@@ -106,7 +106,7 @@ module Solargraph
|
|
106
106
|
def would_require? path
|
107
107
|
require_paths.each do |rp|
|
108
108
|
full = File.join rp, path
|
109
|
-
return true if File.
|
109
|
+
return true if File.file?(full) || File.file?(full << ".rb")
|
110
110
|
end
|
111
111
|
false
|
112
112
|
end
|
@@ -133,6 +133,15 @@ module Solargraph
|
|
133
133
|
@gem_rbs_collection ||= read_rbs_collection_path
|
134
134
|
end
|
135
135
|
|
136
|
+
def rbs_collection_config_path
|
137
|
+
@rbs_collection_config_path ||= begin
|
138
|
+
unless directory.empty? || directory == '*'
|
139
|
+
yaml_file = File.join(directory, 'rbs_collection.yaml')
|
140
|
+
yaml_file if File.file?(yaml_file)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
136
145
|
# Synchronize the workspace from the provided updater.
|
137
146
|
#
|
138
147
|
# @param updater [Source::Updater]
|
@@ -146,6 +155,14 @@ module Solargraph
|
|
146
155
|
server['commandPath'] || 'solargraph'
|
147
156
|
end
|
148
157
|
|
158
|
+
# True if the workspace has a root Gemfile.
|
159
|
+
#
|
160
|
+
# @todo Handle projects with custom Bundler/Gemfile setups (see DocMap#gemspecs_required_from_bundler)
|
161
|
+
#
|
162
|
+
def gemfile?
|
163
|
+
directory && File.file?(File.join(directory, 'Gemfile'))
|
164
|
+
end
|
165
|
+
|
149
166
|
private
|
150
167
|
|
151
168
|
# The language server configuration (or an empty hash if the workspace was
|
@@ -214,7 +231,7 @@ module Solargraph
|
|
214
231
|
def configured_require_paths
|
215
232
|
return ['lib'] if directory.empty?
|
216
233
|
return [File.join(directory, 'lib')] if config.require_paths.empty?
|
217
|
-
config.require_paths.map{|p| File.join(directory, p)}
|
234
|
+
config.require_paths.map { |p| File.join(directory, p) }
|
218
235
|
end
|
219
236
|
|
220
237
|
# @return [void]
|
@@ -230,10 +247,11 @@ module Solargraph
|
|
230
247
|
|
231
248
|
# @return [String, nil]
|
232
249
|
def read_rbs_collection_path
|
233
|
-
|
234
|
-
return unless File.file?(yaml_file)
|
250
|
+
return unless rbs_collection_config_path
|
235
251
|
|
236
|
-
YAML.load_file(
|
252
|
+
path = YAML.load_file(rbs_collection_config_path)&.fetch('path')
|
253
|
+
# make fully qualified
|
254
|
+
File.expand_path(path, directory)
|
237
255
|
end
|
238
256
|
end
|
239
257
|
end
|
@@ -10,14 +10,16 @@ module Solargraph
|
|
10
10
|
def self.make code_object, closure = nil, spec = nil
|
11
11
|
closure ||= Solargraph::Pin::Namespace.new(
|
12
12
|
name: code_object.namespace.to_s,
|
13
|
-
gates: [code_object.namespace.to_s]
|
13
|
+
gates: [code_object.namespace.to_s],
|
14
|
+
source: :yardoc,
|
14
15
|
)
|
15
16
|
Pin::Constant.new(
|
16
17
|
location: object_location(code_object, spec),
|
17
18
|
closure: closure,
|
18
19
|
name: code_object.name.to_s,
|
19
20
|
comments: code_object.docstring ? code_object.docstring.all.to_s : '',
|
20
|
-
visibility: code_object.visibility
|
21
|
+
visibility: code_object.visibility,
|
22
|
+
source: :yardoc
|
21
23
|
)
|
22
24
|
end
|
23
25
|
end
|
@@ -6,6 +6,11 @@ module Solargraph
|
|
6
6
|
module ToMethod
|
7
7
|
extend YardMap::Helpers
|
8
8
|
|
9
|
+
VISIBILITY_OVERRIDE = {
|
10
|
+
# YARD pays attention to 'private' statements prior to class methods but shouldn't
|
11
|
+
["Rails::Engine", :class, "find_root_with_flag"] => :public
|
12
|
+
}
|
13
|
+
|
9
14
|
# @param code_object [YARD::CodeObjects::Base]
|
10
15
|
# @param name [String, nil]
|
11
16
|
# @param scope [Symbol, nil]
|
@@ -25,7 +30,14 @@ module Solargraph
|
|
25
30
|
return_type = ComplexType::SELF if name == 'new'
|
26
31
|
comments = code_object.docstring ? code_object.docstring.all.to_s : ''
|
27
32
|
final_scope = scope || code_object.scope
|
28
|
-
|
33
|
+
override_key = [closure.path, final_scope, name]
|
34
|
+
final_visibility = VISIBILITY_OVERRIDE[override_key]
|
35
|
+
final_visibility ||= VISIBILITY_OVERRIDE[override_key[0..-2]]
|
36
|
+
final_visibility ||= :private if closure.path == 'Kernel' && Kernel.private_instance_methods(false).include?(name)
|
37
|
+
final_visibility ||= visibility
|
38
|
+
final_visibility ||= :private if code_object.module_function? && final_scope == :instance
|
39
|
+
final_visibility ||= :public if code_object.module_function? && final_scope == :class
|
40
|
+
final_visibility ||= code_object.visibility
|
29
41
|
if code_object.is_alias?
|
30
42
|
origin_code_object = code_object.namespace.aliases[code_object]
|
31
43
|
pin = Pin::MethodAlias.new(
|
@@ -57,6 +69,7 @@ module Solargraph
|
|
57
69
|
source: :yardoc,
|
58
70
|
)
|
59
71
|
pin.parameters.concat get_parameters(code_object, location, comments, pin)
|
72
|
+
pin.parameters.freeze
|
60
73
|
end
|
61
74
|
logger.debug { "ToMethod.make: Just created method pin: #{pin.inspect}" }
|
62
75
|
pin
|
@@ -11,7 +11,8 @@ module Solargraph
|
|
11
11
|
closure ||= Solargraph::Pin::Namespace.new(
|
12
12
|
name: code_object.namespace.to_s,
|
13
13
|
closure: Pin::ROOT_PIN,
|
14
|
-
gates: [code_object.namespace.to_s]
|
14
|
+
gates: [code_object.namespace.to_s],
|
15
|
+
source: :yardoc,
|
15
16
|
)
|
16
17
|
Pin::Namespace.new(
|
17
18
|
location: object_location(code_object, spec),
|
@@ -19,7 +20,8 @@ module Solargraph
|
|
19
20
|
comments: code_object.docstring ? code_object.docstring.all.to_s : '',
|
20
21
|
type: code_object.is_a?(YARD::CodeObjects::ClassObject) ? :class : :module,
|
21
22
|
visibility: code_object.visibility,
|
22
|
-
closure: closure
|
23
|
+
closure: closure,
|
24
|
+
source: :yardoc,
|
23
25
|
)
|
24
26
|
end
|
25
27
|
end
|
@@ -47,15 +47,16 @@ module Solargraph
|
|
47
47
|
else
|
48
48
|
code_object.superclass.to_s
|
49
49
|
end
|
50
|
-
result.push Solargraph::Pin::Reference::Superclass.new(name: superclass, closure: nspin)
|
50
|
+
result.push Solargraph::Pin::Reference::Superclass.new(name: superclass, closure: nspin, source: :yard_map)
|
51
51
|
end
|
52
52
|
code_object.class_mixins.each do |m|
|
53
|
-
result.push Solargraph::Pin::Reference::Extend.new(closure: nspin, name: m.path)
|
53
|
+
result.push Solargraph::Pin::Reference::Extend.new(closure: nspin, name: m.path, source: :yard_map)
|
54
54
|
end
|
55
55
|
code_object.instance_mixins.each do |m|
|
56
56
|
result.push Solargraph::Pin::Reference::Include.new(
|
57
57
|
closure: nspin, # @todo Fix this
|
58
|
-
name: m.path
|
58
|
+
name: m.path,
|
59
|
+
source: :yard_map
|
59
60
|
)
|
60
61
|
end
|
61
62
|
elsif code_object.is_a?(YARD::CodeObjects::MethodObject)
|
@@ -23,7 +23,8 @@ module Solargraph
|
|
23
23
|
name: arg_name(a),
|
24
24
|
presence: nil,
|
25
25
|
decl: arg_type(a),
|
26
|
-
asgn_code: a[1]
|
26
|
+
asgn_code: a[1],
|
27
|
+
source: :yard_map
|
27
28
|
)
|
28
29
|
end
|
29
30
|
end
|
@@ -78,7 +79,8 @@ module Solargraph
|
|
78
79
|
scope: scope || code_object.scope,
|
79
80
|
visibility: visibility || code_object.visibility,
|
80
81
|
parameters: InnerMethods.get_parameters(code_object, location, comments),
|
81
|
-
explicit: code_object.is_explicit
|
82
|
+
explicit: code_object.is_explicit?,
|
83
|
+
source: :yard_map
|
82
84
|
)
|
83
85
|
end
|
84
86
|
end
|
data/lib/solargraph/yardoc.rb
CHANGED
@@ -12,7 +12,7 @@ module Solargraph
|
|
12
12
|
# @param gemspec [Gem::Specification]
|
13
13
|
# @return [String] The path to the cached yardoc.
|
14
14
|
def cache(gemspec)
|
15
|
-
path =
|
15
|
+
path = PinCache.yardoc_path gemspec
|
16
16
|
return path if cached?(gemspec)
|
17
17
|
|
18
18
|
Solargraph.logger.info "Caching yardoc for #{gemspec.name} #{gemspec.version}"
|
@@ -26,16 +26,15 @@ module Solargraph
|
|
26
26
|
#
|
27
27
|
# @param gemspec [Gem::Specification]
|
28
28
|
def cached?(gemspec)
|
29
|
-
yardoc = File.join(
|
29
|
+
yardoc = File.join(PinCache.yardoc_path(gemspec), 'complete')
|
30
30
|
File.exist?(yardoc)
|
31
31
|
end
|
32
32
|
|
33
|
-
#
|
33
|
+
# True if another process is currently building the yardoc cache.
|
34
34
|
#
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
File.join(Solargraph::Cache.base_dir, "yard-#{YARD::VERSION}", "#{gemspec.name}-#{gemspec.version}.yardoc")
|
35
|
+
def processing?(gemspec)
|
36
|
+
yardoc = File.join(PinCache.yardoc_path(gemspec), 'processing')
|
37
|
+
File.exist?(yardoc)
|
39
38
|
end
|
40
39
|
|
41
40
|
# Load a gem's yardoc and return its code objects.
|
@@ -45,7 +44,7 @@ module Solargraph
|
|
45
44
|
# @param gemspec [Gem::Specification]
|
46
45
|
# @return [Array<YARD::CodeObjects::Base>]
|
47
46
|
def load!(gemspec)
|
48
|
-
YARD::Registry.load!
|
47
|
+
YARD::Registry.load! PinCache.yardoc_path gemspec
|
49
48
|
YARD::Registry.all
|
50
49
|
end
|
51
50
|
end
|
data/lib/solargraph.rb
CHANGED
@@ -48,11 +48,28 @@ module Solargraph
|
|
48
48
|
autoload :Parser, 'solargraph/parser'
|
49
49
|
autoload :RbsMap, 'solargraph/rbs_map'
|
50
50
|
autoload :GemPins, 'solargraph/gem_pins'
|
51
|
-
autoload :
|
51
|
+
autoload :PinCache, 'solargraph/pin_cache'
|
52
52
|
|
53
53
|
dir = File.dirname(__FILE__)
|
54
54
|
VIEWS_PATH = File.join(dir, 'solargraph', 'views')
|
55
55
|
|
56
|
+
# @param type [Symbol] Type of assert.
|
57
|
+
def self.asserts_on?(type)
|
58
|
+
if ENV['SOLARGRAPH_ASSERTS'].nil? || ENV['SOLARGRAPH_ASSERTS'].empty?
|
59
|
+
false
|
60
|
+
elsif ENV['SOLARGRAPH_ASSERTS'] == 'on'
|
61
|
+
true
|
62
|
+
else
|
63
|
+
logger.warn "Unrecognized SOLARGRAPH_ASSERTS value: #{ENV['SOLARGRAPH_ASSERTS']}"
|
64
|
+
false
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.assert_or_log(type, msg = nil, &block)
|
69
|
+
raise (msg || block.call) if asserts_on?(type) && ![:combine_with_visibility].include?(type)
|
70
|
+
logger.info msg, &block
|
71
|
+
end
|
72
|
+
|
56
73
|
# A convenience method for Solargraph::Logging.logger.
|
57
74
|
#
|
58
75
|
# @return [Logger]
|
data/rbs/fills/tuple.rbs
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
# <-- liberally borrowed from
|
2
|
+
# https://github.com/ruby/rbs/blob/master/core/array.rbs, which
|
3
|
+
# was generated from
|
4
|
+
# https://github.com/ruby/ruby/blob/master/array.c
|
5
|
+
# -->
|
6
|
+
module Solargraph
|
7
|
+
module Fills
|
8
|
+
class Tuple[unchecked out A,
|
9
|
+
unchecked out B = A,
|
10
|
+
unchecked out C = A | B,
|
11
|
+
unchecked out D = A | B | C,
|
12
|
+
unchecked out E = A | B | C | D,
|
13
|
+
unchecked out F = A | B | C | D | E,
|
14
|
+
unchecked out G = A | B | C | D | E | F,
|
15
|
+
unchecked out H = A | B | C | D | E | F | G,
|
16
|
+
unchecked out I = A | B | C | D | E | F | G | H,
|
17
|
+
unchecked out J = A | B | C | D | E | F | G | H | I] < Array[A | B | C | D | E | F | G | H | I | J]
|
18
|
+
# <!--
|
19
|
+
# rdoc-file=array.c
|
20
|
+
# - self[index] -> object or nil
|
21
|
+
# -->
|
22
|
+
# Returns elements from `self`; does not modify `self`.
|
23
|
+
#
|
24
|
+
# In brief:
|
25
|
+
#
|
26
|
+
# a = [:foo, 'bar', 2]
|
27
|
+
#
|
28
|
+
# # Single argument index: returns one element.
|
29
|
+
# a[0] # => :foo # Zero-based index.
|
30
|
+
#
|
31
|
+
# When a single integer argument `index` is given, returns the element at offset
|
32
|
+
# `index`:
|
33
|
+
#
|
34
|
+
# a = [:foo, 'bar', 2]
|
35
|
+
# a[0] # => :foo
|
36
|
+
# a[2] # => 2
|
37
|
+
# a # => [:foo, "bar", 2]
|
38
|
+
def []: (0 index) -> A
|
39
|
+
| (1 index) -> B
|
40
|
+
| (2 index) -> C
|
41
|
+
| (3 index) -> D
|
42
|
+
| (4 index) -> E
|
43
|
+
| (5 index) -> F
|
44
|
+
| (6 index) -> G
|
45
|
+
| (7 index) -> H
|
46
|
+
| (8 index) -> I
|
47
|
+
| (9 index) -> J
|
48
|
+
| (0 index) -> K
|
49
|
+
| (int index) -> nil
|
50
|
+
|
51
|
+
# <!--
|
52
|
+
# rdoc-file=array.c
|
53
|
+
# - at(index) -> object or nil
|
54
|
+
# -->
|
55
|
+
# Returns the element of `self` specified by the given `index` or `nil` if there
|
56
|
+
# is no such element; `index` must be an [integer-convertible
|
57
|
+
# object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects).
|
58
|
+
#
|
59
|
+
# For non-negative `index`, returns the element of `self` at offset `index`:
|
60
|
+
#
|
61
|
+
# a = [:foo, 'bar', 2]
|
62
|
+
# a.at(0) # => :foo
|
63
|
+
# a.at(2) # => 2
|
64
|
+
# a.at(2.0) # => 2
|
65
|
+
#
|
66
|
+
# Related: Array#[]; see also [Methods for
|
67
|
+
# Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
68
|
+
#
|
69
|
+
def at: (0 index) -> A
|
70
|
+
| (1 index) -> B
|
71
|
+
| (2 index) -> C
|
72
|
+
| (3 index) -> D
|
73
|
+
| (4 index) -> E
|
74
|
+
| (5 index) -> F
|
75
|
+
| (6 index) -> G
|
76
|
+
| (7 index) -> H
|
77
|
+
| (8 index) -> I
|
78
|
+
| (9 index) -> J
|
79
|
+
| (int index) -> nil
|
80
|
+
|
81
|
+
# <!--
|
82
|
+
# rdoc-file=array.c
|
83
|
+
# - fetch(index) -> element
|
84
|
+
# - fetch(index, default_value) -> element or default_value
|
85
|
+
# - fetch(index) {|index| ... } -> element or block_return_value
|
86
|
+
# -->
|
87
|
+
# Returns the element of `self` at offset `index` if `index` is in range;
|
88
|
+
# `index` must be an [integer-convertible
|
89
|
+
# object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects).
|
90
|
+
#
|
91
|
+
# With the single argument `index` and no block, returns the element at offset
|
92
|
+
# `index`:
|
93
|
+
#
|
94
|
+
# a = [:foo, 'bar', 2]
|
95
|
+
# a.fetch(1) # => "bar"
|
96
|
+
# a.fetch(1.1) # => "bar"
|
97
|
+
#
|
98
|
+
# With arguments `index` and `default_value` (which may be any object) and no
|
99
|
+
# block, returns `default_value` if `index` is out-of-range:
|
100
|
+
#
|
101
|
+
# a = [:foo, 'bar', 2]
|
102
|
+
# a.fetch(1, nil) # => "bar"
|
103
|
+
# a.fetch(3, :foo) # => :foo
|
104
|
+
#
|
105
|
+
# With argument `index` and a block, returns the element at offset `index` if
|
106
|
+
# index is in range (and the block is not called); otherwise calls the block
|
107
|
+
# with index and returns its return value:
|
108
|
+
#
|
109
|
+
# a = [:foo, 'bar', 2]
|
110
|
+
# a.fetch(1) {|index| raise 'Cannot happen' } # => "bar"
|
111
|
+
# a.fetch(50) {|index| "Value for #{index}" } # => "Value for 50"
|
112
|
+
#
|
113
|
+
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
114
|
+
#
|
115
|
+
def fetch: (0 index) -> A
|
116
|
+
| (1 index) -> B
|
117
|
+
| (2 index) -> C
|
118
|
+
| (3 index) -> D
|
119
|
+
| (4 index) -> E
|
120
|
+
| (5 index) -> F
|
121
|
+
| (6 index) -> G
|
122
|
+
| (7 index) -> H
|
123
|
+
| (8 index) -> I
|
124
|
+
| (9 index) -> J
|
125
|
+
| (int index) -> void
|
126
|
+
| [T] (0 index, T default) -> (A | T)
|
127
|
+
| [T] (1 index, T default) -> (B | T)
|
128
|
+
| [T] (2 index, T default) -> (C | T)
|
129
|
+
| [T] (3 index, T default) -> (D | T)
|
130
|
+
| [T] (4 index, T default) -> (E | T)
|
131
|
+
| [T] (5 index, T default) -> (F | T)
|
132
|
+
| [T] (6 index, T default) -> (G | T)
|
133
|
+
| [T] (7 index, T default) -> (H | T)
|
134
|
+
| [T] (8 index, T default) -> (I | T)
|
135
|
+
| [T] (9 index, T default) -> (J | T)
|
136
|
+
| [T] (int index, T default) -> (A | B | C | D | E | F |G | H | I | J | T)
|
137
|
+
| [T] (0 index) { (int index) -> T } -> (A | T)
|
138
|
+
| [T] (1 index) { (int index) -> T } -> (B | T)
|
139
|
+
| [T] (2 index) { (int index) -> T } -> (C | T)
|
140
|
+
| [T] (3 index) { (int index) -> T } -> (D | T)
|
141
|
+
| [T] (4 index) { (int index) -> T } -> (E | T)
|
142
|
+
| [T] (5 index) { (int index) -> T } -> (F | T)
|
143
|
+
| [T] (6 index) { (int index) -> T } -> (G | T)
|
144
|
+
| [T] (7 index) { (int index) -> T } -> (H | T)
|
145
|
+
| [T] (8 index) { (int index) -> T } -> (I | T)
|
146
|
+
| [T] (9 index) { (int index) -> T } -> (J | T)
|
147
|
+
| [T] (int index) { (int index) -> T } -> (A | B | C | D | E | F |G | H | I | J | T)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
data/rbs_collection.yaml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Download sources
|
2
|
+
sources:
|
3
|
+
- type: git
|
4
|
+
name: ruby/gem_rbs_collection
|
5
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
6
|
+
revision: main
|
7
|
+
repo_dir: gems
|
8
|
+
|
9
|
+
# You can specify local directories as sources also.
|
10
|
+
# - type: local
|
11
|
+
# path: path/to/your/local/repository
|
12
|
+
|
13
|
+
# A directory to install the downloaded RBSs
|
14
|
+
path: .gem_rbs_collection
|
15
|
+
|
16
|
+
# gems:
|
17
|
+
# # If you want to avoid installing rbs files for gems, you can specify them here.
|
18
|
+
# - name: GEM_NAME
|
19
|
+
# ignore: true
|
data/solargraph.gemspec
CHANGED
@@ -34,7 +34,8 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.add_runtime_dependency 'observer', '~> 0.1'
|
35
35
|
s.add_runtime_dependency 'ostruct', '~> 0.6'
|
36
36
|
s.add_runtime_dependency 'parser', '~> 3.0'
|
37
|
-
s.add_runtime_dependency '
|
37
|
+
s.add_runtime_dependency 'prism', '~> 1.4'
|
38
|
+
s.add_runtime_dependency 'rbs', '~> 3.6.1'
|
38
39
|
s.add_runtime_dependency 'reverse_markdown', '~> 3.0'
|
39
40
|
s.add_runtime_dependency 'rubocop', '~> 1.38'
|
40
41
|
s.add_runtime_dependency 'thor', '~> 1.0'
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solargraph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.56.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date: 2025-
|
10
|
+
date: 2025-07-13 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: backport
|
@@ -170,20 +169,34 @@ dependencies:
|
|
170
169
|
- - "~>"
|
171
170
|
- !ruby/object:Gem::Version
|
172
171
|
version: '3.0'
|
172
|
+
- !ruby/object:Gem::Dependency
|
173
|
+
name: prism
|
174
|
+
requirement: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - "~>"
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '1.4'
|
179
|
+
type: :runtime
|
180
|
+
prerelease: false
|
181
|
+
version_requirements: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - "~>"
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: '1.4'
|
173
186
|
- !ruby/object:Gem::Dependency
|
174
187
|
name: rbs
|
175
188
|
requirement: !ruby/object:Gem::Requirement
|
176
189
|
requirements:
|
177
190
|
- - "~>"
|
178
191
|
- !ruby/object:Gem::Version
|
179
|
-
version:
|
192
|
+
version: 3.6.1
|
180
193
|
type: :runtime
|
181
194
|
prerelease: false
|
182
195
|
version_requirements: !ruby/object:Gem::Requirement
|
183
196
|
requirements:
|
184
197
|
- - "~>"
|
185
198
|
- !ruby/object:Gem::Version
|
186
|
-
version:
|
199
|
+
version: 3.6.1
|
187
200
|
- !ruby/object:Gem::Dependency
|
188
201
|
name: reverse_markdown
|
189
202
|
requirement: !ruby/object:Gem::Requirement
|
@@ -401,7 +414,6 @@ files:
|
|
401
414
|
- lib/solargraph/api_map/source_to_yard.rb
|
402
415
|
- lib/solargraph/api_map/store.rb
|
403
416
|
- lib/solargraph/bench.rb
|
404
|
-
- lib/solargraph/cache.rb
|
405
417
|
- lib/solargraph/complex_type.rb
|
406
418
|
- lib/solargraph/complex_type/type_methods.rb
|
407
419
|
- lib/solargraph/complex_type/unique_type.rb
|
@@ -568,6 +580,7 @@ files:
|
|
568
580
|
- lib/solargraph/pin/symbol.rb
|
569
581
|
- lib/solargraph/pin/until.rb
|
570
582
|
- lib/solargraph/pin/while.rb
|
583
|
+
- lib/solargraph/pin_cache.rb
|
571
584
|
- lib/solargraph/position.rb
|
572
585
|
- lib/solargraph/range.rb
|
573
586
|
- lib/solargraph/rbs_map.rb
|
@@ -631,6 +644,8 @@ files:
|
|
631
644
|
- lib/solargraph/yard_map/to_method.rb
|
632
645
|
- lib/solargraph/yard_tags.rb
|
633
646
|
- lib/solargraph/yardoc.rb
|
647
|
+
- rbs/fills/tuple.rbs
|
648
|
+
- rbs_collection.yaml
|
634
649
|
- solargraph.gemspec
|
635
650
|
homepage: https://solargraph.org
|
636
651
|
licenses:
|
@@ -640,7 +655,6 @@ metadata:
|
|
640
655
|
bug_tracker_uri: https://github.com/castwide/solargraph/issues
|
641
656
|
changelog_uri: https://github.com/castwide/solargraph/blob/master/CHANGELOG.md
|
642
657
|
source_code_uri: https://github.com/castwide/solargraph
|
643
|
-
post_install_message:
|
644
658
|
rdoc_options: []
|
645
659
|
require_paths:
|
646
660
|
- lib
|
@@ -655,8 +669,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
655
669
|
- !ruby/object:Gem::Version
|
656
670
|
version: '0'
|
657
671
|
requirements: []
|
658
|
-
rubygems_version: 3.
|
659
|
-
signing_key:
|
672
|
+
rubygems_version: 3.6.7
|
660
673
|
specification_version: 4
|
661
674
|
summary: A Ruby language server
|
662
675
|
test_files: []
|
data/lib/solargraph/cache.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'rbs'
|
3
|
-
|
4
|
-
module Solargraph
|
5
|
-
module Cache
|
6
|
-
class << self
|
7
|
-
# The base directory where cached documentation is installed.
|
8
|
-
#
|
9
|
-
# @return [String]
|
10
|
-
def base_dir
|
11
|
-
# The directory is not stored in a variable so it can be overridden
|
12
|
-
# in specs.
|
13
|
-
ENV['SOLARGRAPH_CACHE'] ||
|
14
|
-
(ENV['XDG_CACHE_HOME'] ? File.join(ENV['XDG_CACHE_HOME'], 'solargraph') : nil) ||
|
15
|
-
File.join(Dir.home, '.cache', 'solargraph')
|
16
|
-
end
|
17
|
-
|
18
|
-
# The working directory for the current Ruby, RBS, and Solargraph versions.
|
19
|
-
#
|
20
|
-
# @return [String]
|
21
|
-
def work_dir
|
22
|
-
# The directory is not stored in a variable so it can be overridden
|
23
|
-
# in specs.
|
24
|
-
File.join(base_dir, "ruby-#{RUBY_VERSION}", "rbs-#{RBS::VERSION}", "solargraph-#{Solargraph::VERSION}")
|
25
|
-
end
|
26
|
-
|
27
|
-
# Append the given path to the current cache directory (`work_dir`).
|
28
|
-
#
|
29
|
-
# @example
|
30
|
-
# Cache.join('date-3.4.1.ser')
|
31
|
-
#
|
32
|
-
# @param path [Array<String>]
|
33
|
-
# @return [String]
|
34
|
-
def join *path
|
35
|
-
File.join(work_dir, *path)
|
36
|
-
end
|
37
|
-
|
38
|
-
# @param path [Array<String>]
|
39
|
-
# @return [Array<Solargraph::Pin::Base>, nil]
|
40
|
-
def load *path
|
41
|
-
file = join(*path)
|
42
|
-
return nil unless File.file?(file)
|
43
|
-
Marshal.load(File.read(file, mode: 'rb'))
|
44
|
-
rescue StandardError => e
|
45
|
-
Solargraph.logger.warn "Failed to load cached file #{file}: [#{e.class}] #{e.message}"
|
46
|
-
FileUtils.rm_f file
|
47
|
-
nil
|
48
|
-
end
|
49
|
-
|
50
|
-
def exist? *path
|
51
|
-
File.file? join(*path)
|
52
|
-
end
|
53
|
-
|
54
|
-
# @param path [Array<String>]
|
55
|
-
# @param pins [Array<Pin::Base>]
|
56
|
-
# @return [void]
|
57
|
-
def save *path, pins
|
58
|
-
file = File.join(work_dir, *path)
|
59
|
-
base = File.dirname(file)
|
60
|
-
FileUtils.mkdir_p base unless File.directory?(base)
|
61
|
-
ser = Marshal.dump(pins)
|
62
|
-
File.write file, ser, mode: 'wb'
|
63
|
-
end
|
64
|
-
|
65
|
-
# @return [void]
|
66
|
-
# @param path [Array<String>]
|
67
|
-
def uncache *path
|
68
|
-
FileUtils.rm_rf File.join(work_dir, *path), secure: true
|
69
|
-
end
|
70
|
-
|
71
|
-
# @return [void]
|
72
|
-
def clear
|
73
|
-
FileUtils.rm_rf base_dir, secure: true
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|