solargraph 0.55.3 → 0.55.5
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 +7 -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 +192 -46
- 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 +7 -4
- 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 +12 -15
- 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 +15 -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 +3 -11
- data/lib/solargraph.rb +18 -1
- data/rbs/fills/tuple.rbs +150 -0
- data/rbs_collection.yaml +19 -0
- data/solargraph.gemspec +1 -0
- metadata +20 -7
- data/lib/solargraph/cache.rb +0 -77
@@ -0,0 +1,185 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'rbs'
|
3
|
+
|
4
|
+
module Solargraph
|
5
|
+
module PinCache
|
6
|
+
class << self
|
7
|
+
include Logging
|
8
|
+
|
9
|
+
# The base directory where cached YARD documentation and serialized pins are serialized
|
10
|
+
#
|
11
|
+
# @return [String]
|
12
|
+
def base_dir
|
13
|
+
# The directory is not stored in a variable so it can be overridden
|
14
|
+
# in specs.
|
15
|
+
ENV['SOLARGRAPH_CACHE'] ||
|
16
|
+
(ENV['XDG_CACHE_HOME'] ? File.join(ENV['XDG_CACHE_HOME'], 'solargraph') : nil) ||
|
17
|
+
File.join(Dir.home, '.cache', 'solargraph')
|
18
|
+
end
|
19
|
+
|
20
|
+
# The working directory for the current Ruby, RBS, and Solargraph versions.
|
21
|
+
#
|
22
|
+
# @return [String]
|
23
|
+
def work_dir
|
24
|
+
# The directory is not stored in a variable so it can be overridden
|
25
|
+
# in specs.
|
26
|
+
File.join(base_dir, "ruby-#{RUBY_VERSION}", "rbs-#{RBS::VERSION}", "solargraph-#{Solargraph::VERSION}")
|
27
|
+
end
|
28
|
+
|
29
|
+
def yardoc_path gemspec
|
30
|
+
File.join(base_dir, "yard-#{YARD::VERSION}", "#{gemspec.name}-#{gemspec.version}.yardoc")
|
31
|
+
end
|
32
|
+
|
33
|
+
def stdlib_path
|
34
|
+
File.join(work_dir, 'stdlib')
|
35
|
+
end
|
36
|
+
|
37
|
+
def stdlib_require_path require
|
38
|
+
File.join(stdlib_path, "#{require}.ser")
|
39
|
+
end
|
40
|
+
|
41
|
+
def deserialize_stdlib_require require
|
42
|
+
load(stdlib_require_path(require))
|
43
|
+
end
|
44
|
+
|
45
|
+
def serialize_stdlib_require require, pins
|
46
|
+
save(stdlib_require_path(require), pins)
|
47
|
+
end
|
48
|
+
|
49
|
+
def core_path
|
50
|
+
File.join(work_dir, 'core.ser')
|
51
|
+
end
|
52
|
+
|
53
|
+
def deserialize_core
|
54
|
+
load(core_path)
|
55
|
+
end
|
56
|
+
|
57
|
+
def serialize_core pins
|
58
|
+
save(core_path, pins)
|
59
|
+
end
|
60
|
+
|
61
|
+
def yard_gem_path gemspec
|
62
|
+
File.join(work_dir, 'yard', "#{gemspec.name}-#{gemspec.version}.ser")
|
63
|
+
end
|
64
|
+
|
65
|
+
def deserialize_yard_gem(gemspec)
|
66
|
+
load(yard_gem_path(gemspec))
|
67
|
+
end
|
68
|
+
|
69
|
+
def serialize_yard_gem(gemspec, pins)
|
70
|
+
save(yard_gem_path(gemspec), pins)
|
71
|
+
end
|
72
|
+
|
73
|
+
def has_yard?(gemspec)
|
74
|
+
exist?(yard_gem_path(gemspec))
|
75
|
+
end
|
76
|
+
|
77
|
+
def rbs_collection_path(gemspec, hash)
|
78
|
+
File.join(work_dir, 'rbs', "#{gemspec.name}-#{gemspec.version}-#{hash || 0}.ser")
|
79
|
+
end
|
80
|
+
|
81
|
+
def rbs_collection_path_prefix(gemspec)
|
82
|
+
File.join(work_dir, 'rbs', "#{gemspec.name}-#{gemspec.version}-")
|
83
|
+
end
|
84
|
+
|
85
|
+
def deserialize_rbs_collection_gem(gemspec, hash)
|
86
|
+
load(rbs_collection_path(gemspec, hash))
|
87
|
+
end
|
88
|
+
|
89
|
+
def serialize_rbs_collection_gem(gemspec, hash, pins)
|
90
|
+
save(rbs_collection_path(gemspec, hash), pins)
|
91
|
+
end
|
92
|
+
|
93
|
+
def combined_path(gemspec, hash)
|
94
|
+
File.join(work_dir, 'combined', "#{gemspec.name}-#{gemspec.version}-#{hash || 0}.ser")
|
95
|
+
end
|
96
|
+
|
97
|
+
def combined_path_prefix(gemspec)
|
98
|
+
File.join(work_dir, 'combined', "#{gemspec.name}-#{gemspec.version}-")
|
99
|
+
end
|
100
|
+
|
101
|
+
def serialize_combined_gem(gemspec, hash, pins)
|
102
|
+
save(combined_path(gemspec, hash), pins)
|
103
|
+
end
|
104
|
+
|
105
|
+
def deserialize_combined_gem gemspec, hash
|
106
|
+
load(combined_path(gemspec, hash))
|
107
|
+
end
|
108
|
+
|
109
|
+
def has_rbs_collection?(gemspec, hash)
|
110
|
+
exist?(rbs_collection_path(gemspec, hash))
|
111
|
+
end
|
112
|
+
|
113
|
+
def uncache_core
|
114
|
+
uncache(core_path)
|
115
|
+
end
|
116
|
+
|
117
|
+
def uncache_stdlib
|
118
|
+
uncache(stdlib_path)
|
119
|
+
end
|
120
|
+
|
121
|
+
def uncache_gem(gemspec, out: nil)
|
122
|
+
uncache(yardoc_path(gemspec), out: out)
|
123
|
+
uncache_by_prefix(rbs_collection_path_prefix(gemspec), out: out)
|
124
|
+
uncache(yard_gem_path(gemspec), out: out)
|
125
|
+
uncache_by_prefix(combined_path_prefix(gemspec), out: out)
|
126
|
+
end
|
127
|
+
|
128
|
+
# @return [void]
|
129
|
+
def clear
|
130
|
+
FileUtils.rm_rf base_dir, secure: true
|
131
|
+
end
|
132
|
+
|
133
|
+
private
|
134
|
+
|
135
|
+
# @param file [String]
|
136
|
+
# @return [Array<Solargraph::Pin::Base>, nil]
|
137
|
+
def load file
|
138
|
+
return nil unless File.file?(file)
|
139
|
+
Marshal.load(File.read(file, mode: 'rb'))
|
140
|
+
rescue StandardError => e
|
141
|
+
Solargraph.logger.warn "Failed to load cached file #{file}: [#{e.class}] #{e.message}"
|
142
|
+
FileUtils.rm_f file
|
143
|
+
nil
|
144
|
+
end
|
145
|
+
|
146
|
+
def exist? *path
|
147
|
+
File.file? join(*path)
|
148
|
+
end
|
149
|
+
|
150
|
+
# @param path [Array<String>]
|
151
|
+
# @param pins [Array<Pin::Base>]
|
152
|
+
# @return [void]
|
153
|
+
def save file, pins
|
154
|
+
base = File.dirname(file)
|
155
|
+
FileUtils.mkdir_p base unless File.directory?(base)
|
156
|
+
ser = Marshal.dump(pins)
|
157
|
+
File.write file, ser, mode: 'wb'
|
158
|
+
logger.debug { "Cache#save: Saved #{pins.length} pins to #{file}" }
|
159
|
+
end
|
160
|
+
|
161
|
+
# @return [void]
|
162
|
+
# @param path_segments [Array<String>]
|
163
|
+
def uncache *path_segments, out: nil
|
164
|
+
path = File.join(*path_segments)
|
165
|
+
if File.exist?(path)
|
166
|
+
FileUtils.rm_rf path, secure: true
|
167
|
+
out.puts "Clearing pin cache in #{path}" unless out.nil?
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
# @return [void]
|
172
|
+
# @param path_segments [Array<String>]
|
173
|
+
def uncache_by_prefix *path_segments, out: nil
|
174
|
+
path = File.join(*path_segments)
|
175
|
+
glob = "#{path}*"
|
176
|
+
out.puts "Clearing pin cache in #{glob}" unless out.nil?
|
177
|
+
Dir.glob(glob).each do |file|
|
178
|
+
next unless File.file?(file)
|
179
|
+
FileUtils.rm_rf file, secure: true
|
180
|
+
out.puts "Clearing pin cache in #{file}" unless out.nil?
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
data/lib/solargraph/position.rb
CHANGED
@@ -26,6 +26,15 @@ module Solargraph
|
|
26
26
|
[line, character]
|
27
27
|
end
|
28
28
|
|
29
|
+
def <=>(other)
|
30
|
+
return nil unless other.is_a?(Position)
|
31
|
+
if line == other.line
|
32
|
+
character <=> other.character
|
33
|
+
else
|
34
|
+
line <=> other.line
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
29
38
|
# Get a hash of the position. This representation is suitable for use in
|
30
39
|
# the language server protocol.
|
31
40
|
#
|
data/lib/solargraph/range.rb
CHANGED
@@ -24,6 +24,15 @@ module Solargraph
|
|
24
24
|
[start, ending]
|
25
25
|
end
|
26
26
|
|
27
|
+
def <=>(other)
|
28
|
+
return nil unless other.is_a?(Range)
|
29
|
+
if start == other.start
|
30
|
+
ending <=> other.ending
|
31
|
+
else
|
32
|
+
start <=> other.start
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
27
36
|
# Get a hash of the range. This representation is suitable for use in
|
28
37
|
# the language server protocol.
|
29
38
|
#
|