solargraph 0.51.2 → 0.54.2
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 +40 -0
- data/.github/workflows/rspec.yml +1 -3
- data/.github/workflows/typecheck.yml +34 -0
- data/.yardopts +2 -2
- data/CHANGELOG.md +127 -5
- data/README.md +13 -16
- data/SPONSORS.md +1 -7
- data/lib/solargraph/api_map/cache.rb +50 -20
- data/lib/solargraph/api_map/source_to_yard.rb +17 -10
- data/lib/solargraph/api_map/store.rb +60 -15
- data/lib/solargraph/api_map.rb +282 -123
- data/lib/solargraph/bench.rb +3 -2
- data/lib/solargraph/cache.rb +29 -5
- data/lib/solargraph/complex_type/type_methods.rb +122 -39
- data/lib/solargraph/complex_type/unique_type.rb +310 -76
- data/lib/solargraph/complex_type.rb +166 -44
- data/lib/solargraph/convention.rb +0 -1
- data/lib/solargraph/converters/dd.rb +5 -0
- data/lib/solargraph/converters/dl.rb +3 -0
- data/lib/solargraph/converters/dt.rb +3 -0
- data/lib/solargraph/diagnostics/rubocop.rb +8 -7
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +1 -0
- data/lib/solargraph/diagnostics/type_check.rb +1 -0
- data/lib/solargraph/diagnostics.rb +2 -2
- data/lib/solargraph/doc_map.rb +187 -0
- data/lib/solargraph/gem_pins.rb +72 -0
- data/lib/solargraph/language_server/host/diagnoser.rb +2 -2
- data/lib/solargraph/language_server/host/dispatch.rb +22 -5
- data/lib/solargraph/language_server/host/message_worker.rb +49 -5
- data/lib/solargraph/language_server/host/sources.rb +8 -65
- data/lib/solargraph/language_server/host.rb +65 -84
- data/lib/solargraph/language_server/message/base.rb +19 -12
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +3 -1
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +13 -1
- data/lib/solargraph/language_server/message/initialize.rb +19 -2
- data/lib/solargraph/language_server/message/text_document/completion.rb +0 -3
- data/lib/solargraph/language_server/message/text_document/definition.rb +3 -3
- data/lib/solargraph/language_server/message/text_document/document_symbol.rb +3 -3
- data/lib/solargraph/language_server/message/text_document/formatting.rb +1 -0
- data/lib/solargraph/language_server/message/text_document/hover.rb +3 -1
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +3 -3
- data/lib/solargraph/language_server/message/text_document.rb +0 -1
- data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +5 -0
- data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +2 -2
- data/lib/solargraph/language_server/progress.rb +135 -0
- data/lib/solargraph/language_server/transport/adapter.rb +16 -1
- data/lib/solargraph/language_server/transport/data_reader.rb +2 -0
- data/lib/solargraph/language_server.rb +1 -0
- data/lib/solargraph/library.rb +207 -111
- data/lib/solargraph/location.rb +15 -1
- data/lib/solargraph/page.rb +6 -0
- data/lib/solargraph/parser/comment_ripper.rb +4 -0
- data/lib/solargraph/parser/node_methods.rb +47 -7
- data/lib/solargraph/parser/node_processor/base.rb +11 -1
- data/lib/solargraph/parser/node_processor.rb +1 -0
- data/lib/solargraph/parser/{legacy → parser_gem}/class_methods.rb +31 -9
- data/lib/solargraph/parser/{legacy → parser_gem}/flawed_builder.rb +3 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_chainer.rb +62 -43
- data/lib/solargraph/parser/parser_gem/node_methods.rb +495 -0
- data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/alias_node.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +57 -0
- data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/begin_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/block_node.rb +3 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/casgn_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/cvasgn_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/def_node.rb +7 -20
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/defs_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/gvasgn_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/ivasgn_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/lvasgn_node.rb +4 -4
- data/lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb +53 -0
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/namespace_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/orasgn_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/resbody_node.rb +3 -3
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/sclass_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/send_node.rb +8 -6
- data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/sym_node.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_processors.rb +56 -0
- data/lib/solargraph/parser/parser_gem.rb +12 -0
- data/lib/solargraph/parser/region.rb +1 -1
- data/lib/solargraph/parser/snippet.rb +2 -0
- data/lib/solargraph/parser.rb +8 -12
- data/lib/solargraph/pin/base.rb +78 -10
- data/lib/solargraph/pin/base_variable.rb +40 -7
- data/lib/solargraph/pin/block.rb +69 -46
- data/lib/solargraph/pin/callable.rb +147 -0
- data/lib/solargraph/pin/closure.rb +23 -3
- data/lib/solargraph/pin/common.rb +6 -6
- data/lib/solargraph/pin/conversions.rb +36 -5
- data/lib/solargraph/pin/delegated_method.rb +6 -2
- data/lib/solargraph/pin/documenting.rb +25 -32
- data/lib/solargraph/pin/instance_variable.rb +6 -2
- data/lib/solargraph/pin/local_variable.rb +13 -1
- data/lib/solargraph/pin/method.rb +205 -32
- data/lib/solargraph/pin/namespace.rb +20 -7
- data/lib/solargraph/pin/parameter.rb +41 -36
- data/lib/solargraph/pin/proxy_type.rb +1 -1
- data/lib/solargraph/pin/reference/override.rb +2 -2
- data/lib/solargraph/pin/reference.rb +8 -0
- data/lib/solargraph/pin/search.rb +3 -3
- data/lib/solargraph/pin/signature.rb +8 -14
- data/lib/solargraph/pin.rb +4 -2
- data/lib/solargraph/range.rb +4 -6
- data/lib/solargraph/rbs_map/conversions.rb +326 -76
- data/lib/solargraph/rbs_map/core_fills.rb +16 -33
- data/lib/solargraph/rbs_map/core_map.rb +3 -13
- data/lib/solargraph/rbs_map/stdlib_map.rb +2 -8
- data/lib/solargraph/rbs_map.rb +32 -13
- data/lib/solargraph/shell.rb +95 -72
- data/lib/solargraph/source/chain/array.rb +33 -0
- data/lib/solargraph/source/chain/block_symbol.rb +13 -0
- data/lib/solargraph/source/chain/block_variable.rb +1 -1
- data/lib/solargraph/source/chain/call.rb +152 -69
- data/lib/solargraph/source/chain/constant.rb +15 -1
- data/lib/solargraph/source/chain/if.rb +23 -0
- data/lib/solargraph/source/chain/link.rb +17 -2
- data/lib/solargraph/source/chain/or.rb +2 -2
- data/lib/solargraph/source/chain/z_super.rb +3 -3
- data/lib/solargraph/source/chain.rb +85 -26
- data/lib/solargraph/source/change.rb +3 -0
- data/lib/solargraph/source/cursor.rb +16 -2
- data/lib/solargraph/source/source_chainer.rb +8 -5
- data/lib/solargraph/source/updater.rb +1 -0
- data/lib/solargraph/source.rb +120 -148
- data/lib/solargraph/source_map/clip.rb +16 -27
- data/lib/solargraph/source_map/data.rb +30 -0
- data/lib/solargraph/source_map/mapper.rb +15 -3
- data/lib/solargraph/source_map.rb +48 -24
- data/lib/solargraph/type_checker/checks.rb +10 -2
- data/lib/solargraph/type_checker/rules.rb +6 -1
- data/lib/solargraph/type_checker.rb +150 -39
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/views/environment.erb +3 -5
- data/lib/solargraph/workspace/config.rb +9 -6
- data/lib/solargraph/workspace.rb +30 -3
- data/lib/solargraph/yard_map/cache.rb +6 -0
- data/lib/solargraph/yard_map/helpers.rb +1 -1
- data/lib/solargraph/yard_map/mapper/to_method.rb +16 -3
- data/lib/solargraph/yard_map/mapper.rb +1 -1
- data/lib/solargraph/yard_map/to_method.rb +11 -4
- data/lib/solargraph/yard_map.rb +1 -292
- data/lib/solargraph/yard_tags.rb +20 -0
- data/lib/solargraph/yardoc.rb +52 -0
- data/lib/solargraph.rb +6 -4
- data/solargraph.gemspec +7 -6
- metadata +71 -82
- data/lib/solargraph/api_map/bundler_methods.rb +0 -22
- data/lib/solargraph/documentor.rb +0 -76
- data/lib/solargraph/language_server/host/cataloger.rb +0 -56
- data/lib/solargraph/parser/legacy/node_methods.rb +0 -325
- data/lib/solargraph/parser/legacy/node_processors/alias_node.rb +0 -23
- data/lib/solargraph/parser/legacy/node_processors/args_node.rb +0 -50
- data/lib/solargraph/parser/legacy/node_processors/begin_node.rb +0 -15
- data/lib/solargraph/parser/legacy/node_processors/sym_node.rb +0 -18
- data/lib/solargraph/parser/legacy/node_processors.rb +0 -55
- data/lib/solargraph/parser/legacy.rb +0 -12
- data/lib/solargraph/parser/rubyvm/class_methods.rb +0 -153
- data/lib/solargraph/parser/rubyvm/node_chainer.rb +0 -160
- data/lib/solargraph/parser/rubyvm/node_methods.rb +0 -317
- data/lib/solargraph/parser/rubyvm/node_processors/args_node.rb +0 -85
- data/lib/solargraph/parser/rubyvm/node_processors/block_node.rb +0 -42
- data/lib/solargraph/parser/rubyvm/node_processors/casgn_node.rb +0 -33
- data/lib/solargraph/parser/rubyvm/node_processors/cvasgn_node.rb +0 -23
- data/lib/solargraph/parser/rubyvm/node_processors/def_node.rb +0 -75
- data/lib/solargraph/parser/rubyvm/node_processors/defs_node.rb +0 -68
- data/lib/solargraph/parser/rubyvm/node_processors/gvasgn_node.rb +0 -23
- data/lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb +0 -38
- data/lib/solargraph/parser/rubyvm/node_processors/kw_arg_node.rb +0 -39
- data/lib/solargraph/parser/rubyvm/node_processors/lit_node.rb +0 -20
- data/lib/solargraph/parser/rubyvm/node_processors/lvasgn_node.rb +0 -27
- data/lib/solargraph/parser/rubyvm/node_processors/namespace_node.rb +0 -39
- data/lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb +0 -26
- data/lib/solargraph/parser/rubyvm/node_processors/orasgn_node.rb +0 -15
- data/lib/solargraph/parser/rubyvm/node_processors/resbody_node.rb +0 -51
- data/lib/solargraph/parser/rubyvm/node_processors/sclass_node.rb +0 -32
- data/lib/solargraph/parser/rubyvm/node_processors/scope_node.rb +0 -15
- data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +0 -279
- data/lib/solargraph/parser/rubyvm/node_processors.rb +0 -64
- data/lib/solargraph/parser/rubyvm/node_wrapper.rb +0 -47
- data/lib/solargraph/parser/rubyvm.rb +0 -40
- data/lib/solargraph/rbs_map/core_signs.rb +0 -33
- data/lib/yard-solargraph.rb +0 -33
@@ -16,7 +16,7 @@ module Solargraph
|
|
16
16
|
# @return [String]
|
17
17
|
attr_reader :method
|
18
18
|
|
19
|
-
# @return [Hash]
|
19
|
+
# @return [Hash{String => Array, Hash, 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
|
@@ -29,7 +29,7 @@ module Solargraph
|
|
29
29
|
end
|
30
30
|
|
31
31
|
# @param text [String]
|
32
|
-
# @return [Hash{Symbol => String}]
|
32
|
+
# @return [Hash{Symbol => String}, nil]
|
33
33
|
def markup_content text
|
34
34
|
return nil if text.strip.empty?
|
35
35
|
{
|
@@ -38,6 +38,8 @@ module Solargraph
|
|
38
38
|
}
|
39
39
|
end
|
40
40
|
|
41
|
+
# @param pins [Array<Pin::Base>]
|
42
|
+
# @return [String]
|
41
43
|
def join_docs pins
|
42
44
|
result = []
|
43
45
|
last_link = nil
|
@@ -1,6 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
|
4
|
+
# @todo PR the RBS gem to add this
|
5
|
+
# @!parse
|
6
|
+
# module ::Gem
|
7
|
+
# class SpecFetcher; end
|
8
|
+
# end
|
4
9
|
|
5
10
|
module Solargraph
|
6
11
|
module LanguageServer
|
@@ -11,16 +16,23 @@ module Solargraph
|
|
11
16
|
# is true, notify the client when the gem is up to date.
|
12
17
|
#
|
13
18
|
class CheckGemVersion < Base
|
19
|
+
# @return [Gem::SpecFetcher]
|
14
20
|
def self.fetcher
|
15
21
|
@fetcher ||= Gem::SpecFetcher.new
|
16
22
|
end
|
17
23
|
|
24
|
+
# @param obj [Gem::SpecFetcher]
|
25
|
+
# @return [Gem::SpecFetcher]
|
18
26
|
def self.fetcher= obj
|
19
27
|
@fetcher = obj
|
20
28
|
end
|
21
29
|
|
22
30
|
GEM_ZERO = Gem::Version.new('0.0.0')
|
23
31
|
|
32
|
+
# @param host [Solargraph::LanguageServer::Host]
|
33
|
+
# @param request [Hash]
|
34
|
+
# @param current [Gem::Version]
|
35
|
+
# @param available [Gem::Version, nil]
|
24
36
|
def initialize host, request, current: Gem::Version.new(Solargraph::VERSION), available: nil
|
25
37
|
super(host, request)
|
26
38
|
@current = current
|
@@ -47,6 +47,8 @@ module Solargraph
|
|
47
47
|
|
48
48
|
private
|
49
49
|
|
50
|
+
# @todo '?' methods should type like RBS 'boolish' rather than a strict true or false
|
51
|
+
# @sg-ignore
|
50
52
|
def support_workspace_folders?
|
51
53
|
params['capabilities'] &&
|
52
54
|
params['capabilities']['workspace'] &&
|
@@ -54,6 +56,7 @@ module Solargraph
|
|
54
56
|
params['workspaceFolders']
|
55
57
|
end
|
56
58
|
|
59
|
+
# @return [Hash{Symbol => undefined}]
|
57
60
|
def static_completion
|
58
61
|
return {} unless host.options['completion']
|
59
62
|
{
|
@@ -64,6 +67,7 @@ module Solargraph
|
|
64
67
|
}
|
65
68
|
end
|
66
69
|
|
70
|
+
# @return [Hash{Symbol => BasicObject}]
|
67
71
|
def static_code_action
|
68
72
|
{
|
69
73
|
codeActionProvider: true,
|
@@ -71,6 +75,7 @@ module Solargraph
|
|
71
75
|
}
|
72
76
|
end
|
73
77
|
|
78
|
+
# @return [Hash{Symbol => BasicObject}]
|
74
79
|
def static_signature_help
|
75
80
|
{
|
76
81
|
signatureHelpProvider: {
|
@@ -79,6 +84,7 @@ module Solargraph
|
|
79
84
|
}
|
80
85
|
end
|
81
86
|
|
87
|
+
# @return [Hash{Symbol => Hash{Symbol => String, Array<String>}}]
|
82
88
|
def static_on_type_formatting
|
83
89
|
{
|
84
90
|
documentOnTypeFormattingProvider: {
|
@@ -88,6 +94,7 @@ module Solargraph
|
|
88
94
|
}
|
89
95
|
end
|
90
96
|
|
97
|
+
# @return [Hash{Symbol => Boolean}]
|
91
98
|
def static_hover
|
92
99
|
return {} unless host.options['hover']
|
93
100
|
{
|
@@ -95,6 +102,7 @@ module Solargraph
|
|
95
102
|
}
|
96
103
|
end
|
97
104
|
|
105
|
+
# @return [Hash{Symbol => Boolean}]
|
98
106
|
def static_document_formatting
|
99
107
|
return {} unless host.options['formatting']
|
100
108
|
{
|
@@ -102,6 +110,7 @@ module Solargraph
|
|
102
110
|
}
|
103
111
|
end
|
104
112
|
|
113
|
+
# @return [Hash{Symbol => Boolean}]
|
105
114
|
def static_document_symbols
|
106
115
|
return {} unless host.options['symbols']
|
107
116
|
{
|
@@ -109,12 +118,14 @@ module Solargraph
|
|
109
118
|
}
|
110
119
|
end
|
111
120
|
|
121
|
+
# @return [Hash{Symbol => Boolean}]
|
112
122
|
def static_workspace_symbols
|
113
123
|
{
|
114
124
|
workspaceSymbolProvider: true
|
115
125
|
}
|
116
126
|
end
|
117
127
|
|
128
|
+
# @return [Hash{Symbol => Boolean}]
|
118
129
|
def static_definitions
|
119
130
|
return {} unless host.options['definitions']
|
120
131
|
{
|
@@ -122,19 +133,23 @@ module Solargraph
|
|
122
133
|
}
|
123
134
|
end
|
124
135
|
|
136
|
+
# @return [Hash{Symbol => Boolean}]
|
125
137
|
def static_type_definitions
|
126
|
-
return {} unless host.options['
|
138
|
+
return {} unless host.options['typeDefinitions']
|
127
139
|
{
|
128
|
-
|
140
|
+
typeDefinitionProvider: true
|
129
141
|
}
|
130
142
|
end
|
131
143
|
|
144
|
+
# @return [Hash{Symbol => Hash{Symbol => Boolean}}]
|
132
145
|
def static_rename
|
133
146
|
{
|
134
147
|
renameProvider: {prepareProvider: true}
|
135
148
|
}
|
136
149
|
end
|
137
150
|
|
151
|
+
|
152
|
+
# @return [Hash{Symbol => Boolean}]
|
138
153
|
def static_references
|
139
154
|
return {} unless host.options['references']
|
140
155
|
{
|
@@ -142,6 +157,7 @@ module Solargraph
|
|
142
157
|
}
|
143
158
|
end
|
144
159
|
|
160
|
+
# @return [Hash{Symbol => Boolean}]
|
145
161
|
def static_folding_range
|
146
162
|
return {} unless host.options['folding']
|
147
163
|
{
|
@@ -149,6 +165,7 @@ module Solargraph
|
|
149
165
|
}
|
150
166
|
end
|
151
167
|
|
168
|
+
# @return [Hash{Symbol => Boolean}]
|
152
169
|
def static_highlights
|
153
170
|
{
|
154
171
|
documentHighlightProvider: true
|
@@ -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
|
@@ -13,10 +13,10 @@ module Solargraph::LanguageServer::Message::TextDocument
|
|
13
13
|
def code_location
|
14
14
|
suggestions = host.definitions_at(params['textDocument']['uri'], @line, @column)
|
15
15
|
return nil if suggestions.empty?
|
16
|
-
suggestions.reject { |pin| pin.
|
16
|
+
suggestions.reject { |pin| pin.best_location.nil? || pin.best_location.filename.nil? }.map do |pin|
|
17
17
|
{
|
18
|
-
uri: file_to_uri(pin.
|
19
|
-
range: pin.
|
18
|
+
uri: file_to_uri(pin.best_location.filename),
|
19
|
+
range: pin.best_location.range.to_hash
|
20
20
|
}
|
21
21
|
end
|
22
22
|
end
|
@@ -6,15 +6,15 @@ class Solargraph::LanguageServer::Message::TextDocument::DocumentSymbol < Solarg
|
|
6
6
|
def process
|
7
7
|
pins = host.document_symbols params['textDocument']['uri']
|
8
8
|
info = pins.map do |pin|
|
9
|
-
next nil unless pin.
|
9
|
+
next nil unless pin.best_location&.filename
|
10
10
|
|
11
11
|
result = {
|
12
12
|
name: pin.name,
|
13
13
|
containerName: pin.namespace,
|
14
14
|
kind: pin.symbol_kind,
|
15
15
|
location: {
|
16
|
-
uri: file_to_uri(pin.
|
17
|
-
range: pin.
|
16
|
+
uri: file_to_uri(pin.best_location.filename),
|
17
|
+
range: pin.best_location.range.to_hash
|
18
18
|
},
|
19
19
|
deprecated: pin.deprecated?
|
20
20
|
}
|
@@ -21,7 +21,7 @@ module Solargraph
|
|
21
21
|
parts.push pin.documentation unless pin.documentation.nil? || pin.documentation.empty?
|
22
22
|
unless parts.empty?
|
23
23
|
data = parts.join("\n\n")
|
24
|
-
next if contents.last
|
24
|
+
next if contents.last&.end_with?(data)
|
25
25
|
contents.push data
|
26
26
|
end
|
27
27
|
last_link = this_link unless this_link.nil?
|
@@ -37,6 +37,8 @@ module Solargraph
|
|
37
37
|
|
38
38
|
private
|
39
39
|
|
40
|
+
# @param contents [Array<String>]
|
41
|
+
# @return [Hash{Symbol => Hash{Symbol => String}}, nil]
|
40
42
|
def contents_or_nil contents
|
41
43
|
stripped = contents
|
42
44
|
.map(&:strip)
|
@@ -13,10 +13,10 @@ module Solargraph::LanguageServer::Message::TextDocument
|
|
13
13
|
def code_location
|
14
14
|
suggestions = host.type_definitions_at(params['textDocument']['uri'], @line, @column)
|
15
15
|
return nil if suggestions.empty?
|
16
|
-
suggestions.reject { |pin| pin.
|
16
|
+
suggestions.reject { |pin| pin.best_location.nil? || pin.best_location.filename.nil? }.map do |pin|
|
17
17
|
{
|
18
|
-
uri: file_to_uri(pin.
|
19
|
-
range: pin.
|
18
|
+
uri: file_to_uri(pin.best_location.filename),
|
19
|
+
range: pin.best_location.range.to_hash
|
20
20
|
}
|
21
21
|
end
|
22
22
|
end
|
@@ -12,7 +12,6 @@ module Solargraph
|
|
12
12
|
autoload :DidSave, 'solargraph/language_server/message/text_document/did_save'
|
13
13
|
autoload :Hover, 'solargraph/language_server/message/text_document/hover'
|
14
14
|
autoload :SignatureHelp, 'solargraph/language_server/message/text_document/signature_help'
|
15
|
-
autoload :DiagnosticsQueue, 'solargraph/language_server/message/text_document/diagnostics_queue'
|
16
15
|
autoload :OnTypeFormatting, 'solargraph/language_server/message/text_document/on_type_formatting'
|
17
16
|
autoload :Definition, 'solargraph/language_server/message/text_document/definition'
|
18
17
|
autoload :TypeDefinition, 'solargraph/language_server/message/text_document/type_definition'
|
@@ -11,8 +11,12 @@ module Solargraph::LanguageServer::Message::Workspace
|
|
11
11
|
|
12
12
|
private
|
13
13
|
|
14
|
+
# @return [void]
|
14
15
|
def register_from_options
|
16
|
+
Solargraph.logger.debug "Registering capabilities from options: #{host.options.inspect}"
|
17
|
+
# @type [Array<String>]
|
15
18
|
y = []
|
19
|
+
# @type [Array<String>]
|
16
20
|
n = []
|
17
21
|
(host.options['completion'] ? y : n).push('textDocument/completion')
|
18
22
|
(host.options['hover'] ? y : n).push('textDocument/hover', 'textDocument/signatureHelp')
|
@@ -20,6 +24,7 @@ module Solargraph::LanguageServer::Message::Workspace
|
|
20
24
|
(host.options['formatting'] ? y : n).push('textDocument/formatting')
|
21
25
|
(host.options['symbols'] ? y : n).push('textDocument/documentSymbol', 'workspace/symbol')
|
22
26
|
(host.options['definitions'] ? y : n).push('textDocument/definition')
|
27
|
+
(host.options['typeDefinitions'] ? y : n).push('textDocument/typeDefinition')
|
23
28
|
(host.options['references'] ? y : n).push('textDocument/references')
|
24
29
|
(host.options['folding'] ? y : n).push('textDocument/folding')
|
25
30
|
(host.options['highlights'] ? y : n).push('textDocument/documentHighlight')
|
@@ -6,14 +6,14 @@ class Solargraph::LanguageServer::Message::Workspace::WorkspaceSymbol < Solargra
|
|
6
6
|
def process
|
7
7
|
pins = host.query_symbols(params['query'])
|
8
8
|
info = pins.map do |pin|
|
9
|
-
uri = file_to_uri(pin.
|
9
|
+
uri = file_to_uri(pin.best_location.filename)
|
10
10
|
{
|
11
11
|
name: pin.path,
|
12
12
|
containerName: pin.namespace,
|
13
13
|
kind: pin.symbol_kind,
|
14
14
|
location: {
|
15
15
|
uri: uri,
|
16
|
-
range: pin.
|
16
|
+
range: pin.best_location.range.to_hash
|
17
17
|
},
|
18
18
|
deprecated: pin.deprecated?
|
19
19
|
}
|
@@ -0,0 +1,135 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'securerandom'
|
4
|
+
|
5
|
+
module Solargraph
|
6
|
+
module LanguageServer
|
7
|
+
# Progress notification handling for language server hosts.
|
8
|
+
#
|
9
|
+
class Progress
|
10
|
+
WAITING = :waiting
|
11
|
+
CREATED = :created
|
12
|
+
FINISHED = :finished
|
13
|
+
|
14
|
+
# @return [String]
|
15
|
+
attr_reader :uuid
|
16
|
+
|
17
|
+
# @return [String]
|
18
|
+
attr_reader :title
|
19
|
+
|
20
|
+
# @return [String, nil]
|
21
|
+
attr_reader :kind
|
22
|
+
|
23
|
+
# @return [String, nil]
|
24
|
+
attr_reader :message
|
25
|
+
|
26
|
+
# @return [Integer]
|
27
|
+
attr_reader :percentage
|
28
|
+
|
29
|
+
# @return [Symbol]
|
30
|
+
attr_reader :status
|
31
|
+
|
32
|
+
# @param title [String]
|
33
|
+
def initialize title
|
34
|
+
@title = title
|
35
|
+
@uuid = SecureRandom.uuid
|
36
|
+
@percentage = 0
|
37
|
+
@status = WAITING
|
38
|
+
end
|
39
|
+
|
40
|
+
# @param message [String]
|
41
|
+
# @param percentage [Integer]
|
42
|
+
def begin message, percentage
|
43
|
+
@kind = 'begin'
|
44
|
+
@message = message
|
45
|
+
@percentage = percentage
|
46
|
+
end
|
47
|
+
|
48
|
+
# @param message [String]
|
49
|
+
# @param percentage [Integer]
|
50
|
+
def report message, percentage
|
51
|
+
@kind = 'report'
|
52
|
+
@message = message
|
53
|
+
@percentage = percentage
|
54
|
+
end
|
55
|
+
|
56
|
+
# @param message [String]
|
57
|
+
def finish message
|
58
|
+
@kind = 'end'
|
59
|
+
@message = message
|
60
|
+
@percentage = 100
|
61
|
+
true
|
62
|
+
end
|
63
|
+
|
64
|
+
# @param host [Solargraph::LanguageServer::Host]
|
65
|
+
def send host
|
66
|
+
return unless host.client_supports_progress? && !finished?
|
67
|
+
|
68
|
+
message = build
|
69
|
+
create(host)
|
70
|
+
host.send_notification '$/progress', message
|
71
|
+
@status = FINISHED if kind == 'end'
|
72
|
+
keep_alive host
|
73
|
+
end
|
74
|
+
|
75
|
+
def created?
|
76
|
+
[CREATED, FINISHED].include?(status)
|
77
|
+
end
|
78
|
+
|
79
|
+
def finished?
|
80
|
+
status == FINISHED
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
# @param host [Solargraph::LanguageServer::Host]
|
86
|
+
# @return [void]
|
87
|
+
def create host
|
88
|
+
return if created?
|
89
|
+
|
90
|
+
host.send_request 'window/workDoneProgress/create', { token: uuid }
|
91
|
+
@status = CREATED
|
92
|
+
end
|
93
|
+
|
94
|
+
def build
|
95
|
+
{
|
96
|
+
token: uuid,
|
97
|
+
value: {
|
98
|
+
kind: kind,
|
99
|
+
cancellable: false
|
100
|
+
}.merge(build_value)
|
101
|
+
}
|
102
|
+
end
|
103
|
+
|
104
|
+
def build_value
|
105
|
+
case kind
|
106
|
+
when 'begin'
|
107
|
+
{ title: title, message: message, percentage: percentage }
|
108
|
+
when 'report'
|
109
|
+
{ message: message, percentage: percentage }
|
110
|
+
when 'end'
|
111
|
+
{ message: message }
|
112
|
+
else
|
113
|
+
raise "Invalid progress kind #{kind}"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# @param host [Host]
|
118
|
+
def keep_alive host
|
119
|
+
mutex.synchronize { @last = Time.now }
|
120
|
+
@keep_alive ||= Thread.new do
|
121
|
+
until finished?
|
122
|
+
sleep 10
|
123
|
+
break if finished?
|
124
|
+
next if mutex.synchronize { Time.now - @last < 10 }
|
125
|
+
send host
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def mutex
|
131
|
+
@mutex ||= Mutex.new
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
@@ -8,6 +8,17 @@ module Solargraph
|
|
8
8
|
# A common module for running language servers in Backport.
|
9
9
|
#
|
10
10
|
module Adapter
|
11
|
+
# This runs in the context of Backport::Adapter, which
|
12
|
+
# provides write() - but if we didn't hide this behind a parse
|
13
|
+
# tag, it would override the one in the class.
|
14
|
+
#
|
15
|
+
# @!method write(text)
|
16
|
+
# @abstract
|
17
|
+
# Write the change to the specified text.
|
18
|
+
# @param text [String] The text to be changed.
|
19
|
+
# @return [String] The updated text.
|
20
|
+
|
21
|
+
# @return [void]
|
11
22
|
def opening
|
12
23
|
@host = Solargraph::LanguageServer::Host.new
|
13
24
|
@host.add_observer self
|
@@ -18,15 +29,18 @@ module Solargraph
|
|
18
29
|
end
|
19
30
|
end
|
20
31
|
|
32
|
+
# @return [void]
|
21
33
|
def closing
|
22
34
|
@host.stop
|
23
35
|
end
|
24
36
|
|
25
37
|
# @param data [String]
|
38
|
+
# @return [void]
|
26
39
|
def receiving data
|
27
40
|
@data_reader.receive data
|
28
41
|
end
|
29
42
|
|
43
|
+
# @return [void]
|
30
44
|
def update
|
31
45
|
if @host.stopped?
|
32
46
|
shutdown
|
@@ -38,12 +52,13 @@ module Solargraph
|
|
38
52
|
|
39
53
|
private
|
40
54
|
|
41
|
-
# @param request [
|
55
|
+
# @param request [Hash]
|
42
56
|
# @return [void]
|
43
57
|
def process request
|
44
58
|
@host.process(request)
|
45
59
|
end
|
46
60
|
|
61
|
+
# @return [void]
|
47
62
|
def shutdown
|
48
63
|
Backport.stop unless @host.options['transport'] == 'external'
|
49
64
|
end
|
@@ -16,6 +16,7 @@ module Solargraph
|
|
16
16
|
# client.
|
17
17
|
#
|
18
18
|
# @yieldparam [Hash] The message received from the client
|
19
|
+
# @return [void]
|
19
20
|
def set_message_handler &block
|
20
21
|
@message_handler = block
|
21
22
|
end
|
@@ -26,6 +27,7 @@ module Solargraph
|
|
26
27
|
# will be buffered and subsequent data will be appended to the buffer.
|
27
28
|
#
|
28
29
|
# @param data [String]
|
30
|
+
# @return [void]
|
29
31
|
def receive data
|
30
32
|
data.each_char do |char|
|
31
33
|
@buffer.concat char
|
@@ -15,5 +15,6 @@ module Solargraph
|
|
15
15
|
autoload :MessageTypes, 'solargraph/language_server/message_types'
|
16
16
|
autoload :Request, 'solargraph/language_server/request'
|
17
17
|
autoload :Transport, 'solargraph/language_server/transport'
|
18
|
+
autoload :Progress, 'solargraph/language_server/progress'
|
18
19
|
end
|
19
20
|
end
|