solargraph 0.58.3 → 0.59.0.dev.1
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 -38
- data/.github/workflows/rspec.yml +45 -13
- data/.github/workflows/typecheck.yml +2 -2
- data/.gitignore +0 -1
- data/.rubocop_todo.yml +27 -49
- data/CHANGELOG.md +1 -10
- data/README.md +3 -3
- data/Rakefile +1 -0
- 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 +22 -11
- data/lib/solargraph/api_map/source_to_yard.rb +13 -1
- data/lib/solargraph/api_map/store.rb +11 -8
- data/lib/solargraph/api_map.rb +105 -50
- data/lib/solargraph/bench.rb +45 -45
- data/lib/solargraph/complex_type/conformance.rb +176 -0
- data/lib/solargraph/complex_type/type_methods.rb +16 -2
- data/lib/solargraph/complex_type/unique_type.rb +170 -20
- data/lib/solargraph/complex_type.rb +119 -14
- data/lib/solargraph/convention/data_definition/data_assignment_node.rb +61 -61
- data/lib/solargraph/convention/data_definition/data_definition_node.rb +3 -1
- data/lib/solargraph/convention/data_definition.rb +4 -1
- 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 +1 -0
- data/lib/solargraph/convention/struct_definition/struct_definition_node.rb +1 -0
- data/lib/solargraph/convention/struct_definition.rb +5 -1
- data/lib/solargraph/convention.rb +78 -78
- data/lib/solargraph/converters/dd.rb +17 -17
- data/lib/solargraph/converters/dl.rb +15 -15
- data/lib/solargraph/converters/dt.rb +15 -15
- data/lib/solargraph/converters/misc.rb +1 -1
- data/lib/solargraph/diagnostics/require_not_found.rb +1 -0
- data/lib/solargraph/diagnostics/rubocop.rb +1 -0
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +2 -0
- data/lib/solargraph/diagnostics/type_check.rb +1 -0
- data/lib/solargraph/diagnostics/update_errors.rb +41 -41
- data/lib/solargraph/doc_map.rb +134 -373
- data/lib/solargraph/equality.rb +1 -1
- data/lib/solargraph/gem_pins.rb +14 -15
- data/lib/solargraph/language_server/error_codes.rb +20 -20
- data/lib/solargraph/language_server/host/diagnoser.rb +89 -89
- data/lib/solargraph/language_server/host/dispatch.rb +1 -0
- data/lib/solargraph/language_server/host/message_worker.rb +2 -1
- data/lib/solargraph/language_server/host/sources.rb +1 -0
- data/lib/solargraph/language_server/host.rb +6 -1
- data/lib/solargraph/language_server/message/base.rb +97 -97
- data/lib/solargraph/language_server/message/client/register_capability.rb +15 -15
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +60 -60
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +2 -7
- 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 +19 -19
- data/lib/solargraph/language_server/message/extended/search.rb +20 -20
- data/lib/solargraph/language_server/message/initialize.rb +191 -191
- data/lib/solargraph/language_server/message/text_document/completion.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/definition.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/document_highlight.rb +16 -16
- data/lib/solargraph/language_server/message/text_document/document_symbol.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/formatting.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/hover.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/prepare_rename.rb +11 -11
- data/lib/solargraph/language_server/message/text_document/references.rb +16 -16
- data/lib/solargraph/language_server/message/text_document/rename.rb +19 -19
- data/lib/solargraph/language_server/message/text_document/signature_help.rb +1 -0
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +2 -0
- data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +35 -35
- data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +40 -40
- data/lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb +26 -26
- data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +2 -0
- data/lib/solargraph/language_server/message.rb +94 -94
- data/lib/solargraph/language_server/request.rb +27 -27
- data/lib/solargraph/language_server/transport/data_reader.rb +74 -74
- data/lib/solargraph/language_server/uri_helpers.rb +49 -49
- data/lib/solargraph/library.rb +59 -13
- data/lib/solargraph/location.rb +9 -4
- data/lib/solargraph/logging.rb +21 -1
- data/lib/solargraph/page.rb +92 -92
- data/lib/solargraph/parser/comment_ripper.rb +7 -0
- data/lib/solargraph/parser/flow_sensitive_typing.rb +330 -102
- data/lib/solargraph/parser/node_processor/base.rb +32 -2
- data/lib/solargraph/parser/node_processor.rb +7 -6
- data/lib/solargraph/parser/parser_gem/class_methods.rb +28 -10
- data/lib/solargraph/parser/parser_gem/flawed_builder.rb +19 -19
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +31 -6
- data/lib/solargraph/parser/parser_gem/node_methods.rb +27 -7
- data/lib/solargraph/parser/parser_gem/node_processors/and_node.rb +4 -4
- data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +2 -0
- 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 -11
- data/lib/solargraph/parser/parser_gem/node_processors/def_node.rb +7 -0
- data/lib/solargraph/parser/parser_gem/node_processors/defs_node.rb +37 -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 +3 -2
- 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 +2 -2
- 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 +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +12 -7
- 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 +5 -1
- data/lib/solargraph/parser/parser_gem/node_processors.rb +4 -0
- data/lib/solargraph/parser/parser_gem.rb +12 -12
- data/lib/solargraph/parser/region.rb +9 -3
- data/lib/solargraph/parser/snippet.rb +1 -1
- data/lib/solargraph/parser.rb +23 -23
- data/lib/solargraph/pin/base.rb +53 -21
- data/lib/solargraph/pin/base_variable.rb +312 -20
- data/lib/solargraph/pin/block.rb +26 -4
- data/lib/solargraph/pin/breakable.rb +5 -1
- data/lib/solargraph/pin/callable.rb +50 -3
- data/lib/solargraph/pin/closure.rb +2 -6
- data/lib/solargraph/pin/common.rb +20 -5
- data/lib/solargraph/pin/compound_statement.rb +55 -0
- data/lib/solargraph/pin/constant.rb +45 -45
- data/lib/solargraph/pin/conversions.rb +2 -1
- data/lib/solargraph/pin/delegated_method.rb +15 -4
- data/lib/solargraph/pin/documenting.rb +1 -0
- data/lib/solargraph/pin/instance_variable.rb +5 -1
- data/lib/solargraph/pin/keyword.rb +0 -4
- data/lib/solargraph/pin/local_variable.rb +13 -57
- data/lib/solargraph/pin/method.rb +90 -42
- data/lib/solargraph/pin/method_alias.rb +8 -0
- data/lib/solargraph/pin/namespace.rb +7 -1
- data/lib/solargraph/pin/parameter.rb +76 -13
- data/lib/solargraph/pin/proxy_type.rb +2 -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 +2 -0
- data/lib/solargraph/pin/search.rb +1 -0
- data/lib/solargraph/pin/signature.rb +8 -0
- data/lib/solargraph/pin/symbol.rb +1 -1
- data/lib/solargraph/pin/until.rb +1 -1
- data/lib/solargraph/pin/while.rb +1 -1
- data/lib/solargraph/pin.rb +2 -0
- data/lib/solargraph/pin_cache.rb +477 -57
- data/lib/solargraph/position.rb +12 -26
- data/lib/solargraph/range.rb +6 -6
- data/lib/solargraph/rbs_map/conversions.rb +33 -10
- data/lib/solargraph/rbs_map/core_fills.rb +84 -84
- data/lib/solargraph/rbs_map/core_map.rb +24 -17
- data/lib/solargraph/rbs_map/stdlib_map.rb +34 -5
- data/lib/solargraph/rbs_map.rb +74 -20
- data/lib/solargraph/server_methods.rb +16 -16
- data/lib/solargraph/shell.rb +73 -39
- data/lib/solargraph/source/chain/array.rb +37 -37
- data/lib/solargraph/source/chain/call.rb +52 -17
- data/lib/solargraph/source/chain/class_variable.rb +13 -13
- data/lib/solargraph/source/chain/constant.rb +2 -0
- data/lib/solargraph/source/chain/global_variable.rb +13 -13
- data/lib/solargraph/source/chain/hash.rb +1 -0
- data/lib/solargraph/source/chain/if.rb +1 -0
- data/lib/solargraph/source/chain/instance_variable.rb +22 -1
- data/lib/solargraph/source/chain/link.rb +109 -109
- data/lib/solargraph/source/chain/literal.rb +5 -0
- data/lib/solargraph/source/chain/or.rb +9 -1
- data/lib/solargraph/source/chain/q_call.rb +11 -11
- data/lib/solargraph/source/chain/variable.rb +13 -13
- data/lib/solargraph/source/chain/z_super.rb +30 -30
- data/lib/solargraph/source/chain.rb +25 -22
- data/lib/solargraph/source/change.rb +9 -2
- data/lib/solargraph/source/cursor.rb +7 -1
- data/lib/solargraph/source/source_chainer.rb +13 -3
- data/lib/solargraph/source/updater.rb +4 -0
- data/lib/solargraph/source.rb +33 -7
- data/lib/solargraph/source_map/clip.rb +13 -2
- data/lib/solargraph/source_map/data.rb +4 -1
- data/lib/solargraph/source_map/mapper.rb +24 -1
- data/lib/solargraph/source_map.rb +14 -6
- data/lib/solargraph/type_checker/problem.rb +3 -1
- data/lib/solargraph/type_checker/rules.rb +75 -2
- data/lib/solargraph/type_checker.rb +111 -30
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +3 -1
- data/lib/solargraph/workspace/gemspecs.rb +367 -0
- data/lib/solargraph/workspace/require_paths.rb +1 -0
- data/lib/solargraph/workspace.rb +158 -16
- data/lib/solargraph/yard_map/helpers.rb +2 -1
- data/lib/solargraph/yard_map/mapper/to_method.rb +5 -1
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +1 -0
- data/lib/solargraph/yard_map/mapper.rb +5 -0
- data/lib/solargraph/yard_tags.rb +20 -20
- data/lib/solargraph/yardoc.rb +33 -23
- data/lib/solargraph.rb +24 -3
- 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 +2 -1
- metadata +12 -7
- 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,16 +1,16 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph::LanguageServer::Message::TextDocument
|
|
4
|
-
class References < Base
|
|
5
|
-
def process
|
|
6
|
-
locs = host.references_from(params['textDocument']['uri'], params['position']['line'], params['position']['character'])
|
|
7
|
-
result = locs.map do |loc|
|
|
8
|
-
{
|
|
9
|
-
uri: file_to_uri(loc.filename),
|
|
10
|
-
range: loc.range.to_hash
|
|
11
|
-
}
|
|
12
|
-
end
|
|
13
|
-
set_result result
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph::LanguageServer::Message::TextDocument
|
|
4
|
+
class References < Base
|
|
5
|
+
def process
|
|
6
|
+
locs = host.references_from(params['textDocument']['uri'], params['position']['line'], params['position']['character'])
|
|
7
|
+
result = locs.map do |loc|
|
|
8
|
+
{
|
|
9
|
+
uri: file_to_uri(loc.filename),
|
|
10
|
+
range: loc.range.to_hash
|
|
11
|
+
}
|
|
12
|
+
end
|
|
13
|
+
set_result result
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph::LanguageServer::Message::TextDocument
|
|
4
|
-
class Rename < Base
|
|
5
|
-
def process
|
|
6
|
-
locs = host.references_from(params['textDocument']['uri'], params['position']['line'], params['position']['character'], strip: true)
|
|
7
|
-
changes = {}
|
|
8
|
-
locs.each do |loc|
|
|
9
|
-
uri = file_to_uri(loc.filename)
|
|
10
|
-
changes[uri] ||= []
|
|
11
|
-
changes[uri].push({
|
|
12
|
-
range: loc.range.to_hash,
|
|
13
|
-
newText: params['newName']
|
|
14
|
-
})
|
|
15
|
-
end
|
|
16
|
-
set_result changes: changes
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph::LanguageServer::Message::TextDocument
|
|
4
|
+
class Rename < Base
|
|
5
|
+
def process
|
|
6
|
+
locs = host.references_from(params['textDocument']['uri'], params['position']['line'], params['position']['character'], strip: true)
|
|
7
|
+
changes = {}
|
|
8
|
+
locs.each do |loc|
|
|
9
|
+
uri = file_to_uri(loc.filename)
|
|
10
|
+
changes[uri] ||= []
|
|
11
|
+
changes[uri].push({
|
|
12
|
+
range: loc.range.to_hash,
|
|
13
|
+
newText: params['newName']
|
|
14
|
+
})
|
|
15
|
+
end
|
|
16
|
+
set_result changes: changes
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -13,7 +13,9 @@ module Solargraph::LanguageServer::Message::TextDocument
|
|
|
13
13
|
# @return [Array<Hash>, nil]
|
|
14
14
|
def code_location
|
|
15
15
|
suggestions = host.type_definitions_at(params['textDocument']['uri'], @line, @column)
|
|
16
|
+
# @sg-ignore Need to add nil check here
|
|
16
17
|
return nil if suggestions.empty?
|
|
18
|
+
# @sg-ignore Need to add nil check here
|
|
17
19
|
suggestions.reject { |pin| pin.best_location.nil? || pin.best_location.filename.nil? }.map do |pin|
|
|
18
20
|
{
|
|
19
21
|
uri: file_to_uri(pin.best_location.filename),
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph::LanguageServer::Message::Workspace
|
|
4
|
-
class DidChangeConfiguration < Solargraph::LanguageServer::Message::Base
|
|
5
|
-
def process
|
|
6
|
-
return unless params['settings']
|
|
7
|
-
update = params['settings']['solargraph']
|
|
8
|
-
host.configure update
|
|
9
|
-
register_from_options
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
private
|
|
13
|
-
|
|
14
|
-
# @return [void]
|
|
15
|
-
def register_from_options
|
|
16
|
-
Solargraph.logger.debug "Registering capabilities from options: #{host.options.inspect}"
|
|
17
|
-
# @type [Array<String>]
|
|
18
|
-
y = []
|
|
19
|
-
# @type [Array<String>]
|
|
20
|
-
n = []
|
|
21
|
-
(host.options['completion'] ? y : n).push('textDocument/completion')
|
|
22
|
-
(host.options['hover'] ? y : n).push('textDocument/hover', 'textDocument/signatureHelp')
|
|
23
|
-
(host.options['autoformat'] ? y : n).push('textDocument/onTypeFormatting')
|
|
24
|
-
(host.options['formatting'] ? y : n).push('textDocument/formatting')
|
|
25
|
-
(host.options['symbols'] ? y : n).push('textDocument/documentSymbol', 'workspace/symbol')
|
|
26
|
-
(host.options['definitions'] ? y : n).push('textDocument/definition')
|
|
27
|
-
(host.options['typeDefinitions'] ? y : n).push('textDocument/typeDefinition')
|
|
28
|
-
(host.options['references'] ? y : n).push('textDocument/references')
|
|
29
|
-
(host.options['folding'] ? y : n).push('textDocument/folding')
|
|
30
|
-
(host.options['highlights'] ? y : n).push('textDocument/documentHighlight')
|
|
31
|
-
host.register_capabilities y
|
|
32
|
-
host.unregister_capabilities n
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph::LanguageServer::Message::Workspace
|
|
4
|
+
class DidChangeConfiguration < Solargraph::LanguageServer::Message::Base
|
|
5
|
+
def process
|
|
6
|
+
return unless params['settings']
|
|
7
|
+
update = params['settings']['solargraph']
|
|
8
|
+
host.configure update
|
|
9
|
+
register_from_options
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
# @return [void]
|
|
15
|
+
def register_from_options
|
|
16
|
+
Solargraph.logger.debug "Registering capabilities from options: #{host.options.inspect}"
|
|
17
|
+
# @type [Array<String>]
|
|
18
|
+
y = []
|
|
19
|
+
# @type [Array<String>]
|
|
20
|
+
n = []
|
|
21
|
+
(host.options['completion'] ? y : n).push('textDocument/completion')
|
|
22
|
+
(host.options['hover'] ? y : n).push('textDocument/hover', 'textDocument/signatureHelp')
|
|
23
|
+
(host.options['autoformat'] ? y : n).push('textDocument/onTypeFormatting')
|
|
24
|
+
(host.options['formatting'] ? y : n).push('textDocument/formatting')
|
|
25
|
+
(host.options['symbols'] ? y : n).push('textDocument/documentSymbol', 'workspace/symbol')
|
|
26
|
+
(host.options['definitions'] ? y : n).push('textDocument/definition')
|
|
27
|
+
(host.options['typeDefinitions'] ? y : n).push('textDocument/typeDefinition')
|
|
28
|
+
(host.options['references'] ? y : n).push('textDocument/references')
|
|
29
|
+
(host.options['folding'] ? y : n).push('textDocument/folding')
|
|
30
|
+
(host.options['highlights'] ? y : n).push('textDocument/documentHighlight')
|
|
31
|
+
host.register_capabilities y
|
|
32
|
+
host.unregister_capabilities n
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph::LanguageServer::Message::Workspace
|
|
4
|
-
class DidChangeWatchedFiles < Solargraph::LanguageServer::Message::Base
|
|
5
|
-
CREATED = 1
|
|
6
|
-
CHANGED = 2
|
|
7
|
-
DELETED = 3
|
|
8
|
-
|
|
9
|
-
include Solargraph::LanguageServer::UriHelpers
|
|
10
|
-
|
|
11
|
-
def process
|
|
12
|
-
need_catalog = false
|
|
13
|
-
to_create = []
|
|
14
|
-
to_delete = []
|
|
15
|
-
|
|
16
|
-
# @param change [Hash]
|
|
17
|
-
params['changes'].each do |change|
|
|
18
|
-
if change['type'] == CREATED
|
|
19
|
-
to_create << change['uri']
|
|
20
|
-
need_catalog = true
|
|
21
|
-
elsif change['type'] == CHANGED
|
|
22
|
-
next if host.open?(change['uri'])
|
|
23
|
-
to_create << change['uri']
|
|
24
|
-
need_catalog = true
|
|
25
|
-
elsif change['type'] == DELETED
|
|
26
|
-
to_delete << change['uri']
|
|
27
|
-
need_catalog = true
|
|
28
|
-
else
|
|
29
|
-
set_error Solargraph::LanguageServer::ErrorCodes::INVALID_PARAMS, "Unknown change type ##{change['type']} for #{uri_to_file(change['uri'])}"
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
host.create *to_create
|
|
34
|
-
host.delete *to_delete
|
|
35
|
-
|
|
36
|
-
# Force host to catalog libraries after file changes (see castwide/solargraph#139)
|
|
37
|
-
host.catalog if need_catalog
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph::LanguageServer::Message::Workspace
|
|
4
|
+
class DidChangeWatchedFiles < Solargraph::LanguageServer::Message::Base
|
|
5
|
+
CREATED = 1
|
|
6
|
+
CHANGED = 2
|
|
7
|
+
DELETED = 3
|
|
8
|
+
|
|
9
|
+
include Solargraph::LanguageServer::UriHelpers
|
|
10
|
+
|
|
11
|
+
def process
|
|
12
|
+
need_catalog = false
|
|
13
|
+
to_create = []
|
|
14
|
+
to_delete = []
|
|
15
|
+
|
|
16
|
+
# @param change [Hash]
|
|
17
|
+
params['changes'].each do |change|
|
|
18
|
+
if change['type'] == CREATED
|
|
19
|
+
to_create << change['uri']
|
|
20
|
+
need_catalog = true
|
|
21
|
+
elsif change['type'] == CHANGED
|
|
22
|
+
next if host.open?(change['uri'])
|
|
23
|
+
to_create << change['uri']
|
|
24
|
+
need_catalog = true
|
|
25
|
+
elsif change['type'] == DELETED
|
|
26
|
+
to_delete << change['uri']
|
|
27
|
+
need_catalog = true
|
|
28
|
+
else
|
|
29
|
+
set_error Solargraph::LanguageServer::ErrorCodes::INVALID_PARAMS, "Unknown change type ##{change['type']} for #{uri_to_file(change['uri'])}"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
host.create *to_create
|
|
34
|
+
host.delete *to_delete
|
|
35
|
+
|
|
36
|
+
# Force host to catalog libraries after file changes (see castwide/solargraph#139)
|
|
37
|
+
host.catalog if need_catalog
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph::LanguageServer::Message::Workspace
|
|
4
|
-
class DidChangeWorkspaceFolders < Solargraph::LanguageServer::Message::Base
|
|
5
|
-
def process
|
|
6
|
-
add_folders
|
|
7
|
-
remove_folders
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
private
|
|
11
|
-
|
|
12
|
-
# @return [void]
|
|
13
|
-
def add_folders
|
|
14
|
-
return unless params['event'] && params['event']['added']
|
|
15
|
-
host.prepare_folders params['event']['added']
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# @return [void]
|
|
19
|
-
def remove_folders
|
|
20
|
-
return unless params['event'] && params['event']['removed']
|
|
21
|
-
params['event']['removed'].each do |folder|
|
|
22
|
-
host.remove_folders params['event']['removed']
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph::LanguageServer::Message::Workspace
|
|
4
|
+
class DidChangeWorkspaceFolders < Solargraph::LanguageServer::Message::Base
|
|
5
|
+
def process
|
|
6
|
+
add_folders
|
|
7
|
+
remove_folders
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
# @return [void]
|
|
13
|
+
def add_folders
|
|
14
|
+
return unless params['event'] && params['event']['added']
|
|
15
|
+
host.prepare_folders params['event']['added']
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# @return [void]
|
|
19
|
+
def remove_folders
|
|
20
|
+
return unless params['event'] && params['event']['removed']
|
|
21
|
+
params['event']['removed'].each do |folder|
|
|
22
|
+
host.remove_folders params['event']['removed']
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -6,6 +6,7 @@ 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
|
+
# @sg-ignore Need to add nil check here
|
|
9
10
|
uri = file_to_uri(pin.best_location.filename)
|
|
10
11
|
{
|
|
11
12
|
name: pin.path,
|
|
@@ -13,6 +14,7 @@ class Solargraph::LanguageServer::Message::Workspace::WorkspaceSymbol < Solargra
|
|
|
13
14
|
kind: pin.symbol_kind,
|
|
14
15
|
location: {
|
|
15
16
|
uri: uri,
|
|
17
|
+
# @sg-ignore Need to add nil check here
|
|
16
18
|
range: pin.best_location.range.to_hash
|
|
17
19
|
},
|
|
18
20
|
deprecated: pin.deprecated?
|
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'solargraph'
|
|
4
|
-
|
|
5
|
-
module Solargraph
|
|
6
|
-
module LanguageServer
|
|
7
|
-
# The Message namespace contains classes that implement language server
|
|
8
|
-
# protocol methods.
|
|
9
|
-
#
|
|
10
|
-
module Message
|
|
11
|
-
autoload :Base, 'solargraph/language_server/message/base'
|
|
12
|
-
autoload :Initialize, 'solargraph/language_server/message/initialize'
|
|
13
|
-
autoload :Initialized, 'solargraph/language_server/message/initialized'
|
|
14
|
-
autoload :TextDocument, 'solargraph/language_server/message/text_document'
|
|
15
|
-
autoload :CompletionItem, 'solargraph/language_server/message/completion_item'
|
|
16
|
-
autoload :CancelRequest, 'solargraph/language_server/message/cancel_request'
|
|
17
|
-
autoload :MethodNotFound, 'solargraph/language_server/message/method_not_found'
|
|
18
|
-
autoload :MethodNotImplemented, 'solargraph/language_server/message/method_not_implemented'
|
|
19
|
-
autoload :Extended, 'solargraph/language_server/message/extended'
|
|
20
|
-
autoload :Shutdown, 'solargraph/language_server/message/shutdown'
|
|
21
|
-
autoload :ExitNotification, 'solargraph/language_server/message/exit_notification'
|
|
22
|
-
autoload :Workspace, 'solargraph/language_server/message/workspace'
|
|
23
|
-
|
|
24
|
-
class << self
|
|
25
|
-
# Register a method name and message for handling by the language
|
|
26
|
-
# server.
|
|
27
|
-
#
|
|
28
|
-
# @example
|
|
29
|
-
# Message.register 'initialize', Solargraph::Message::Initialize
|
|
30
|
-
#
|
|
31
|
-
# @param path [String] The method name
|
|
32
|
-
# @param message_class [Class<Message::Base>] The message class
|
|
33
|
-
# @return [void]
|
|
34
|
-
def register path, message_class
|
|
35
|
-
method_map[path] = message_class
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
# @param path [String]
|
|
39
|
-
# @return [Class<Solargraph::LanguageServer::Message::Base>]
|
|
40
|
-
def select path
|
|
41
|
-
if method_map.has_key?(path)
|
|
42
|
-
method_map[path]
|
|
43
|
-
elsif path.start_with?('$/')
|
|
44
|
-
MethodNotImplemented
|
|
45
|
-
else
|
|
46
|
-
MethodNotFound
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
private
|
|
51
|
-
|
|
52
|
-
# @return [Hash{String => Class<Message::Base>}]
|
|
53
|
-
def method_map
|
|
54
|
-
@method_map ||= {}
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
register 'initialize', Initialize
|
|
59
|
-
register 'initialized', Initialized
|
|
60
|
-
register 'textDocument/completion', TextDocument::Completion
|
|
61
|
-
register 'completionItem/resolve', CompletionItem::Resolve
|
|
62
|
-
register 'textDocument/signatureHelp', TextDocument::SignatureHelp
|
|
63
|
-
register 'textDocument/didOpen', TextDocument::DidOpen
|
|
64
|
-
register 'textDocument/didChange', TextDocument::DidChange
|
|
65
|
-
register 'textDocument/didSave', TextDocument::DidSave
|
|
66
|
-
register 'textDocument/didClose', TextDocument::DidClose
|
|
67
|
-
register 'textDocument/hover', TextDocument::Hover
|
|
68
|
-
register 'textDocument/definition', TextDocument::Definition
|
|
69
|
-
register 'textDocument/typeDefinition', TextDocument::TypeDefinition
|
|
70
|
-
register 'textDocument/formatting', TextDocument::Formatting
|
|
71
|
-
register 'textDocument/onTypeFormatting', TextDocument::OnTypeFormatting
|
|
72
|
-
register 'textDocument/documentSymbol', TextDocument::DocumentSymbol
|
|
73
|
-
register 'textDocument/references', TextDocument::References
|
|
74
|
-
register 'textDocument/rename', TextDocument::Rename
|
|
75
|
-
register 'textDocument/prepareRename', TextDocument::PrepareRename
|
|
76
|
-
register 'textDocument/foldingRange', TextDocument::FoldingRange
|
|
77
|
-
# register 'textDocument/codeAction', TextDocument::CodeAction
|
|
78
|
-
register 'textDocument/documentHighlight', TextDocument::DocumentHighlight
|
|
79
|
-
register 'workspace/didChangeWatchedFiles', Workspace::DidChangeWatchedFiles
|
|
80
|
-
register 'workspace/didChangeConfiguration', Workspace::DidChangeConfiguration
|
|
81
|
-
register 'workspace/didChangeWorkspaceFolders', Workspace::DidChangeWorkspaceFolders
|
|
82
|
-
register 'workspace/symbol', Workspace::WorkspaceSymbol
|
|
83
|
-
register '$/cancelRequest', CancelRequest
|
|
84
|
-
register '$/solargraph/document', Extended::Document
|
|
85
|
-
register '$/solargraph/search', Extended::Search
|
|
86
|
-
register '$/solargraph/checkGemVersion', Extended::CheckGemVersion
|
|
87
|
-
register '$/solargraph/documentGems', Extended::DocumentGems
|
|
88
|
-
register '$/solargraph/downloadCore', Extended::DownloadCore
|
|
89
|
-
register '$/solargraph/environment', Extended::Environment
|
|
90
|
-
register 'shutdown', Shutdown
|
|
91
|
-
register 'exit', ExitNotification
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'solargraph'
|
|
4
|
+
|
|
5
|
+
module Solargraph
|
|
6
|
+
module LanguageServer
|
|
7
|
+
# The Message namespace contains classes that implement language server
|
|
8
|
+
# protocol methods.
|
|
9
|
+
#
|
|
10
|
+
module Message
|
|
11
|
+
autoload :Base, 'solargraph/language_server/message/base'
|
|
12
|
+
autoload :Initialize, 'solargraph/language_server/message/initialize'
|
|
13
|
+
autoload :Initialized, 'solargraph/language_server/message/initialized'
|
|
14
|
+
autoload :TextDocument, 'solargraph/language_server/message/text_document'
|
|
15
|
+
autoload :CompletionItem, 'solargraph/language_server/message/completion_item'
|
|
16
|
+
autoload :CancelRequest, 'solargraph/language_server/message/cancel_request'
|
|
17
|
+
autoload :MethodNotFound, 'solargraph/language_server/message/method_not_found'
|
|
18
|
+
autoload :MethodNotImplemented, 'solargraph/language_server/message/method_not_implemented'
|
|
19
|
+
autoload :Extended, 'solargraph/language_server/message/extended'
|
|
20
|
+
autoload :Shutdown, 'solargraph/language_server/message/shutdown'
|
|
21
|
+
autoload :ExitNotification, 'solargraph/language_server/message/exit_notification'
|
|
22
|
+
autoload :Workspace, 'solargraph/language_server/message/workspace'
|
|
23
|
+
|
|
24
|
+
class << self
|
|
25
|
+
# Register a method name and message for handling by the language
|
|
26
|
+
# server.
|
|
27
|
+
#
|
|
28
|
+
# @example
|
|
29
|
+
# Message.register 'initialize', Solargraph::Message::Initialize
|
|
30
|
+
#
|
|
31
|
+
# @param path [String] The method name
|
|
32
|
+
# @param message_class [Class<Message::Base>] The message class
|
|
33
|
+
# @return [void]
|
|
34
|
+
def register path, message_class
|
|
35
|
+
method_map[path] = message_class
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# @param path [String]
|
|
39
|
+
# @return [Class<Solargraph::LanguageServer::Message::Base>]
|
|
40
|
+
def select path
|
|
41
|
+
if method_map.has_key?(path)
|
|
42
|
+
method_map[path]
|
|
43
|
+
elsif path.start_with?('$/')
|
|
44
|
+
MethodNotImplemented
|
|
45
|
+
else
|
|
46
|
+
MethodNotFound
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
|
|
52
|
+
# @return [Hash{String => Class<Message::Base>}]
|
|
53
|
+
def method_map
|
|
54
|
+
@method_map ||= {}
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
register 'initialize', Initialize
|
|
59
|
+
register 'initialized', Initialized
|
|
60
|
+
register 'textDocument/completion', TextDocument::Completion
|
|
61
|
+
register 'completionItem/resolve', CompletionItem::Resolve
|
|
62
|
+
register 'textDocument/signatureHelp', TextDocument::SignatureHelp
|
|
63
|
+
register 'textDocument/didOpen', TextDocument::DidOpen
|
|
64
|
+
register 'textDocument/didChange', TextDocument::DidChange
|
|
65
|
+
register 'textDocument/didSave', TextDocument::DidSave
|
|
66
|
+
register 'textDocument/didClose', TextDocument::DidClose
|
|
67
|
+
register 'textDocument/hover', TextDocument::Hover
|
|
68
|
+
register 'textDocument/definition', TextDocument::Definition
|
|
69
|
+
register 'textDocument/typeDefinition', TextDocument::TypeDefinition
|
|
70
|
+
register 'textDocument/formatting', TextDocument::Formatting
|
|
71
|
+
register 'textDocument/onTypeFormatting', TextDocument::OnTypeFormatting
|
|
72
|
+
register 'textDocument/documentSymbol', TextDocument::DocumentSymbol
|
|
73
|
+
register 'textDocument/references', TextDocument::References
|
|
74
|
+
register 'textDocument/rename', TextDocument::Rename
|
|
75
|
+
register 'textDocument/prepareRename', TextDocument::PrepareRename
|
|
76
|
+
register 'textDocument/foldingRange', TextDocument::FoldingRange
|
|
77
|
+
# register 'textDocument/codeAction', TextDocument::CodeAction
|
|
78
|
+
register 'textDocument/documentHighlight', TextDocument::DocumentHighlight
|
|
79
|
+
register 'workspace/didChangeWatchedFiles', Workspace::DidChangeWatchedFiles
|
|
80
|
+
register 'workspace/didChangeConfiguration', Workspace::DidChangeConfiguration
|
|
81
|
+
register 'workspace/didChangeWorkspaceFolders', Workspace::DidChangeWorkspaceFolders
|
|
82
|
+
register 'workspace/symbol', Workspace::WorkspaceSymbol
|
|
83
|
+
register '$/cancelRequest', CancelRequest
|
|
84
|
+
register '$/solargraph/document', Extended::Document
|
|
85
|
+
register '$/solargraph/search', Extended::Search
|
|
86
|
+
register '$/solargraph/checkGemVersion', Extended::CheckGemVersion
|
|
87
|
+
register '$/solargraph/documentGems', Extended::DocumentGems
|
|
88
|
+
register '$/solargraph/downloadCore', Extended::DownloadCore
|
|
89
|
+
register '$/solargraph/environment', Extended::Environment
|
|
90
|
+
register 'shutdown', Shutdown
|
|
91
|
+
register 'exit', ExitNotification
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module LanguageServer
|
|
5
|
-
class Request
|
|
6
|
-
# @param id [Integer]
|
|
7
|
-
# @param &block The block that processes the client's response
|
|
8
|
-
def initialize id, &block
|
|
9
|
-
@id = id
|
|
10
|
-
@block = block
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
# @param result [Object]
|
|
14
|
-
# @generic T
|
|
15
|
-
# @yieldreturn [generic<T>]
|
|
16
|
-
# @return [generic<T>, nil]
|
|
17
|
-
def process result
|
|
18
|
-
@block.call(result) unless @block.nil?
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# @return [void]
|
|
22
|
-
def send_response
|
|
23
|
-
# noop
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module LanguageServer
|
|
5
|
+
class Request
|
|
6
|
+
# @param id [Integer]
|
|
7
|
+
# @param &block The block that processes the client's response
|
|
8
|
+
def initialize id, &block
|
|
9
|
+
@id = id
|
|
10
|
+
@block = block
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# @param result [Object]
|
|
14
|
+
# @generic T
|
|
15
|
+
# @yieldreturn [generic<T>]
|
|
16
|
+
# @return [generic<T>, nil]
|
|
17
|
+
def process result
|
|
18
|
+
@block.call(result) unless @block.nil?
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# @return [void]
|
|
22
|
+
def send_response
|
|
23
|
+
# noop
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|