solargraph 0.54.1 → 0.56.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/plugins.yml +2 -0
- data/.github/workflows/typecheck.yml +3 -1
- data/.gitignore +2 -0
- data/CHANGELOG.md +70 -0
- data/README.md +13 -3
- data/lib/solargraph/api_map/cache.rb +10 -1
- data/lib/solargraph/api_map/index.rb +175 -0
- data/lib/solargraph/api_map/store.rb +79 -126
- data/lib/solargraph/api_map.rb +247 -93
- data/lib/solargraph/bench.rb +17 -1
- data/lib/solargraph/complex_type/type_methods.rb +13 -1
- data/lib/solargraph/complex_type/unique_type.rb +118 -9
- data/lib/solargraph/complex_type.rb +48 -18
- data/lib/solargraph/convention/base.rb +3 -3
- data/lib/solargraph/convention/struct_definition/struct_assignment_node.rb +60 -0
- data/lib/solargraph/convention/struct_definition/struct_definition_node.rb +100 -0
- data/lib/solargraph/convention/struct_definition.rb +101 -0
- data/lib/solargraph/convention.rb +5 -3
- data/lib/solargraph/doc_map.rb +274 -56
- data/lib/solargraph/equality.rb +33 -0
- data/lib/solargraph/gem_pins.rb +53 -37
- data/lib/solargraph/language_server/host/message_worker.rb +31 -11
- data/lib/solargraph/language_server/host.rb +24 -13
- data/lib/solargraph/language_server/message/base.rb +19 -12
- 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/language_server/message/initialize.rb +3 -1
- data/lib/solargraph/language_server/message/text_document/completion.rb +0 -3
- data/lib/solargraph/language_server/message/text_document/formatting.rb +4 -0
- data/lib/solargraph/library.rb +13 -11
- data/lib/solargraph/location.rb +28 -0
- data/lib/solargraph/logging.rb +1 -0
- data/lib/solargraph/parser/comment_ripper.rb +12 -6
- data/lib/solargraph/parser/flow_sensitive_typing.rb +227 -0
- data/lib/solargraph/parser/node_methods.rb +15 -1
- data/lib/solargraph/parser/node_processor.rb +3 -1
- data/lib/solargraph/parser/parser_gem/class_methods.rb +16 -14
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +17 -23
- data/lib/solargraph/parser/parser_gem/node_methods.rb +5 -3
- data/lib/solargraph/parser/parser_gem/node_processors/alias_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/and_node.rb +21 -0
- 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 +23 -2
- 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/if_node.rb +21 -0
- data/lib/solargraph/parser/parser_gem/node_processors/ivasgn_node.rb +4 -2
- data/lib/solargraph/parser/parser_gem/node_processors/lvasgn_node.rb +4 -3
- data/lib/solargraph/parser/parser_gem/node_processors/namespace_node.rb +29 -6
- data/lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb +41 -0
- 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 +29 -0
- data/lib/solargraph/parser/parser_gem/node_processors/while_node.rb +29 -0
- data/lib/solargraph/parser/parser_gem/node_processors.rb +10 -0
- data/lib/solargraph/parser/region.rb +1 -1
- data/lib/solargraph/parser.rb +1 -0
- data/lib/solargraph/pin/base.rb +326 -43
- data/lib/solargraph/pin/base_variable.rb +18 -10
- data/lib/solargraph/pin/block.rb +3 -3
- data/lib/solargraph/pin/breakable.rb +9 -0
- data/lib/solargraph/pin/callable.rb +77 -6
- data/lib/solargraph/pin/closure.rb +18 -1
- data/lib/solargraph/pin/common.rb +5 -0
- data/lib/solargraph/pin/delegated_method.rb +20 -1
- data/lib/solargraph/pin/documenting.rb +16 -0
- data/lib/solargraph/pin/keyword.rb +7 -2
- data/lib/solargraph/pin/local_variable.rb +15 -6
- data/lib/solargraph/pin/method.rb +172 -42
- data/lib/solargraph/pin/namespace.rb +17 -9
- data/lib/solargraph/pin/parameter.rb +61 -11
- data/lib/solargraph/pin/proxy_type.rb +12 -6
- 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/until.rb +18 -0
- data/lib/solargraph/pin/while.rb +18 -0
- data/lib/solargraph/pin.rb +4 -1
- data/lib/solargraph/pin_cache.rb +185 -0
- data/lib/solargraph/position.rb +16 -0
- data/lib/solargraph/range.rb +16 -0
- data/lib/solargraph/rbs_map/conversions.rb +199 -66
- data/lib/solargraph/rbs_map/core_fills.rb +32 -16
- 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 -16
- data/lib/solargraph/shell.rb +19 -18
- data/lib/solargraph/source/chain/array.rb +12 -8
- 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 +62 -25
- data/lib/solargraph/source/chain/constant.rb +1 -1
- data/lib/solargraph/source/chain/hash.rb +9 -3
- data/lib/solargraph/source/chain/head.rb +1 -1
- data/lib/solargraph/source/chain/if.rb +6 -1
- data/lib/solargraph/source/chain/link.rb +19 -5
- data/lib/solargraph/source/chain/literal.rb +27 -2
- data/lib/solargraph/source/chain/or.rb +1 -1
- data/lib/solargraph/source/chain/z_super.rb +1 -1
- data/lib/solargraph/source/chain.rb +106 -62
- data/lib/solargraph/source/cursor.rb +1 -11
- data/lib/solargraph/source/source_chainer.rb +2 -2
- data/lib/solargraph/source.rb +2 -1
- data/lib/solargraph/source_map/clip.rb +4 -2
- data/lib/solargraph/source_map/mapper.rb +9 -5
- data/lib/solargraph/source_map.rb +0 -17
- data/lib/solargraph/type_checker/checks.rb +4 -0
- data/lib/solargraph/type_checker.rb +41 -14
- 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/config.rb +7 -3
- data/lib/solargraph/workspace.rb +16 -6
- data/lib/solargraph/yard_map/mapper/to_constant.rb +5 -2
- data/lib/solargraph/yard_map/mapper/to_method.rb +55 -15
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +5 -2
- data/lib/solargraph/yard_map/mapper.rb +5 -3
- data/lib/solargraph/yard_map/to_method.rb +4 -2
- data/lib/solargraph/yardoc.rb +6 -9
- data/lib/solargraph.rb +20 -1
- data/rbs/fills/tuple.rbs +150 -0
- data/rbs_collection.yaml +19 -0
- data/solargraph.gemspec +6 -5
- metadata +56 -29
- data/lib/solargraph/cache.rb +0 -77
|
@@ -24,10 +24,8 @@ module Solargraph
|
|
|
24
24
|
attr_writer :client_capabilities
|
|
25
25
|
|
|
26
26
|
def initialize
|
|
27
|
-
@cancel_semaphore = Mutex.new
|
|
28
27
|
@buffer_semaphore = Mutex.new
|
|
29
28
|
@request_mutex = Mutex.new
|
|
30
|
-
@cancel = []
|
|
31
29
|
@buffer = String.new
|
|
32
30
|
@stopped = true
|
|
33
31
|
@next_request_id = 1
|
|
@@ -65,7 +63,7 @@ module Solargraph
|
|
|
65
63
|
# @param id [Integer]
|
|
66
64
|
# @return [void]
|
|
67
65
|
def cancel id
|
|
68
|
-
|
|
66
|
+
cancelled.push id
|
|
69
67
|
end
|
|
70
68
|
|
|
71
69
|
# True if the host received a request to cancel the method with the
|
|
@@ -74,9 +72,7 @@ module Solargraph
|
|
|
74
72
|
# @param id [Integer]
|
|
75
73
|
# @return [Boolean]
|
|
76
74
|
def cancel? id
|
|
77
|
-
|
|
78
|
-
@cancel_semaphore.synchronize { result = @cancel.include? id }
|
|
79
|
-
result
|
|
75
|
+
cancelled.include? id
|
|
80
76
|
end
|
|
81
77
|
|
|
82
78
|
# Delete the specified ID from the list of cancelled IDs if it exists.
|
|
@@ -84,7 +80,7 @@ module Solargraph
|
|
|
84
80
|
# @param id [Integer]
|
|
85
81
|
# @return [void]
|
|
86
82
|
def clear id
|
|
87
|
-
|
|
83
|
+
cancelled.delete id
|
|
88
84
|
end
|
|
89
85
|
|
|
90
86
|
# Called by adapter, to handle the request
|
|
@@ -101,11 +97,11 @@ module Solargraph
|
|
|
101
97
|
# @return [Solargraph::LanguageServer::Message::Base, nil] The message handler.
|
|
102
98
|
def receive request
|
|
103
99
|
if request['method']
|
|
104
|
-
logger.info "
|
|
100
|
+
logger.info "Host received ##{request['id']} #{request['method']}"
|
|
105
101
|
logger.debug request
|
|
106
102
|
message = Message.select(request['method']).new(self, request)
|
|
107
103
|
begin
|
|
108
|
-
message.process
|
|
104
|
+
message.process unless cancel?(request['id'])
|
|
109
105
|
rescue StandardError => e
|
|
110
106
|
logger.warn "Error processing request: [#{e.class}] #{e.message}"
|
|
111
107
|
logger.warn e.backtrace.join("\n")
|
|
@@ -303,6 +299,10 @@ module Solargraph
|
|
|
303
299
|
end
|
|
304
300
|
end
|
|
305
301
|
|
|
302
|
+
def command_path
|
|
303
|
+
options['commandPath'] || 'solargraph'
|
|
304
|
+
end
|
|
305
|
+
|
|
306
306
|
# Prepare multiple folders.
|
|
307
307
|
#
|
|
308
308
|
# @param array [Array<Hash{String => String}>]
|
|
@@ -381,7 +381,6 @@ module Solargraph
|
|
|
381
381
|
envelope = "Content-Length: #{json.bytesize}\r\n\r\n#{json}"
|
|
382
382
|
queue envelope
|
|
383
383
|
@next_request_id += 1
|
|
384
|
-
logger.info "Server sent #{method}"
|
|
385
384
|
logger.debug params
|
|
386
385
|
end
|
|
387
386
|
end
|
|
@@ -476,6 +475,7 @@ module Solargraph
|
|
|
476
475
|
def locate_pins params
|
|
477
476
|
return [] unless params['data'] && params['data']['uri']
|
|
478
477
|
library = library_for(params['data']['uri'])
|
|
478
|
+
# @type [Array<Pin::Base>]
|
|
479
479
|
result = []
|
|
480
480
|
if params['data']['location']
|
|
481
481
|
location = Location.new(
|
|
@@ -505,7 +505,8 @@ module Solargraph
|
|
|
505
505
|
parameters: pin.parameters,
|
|
506
506
|
return_type: ComplexType.try_parse(params['data']['path']),
|
|
507
507
|
comments: pin.comments,
|
|
508
|
-
closure: pin.closure
|
|
508
|
+
closure: pin.closure,
|
|
509
|
+
source: :solargraph
|
|
509
510
|
)
|
|
510
511
|
end)
|
|
511
512
|
end
|
|
@@ -575,7 +576,7 @@ module Solargraph
|
|
|
575
576
|
# @param column [Integer]
|
|
576
577
|
# @param strip [Boolean] Strip special characters from variable names
|
|
577
578
|
# @param only [Boolean] If true, search current file only
|
|
578
|
-
# @return [Array<Solargraph::
|
|
579
|
+
# @return [Array<Solargraph::Location>]
|
|
579
580
|
def references_from uri, line, column, strip: true, only: false
|
|
580
581
|
library = library_for(uri)
|
|
581
582
|
library.references_from(uri_to_file(uri), line, column, strip: strip, only: only)
|
|
@@ -601,7 +602,11 @@ module Solargraph
|
|
|
601
602
|
# @return [Array]
|
|
602
603
|
def document query
|
|
603
604
|
result = []
|
|
604
|
-
libraries.
|
|
605
|
+
if libraries.empty?
|
|
606
|
+
result.concat generic_library.document(query)
|
|
607
|
+
else
|
|
608
|
+
libraries.each { |lib| result.concat lib.document(query) }
|
|
609
|
+
end
|
|
605
610
|
result
|
|
606
611
|
end
|
|
607
612
|
|
|
@@ -693,6 +698,11 @@ module Solargraph
|
|
|
693
698
|
|
|
694
699
|
private
|
|
695
700
|
|
|
701
|
+
# @return [Array<Integer>]
|
|
702
|
+
def cancelled
|
|
703
|
+
@cancelled ||= []
|
|
704
|
+
end
|
|
705
|
+
|
|
696
706
|
# @return [MessageWorker]
|
|
697
707
|
def message_worker
|
|
698
708
|
@message_worker ||= MessageWorker.new(self)
|
|
@@ -748,6 +758,7 @@ module Solargraph
|
|
|
748
758
|
return change if source.code.length + 1 != change['text'].length
|
|
749
759
|
diffs = Diff::LCS.diff(source.code, change['text'])
|
|
750
760
|
return change if diffs.length.zero? || diffs.length > 1 || diffs.first.length > 1
|
|
761
|
+
# @sg-ignore push this upstream
|
|
751
762
|
# @type [Diff::LCS::Change]
|
|
752
763
|
diff = diffs.first.first
|
|
753
764
|
return change unless diff.adding? && ['.', ':', '(', ',', ' '].include?(diff.element)
|
|
@@ -16,7 +16,7 @@ module Solargraph
|
|
|
16
16
|
# @return [String]
|
|
17
17
|
attr_reader :method
|
|
18
18
|
|
|
19
|
-
# @return [Hash{String => Array
|
|
19
|
+
# @return [Hash{String => Array<undefined>, Hash{String => undefined}, String, Integer}]
|
|
20
20
|
attr_reader :params
|
|
21
21
|
|
|
22
22
|
# @return [Hash, Array, nil]
|
|
@@ -61,18 +61,11 @@ module Solargraph
|
|
|
61
61
|
# @return [void]
|
|
62
62
|
def send_response
|
|
63
63
|
return if id.nil?
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
# cancel should send response RequestCancelled
|
|
67
|
-
Solargraph::Logging.logger.info "Cancelled response to #{method}"
|
|
68
|
-
set_result nil
|
|
69
|
-
set_error ErrorCodes::REQUEST_CANCELLED, "cancelled by client"
|
|
70
|
-
else
|
|
71
|
-
Solargraph::Logging.logger.info "Sending response to #{method}"
|
|
72
|
-
end
|
|
64
|
+
|
|
65
|
+
accept_or_cancel
|
|
73
66
|
response = {
|
|
74
|
-
jsonrpc:
|
|
75
|
-
id: id
|
|
67
|
+
jsonrpc: '2.0',
|
|
68
|
+
id: id
|
|
76
69
|
}
|
|
77
70
|
response[:result] = result unless result.nil?
|
|
78
71
|
response[:error] = error unless error.nil?
|
|
@@ -83,6 +76,20 @@ module Solargraph
|
|
|
83
76
|
host.queue envelope
|
|
84
77
|
host.clear id
|
|
85
78
|
end
|
|
79
|
+
|
|
80
|
+
private
|
|
81
|
+
|
|
82
|
+
def accept_or_cancel
|
|
83
|
+
if host.cancel?(id)
|
|
84
|
+
# https://microsoft.github.io/language-server-protocol/specifications/specification-current/#cancelRequest
|
|
85
|
+
# cancel should send response RequestCancelled
|
|
86
|
+
Solargraph::Logging.logger.info "Cancelled response to ##{id} #{method}"
|
|
87
|
+
set_result nil
|
|
88
|
+
set_error ErrorCodes::REQUEST_CANCELLED, 'Cancelled by client'
|
|
89
|
+
else
|
|
90
|
+
Solargraph::Logging.logger.info "Sending response to ##{id} #{method}"
|
|
91
|
+
end
|
|
92
|
+
end
|
|
86
93
|
end
|
|
87
94
|
end
|
|
88
95
|
end
|
|
@@ -83,6 +83,8 @@ module Solargraph
|
|
|
83
83
|
@fetched = true
|
|
84
84
|
begin
|
|
85
85
|
@available ||= begin
|
|
86
|
+
# @sg-ignore
|
|
87
|
+
# @type [Gem::Dependency, nil]
|
|
86
88
|
tuple = CheckGemVersion.fetcher.search_for_dependency(Gem::Dependency.new('solargraph')).flatten.first
|
|
87
89
|
if tuple.nil?
|
|
88
90
|
@error = 'An error occurred fetching the gem data'
|
|
@@ -6,12 +6,15 @@ module Solargraph
|
|
|
6
6
|
module Extended
|
|
7
7
|
class Document < Base
|
|
8
8
|
def process
|
|
9
|
-
|
|
9
|
+
api_map, pins = host.document(params['query'])
|
|
10
10
|
page = Solargraph::Page.new(host.options['viewsPath'])
|
|
11
|
-
content = page.render('document', layout: true, locals: {
|
|
11
|
+
content = page.render('document', layout: true, locals: { api_map: api_map, pins: pins })
|
|
12
12
|
set_result(
|
|
13
13
|
content: content
|
|
14
14
|
)
|
|
15
|
+
rescue StandardError => e
|
|
16
|
+
Solargraph.logger.warn "Error processing document: [#{e.class}] #{e.message}"
|
|
17
|
+
Solargraph.logger.debug e.backtrace.join("\n")
|
|
15
18
|
end
|
|
16
19
|
end
|
|
17
20
|
end
|
|
@@ -11,9 +11,9 @@ module Solargraph
|
|
|
11
11
|
#
|
|
12
12
|
class DocumentGems < Base
|
|
13
13
|
def process
|
|
14
|
-
cmd =
|
|
15
|
-
cmd
|
|
16
|
-
o, s = Open3.capture2(cmd)
|
|
14
|
+
cmd = [host.command_path, 'gems']
|
|
15
|
+
cmd.push '--rebuild' if params['rebuild']
|
|
16
|
+
o, s = Open3.capture2(*cmd)
|
|
17
17
|
if s != 0
|
|
18
18
|
host.show_message "An error occurred while building gem documentation.", LanguageServer::MessageTypes::ERROR
|
|
19
19
|
set_result({
|
|
@@ -174,7 +174,9 @@ module Solargraph
|
|
|
174
174
|
|
|
175
175
|
# @param section [String]
|
|
176
176
|
# @param capability [String]
|
|
177
|
-
# @
|
|
177
|
+
# @todo Need support for RBS' boolish "type", which doesn't
|
|
178
|
+
# enforce strict true/false-ness
|
|
179
|
+
# @sg-ignore
|
|
178
180
|
def dynamic_registration_for? section, capability
|
|
179
181
|
result = (params['capabilities'] &&
|
|
180
182
|
params['capabilities'][section] &&
|
|
@@ -12,9 +12,6 @@ module Solargraph
|
|
|
12
12
|
col = params['position']['character']
|
|
13
13
|
begin
|
|
14
14
|
completion = host.completions_at(params['textDocument']['uri'], line, col)
|
|
15
|
-
if host.cancel?(id)
|
|
16
|
-
return set_result(empty_result) if host.cancel?(id)
|
|
17
|
-
end
|
|
18
15
|
items = []
|
|
19
16
|
last_context = nil
|
|
20
17
|
idx = -1
|
|
@@ -33,6 +33,7 @@ module Solargraph
|
|
|
33
33
|
|
|
34
34
|
private
|
|
35
35
|
|
|
36
|
+
# @param corrections [String]
|
|
36
37
|
def log_corrections(corrections)
|
|
37
38
|
corrections = corrections&.strip
|
|
38
39
|
return if corrections&.empty?
|
|
@@ -51,6 +52,7 @@ module Solargraph
|
|
|
51
52
|
conf['rubocop'] || {}
|
|
52
53
|
end
|
|
53
54
|
|
|
55
|
+
# @param config [Hash{String => String}]
|
|
54
56
|
def cli_args file_uri, config
|
|
55
57
|
file = UriHelpers.uri_to_file(file_uri)
|
|
56
58
|
args = [
|
|
@@ -68,6 +70,7 @@ module Solargraph
|
|
|
68
70
|
args + [file]
|
|
69
71
|
end
|
|
70
72
|
|
|
73
|
+
# @param config [Hash{String => String}]
|
|
71
74
|
def formatter_class(config)
|
|
72
75
|
if self.class.const_defined?('BlankRubocopFormatter')
|
|
73
76
|
# @sg-ignore
|
|
@@ -79,6 +82,7 @@ module Solargraph
|
|
|
79
82
|
end
|
|
80
83
|
end
|
|
81
84
|
|
|
85
|
+
# @param value [Array, String]
|
|
82
86
|
def cop_list(value)
|
|
83
87
|
value = value.join(',') if value.respond_to?(:join)
|
|
84
88
|
return nil if value == '' || !value.is_a?(String)
|
data/lib/solargraph/library.rb
CHANGED
|
@@ -132,6 +132,7 @@ module Solargraph
|
|
|
132
132
|
result = false
|
|
133
133
|
filenames.each do |filename|
|
|
134
134
|
detach filename
|
|
135
|
+
source_map_hash.delete(filename)
|
|
135
136
|
result ||= workspace.remove(filename)
|
|
136
137
|
end
|
|
137
138
|
result
|
|
@@ -192,11 +193,7 @@ module Solargraph
|
|
|
192
193
|
else
|
|
193
194
|
mutex.synchronize do
|
|
194
195
|
clip = api_map.clip(cursor)
|
|
195
|
-
|
|
196
|
-
[Pin::ProxyType.new(name: cursor.word, return_type: clip.infer)]
|
|
197
|
-
else
|
|
198
|
-
clip.define.map { |pin| pin.realize(api_map) }
|
|
199
|
-
end
|
|
196
|
+
clip.define.map { |pin| pin.realize(api_map) }
|
|
200
197
|
end
|
|
201
198
|
end
|
|
202
199
|
rescue FileNotFoundError => e
|
|
@@ -240,7 +237,7 @@ module Solargraph
|
|
|
240
237
|
# @param column [Integer]
|
|
241
238
|
# @param strip [Boolean] Strip special characters from variable names
|
|
242
239
|
# @param only [Boolean] Search for references in the current file only
|
|
243
|
-
# @return [Array<Solargraph::
|
|
240
|
+
# @return [Array<Solargraph::Location>]
|
|
244
241
|
# @todo Take a Location instead of filename/line/column
|
|
245
242
|
def references_from filename, line, column, strip: false, only: false
|
|
246
243
|
sync_catalog
|
|
@@ -330,9 +327,10 @@ module Solargraph
|
|
|
330
327
|
|
|
331
328
|
# @param query [String]
|
|
332
329
|
# @return [Enumerable<YARD::CodeObjects::Base>]
|
|
330
|
+
# @return [Array(ApiMap, Enumerable<Pin::Base>)]
|
|
333
331
|
def document query
|
|
334
332
|
sync_catalog
|
|
335
|
-
mutex.synchronize { api_map.
|
|
333
|
+
mutex.synchronize { [api_map, api_map.get_path_pins(query)] }
|
|
336
334
|
end
|
|
337
335
|
|
|
338
336
|
# @param query [String]
|
|
@@ -398,6 +396,8 @@ module Solargraph
|
|
|
398
396
|
return [] unless open?(filename)
|
|
399
397
|
result = []
|
|
400
398
|
source = read(filename)
|
|
399
|
+
|
|
400
|
+
# @type [Hash{Class<Solargraph::Diagnostics::Base> => Array<String>}]
|
|
401
401
|
repargs = {}
|
|
402
402
|
workspace.config.reporters.each do |line|
|
|
403
403
|
if line == 'all!'
|
|
@@ -431,7 +431,8 @@ module Solargraph
|
|
|
431
431
|
Bench.new(
|
|
432
432
|
source_maps: source_map_hash.values,
|
|
433
433
|
workspace: workspace,
|
|
434
|
-
external_requires: external_requires
|
|
434
|
+
external_requires: external_requires,
|
|
435
|
+
live_map: @current ? source_map_hash[@current.filename] : nil
|
|
435
436
|
)
|
|
436
437
|
end
|
|
437
438
|
|
|
@@ -587,7 +588,8 @@ module Solargraph
|
|
|
587
588
|
# @return [void]
|
|
588
589
|
def cache_next_gemspec
|
|
589
590
|
return if @cache_progress
|
|
590
|
-
spec = api_map.
|
|
591
|
+
spec = (api_map.uncached_yard_gemspecs + api_map.uncached_rbs_collection_gemspecs).
|
|
592
|
+
find { |spec| !cache_errors.include?(spec) }
|
|
591
593
|
return end_cache_progress unless spec
|
|
592
594
|
|
|
593
595
|
pending = api_map.uncached_gemspecs.length - cache_errors.length - 1
|
|
@@ -650,12 +652,12 @@ module Solargraph
|
|
|
650
652
|
return if @sync_count == 0
|
|
651
653
|
|
|
652
654
|
mutex.synchronize do
|
|
653
|
-
logger.warn "CATALOG"
|
|
654
655
|
logger.info "Cataloging #{workspace.directory.empty? ? 'generic workspace' : workspace.directory}"
|
|
655
656
|
api_map.catalog bench
|
|
656
657
|
source_map_hash.values.each { |map| find_external_requires(map) }
|
|
657
658
|
logger.info "Catalog complete (#{api_map.source_maps.length} files, #{api_map.pins.length} pins)"
|
|
658
|
-
logger.info "#{api_map.
|
|
659
|
+
logger.info "#{api_map.uncached_yard_gemspecs.length} uncached YARD gemspecs"
|
|
660
|
+
logger.info "#{api_map.uncached_rbs_collection_gemspecs.length} uncached RBS collection gemspecs"
|
|
659
661
|
cache_next_gemspec
|
|
660
662
|
@sync_count = 0
|
|
661
663
|
end
|
data/lib/solargraph/location.rb
CHANGED
|
@@ -5,6 +5,8 @@ module Solargraph
|
|
|
5
5
|
# and Range.
|
|
6
6
|
#
|
|
7
7
|
class Location
|
|
8
|
+
include Equality
|
|
9
|
+
|
|
8
10
|
# @return [String]
|
|
9
11
|
attr_reader :filename
|
|
10
12
|
|
|
@@ -18,11 +20,37 @@ module Solargraph
|
|
|
18
20
|
@range = range
|
|
19
21
|
end
|
|
20
22
|
|
|
23
|
+
# @sg-ignore Fix "Not enough arguments to Module#protected"
|
|
24
|
+
protected def equality_fields
|
|
25
|
+
[filename, range]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def <=>(other)
|
|
29
|
+
return nil unless other.is_a?(Location)
|
|
30
|
+
if filename == other.filename
|
|
31
|
+
range <=> other.range
|
|
32
|
+
else
|
|
33
|
+
filename <=> other.filename
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def rbs?
|
|
38
|
+
filename.end_with?('.rbs')
|
|
39
|
+
end
|
|
40
|
+
|
|
21
41
|
# @param location [self]
|
|
22
42
|
def contain? location
|
|
23
43
|
range.contain?(location.range.start) && range.contain?(location.range.ending) && filename == location.filename
|
|
24
44
|
end
|
|
25
45
|
|
|
46
|
+
def inspect
|
|
47
|
+
"<#{self.class.name}: filename=#{filename}, range=#{range.inspect}>"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def to_s
|
|
51
|
+
inspect
|
|
52
|
+
end
|
|
53
|
+
|
|
26
54
|
# @return [Hash]
|
|
27
55
|
def to_hash
|
|
28
56
|
{
|
data/lib/solargraph/logging.rb
CHANGED
|
@@ -13,6 +13,8 @@ module Solargraph
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def on_comment *args
|
|
16
|
+
# @sg-ignore
|
|
17
|
+
# @type [Array(Symbol, String, Array([Integer, nil], [Integer, nil]))]
|
|
16
18
|
result = super
|
|
17
19
|
if @buffer_lines[result[2][0]][0..result[2][1]].strip =~ /^#/
|
|
18
20
|
chomped = result[1].chomp
|
|
@@ -24,24 +26,28 @@ module Solargraph
|
|
|
24
26
|
result
|
|
25
27
|
end
|
|
26
28
|
|
|
29
|
+
# @param result [Array(Symbol, String, Array([Integer, nil], [Integer, nil]))]
|
|
30
|
+
# @return [void]
|
|
31
|
+
def create_snippet(result)
|
|
32
|
+
chomped = result[1].chomp
|
|
33
|
+
@comments[result[2][0]] = Snippet.new(Range.from_to(result[2][0] || 0, result[2][1] || 0, result[2][0] || 0, (result[2][1] || 0) + chomped.length), chomped)
|
|
34
|
+
end
|
|
35
|
+
|
|
27
36
|
def on_embdoc_beg *args
|
|
28
37
|
result = super
|
|
29
|
-
|
|
30
|
-
@comments[result[2][0]] = Snippet.new(Range.from_to(result[2][0], result[2][1], result[2][0], result[2][1] + chomped.length), chomped)
|
|
38
|
+
create_snippet(result)
|
|
31
39
|
result
|
|
32
40
|
end
|
|
33
41
|
|
|
34
42
|
def on_embdoc *args
|
|
35
43
|
result = super
|
|
36
|
-
|
|
37
|
-
@comments[result[2][0]] = Snippet.new(Range.from_to(result[2][0], result[2][1], result[2][0], result[2][1] + chomped.length), chomped)
|
|
44
|
+
create_snippet(result)
|
|
38
45
|
result
|
|
39
46
|
end
|
|
40
47
|
|
|
41
48
|
def on_embdoc_end *args
|
|
42
49
|
result = super
|
|
43
|
-
|
|
44
|
-
@comments[result[2][0]] = Snippet.new(Range.from_to(result[2][0], result[2][1], result[2][0], result[2][1] + chomped.length), chomped)
|
|
50
|
+
create_snippet(result)
|
|
45
51
|
result
|
|
46
52
|
end
|
|
47
53
|
|