solargraph 0.58.3 → 0.59.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 +12 -5
- data/.github/workflows/plugins.yml +54 -34
- data/.github/workflows/rspec.yml +15 -28
- data/.github/workflows/typecheck.yml +6 -3
- data/.rubocop.yml +38 -6
- data/.rubocop_todo.yml +53 -966
- data/CHANGELOG.md +24 -0
- 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 +12 -3
- data/lib/solargraph/api_map/index.rb +29 -18
- data/lib/solargraph/api_map/source_to_yard.rb +22 -9
- data/lib/solargraph/api_map/store.rb +40 -30
- data/lib/solargraph/api_map.rb +160 -78
- data/lib/solargraph/bench.rb +2 -3
- data/lib/solargraph/complex_type/conformance.rb +176 -0
- data/lib/solargraph/complex_type/type_methods.rb +31 -18
- data/lib/solargraph/complex_type/unique_type.rb +221 -63
- data/lib/solargraph/complex_type.rb +173 -59
- data/lib/solargraph/convention/active_support_concern.rb +111 -111
- data/lib/solargraph/convention/base.rb +50 -50
- data/lib/solargraph/convention/data_definition/data_assignment_node.rb +1 -1
- 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 +1 -1
- data/lib/solargraph/convention/gemspec.rb +1 -1
- data/lib/solargraph/convention/rakefile.rb +1 -1
- 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 +2 -2
- data/lib/solargraph/converters/dd.rb +2 -0
- data/lib/solargraph/converters/dl.rb +2 -0
- data/lib/solargraph/converters/dt.rb +2 -0
- data/lib/solargraph/converters/misc.rb +2 -0
- 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 +4 -8
- data/lib/solargraph/diagnostics.rb +55 -55
- data/lib/solargraph/doc_map.rb +38 -39
- data/lib/solargraph/environ.rb +52 -52
- data/lib/solargraph/equality.rb +4 -4
- data/lib/solargraph/gem_pins.rb +4 -15
- data/lib/solargraph/language_server/error_codes.rb +10 -10
- 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 +35 -28
- data/lib/solargraph/language_server/message/base.rb +1 -1
- data/lib/solargraph/language_server/message/client/register_capability.rb +1 -3
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +6 -8
- 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 +7 -7
- data/lib/solargraph/language_server/message/extended/download_core.rb +2 -1
- data/lib/solargraph/language_server/message/extended/environment.rb +25 -25
- data/lib/solargraph/language_server/message/extended/search.rb +1 -1
- data/lib/solargraph/language_server/message/initialize.rb +20 -14
- data/lib/solargraph/language_server/message/initialized.rb +28 -28
- 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 +17 -10
- 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 +13 -6
- data/lib/solargraph/language_server/message/text_document/references.rb +17 -10
- data/lib/solargraph/language_server/message/text_document/rename.rb +20 -13
- 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/text_document.rb +28 -28
- data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +34 -28
- data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +38 -30
- data/lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb +23 -17
- data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +27 -17
- data/lib/solargraph/language_server/message.rb +1 -1
- data/lib/solargraph/language_server/progress.rb +143 -143
- data/lib/solargraph/language_server/request.rb +4 -2
- data/lib/solargraph/language_server/transport/adapter.rb +68 -68
- data/lib/solargraph/language_server/transport/data_reader.rb +11 -13
- data/lib/solargraph/language_server/uri_helpers.rb +2 -2
- data/lib/solargraph/language_server.rb +20 -20
- data/lib/solargraph/library.rb +57 -38
- data/lib/solargraph/location.rb +17 -14
- data/lib/solargraph/logging.rb +22 -4
- data/lib/solargraph/page.rb +1 -1
- data/lib/solargraph/parser/comment_ripper.rb +19 -4
- data/lib/solargraph/parser/flow_sensitive_typing.rb +324 -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 +30 -14
- data/lib/solargraph/parser/parser_gem/flawed_builder.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +51 -25
- data/lib/solargraph/parser/parser_gem/node_methods.rb +181 -73
- data/lib/solargraph/parser/parser_gem/node_processors/alias_node.rb +24 -24
- 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 +11 -12
- data/lib/solargraph/parser/parser_gem/node_processors/casgn_node.rb +36 -36
- data/lib/solargraph/parser/parser_gem/node_processors/cvasgn_node.rb +24 -24
- data/lib/solargraph/parser/parser_gem/node_processors/def_node.rb +10 -3
- data/lib/solargraph/parser/parser_gem/node_processors/defs_node.rb +9 -8
- data/lib/solargraph/parser/parser_gem/node_processors/gvasgn_node.rb +24 -24
- 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/namespace_node.rb +40 -40
- 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/sym_node.rb +20 -20
- data/lib/solargraph/parser/parser_gem/node_processors/until_node.rb +1 -1
- 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 +2 -0
- data/lib/solargraph/parser/region.rb +9 -3
- data/lib/solargraph/parser/snippet.rb +3 -1
- data/lib/solargraph/parser.rb +2 -0
- data/lib/solargraph/pin/base.rb +126 -82
- 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 +3 -5
- 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 +158 -104
- data/lib/solargraph/pin/method_alias.rb +8 -0
- data/lib/solargraph/pin/namespace.rb +19 -12
- data/lib/solargraph/pin/parameter.rb +102 -36
- data/lib/solargraph/pin/proxy_type.rb +4 -1
- data/lib/solargraph/pin/reference/override.rb +1 -1
- data/lib/solargraph/pin/reference/require.rb +14 -14
- data/lib/solargraph/pin/reference/superclass.rb +2 -0
- data/lib/solargraph/pin/reference/type_alias.rb +16 -0
- data/lib/solargraph/pin/reference.rb +20 -0
- data/lib/solargraph/pin/search.rb +8 -7
- data/lib/solargraph/pin/signature.rb +15 -12
- data/lib/solargraph/pin/singleton.rb +11 -11
- 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 +22 -19
- data/lib/solargraph/position.rb +17 -10
- data/lib/solargraph/range.rb +16 -15
- data/lib/solargraph/rbs_map/conversions.rb +367 -231
- data/lib/solargraph/rbs_map/core_fills.rb +18 -11
- 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 +76 -32
- data/lib/solargraph/server_methods.rb +1 -1
- data/lib/solargraph/shell.rb +258 -66
- data/lib/solargraph/source/chain/array.rb +3 -12
- data/lib/solargraph/source/chain/block_symbol.rb +13 -13
- data/lib/solargraph/source/chain/block_variable.rb +13 -13
- data/lib/solargraph/source/chain/call.rb +96 -56
- data/lib/solargraph/source/chain/class_variable.rb +1 -1
- data/lib/solargraph/source/chain/constant.rb +5 -1
- data/lib/solargraph/source/chain/global_variable.rb +1 -1
- data/lib/solargraph/source/chain/hash.rb +8 -5
- data/lib/solargraph/source/chain/head.rb +19 -19
- 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 +12 -22
- data/lib/solargraph/source/chain/literal.rb +22 -15
- data/lib/solargraph/source/chain/or.rb +10 -4
- data/lib/solargraph/source/chain/q_call.rb +2 -0
- data/lib/solargraph/source/chain/variable.rb +3 -1
- data/lib/solargraph/source/chain/z_super.rb +1 -3
- data/lib/solargraph/source/chain.rb +51 -38
- data/lib/solargraph/source/change.rb +12 -5
- data/lib/solargraph/source/cursor.rb +33 -18
- 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 +54 -30
- data/lib/solargraph/source_map/data.rb +4 -1
- data/lib/solargraph/source_map/mapper.rb +69 -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 +196 -122
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +14 -11
- data/lib/solargraph/workspace/gemspecs.rb +367 -0
- data/lib/solargraph/workspace/require_paths.rb +1 -0
- data/lib/solargraph/workspace.rb +50 -28
- data/lib/solargraph/yard_map/cache.rb +25 -25
- data/lib/solargraph/yard_map/helpers.rb +8 -3
- data/lib/solargraph/yard_map/mapper/to_constant.rb +28 -28
- 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_map.rb +17 -18
- data/lib/solargraph/yard_tags.rb +2 -2
- data/lib/solargraph/yardoc.rb +7 -4
- data/lib/solargraph.rb +33 -10
- data/rbs/fills/rubygems/0/dependency.rbs +193 -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 +37 -35
- metadata +41 -42
- 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
- data/rbs/fills/tuple/tuple.rbs +0 -149
|
@@ -26,20 +26,27 @@ module Solargraph
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
# FIXME: lsp default is utf-16, may have different position
|
|
29
|
-
result[:capabilities][:positionEncoding] =
|
|
29
|
+
result[:capabilities][:positionEncoding] = 'utf-32' if params.dig('capabilities', 'general',
|
|
30
|
+
'positionEncodings')&.include?('utf-32')
|
|
30
31
|
result[:capabilities].merge! static_completion unless dynamic_registration_for?('textDocument', 'completion')
|
|
31
|
-
result[:capabilities].merge! static_signature_help unless dynamic_registration_for?('textDocument',
|
|
32
|
+
result[:capabilities].merge! static_signature_help unless dynamic_registration_for?('textDocument',
|
|
33
|
+
'signatureHelp')
|
|
32
34
|
# result[:capabilities].merge! static_on_type_formatting unless dynamic_registration_for?('textDocument', 'onTypeFormatting')
|
|
33
35
|
result[:capabilities].merge! static_hover unless dynamic_registration_for?('textDocument', 'hover')
|
|
34
|
-
result[:capabilities].merge! static_document_formatting unless dynamic_registration_for?('textDocument',
|
|
35
|
-
|
|
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')
|
|
36
40
|
result[:capabilities].merge! static_definitions unless dynamic_registration_for?('textDocument', 'definition')
|
|
37
|
-
result[:capabilities].merge! static_type_definitions unless dynamic_registration_for?('textDocument',
|
|
41
|
+
result[:capabilities].merge! static_type_definitions unless dynamic_registration_for?('textDocument',
|
|
42
|
+
'typeDefinition')
|
|
38
43
|
result[:capabilities].merge! static_rename unless dynamic_registration_for?('textDocument', 'rename')
|
|
39
44
|
result[:capabilities].merge! static_references unless dynamic_registration_for?('textDocument', 'references')
|
|
40
45
|
result[:capabilities].merge! static_workspace_symbols unless dynamic_registration_for?('workspace', 'symbol')
|
|
41
|
-
result[:capabilities].merge! static_folding_range unless dynamic_registration_for?('textDocument',
|
|
42
|
-
|
|
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')
|
|
43
50
|
# @todo Temporarily disabled
|
|
44
51
|
# result[:capabilities].merge! static_code_action unless dynamic_registration_for?('textDocument', 'codeAction')
|
|
45
52
|
set_result result
|
|
@@ -71,7 +78,7 @@ module Solargraph
|
|
|
71
78
|
def static_code_action
|
|
72
79
|
{
|
|
73
80
|
codeActionProvider: true,
|
|
74
|
-
codeActionKinds: [
|
|
81
|
+
codeActionKinds: ['quickfix']
|
|
75
82
|
}
|
|
76
83
|
end
|
|
77
84
|
|
|
@@ -144,11 +151,10 @@ module Solargraph
|
|
|
144
151
|
# @return [Hash{Symbol => Hash{Symbol => Boolean}}]
|
|
145
152
|
def static_rename
|
|
146
153
|
{
|
|
147
|
-
renameProvider: {prepareProvider: true}
|
|
154
|
+
renameProvider: { prepareProvider: true }
|
|
148
155
|
}
|
|
149
156
|
end
|
|
150
157
|
|
|
151
|
-
|
|
152
158
|
# @return [Hash{Symbol => Boolean}]
|
|
153
159
|
def static_references
|
|
154
160
|
return {} unless host.options['references']
|
|
@@ -178,10 +184,10 @@ module Solargraph
|
|
|
178
184
|
# enforce strict true/false-ness
|
|
179
185
|
# @sg-ignore
|
|
180
186
|
def dynamic_registration_for? section, capability
|
|
181
|
-
result =
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
187
|
+
result = params['capabilities'] &&
|
|
188
|
+
params['capabilities'][section] &&
|
|
189
|
+
params['capabilities'][section][capability] &&
|
|
190
|
+
params['capabilities'][section][capability]['dynamicRegistration']
|
|
185
191
|
host.allow_registration("#{section}/#{capability}") if result
|
|
186
192
|
result
|
|
187
193
|
end
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module LanguageServer
|
|
5
|
-
module Message
|
|
6
|
-
class Initialized < Base
|
|
7
|
-
def process
|
|
8
|
-
# @todo Temporarily removed textDocument/codeAction
|
|
9
|
-
host.register_capabilities %w[
|
|
10
|
-
textDocument/completion
|
|
11
|
-
textDocument/hover
|
|
12
|
-
textDocument/signatureHelp
|
|
13
|
-
textDocument/formatting
|
|
14
|
-
textDocument/documentSymbol
|
|
15
|
-
textDocument/definition
|
|
16
|
-
textDocument/typeDefinition
|
|
17
|
-
textDocument/references
|
|
18
|
-
textDocument/rename
|
|
19
|
-
textDocument/prepareRename
|
|
20
|
-
textDocument/foldingRange
|
|
21
|
-
textDocument/documentHighlight
|
|
22
|
-
workspace/symbol
|
|
23
|
-
]
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module LanguageServer
|
|
5
|
+
module Message
|
|
6
|
+
class Initialized < Base
|
|
7
|
+
def process
|
|
8
|
+
# @todo Temporarily removed textDocument/codeAction
|
|
9
|
+
host.register_capabilities %w[
|
|
10
|
+
textDocument/completion
|
|
11
|
+
textDocument/hover
|
|
12
|
+
textDocument/signatureHelp
|
|
13
|
+
textDocument/formatting
|
|
14
|
+
textDocument/documentSymbol
|
|
15
|
+
textDocument/definition
|
|
16
|
+
textDocument/typeDefinition
|
|
17
|
+
textDocument/references
|
|
18
|
+
textDocument/rename
|
|
19
|
+
textDocument/prepareRename
|
|
20
|
+
textDocument/foldingRange
|
|
21
|
+
textDocument/documentHighlight
|
|
22
|
+
workspace/symbol
|
|
23
|
+
]
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
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
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module Solargraph
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
12
20
|
end
|
|
13
|
-
set_result result
|
|
14
21
|
end
|
|
15
22
|
end
|
|
16
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
|
|
@@ -43,7 +43,7 @@ module Solargraph
|
|
|
43
43
|
|
|
44
44
|
# @param corrections [String]
|
|
45
45
|
# @return [void]
|
|
46
|
-
def log_corrections
|
|
46
|
+
def log_corrections corrections
|
|
47
47
|
corrections = corrections&.strip
|
|
48
48
|
return if corrections&.empty?
|
|
49
49
|
|
|
@@ -56,7 +56,7 @@ module Solargraph
|
|
|
56
56
|
|
|
57
57
|
# @param file_uri [String]
|
|
58
58
|
# @return [Hash{String => undefined}]
|
|
59
|
-
def config_for
|
|
59
|
+
def config_for file_uri
|
|
60
60
|
conf = host.formatter_config(file_uri)
|
|
61
61
|
return {} unless conf.is_a?(Hash)
|
|
62
62
|
|
|
@@ -71,10 +71,10 @@ module Solargraph
|
|
|
71
71
|
args = [
|
|
72
72
|
config['cops'] == 'all' ? '-A' : '-a',
|
|
73
73
|
'--cache', 'false',
|
|
74
|
-
'--format', formatter_class(config).name
|
|
74
|
+
'--format', formatter_class(config).name
|
|
75
75
|
]
|
|
76
76
|
|
|
77
|
-
[
|
|
77
|
+
%w[except only].each do |arg|
|
|
78
78
|
cops = cop_list(config[arg])
|
|
79
79
|
args += ["--#{arg}", cops] if cops
|
|
80
80
|
end
|
|
@@ -86,7 +86,7 @@ module Solargraph
|
|
|
86
86
|
# @param config [Hash{String => String}]
|
|
87
87
|
# @sg-ignore
|
|
88
88
|
# @return [Class<RuboCop::Formatter::BaseFormatter>]
|
|
89
|
-
def formatter_class
|
|
89
|
+
def formatter_class config
|
|
90
90
|
if self.class.const_defined?('BlankRubocopFormatter')
|
|
91
91
|
# @sg-ignore
|
|
92
92
|
BlankRubocopFormatter
|
|
@@ -98,9 +98,11 @@ module Solargraph
|
|
|
98
98
|
end
|
|
99
99
|
|
|
100
100
|
# @param value [Array, String]
|
|
101
|
+
#
|
|
101
102
|
# @return [String, nil]
|
|
102
|
-
def cop_list
|
|
103
|
+
def cop_list value
|
|
103
104
|
# @type [String]
|
|
105
|
+
# @sg-ignore Translate to something flow sensitive typing understands
|
|
104
106
|
value = value.join(',') if value.respond_to?(:join)
|
|
105
107
|
return nil if value == '' || !value.is_a?(String)
|
|
106
108
|
value
|
|
@@ -11,12 +11,11 @@ module Solargraph
|
|
|
11
11
|
contents = []
|
|
12
12
|
suggestions = host.definitions_at(params['textDocument']['uri'], line, col)
|
|
13
13
|
last_link = nil
|
|
14
|
+
# @sg-ignore Need to add nil check here
|
|
14
15
|
suggestions.each do |pin|
|
|
15
16
|
parts = []
|
|
16
17
|
this_link = host.options['enablePages'] ? pin.link_documentation : pin.text_documentation
|
|
17
|
-
if !this_link.nil? && this_link != last_link
|
|
18
|
-
parts.push this_link
|
|
19
|
-
end
|
|
18
|
+
parts.push this_link if !this_link.nil? && this_link != last_link
|
|
20
19
|
parts.push "`#{pin.detail}`" unless pin.is_a?(Pin::Namespace) || pin.detail.nil?
|
|
21
20
|
parts.push pin.documentation unless pin.documentation.nil? || pin.documentation.empty?
|
|
22
21
|
unless parts.empty?
|
|
@@ -31,6 +30,7 @@ module Solargraph
|
|
|
31
30
|
)
|
|
32
31
|
rescue FileNotFoundError => e
|
|
33
32
|
Logging.logger.warn "[#{e.class}] #{e.message}"
|
|
33
|
+
# @sg-ignore Need to add nil check here
|
|
34
34
|
Logging.logger.warn e.backtrace.join("\n")
|
|
35
35
|
set_result nil
|
|
36
36
|
end
|
|
@@ -41,8 +41,8 @@ module Solargraph
|
|
|
41
41
|
# @return [Hash{Symbol => Hash{Symbol => String}}, nil]
|
|
42
42
|
def contents_or_nil contents
|
|
43
43
|
stripped = contents
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
.map(&:strip)
|
|
45
|
+
.reject(&:empty?)
|
|
46
46
|
return nil if stripped.empty?
|
|
47
47
|
{
|
|
48
48
|
contents: {
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module Solargraph
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
module Solargraph
|
|
4
|
+
module LanguageServer
|
|
5
|
+
module Message
|
|
6
|
+
module TextDocument
|
|
7
|
+
class PrepareRename < Base
|
|
8
|
+
def process
|
|
9
|
+
line = params['position']['line']
|
|
10
|
+
col = params['position']['character']
|
|
11
|
+
set_result host.sources.find(params['textDocument']['uri']).cursor_at(Solargraph::Position.new(line,
|
|
12
|
+
col)).range.to_hash
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
9
16
|
end
|
|
10
17
|
end
|
|
11
18
|
end
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module Solargraph
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
module Solargraph
|
|
4
|
+
module LanguageServer
|
|
5
|
+
module Message
|
|
6
|
+
module TextDocument
|
|
7
|
+
class References < Base
|
|
8
|
+
def process
|
|
9
|
+
locs = host.references_from(params['textDocument']['uri'], params['position']['line'],
|
|
10
|
+
params['position']['character'])
|
|
11
|
+
result = locs.map do |loc|
|
|
12
|
+
{
|
|
13
|
+
uri: file_to_uri(loc.filename),
|
|
14
|
+
range: loc.range.to_hash
|
|
15
|
+
}
|
|
16
|
+
end
|
|
17
|
+
set_result result
|
|
18
|
+
end
|
|
19
|
+
end
|
|
12
20
|
end
|
|
13
|
-
set_result result
|
|
14
21
|
end
|
|
15
22
|
end
|
|
16
23
|
end
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module Solargraph
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
module Solargraph
|
|
4
|
+
module LanguageServer
|
|
5
|
+
module Message
|
|
6
|
+
module TextDocument
|
|
7
|
+
class Rename < Base
|
|
8
|
+
def process
|
|
9
|
+
locs = host.references_from(params['textDocument']['uri'], params['position']['line'],
|
|
10
|
+
params['position']['character'], strip: true)
|
|
11
|
+
changes = {}
|
|
12
|
+
locs.each do |loc|
|
|
13
|
+
uri = file_to_uri(loc.filename)
|
|
14
|
+
changes[uri] ||= []
|
|
15
|
+
changes[uri].push({
|
|
16
|
+
range: loc.range.to_hash,
|
|
17
|
+
newText: params['newName']
|
|
18
|
+
})
|
|
19
|
+
end
|
|
20
|
+
set_result changes: changes
|
|
21
|
+
end
|
|
22
|
+
end
|
|
15
23
|
end
|
|
16
|
-
set_result changes: changes
|
|
17
24
|
end
|
|
18
25
|
end
|
|
19
26
|
end
|
|
@@ -10,10 +10,11 @@ module Solargraph
|
|
|
10
10
|
col = params['position']['character']
|
|
11
11
|
suggestions = host.signatures_at(params['textDocument']['uri'], line, col)
|
|
12
12
|
set_result({
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
signatures: suggestions.flat_map(&:signature_help)
|
|
14
|
+
})
|
|
15
15
|
rescue FileNotFoundError => e
|
|
16
16
|
Logging.logger.warn "[#{e.class}] #{e.message}"
|
|
17
|
+
# @sg-ignore Need to add nil check here
|
|
17
18
|
Logging.logger.warn e.backtrace.join("\n")
|
|
18
19
|
set_result nil
|
|
19
20
|
end
|
|
@@ -1,24 +1,32 @@
|
|
|
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 TypeDefinition < Base
|
|
8
|
+
def process
|
|
9
|
+
@line = params['position']['line']
|
|
10
|
+
@column = params['position']['character']
|
|
11
|
+
set_result(code_location || [])
|
|
12
|
+
end
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
private
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
# @return [Array<Hash>, nil]
|
|
17
|
+
def code_location
|
|
18
|
+
suggestions = host.type_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
|
|
29
|
+
end
|
|
22
30
|
end
|
|
23
31
|
end
|
|
24
32
|
end
|