solargraph 0.56.0 → 0.57.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/.github/workflows/linting.yml +125 -0
- data/.github/workflows/plugins.yml +148 -6
- data/.github/workflows/rspec.yml +39 -4
- data/.github/workflows/typecheck.yml +5 -2
- data/.gitignore +5 -0
- data/.overcommit.yml +72 -0
- data/.rspec +1 -0
- data/.rubocop.yml +66 -0
- data/.rubocop_todo.yml +2627 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +56 -1
- data/README.md +8 -4
- data/Rakefile +125 -13
- data/lib/solargraph/api_map/cache.rb +3 -2
- data/lib/solargraph/api_map/constants.rb +218 -0
- data/lib/solargraph/api_map/index.rb +20 -26
- data/lib/solargraph/api_map/source_to_yard.rb +10 -4
- data/lib/solargraph/api_map/store.rb +126 -18
- data/lib/solargraph/api_map.rb +212 -234
- data/lib/solargraph/bench.rb +1 -0
- data/lib/solargraph/complex_type/type_methods.rb +1 -0
- data/lib/solargraph/complex_type/unique_type.rb +7 -7
- data/lib/solargraph/complex_type.rb +5 -1
- data/lib/solargraph/convention/active_support_concern.rb +111 -0
- data/lib/solargraph/convention/base.rb +17 -0
- data/lib/solargraph/convention/data_definition/data_assignment_node.rb +61 -0
- data/lib/solargraph/convention/data_definition/data_definition_node.rb +91 -0
- data/lib/solargraph/convention/data_definition.rb +105 -0
- data/lib/solargraph/convention/gemspec.rb +3 -2
- data/lib/solargraph/convention/struct_definition/struct_assignment_node.rb +2 -1
- data/lib/solargraph/convention/struct_definition/struct_definition_node.rb +4 -2
- data/lib/solargraph/convention/struct_definition.rb +87 -24
- data/lib/solargraph/convention.rb +32 -2
- data/lib/solargraph/diagnostics/rubocop.rb +6 -1
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +1 -1
- data/lib/solargraph/doc_map.rb +48 -17
- data/lib/solargraph/environ.rb +9 -2
- data/lib/solargraph/gem_pins.rb +17 -11
- data/lib/solargraph/language_server/host/dispatch.rb +2 -0
- data/lib/solargraph/language_server/host/message_worker.rb +3 -0
- data/lib/solargraph/language_server/host.rb +2 -1
- data/lib/solargraph/language_server/message/base.rb +2 -1
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +1 -1
- data/lib/solargraph/language_server/message/text_document/definition.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/formatting.rb +16 -2
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +1 -0
- data/lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb +2 -0
- data/lib/solargraph/language_server/progress.rb +8 -0
- data/lib/solargraph/language_server/request.rb +1 -0
- data/lib/solargraph/library.rb +47 -30
- data/lib/solargraph/location.rb +2 -0
- data/lib/solargraph/logging.rb +11 -2
- data/lib/solargraph/page.rb +4 -0
- data/lib/solargraph/parser/comment_ripper.rb +8 -1
- data/lib/solargraph/parser/flow_sensitive_typing.rb +32 -4
- data/lib/solargraph/parser/node_methods.rb +2 -2
- data/lib/solargraph/parser/node_processor/base.rb +10 -5
- data/lib/solargraph/parser/node_processor.rb +24 -8
- data/lib/solargraph/parser/parser_gem/class_methods.rb +1 -1
- data/lib/solargraph/parser/parser_gem/flawed_builder.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +3 -1
- data/lib/solargraph/parser/parser_gem/node_methods.rb +4 -2
- data/lib/solargraph/parser/parser_gem/node_processors/block_node.rb +3 -2
- data/lib/solargraph/parser/parser_gem/node_processors/casgn_node.rb +1 -21
- data/lib/solargraph/parser/parser_gem/node_processors/if_node.rb +2 -0
- data/lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb +7 -1
- data/lib/solargraph/parser/parser_gem/node_processors/namespace_node.rb +0 -22
- data/lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors/orasgn_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors/resbody_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +35 -14
- data/lib/solargraph/parser/parser_gem/node_processors/sym_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors.rb +4 -0
- data/lib/solargraph/parser/region.rb +3 -0
- data/lib/solargraph/parser/snippet.rb +2 -0
- data/lib/solargraph/pin/base.rb +65 -8
- data/lib/solargraph/pin/base_variable.rb +1 -2
- data/lib/solargraph/pin/callable.rb +9 -0
- data/lib/solargraph/pin/closure.rb +2 -0
- data/lib/solargraph/pin/common.rb +6 -2
- data/lib/solargraph/pin/constant.rb +2 -0
- data/lib/solargraph/pin/delegated_method.rb +1 -0
- data/lib/solargraph/pin/local_variable.rb +4 -1
- data/lib/solargraph/pin/method.rb +12 -7
- data/lib/solargraph/pin/method_alias.rb +3 -0
- data/lib/solargraph/pin/parameter.rb +18 -8
- data/lib/solargraph/pin/proxy_type.rb +1 -0
- data/lib/solargraph/pin/reference/override.rb +15 -1
- data/lib/solargraph/pin/reference/superclass.rb +5 -0
- data/lib/solargraph/pin/reference.rb +26 -0
- data/lib/solargraph/pin/search.rb +3 -1
- data/lib/solargraph/pin/signature.rb +2 -0
- data/lib/solargraph/pin/symbol.rb +5 -0
- data/lib/solargraph/pin_cache.rb +64 -4
- data/lib/solargraph/position.rb +2 -0
- data/lib/solargraph/range.rb +1 -0
- data/lib/solargraph/rbs_map/conversions.rb +47 -18
- data/lib/solargraph/rbs_map/core_map.rb +3 -0
- data/lib/solargraph/rbs_map.rb +15 -2
- data/lib/solargraph/shell.rb +3 -0
- data/lib/solargraph/source/chain/link.rb +10 -1
- data/lib/solargraph/source/chain.rb +9 -2
- data/lib/solargraph/source/change.rb +2 -2
- data/lib/solargraph/source/cursor.rb +2 -3
- data/lib/solargraph/source/source_chainer.rb +1 -1
- data/lib/solargraph/source.rb +5 -2
- data/lib/solargraph/source_map/clip.rb +1 -1
- data/lib/solargraph/source_map/data.rb +4 -0
- data/lib/solargraph/source_map/mapper.rb +4 -2
- data/lib/solargraph/source_map.rb +21 -14
- data/lib/solargraph/type_checker/param_def.rb +2 -0
- data/lib/solargraph/type_checker/rules.rb +8 -0
- data/lib/solargraph/type_checker.rb +173 -120
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +1 -3
- data/lib/solargraph/workspace/require_paths.rb +98 -0
- data/lib/solargraph/workspace.rb +24 -48
- data/lib/solargraph/yard_map/helpers.rb +29 -1
- data/lib/solargraph/yard_map/mapper/to_constant.rb +5 -5
- data/lib/solargraph/yard_map/mapper/to_method.rb +3 -8
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +7 -7
- data/lib/solargraph/yardoc.rb +18 -3
- data/lib/solargraph.rb +15 -0
- data/rbs/fills/tuple.rbs +2 -3
- data/sig/shims/parser/3.2.0.1/builders/default.rbs +195 -0
- data/sig/shims/thor/1.2.0.1/.rbs_meta.yaml +9 -0
- data/sig/shims/thor/1.2.0.1/manifest.yaml +7 -0
- data/sig/shims/thor/1.2.0.1/thor.rbs +17 -0
- data/solargraph.gemspec +14 -4
- metadata +128 -11
- data/lib/.rubocop.yml +0 -22
@@ -22,7 +22,8 @@ module Solargraph
|
|
22
22
|
# @param attribute [Boolean]
|
23
23
|
# @param signatures [::Array<Signature>, nil]
|
24
24
|
# @param anon_splat [Boolean]
|
25
|
-
def initialize visibility: :public, explicit: true, block: :undefined, node: nil, attribute: false, signatures: nil, anon_splat: false,
|
25
|
+
def initialize visibility: :public, explicit: true, block: :undefined, node: nil, attribute: false, signatures: nil, anon_splat: false,
|
26
|
+
**splat
|
26
27
|
super(**splat)
|
27
28
|
@visibility = visibility
|
28
29
|
@explicit = explicit
|
@@ -50,7 +51,7 @@ module Solargraph
|
|
50
51
|
end
|
51
52
|
|
52
53
|
# @param other [Pin::Method]
|
53
|
-
# @return [Symbol]
|
54
|
+
# @return [::Symbol]
|
54
55
|
def combine_visibility(other)
|
55
56
|
if dodgy_visibility_source? && !other.dodgy_visibility_source?
|
56
57
|
other.visibility
|
@@ -76,6 +77,9 @@ module Solargraph
|
|
76
77
|
end
|
77
78
|
|
78
79
|
def combine_with(other, attrs = {})
|
80
|
+
priority_choice = choose_priority(other)
|
81
|
+
return priority_choice unless priority_choice.nil?
|
82
|
+
|
79
83
|
sigs = combine_signatures(other)
|
80
84
|
parameters = if sigs.length > 0
|
81
85
|
[].freeze
|
@@ -199,9 +203,11 @@ module Solargraph
|
|
199
203
|
)
|
200
204
|
end
|
201
205
|
yield_return_type = ComplexType.try_parse(*yieldreturn_tags.flat_map(&:types))
|
202
|
-
block = Signature.new(generics: generics, parameters: yield_parameters, return_type: yield_return_type, source: source,
|
206
|
+
block = Signature.new(generics: generics, parameters: yield_parameters, return_type: yield_return_type, source: source,
|
207
|
+
closure: self, location: location, type_location: type_location)
|
203
208
|
end
|
204
|
-
signature = Signature.new(generics: generics, parameters: parameters, return_type: return_type, block: block, closure: self, source: source
|
209
|
+
signature = Signature.new(generics: generics, parameters: parameters, return_type: return_type, block: block, closure: self, source: source,
|
210
|
+
location: location, type_location: type_location)
|
205
211
|
block.closure = signature if block
|
206
212
|
signature
|
207
213
|
end
|
@@ -299,7 +305,6 @@ module Solargraph
|
|
299
305
|
super
|
300
306
|
end
|
301
307
|
|
302
|
-
# @sg-ignore
|
303
308
|
def documentation
|
304
309
|
if @documentation.nil?
|
305
310
|
method_docs ||= super || ''
|
@@ -423,7 +428,7 @@ module Solargraph
|
|
423
428
|
@resolved_ref_tag = true
|
424
429
|
return self unless docstring.ref_tags.any?
|
425
430
|
docstring.ref_tags.each do |tag|
|
426
|
-
ref = if tag.owner.to_s.start_with?(/[
|
431
|
+
ref = if tag.owner.to_s.start_with?(/[#.]/)
|
427
432
|
api_map.get_methods(namespace)
|
428
433
|
.select { |pin| pin.path.end_with?(tag.owner.to_s) }
|
429
434
|
.first
|
@@ -547,7 +552,7 @@ module Solargraph
|
|
547
552
|
# @param api_map [ApiMap]
|
548
553
|
# @return [ComplexType, nil]
|
549
554
|
def resolve_reference ref, api_map
|
550
|
-
parts = ref.split(/[
|
555
|
+
parts = ref.split(/[.#]/)
|
551
556
|
if parts.first.empty? || parts.one?
|
552
557
|
path = "#{namespace}#{ref}"
|
553
558
|
else
|
@@ -13,6 +13,9 @@ module Solargraph
|
|
13
13
|
# @return [String]
|
14
14
|
attr_reader :original
|
15
15
|
|
16
|
+
# @param scope [::Symbol]
|
17
|
+
# @param original [String, nil] The name of the original method
|
18
|
+
# @param splat [Hash] Additional options supported by superclasses
|
16
19
|
def initialize scope: :instance, original: nil, **splat
|
17
20
|
super(**splat)
|
18
21
|
@scope = scope
|
@@ -105,15 +105,13 @@ module Solargraph
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
-
# @return [String]
|
109
|
-
|
108
|
+
# @return [String] the full name of the parameter, including any
|
109
|
+
# declarative symbols such as `*` or `:` indicating type of
|
110
|
+
# parameter. This is used in method signatures.
|
111
|
+
def full_name
|
110
112
|
case decl
|
111
|
-
when :
|
112
|
-
"#{name} = #{asgn_code || '?'}"
|
113
|
-
when :kwarg
|
113
|
+
when :kwarg, :kwoptarg
|
114
114
|
"#{name}:"
|
115
|
-
when :kwoptarg
|
116
|
-
"#{name}: #{asgn_code || '?'}"
|
117
115
|
when :restarg
|
118
116
|
"*#{name}"
|
119
117
|
when :kwrestarg
|
@@ -125,6 +123,18 @@ module Solargraph
|
|
125
123
|
end
|
126
124
|
end
|
127
125
|
|
126
|
+
# @return [String]
|
127
|
+
def full
|
128
|
+
full_name + case decl
|
129
|
+
when :optarg
|
130
|
+
" = #{asgn_code || '?'}"
|
131
|
+
when :kwoptarg
|
132
|
+
" #{asgn_code || '?'}"
|
133
|
+
else
|
134
|
+
''
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
128
138
|
# @return [ComplexType]
|
129
139
|
def return_type
|
130
140
|
if @return_type.nil?
|
@@ -237,7 +247,7 @@ module Solargraph
|
|
237
247
|
def resolve_reference ref, api_map, skip
|
238
248
|
return nil if skip.include?(ref)
|
239
249
|
skip.push ref
|
240
|
-
parts = ref.split(/[
|
250
|
+
parts = ref.split(/[.#]/)
|
241
251
|
if parts.first.empty?
|
242
252
|
path = "#{namespace}#{ref}"
|
243
253
|
else
|
@@ -4,6 +4,7 @@ module Solargraph
|
|
4
4
|
module Pin
|
5
5
|
class ProxyType < Base
|
6
6
|
# @param return_type [ComplexType]
|
7
|
+
# @param binder [ComplexType, ComplexType::UniqueType, nil]
|
7
8
|
def initialize return_type: ComplexType::UNDEFINED, binder: nil, **splat
|
8
9
|
super(**splat)
|
9
10
|
@return_type = return_type
|
@@ -14,16 +14,30 @@ module Solargraph
|
|
14
14
|
nil
|
15
15
|
end
|
16
16
|
|
17
|
+
# @param location [Location, nil]
|
18
|
+
# @param name [String]
|
19
|
+
# @param tags [::Array<YARD::Tags::Tag>]
|
20
|
+
# @param delete [::Array<Symbol>]
|
21
|
+
# @param splat [Hash]
|
17
22
|
def initialize location, name, tags, delete = [], **splat
|
18
23
|
super(location: location, name: name, **splat)
|
19
24
|
@tags = tags
|
20
25
|
@delete = delete
|
21
26
|
end
|
22
27
|
|
28
|
+
# @param name [String]
|
29
|
+
# @param tags [::Array<String>]
|
30
|
+
# @param delete [::Array<Symbol>]
|
31
|
+
# @param splat [Hash]
|
32
|
+
# @return [Solargraph::Pin::Reference::Override]
|
23
33
|
def self.method_return name, *tags, delete: [], **splat
|
24
|
-
new(nil, name, [YARD::Tags::Tag.new('return',
|
34
|
+
new(nil, name, [YARD::Tags::Tag.new('return', '', tags)], delete, **splat)
|
25
35
|
end
|
26
36
|
|
37
|
+
# @param name [String]
|
38
|
+
# @param comment [String]
|
39
|
+
# @param splat [Hash]
|
40
|
+
# @return [Solargraph::Pin::Reference::Override]
|
27
41
|
def self.from_comment name, comment, **splat
|
28
42
|
new(nil, name, Solargraph::Source.parse_docstring(comment).to_docstring.tags, **splat)
|
29
43
|
end
|
@@ -17,6 +17,32 @@ module Solargraph
|
|
17
17
|
super(**splat)
|
18
18
|
@generic_values = generic_values
|
19
19
|
end
|
20
|
+
|
21
|
+
# @return [String]
|
22
|
+
def parameter_tag
|
23
|
+
@parameter_tag ||= if generic_values&.any?
|
24
|
+
"<#{generic_values.join(', ')}>"
|
25
|
+
else
|
26
|
+
''
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [ComplexType]
|
31
|
+
def parametrized_tag
|
32
|
+
@parametrized_tag ||= ComplexType.try_parse(
|
33
|
+
name +
|
34
|
+
if generic_values&.length&.> 0
|
35
|
+
"<#{generic_values.join(', ')}>"
|
36
|
+
else
|
37
|
+
''
|
38
|
+
end
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
# @return [Array<String>]
|
43
|
+
def reference_gates
|
44
|
+
closure.gates
|
45
|
+
end
|
20
46
|
end
|
21
47
|
end
|
22
48
|
end
|
@@ -12,6 +12,8 @@ module Solargraph
|
|
12
12
|
# @return [Pin::Base]
|
13
13
|
attr_reader :pin
|
14
14
|
|
15
|
+
# @param match [Float] The match score for the pin
|
16
|
+
# @param pin [Pin::Base]
|
15
17
|
def initialize match, pin
|
16
18
|
@match = match
|
17
19
|
@pin = pin
|
@@ -48,7 +50,7 @@ module Solargraph
|
|
48
50
|
# @param str2 [String]
|
49
51
|
# @return [Float]
|
50
52
|
def fuzzy_string_match str1, str2
|
51
|
-
return
|
53
|
+
return 1.0 + (str2.length.to_f / str1.length.to_f) if str1.downcase.include?(str2.downcase)
|
52
54
|
JaroWinkler.similarity(str1, str2, ignore_case: true)
|
53
55
|
end
|
54
56
|
end
|
@@ -39,6 +39,8 @@ module Solargraph
|
|
39
39
|
end
|
40
40
|
return ComplexType::UNDEFINED if closure.nil?
|
41
41
|
return ComplexType::UNDEFINED unless closure.is_a?(Pin::Method)
|
42
|
+
# @sg-ignore need is_a? support
|
43
|
+
# @type [Array<Pin::Method>]
|
42
44
|
method_stack = closure.rest_of_stack api_map
|
43
45
|
logger.debug { "Signature#typify(self=#{self}) - method_stack: #{method_stack}" }
|
44
46
|
method_stack.each do |pin|
|
@@ -20,6 +20,10 @@ module Solargraph
|
|
20
20
|
''
|
21
21
|
end
|
22
22
|
|
23
|
+
def closure
|
24
|
+
@closure ||= Pin::ROOT_PIN
|
25
|
+
end
|
26
|
+
|
23
27
|
def completion_item_kind
|
24
28
|
Solargraph::LanguageServer::CompletionItemKinds::KEYWORD
|
25
29
|
end
|
@@ -36,6 +40,7 @@ module Solargraph
|
|
36
40
|
[]
|
37
41
|
end
|
38
42
|
|
43
|
+
# @return [::Symbol]
|
39
44
|
def visibility
|
40
45
|
:public
|
41
46
|
end
|
data/lib/solargraph/pin_cache.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'yard-activesupport-concern'
|
1
2
|
require 'fileutils'
|
2
3
|
require 'rbs'
|
3
4
|
|
@@ -26,98 +27,156 @@ module Solargraph
|
|
26
27
|
File.join(base_dir, "ruby-#{RUBY_VERSION}", "rbs-#{RBS::VERSION}", "solargraph-#{Solargraph::VERSION}")
|
27
28
|
end
|
28
29
|
|
30
|
+
# @param gemspec [Gem::Specification]
|
31
|
+
# @return [String]
|
29
32
|
def yardoc_path gemspec
|
30
|
-
File.join(base_dir,
|
33
|
+
File.join(base_dir,
|
34
|
+
"yard-#{YARD::VERSION}",
|
35
|
+
"yard-activesupport-concern-#{YARD::ActiveSupport::Concern::VERSION}",
|
36
|
+
"#{gemspec.name}-#{gemspec.version}.yardoc")
|
31
37
|
end
|
32
38
|
|
39
|
+
# @return [String]
|
33
40
|
def stdlib_path
|
34
41
|
File.join(work_dir, 'stdlib')
|
35
42
|
end
|
36
43
|
|
44
|
+
# @param require [String]
|
45
|
+
# @return [String]
|
37
46
|
def stdlib_require_path require
|
38
47
|
File.join(stdlib_path, "#{require}.ser")
|
39
48
|
end
|
40
49
|
|
50
|
+
# @param require [String]
|
51
|
+
# @return [Array<Pin::Base>]
|
41
52
|
def deserialize_stdlib_require require
|
42
53
|
load(stdlib_require_path(require))
|
43
54
|
end
|
44
55
|
|
56
|
+
# @param require [String]
|
57
|
+
# @param pins [Array<Pin::Base>]
|
58
|
+
# @return [void]
|
45
59
|
def serialize_stdlib_require require, pins
|
46
60
|
save(stdlib_require_path(require), pins)
|
47
61
|
end
|
48
62
|
|
63
|
+
# @return [String]
|
49
64
|
def core_path
|
50
65
|
File.join(work_dir, 'core.ser')
|
51
66
|
end
|
52
67
|
|
68
|
+
# @return [Array<Pin::Base>]
|
53
69
|
def deserialize_core
|
54
70
|
load(core_path)
|
55
71
|
end
|
56
72
|
|
73
|
+
# @param pins [Array<Pin::Base>]
|
74
|
+
# @return [void]
|
57
75
|
def serialize_core pins
|
58
76
|
save(core_path, pins)
|
59
77
|
end
|
60
78
|
|
79
|
+
# @param gemspec [Gem::Specification]
|
80
|
+
# @return [String]
|
61
81
|
def yard_gem_path gemspec
|
62
82
|
File.join(work_dir, 'yard', "#{gemspec.name}-#{gemspec.version}.ser")
|
63
83
|
end
|
64
84
|
|
85
|
+
# @param gemspec [Gem::Specification]
|
86
|
+
# @return [Array<Pin::Base>]
|
65
87
|
def deserialize_yard_gem(gemspec)
|
66
88
|
load(yard_gem_path(gemspec))
|
67
89
|
end
|
68
90
|
|
91
|
+
# @param gemspec [Gem::Specification]
|
92
|
+
# @param pins [Array<Pin::Base>]
|
93
|
+
# @return [void]
|
69
94
|
def serialize_yard_gem(gemspec, pins)
|
70
95
|
save(yard_gem_path(gemspec), pins)
|
71
96
|
end
|
72
97
|
|
98
|
+
# @param gemspec [Gem::Specification]
|
99
|
+
# @return [Boolean]
|
73
100
|
def has_yard?(gemspec)
|
74
101
|
exist?(yard_gem_path(gemspec))
|
75
102
|
end
|
76
103
|
|
104
|
+
# @param gemspec [Gem::Specification]
|
105
|
+
# @param hash [String, nil]
|
106
|
+
# @return [String]
|
77
107
|
def rbs_collection_path(gemspec, hash)
|
78
108
|
File.join(work_dir, 'rbs', "#{gemspec.name}-#{gemspec.version}-#{hash || 0}.ser")
|
79
109
|
end
|
80
110
|
|
111
|
+
# @param gemspec [Gem::Specification]
|
112
|
+
# @return [String]
|
81
113
|
def rbs_collection_path_prefix(gemspec)
|
82
114
|
File.join(work_dir, 'rbs', "#{gemspec.name}-#{gemspec.version}-")
|
83
115
|
end
|
84
116
|
|
117
|
+
# @param gemspec [Gem::Specification]
|
118
|
+
# @param hash [String, nil]
|
119
|
+
# @return [Array<Pin::Base>]
|
85
120
|
def deserialize_rbs_collection_gem(gemspec, hash)
|
86
121
|
load(rbs_collection_path(gemspec, hash))
|
87
122
|
end
|
88
123
|
|
124
|
+
# @param gemspec [Gem::Specification]
|
125
|
+
# @param hash [String, nil]
|
126
|
+
# @param pins [Array<Pin::Base>]n
|
127
|
+
# @return [void]
|
89
128
|
def serialize_rbs_collection_gem(gemspec, hash, pins)
|
90
129
|
save(rbs_collection_path(gemspec, hash), pins)
|
91
130
|
end
|
92
131
|
|
132
|
+
# @param gemspec [Gem::Specification]
|
133
|
+
# @param hash [String, nil]
|
134
|
+
# @return [String]
|
93
135
|
def combined_path(gemspec, hash)
|
94
136
|
File.join(work_dir, 'combined', "#{gemspec.name}-#{gemspec.version}-#{hash || 0}.ser")
|
95
137
|
end
|
96
138
|
|
139
|
+
# @param gemspec [Gem::Specification]
|
140
|
+
# @return [String]
|
97
141
|
def combined_path_prefix(gemspec)
|
98
142
|
File.join(work_dir, 'combined', "#{gemspec.name}-#{gemspec.version}-")
|
99
143
|
end
|
100
144
|
|
145
|
+
# @param gemspec [Gem::Specification]
|
146
|
+
# @param hash [String, nil]
|
147
|
+
# @param pins [Array<Pin::Base>]
|
148
|
+
# @return [void]
|
101
149
|
def serialize_combined_gem(gemspec, hash, pins)
|
102
150
|
save(combined_path(gemspec, hash), pins)
|
103
151
|
end
|
104
152
|
|
153
|
+
# @param gemspec [Gem::Specification]
|
154
|
+
# @param hash [String, nil]
|
155
|
+
# @return [Array<Pin::Base>]
|
105
156
|
def deserialize_combined_gem gemspec, hash
|
106
157
|
load(combined_path(gemspec, hash))
|
107
158
|
end
|
108
159
|
|
160
|
+
# @param gemspec [Gem::Specification]
|
161
|
+
# @param hash [String, nil]
|
162
|
+
# @return [Boolean]
|
109
163
|
def has_rbs_collection?(gemspec, hash)
|
110
164
|
exist?(rbs_collection_path(gemspec, hash))
|
111
165
|
end
|
112
166
|
|
167
|
+
# @return [void]
|
113
168
|
def uncache_core
|
114
169
|
uncache(core_path)
|
115
170
|
end
|
116
171
|
|
172
|
+
# @return [void]
|
117
173
|
def uncache_stdlib
|
118
174
|
uncache(stdlib_path)
|
119
175
|
end
|
120
176
|
|
177
|
+
# @param gemspec [Gem::Specification]
|
178
|
+
# @param out [IO, nil]
|
179
|
+
# @return [void]
|
121
180
|
def uncache_gem(gemspec, out: nil)
|
122
181
|
uncache(yardoc_path(gemspec), out: out)
|
123
182
|
uncache_by_prefix(rbs_collection_path_prefix(gemspec), out: out)
|
@@ -143,11 +202,12 @@ module Solargraph
|
|
143
202
|
nil
|
144
203
|
end
|
145
204
|
|
205
|
+
# @param path [String]
|
146
206
|
def exist? *path
|
147
|
-
File.file? join(*path)
|
207
|
+
File.file? File.join(*path)
|
148
208
|
end
|
149
209
|
|
150
|
-
# @param
|
210
|
+
# @param file [String]
|
151
211
|
# @param pins [Array<Pin::Base>]
|
152
212
|
# @return [void]
|
153
213
|
def save file, pins
|
@@ -158,8 +218,8 @@ module Solargraph
|
|
158
218
|
logger.debug { "Cache#save: Saved #{pins.length} pins to #{file}" }
|
159
219
|
end
|
160
220
|
|
161
|
-
# @return [void]
|
162
221
|
# @param path_segments [Array<String>]
|
222
|
+
# @return [void]
|
163
223
|
def uncache *path_segments, out: nil
|
164
224
|
path = File.join(*path_segments)
|
165
225
|
if File.exist?(path)
|
data/lib/solargraph/position.rb
CHANGED
@@ -26,6 +26,7 @@ module Solargraph
|
|
26
26
|
[line, character]
|
27
27
|
end
|
28
28
|
|
29
|
+
# @param other [Position]
|
29
30
|
def <=>(other)
|
30
31
|
return nil unless other.is_a?(Position)
|
31
32
|
if line == other.line
|
@@ -57,6 +58,7 @@ module Solargraph
|
|
57
58
|
# @return [Integer]
|
58
59
|
def self.to_offset text, position
|
59
60
|
return 0 if text.empty?
|
61
|
+
# @sg-ignore Unresolved call to + on Integer
|
60
62
|
text.lines[0...position.line].sum(&:length) + position.character
|
61
63
|
end
|
62
64
|
|