solargraph 0.58.2 → 0.59.0.dev.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/.envrc +3 -0
- data/.github/workflows/linting.yml +4 -5
- data/.github/workflows/plugins.yml +41 -34
- data/.github/workflows/rspec.yml +44 -23
- data/.github/workflows/typecheck.yml +2 -2
- data/.rubocop.yml +32 -5
- data/.rubocop_todo.yml +50 -966
- data/Gemfile +3 -1
- data/README.md +3 -3
- data/Rakefile +26 -23
- data/bin/solargraph +2 -1
- data/lib/solargraph/api_map/cache.rb +3 -3
- data/lib/solargraph/api_map/constants.rb +13 -3
- data/lib/solargraph/api_map/index.rb +23 -18
- data/lib/solargraph/api_map/source_to_yard.rb +22 -9
- data/lib/solargraph/api_map/store.rb +33 -28
- data/lib/solargraph/api_map.rb +150 -82
- data/lib/solargraph/bench.rb +44 -45
- data/lib/solargraph/complex_type/conformance.rb +176 -0
- data/lib/solargraph/complex_type/type_methods.rb +28 -17
- data/lib/solargraph/complex_type/unique_type.rb +218 -57
- data/lib/solargraph/complex_type.rb +170 -57
- data/lib/solargraph/convention/data_definition/data_assignment_node.rb +61 -61
- data/lib/solargraph/convention/data_definition/data_definition_node.rb +7 -5
- data/lib/solargraph/convention/data_definition.rb +5 -2
- data/lib/solargraph/convention/gemfile.rb +15 -15
- data/lib/solargraph/convention/gemspec.rb +23 -23
- data/lib/solargraph/convention/rakefile.rb +17 -17
- data/lib/solargraph/convention/struct_definition/struct_assignment_node.rb +2 -1
- data/lib/solargraph/convention/struct_definition/struct_definition_node.rb +4 -3
- data/lib/solargraph/convention/struct_definition.rb +8 -4
- data/lib/solargraph/convention.rb +78 -78
- data/lib/solargraph/converters/dd.rb +19 -17
- data/lib/solargraph/converters/dl.rb +17 -15
- data/lib/solargraph/converters/dt.rb +17 -15
- data/lib/solargraph/converters/misc.rb +3 -1
- data/lib/solargraph/diagnostics/require_not_found.rb +1 -0
- data/lib/solargraph/diagnostics/rubocop.rb +11 -10
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +5 -3
- data/lib/solargraph/diagnostics/type_check.rb +11 -10
- data/lib/solargraph/diagnostics/update_errors.rb +37 -41
- data/lib/solargraph/doc_map.rb +133 -373
- data/lib/solargraph/equality.rb +4 -4
- data/lib/solargraph/gem_pins.rb +21 -20
- data/lib/solargraph/language_server/error_codes.rb +20 -20
- data/lib/solargraph/language_server/host/diagnoser.rb +1 -1
- data/lib/solargraph/language_server/host/dispatch.rb +3 -3
- data/lib/solargraph/language_server/host/message_worker.rb +4 -3
- data/lib/solargraph/language_server/host/sources.rb +2 -1
- data/lib/solargraph/language_server/host.rb +30 -22
- data/lib/solargraph/language_server/message/base.rb +97 -97
- data/lib/solargraph/language_server/message/client/register_capability.rb +13 -15
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +58 -60
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +12 -18
- data/lib/solargraph/language_server/message/extended/document.rb +1 -0
- data/lib/solargraph/language_server/message/extended/document_gems.rb +32 -32
- data/lib/solargraph/language_server/message/extended/download_core.rb +20 -19
- data/lib/solargraph/language_server/message/extended/search.rb +20 -20
- data/lib/solargraph/language_server/message/initialize.rb +197 -191
- data/lib/solargraph/language_server/message/text_document/completion.rb +10 -8
- data/lib/solargraph/language_server/message/text_document/definition.rb +41 -32
- data/lib/solargraph/language_server/message/text_document/document_highlight.rb +23 -16
- data/lib/solargraph/language_server/message/text_document/document_symbol.rb +29 -19
- data/lib/solargraph/language_server/message/text_document/formatting.rb +8 -6
- data/lib/solargraph/language_server/message/text_document/hover.rb +5 -5
- data/lib/solargraph/language_server/message/text_document/prepare_rename.rb +18 -11
- data/lib/solargraph/language_server/message/text_document/references.rb +23 -16
- data/lib/solargraph/language_server/message/text_document/rename.rb +26 -19
- data/lib/solargraph/language_server/message/text_document/signature_help.rb +3 -2
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +25 -17
- data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +41 -35
- data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +48 -40
- data/lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb +32 -26
- data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +27 -17
- data/lib/solargraph/language_server/message.rb +94 -94
- data/lib/solargraph/language_server/request.rb +29 -27
- data/lib/solargraph/language_server/transport/data_reader.rb +72 -74
- data/lib/solargraph/language_server/uri_helpers.rb +49 -49
- data/lib/solargraph/library.rb +85 -44
- data/lib/solargraph/location.rb +17 -14
- data/lib/solargraph/logging.rb +24 -4
- data/lib/solargraph/page.rb +92 -92
- data/lib/solargraph/parser/comment_ripper.rb +19 -4
- data/lib/solargraph/parser/flow_sensitive_typing.rb +326 -108
- data/lib/solargraph/parser/node_processor/base.rb +34 -4
- data/lib/solargraph/parser/node_processor.rb +8 -7
- data/lib/solargraph/parser/parser_gem/class_methods.rb +32 -14
- data/lib/solargraph/parser/parser_gem/flawed_builder.rb +19 -19
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +50 -25
- data/lib/solargraph/parser/parser_gem/node_methods.rb +91 -70
- data/lib/solargraph/parser/parser_gem/node_processors/and_node.rb +4 -4
- data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +13 -11
- data/lib/solargraph/parser/parser_gem/node_processors/begin_node.rb +9 -0
- data/lib/solargraph/parser/parser_gem/node_processors/block_node.rb +12 -12
- data/lib/solargraph/parser/parser_gem/node_processors/def_node.rb +10 -3
- data/lib/solargraph/parser/parser_gem/node_processors/defs_node.rb +38 -37
- data/lib/solargraph/parser/parser_gem/node_processors/if_node.rb +36 -6
- data/lib/solargraph/parser/parser_gem/node_processors/ivasgn_node.rb +5 -3
- data/lib/solargraph/parser/parser_gem/node_processors/lvasgn_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb +3 -1
- data/lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb +3 -3
- data/lib/solargraph/parser/parser_gem/node_processors/or_node.rb +22 -0
- data/lib/solargraph/parser/parser_gem/node_processors/orasgn_node.rb +1 -1
- 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 -5
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +124 -113
- data/lib/solargraph/parser/parser_gem/node_processors/until_node.rb +29 -29
- data/lib/solargraph/parser/parser_gem/node_processors/when_node.rb +23 -0
- data/lib/solargraph/parser/parser_gem/node_processors/while_node.rb +6 -2
- data/lib/solargraph/parser/parser_gem/node_processors.rb +4 -0
- data/lib/solargraph/parser/parser_gem.rb +14 -12
- data/lib/solargraph/parser/region.rb +9 -3
- data/lib/solargraph/parser/snippet.rb +3 -1
- data/lib/solargraph/parser.rb +25 -23
- data/lib/solargraph/pin/base.rb +126 -80
- data/lib/solargraph/pin/base_variable.rb +273 -24
- data/lib/solargraph/pin/block.rb +29 -6
- data/lib/solargraph/pin/breakable.rb +7 -1
- data/lib/solargraph/pin/callable.rb +65 -21
- data/lib/solargraph/pin/closure.rb +7 -10
- data/lib/solargraph/pin/common.rb +24 -6
- data/lib/solargraph/pin/compound_statement.rb +55 -0
- data/lib/solargraph/pin/constant.rb +43 -45
- data/lib/solargraph/pin/conversions.rb +10 -4
- data/lib/solargraph/pin/delegated_method.rb +19 -8
- data/lib/solargraph/pin/documenting.rb +4 -2
- data/lib/solargraph/pin/instance_variable.rb +5 -1
- data/lib/solargraph/pin/keyword.rb +0 -4
- data/lib/solargraph/pin/local_variable.rb +15 -59
- data/lib/solargraph/pin/method.rb +153 -104
- data/lib/solargraph/pin/method_alias.rb +8 -0
- data/lib/solargraph/pin/namespace.rb +19 -12
- data/lib/solargraph/pin/parameter.rb +100 -36
- data/lib/solargraph/pin/proxy_type.rb +4 -1
- data/lib/solargraph/pin/reference/override.rb +1 -1
- data/lib/solargraph/pin/reference/superclass.rb +2 -0
- data/lib/solargraph/pin/reference.rb +19 -0
- data/lib/solargraph/pin/search.rb +3 -2
- data/lib/solargraph/pin/signature.rb +15 -12
- data/lib/solargraph/pin/symbol.rb +2 -1
- data/lib/solargraph/pin/until.rb +2 -4
- data/lib/solargraph/pin/while.rb +2 -4
- data/lib/solargraph/pin.rb +2 -0
- data/lib/solargraph/pin_cache.rb +490 -73
- data/lib/solargraph/position.rb +14 -10
- data/lib/solargraph/range.rb +16 -15
- data/lib/solargraph/rbs_map/conversions.rb +343 -214
- data/lib/solargraph/rbs_map/core_fills.rb +91 -84
- data/lib/solargraph/rbs_map/core_map.rb +24 -17
- data/lib/solargraph/rbs_map/stdlib_map.rb +33 -5
- data/lib/solargraph/rbs_map.rb +77 -32
- data/lib/solargraph/server_methods.rb +16 -16
- data/lib/solargraph/shell.rb +128 -73
- data/lib/solargraph/source/chain/array.rb +39 -37
- data/lib/solargraph/source/chain/call.rb +96 -56
- data/lib/solargraph/source/chain/class_variable.rb +13 -13
- data/lib/solargraph/source/chain/constant.rb +5 -1
- data/lib/solargraph/source/chain/global_variable.rb +13 -13
- data/lib/solargraph/source/chain/hash.rb +8 -5
- data/lib/solargraph/source/chain/if.rb +12 -10
- data/lib/solargraph/source/chain/instance_variable.rb +24 -1
- data/lib/solargraph/source/chain/link.rb +99 -109
- data/lib/solargraph/source/chain/literal.rb +9 -6
- data/lib/solargraph/source/chain/or.rb +10 -4
- data/lib/solargraph/source/chain/q_call.rb +13 -11
- data/lib/solargraph/source/chain/variable.rb +15 -13
- data/lib/solargraph/source/chain/z_super.rb +28 -30
- data/lib/solargraph/source/chain.rb +49 -38
- data/lib/solargraph/source/change.rb +12 -5
- data/lib/solargraph/source/cursor.rb +23 -17
- data/lib/solargraph/source/encoding_fixes.rb +6 -7
- data/lib/solargraph/source/source_chainer.rb +56 -32
- data/lib/solargraph/source/updater.rb +5 -1
- data/lib/solargraph/source.rb +59 -35
- data/lib/solargraph/source_map/clip.rb +48 -29
- data/lib/solargraph/source_map/data.rb +4 -1
- data/lib/solargraph/source_map/mapper.rb +71 -42
- data/lib/solargraph/source_map.rb +21 -9
- data/lib/solargraph/type_checker/problem.rb +3 -1
- data/lib/solargraph/type_checker/rules.rb +81 -8
- data/lib/solargraph/type_checker.rb +195 -120
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +13 -10
- data/lib/solargraph/workspace/gemspecs.rb +367 -0
- data/lib/solargraph/workspace/require_paths.rb +1 -0
- data/lib/solargraph/workspace.rb +149 -30
- data/lib/solargraph/yard_map/helpers.rb +8 -3
- data/lib/solargraph/yard_map/mapper/to_method.rb +13 -7
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +2 -1
- data/lib/solargraph/yard_map/mapper.rb +13 -8
- data/lib/solargraph/yard_tags.rb +20 -20
- data/lib/solargraph/yardoc.rb +33 -23
- data/lib/solargraph.rb +29 -8
- data/rbs/fills/rubygems/0/dependency.rbs +193 -0
- data/rbs/fills/tuple/tuple.rbs +28 -0
- data/rbs/shims/ast/0/node.rbs +1 -1
- data/rbs/shims/diff-lcs/1.5/diff-lcs.rbs +11 -0
- data/solargraph.gemspec +36 -34
- metadata +38 -33
- data/lib/solargraph/type_checker/checks.rb +0 -124
- data/lib/solargraph/type_checker/param_def.rb +0 -37
- data/lib/solargraph/yard_map/to_method.rb +0 -89
|
@@ -1,191 +1,197 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module LanguageServer
|
|
5
|
-
module Message
|
|
6
|
-
class Initialize < Base
|
|
7
|
-
def process
|
|
8
|
-
host.configure params['initializationOptions']
|
|
9
|
-
host.client_capabilities = params['capabilities']
|
|
10
|
-
if support_workspace_folders?
|
|
11
|
-
host.prepare_folders params['workspaceFolders']
|
|
12
|
-
elsif params['rootUri']
|
|
13
|
-
host.prepare UriHelpers.uri_to_file(params['rootUri'])
|
|
14
|
-
else
|
|
15
|
-
host.prepare params['rootPath']
|
|
16
|
-
end
|
|
17
|
-
result = {
|
|
18
|
-
capabilities: {
|
|
19
|
-
textDocumentSync: 2, # @todo What should this be?
|
|
20
|
-
workspace: {
|
|
21
|
-
workspaceFolders: {
|
|
22
|
-
supported: true,
|
|
23
|
-
changeNotifications: true
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
# FIXME: lsp default is utf-16, may have different position
|
|
29
|
-
result[:capabilities][:positionEncoding] =
|
|
30
|
-
|
|
31
|
-
result[:capabilities].merge!
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
result[:capabilities].merge!
|
|
35
|
-
result[:capabilities].merge!
|
|
36
|
-
result[:capabilities].merge!
|
|
37
|
-
|
|
38
|
-
result[:capabilities].merge!
|
|
39
|
-
|
|
40
|
-
result[:capabilities].merge!
|
|
41
|
-
result[:capabilities].merge!
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
{
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
# @return [Hash{Symbol => Boolean}]
|
|
129
|
-
def
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
{
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module LanguageServer
|
|
5
|
+
module Message
|
|
6
|
+
class Initialize < Base
|
|
7
|
+
def process
|
|
8
|
+
host.configure params['initializationOptions']
|
|
9
|
+
host.client_capabilities = params['capabilities']
|
|
10
|
+
if support_workspace_folders?
|
|
11
|
+
host.prepare_folders params['workspaceFolders']
|
|
12
|
+
elsif params['rootUri']
|
|
13
|
+
host.prepare UriHelpers.uri_to_file(params['rootUri'])
|
|
14
|
+
else
|
|
15
|
+
host.prepare params['rootPath']
|
|
16
|
+
end
|
|
17
|
+
result = {
|
|
18
|
+
capabilities: {
|
|
19
|
+
textDocumentSync: 2, # @todo What should this be?
|
|
20
|
+
workspace: {
|
|
21
|
+
workspaceFolders: {
|
|
22
|
+
supported: true,
|
|
23
|
+
changeNotifications: true
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
# FIXME: lsp default is utf-16, may have different position
|
|
29
|
+
result[:capabilities][:positionEncoding] = 'utf-32' if params.dig('capabilities', 'general',
|
|
30
|
+
'positionEncodings')&.include?('utf-32')
|
|
31
|
+
result[:capabilities].merge! static_completion unless dynamic_registration_for?('textDocument', 'completion')
|
|
32
|
+
result[:capabilities].merge! static_signature_help unless dynamic_registration_for?('textDocument',
|
|
33
|
+
'signatureHelp')
|
|
34
|
+
# result[:capabilities].merge! static_on_type_formatting unless dynamic_registration_for?('textDocument', 'onTypeFormatting')
|
|
35
|
+
result[:capabilities].merge! static_hover unless dynamic_registration_for?('textDocument', 'hover')
|
|
36
|
+
result[:capabilities].merge! static_document_formatting unless dynamic_registration_for?('textDocument',
|
|
37
|
+
'formatting')
|
|
38
|
+
result[:capabilities].merge! static_document_symbols unless dynamic_registration_for?('textDocument',
|
|
39
|
+
'documentSymbol')
|
|
40
|
+
result[:capabilities].merge! static_definitions unless dynamic_registration_for?('textDocument', 'definition')
|
|
41
|
+
result[:capabilities].merge! static_type_definitions unless dynamic_registration_for?('textDocument',
|
|
42
|
+
'typeDefinition')
|
|
43
|
+
result[:capabilities].merge! static_rename unless dynamic_registration_for?('textDocument', 'rename')
|
|
44
|
+
result[:capabilities].merge! static_references unless dynamic_registration_for?('textDocument', 'references')
|
|
45
|
+
result[:capabilities].merge! static_workspace_symbols unless dynamic_registration_for?('workspace', 'symbol')
|
|
46
|
+
result[:capabilities].merge! static_folding_range unless dynamic_registration_for?('textDocument',
|
|
47
|
+
'foldingRange')
|
|
48
|
+
result[:capabilities].merge! static_highlights unless dynamic_registration_for?('textDocument',
|
|
49
|
+
'documentHighlight')
|
|
50
|
+
# @todo Temporarily disabled
|
|
51
|
+
# result[:capabilities].merge! static_code_action unless dynamic_registration_for?('textDocument', 'codeAction')
|
|
52
|
+
set_result result
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
# @todo '?' methods should type like RBS 'boolish' rather than a strict true or false
|
|
58
|
+
# @sg-ignore
|
|
59
|
+
def support_workspace_folders?
|
|
60
|
+
params['capabilities'] &&
|
|
61
|
+
params['capabilities']['workspace'] &&
|
|
62
|
+
params['capabilities']['workspace']['workspaceFolders'] &&
|
|
63
|
+
params['workspaceFolders']
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# @return [Hash{Symbol => undefined}]
|
|
67
|
+
def static_completion
|
|
68
|
+
return {} unless host.options['completion']
|
|
69
|
+
{
|
|
70
|
+
completionProvider: {
|
|
71
|
+
resolveProvider: true,
|
|
72
|
+
triggerCharacters: ['.', ':', '@']
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# @return [Hash{Symbol => BasicObject}]
|
|
78
|
+
def static_code_action
|
|
79
|
+
{
|
|
80
|
+
codeActionProvider: true,
|
|
81
|
+
codeActionKinds: ['quickfix']
|
|
82
|
+
}
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# @return [Hash{Symbol => BasicObject}]
|
|
86
|
+
def static_signature_help
|
|
87
|
+
{
|
|
88
|
+
signatureHelpProvider: {
|
|
89
|
+
triggerCharacters: ['(', ',']
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# @return [Hash{Symbol => Hash{Symbol => String, Array<String>}}]
|
|
95
|
+
def static_on_type_formatting
|
|
96
|
+
{
|
|
97
|
+
documentOnTypeFormattingProvider: {
|
|
98
|
+
firstTriggerCharacter: '{',
|
|
99
|
+
moreTriggerCharacter: ['(']
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# @return [Hash{Symbol => Boolean}]
|
|
105
|
+
def static_hover
|
|
106
|
+
return {} unless host.options['hover']
|
|
107
|
+
{
|
|
108
|
+
hoverProvider: true
|
|
109
|
+
}
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# @return [Hash{Symbol => Boolean}]
|
|
113
|
+
def static_document_formatting
|
|
114
|
+
return {} unless host.options['formatting']
|
|
115
|
+
{
|
|
116
|
+
documentFormattingProvider: true
|
|
117
|
+
}
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# @return [Hash{Symbol => Boolean}]
|
|
121
|
+
def static_document_symbols
|
|
122
|
+
return {} unless host.options['symbols']
|
|
123
|
+
{
|
|
124
|
+
documentSymbolProvider: true
|
|
125
|
+
}
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# @return [Hash{Symbol => Boolean}]
|
|
129
|
+
def static_workspace_symbols
|
|
130
|
+
{
|
|
131
|
+
workspaceSymbolProvider: true
|
|
132
|
+
}
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# @return [Hash{Symbol => Boolean}]
|
|
136
|
+
def static_definitions
|
|
137
|
+
return {} unless host.options['definitions']
|
|
138
|
+
{
|
|
139
|
+
definitionProvider: true
|
|
140
|
+
}
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# @return [Hash{Symbol => Boolean}]
|
|
144
|
+
def static_type_definitions
|
|
145
|
+
return {} unless host.options['typeDefinitions']
|
|
146
|
+
{
|
|
147
|
+
typeDefinitionProvider: true
|
|
148
|
+
}
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# @return [Hash{Symbol => Hash{Symbol => Boolean}}]
|
|
152
|
+
def static_rename
|
|
153
|
+
{
|
|
154
|
+
renameProvider: { prepareProvider: true }
|
|
155
|
+
}
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# @return [Hash{Symbol => Boolean}]
|
|
159
|
+
def static_references
|
|
160
|
+
return {} unless host.options['references']
|
|
161
|
+
{
|
|
162
|
+
referencesProvider: true
|
|
163
|
+
}
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# @return [Hash{Symbol => Boolean}]
|
|
167
|
+
def static_folding_range
|
|
168
|
+
return {} unless host.options['folding']
|
|
169
|
+
{
|
|
170
|
+
foldingRangeProvider: true
|
|
171
|
+
}
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# @return [Hash{Symbol => Boolean}]
|
|
175
|
+
def static_highlights
|
|
176
|
+
{
|
|
177
|
+
documentHighlightProvider: true
|
|
178
|
+
}
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# @param section [String]
|
|
182
|
+
# @param capability [String]
|
|
183
|
+
# @todo Need support for RBS' boolish "type", which doesn't
|
|
184
|
+
# enforce strict true/false-ness
|
|
185
|
+
# @sg-ignore
|
|
186
|
+
def dynamic_registration_for? section, capability
|
|
187
|
+
result = params['capabilities'] &&
|
|
188
|
+
params['capabilities'][section] &&
|
|
189
|
+
params['capabilities'][section][capability] &&
|
|
190
|
+
params['capabilities'][section][capability]['dynamicRegistration']
|
|
191
|
+
host.allow_registration("#{section}/#{capability}") if result
|
|
192
|
+
result
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
end
|
|
@@ -6,7 +6,7 @@ module Solargraph
|
|
|
6
6
|
module TextDocument
|
|
7
7
|
class Completion < Base
|
|
8
8
|
def process
|
|
9
|
-
return set_error(ErrorCodes::REQUEST_CANCELLED,
|
|
9
|
+
return set_error(ErrorCodes::REQUEST_CANCELLED, 'cancelled by so many request') if host.pending_completions?
|
|
10
10
|
|
|
11
11
|
line = params['position']['line']
|
|
12
12
|
col = params['position']['character']
|
|
@@ -15,15 +15,16 @@ module Solargraph
|
|
|
15
15
|
items = []
|
|
16
16
|
last_context = nil
|
|
17
17
|
idx = -1
|
|
18
|
+
# @sg-ignore Need to add nil check here
|
|
18
19
|
completion.pins.each do |pin|
|
|
19
20
|
idx += 1 if last_context != pin.context
|
|
20
21
|
items.push pin.completion_item.merge({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
textEdit: {
|
|
23
|
+
range: completion.range.to_hash,
|
|
24
|
+
newText: pin.name.sub(/=$/, ' = ').sub(/:$/, ': ')
|
|
25
|
+
},
|
|
26
|
+
sortText: "#{idx.to_s.rjust(4, '0')}#{pin.name}"
|
|
27
|
+
})
|
|
27
28
|
items.last[:data][:uri] = params['textDocument']['uri']
|
|
28
29
|
last_context = pin.context
|
|
29
30
|
end
|
|
@@ -31,12 +32,13 @@ module Solargraph
|
|
|
31
32
|
isIncomplete: false,
|
|
32
33
|
items: items
|
|
33
34
|
)
|
|
34
|
-
rescue InvalidOffsetError
|
|
35
|
+
rescue InvalidOffsetError
|
|
35
36
|
Logging.logger.info "Completion ignored invalid offset: #{params['textDocument']['uri']}, line #{line}, character #{col}"
|
|
36
37
|
set_result empty_result
|
|
37
38
|
end
|
|
38
39
|
rescue FileNotFoundError => e
|
|
39
40
|
Logging.logger.warn "[#{e.class}] #{e.message}"
|
|
41
|
+
# @sg-ignore Need to add nil check here
|
|
40
42
|
Logging.logger.warn e.backtrace.join("\n")
|
|
41
43
|
set_result empty_result
|
|
42
44
|
end
|
|
@@ -1,40 +1,49 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module Solargraph
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
module Solargraph
|
|
4
|
+
module LanguageServer
|
|
5
|
+
module Message
|
|
6
|
+
module TextDocument
|
|
7
|
+
class Definition < Base
|
|
8
|
+
def process
|
|
9
|
+
@line = params['position']['line']
|
|
10
|
+
@column = params['position']['character']
|
|
11
|
+
set_result(code_location || require_location || [])
|
|
12
|
+
end
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
private
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
# @return [Array<Hash>, nil]
|
|
17
|
+
def code_location
|
|
18
|
+
suggestions = host.definitions_at(params['textDocument']['uri'], @line, @column)
|
|
19
|
+
# @sg-ignore Need to add nil check here
|
|
20
|
+
return nil if suggestions.empty?
|
|
21
|
+
# @sg-ignore Need to add nil check here
|
|
22
|
+
suggestions.reject { |pin| pin.best_location.nil? || pin.best_location.filename.nil? }.map do |pin|
|
|
23
|
+
{
|
|
24
|
+
uri: file_to_uri(pin.best_location.filename),
|
|
25
|
+
range: pin.best_location.range.to_hash
|
|
26
|
+
}
|
|
27
|
+
end
|
|
28
|
+
end
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
# @return [Array<Hash>, nil]
|
|
31
|
+
def require_location
|
|
32
|
+
# @todo Terrible hack
|
|
33
|
+
lib = host.library_for(params['textDocument']['uri'])
|
|
34
|
+
rloc = Solargraph::Location.new(uri_to_file(params['textDocument']['uri']),
|
|
35
|
+
Solargraph::Range.from_to(@line, @column, @line, @column))
|
|
36
|
+
dloc = lib.locate_ref(rloc)
|
|
37
|
+
return nil if dloc.nil?
|
|
38
|
+
[
|
|
39
|
+
{
|
|
40
|
+
uri: file_to_uri(dloc.filename),
|
|
41
|
+
range: dloc.range.to_hash
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
38
47
|
end
|
|
39
48
|
end
|
|
40
49
|
end
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module LanguageServer
|
|
5
|
+
module Message
|
|
6
|
+
module TextDocument
|
|
7
|
+
class DocumentHighlight < Base
|
|
8
|
+
def process
|
|
9
|
+
locs = host.references_from(params['textDocument']['uri'], params['position']['line'],
|
|
10
|
+
params['position']['character'], strip: true, only: true)
|
|
11
|
+
result = locs.map do |loc|
|
|
12
|
+
{
|
|
13
|
+
range: loc.range.to_hash,
|
|
14
|
+
kind: 1
|
|
15
|
+
}
|
|
16
|
+
end
|
|
17
|
+
set_result result
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -1,26 +1,36 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
module Solargraph
|
|
4
|
+
module LanguageServer
|
|
5
|
+
module Message
|
|
6
|
+
module TextDocument
|
|
7
|
+
class DocumentSymbol < Solargraph::LanguageServer::Message::Base
|
|
8
|
+
include Solargraph::LanguageServer::UriHelpers
|
|
5
9
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
def process
|
|
11
|
+
pins = host.document_symbols params['textDocument']['uri']
|
|
12
|
+
info = pins.map do |pin|
|
|
13
|
+
next nil unless pin.best_location&.filename
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
result = {
|
|
16
|
+
name: pin.name,
|
|
17
|
+
containerName: pin.namespace,
|
|
18
|
+
kind: pin.symbol_kind,
|
|
19
|
+
location: {
|
|
20
|
+
# @sg-ignore Need to add nil check here
|
|
21
|
+
uri: file_to_uri(pin.best_location.filename),
|
|
22
|
+
# @sg-ignore Need to add nil check here
|
|
23
|
+
range: pin.best_location.range.to_hash
|
|
24
|
+
},
|
|
25
|
+
deprecated: pin.deprecated?
|
|
26
|
+
}
|
|
27
|
+
result
|
|
28
|
+
end.compact
|
|
23
29
|
|
|
24
|
-
|
|
30
|
+
set_result info
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
25
35
|
end
|
|
26
36
|
end
|