solargraph 0.32.1 → 0.32.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.rubocop.yml +6 -0
- data/.travis.yml +25 -0
- data/EXAMPLES.md +76 -0
- data/Gemfile +3 -0
- data/LANGUAGE_SERVER.md +51 -0
- data/LICENSE +21 -0
- data/OVERVIEW.md +37 -0
- data/README.md +106 -0
- data/Rakefile +14 -0
- data/SERVER.md +95 -0
- data/bin/solargraph +0 -0
- data/bin/solargraph-runtime +5 -5
- data/lib/solargraph.rb +54 -54
- data/lib/solargraph/api_map.rb +659 -659
- data/lib/solargraph/api_map/cache.rb +49 -49
- data/lib/solargraph/api_map/source_to_yard.rb +67 -67
- data/lib/solargraph/api_map/store.rb +201 -201
- data/lib/solargraph/bundle.rb +24 -24
- data/lib/solargraph/complex_type.rb +150 -150
- data/lib/solargraph/complex_type/type_methods.rb +124 -124
- data/lib/solargraph/complex_type/unique_type.rb +44 -44
- data/lib/solargraph/core_fills.rb +37 -37
- data/lib/solargraph/diagnostics.rb +52 -52
- data/lib/solargraph/diagnostics/base.rb +20 -20
- data/lib/solargraph/diagnostics/require_not_found.rb +28 -28
- data/lib/solargraph/diagnostics/rubocop.rb +98 -98
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +46 -46
- data/lib/solargraph/diagnostics/type_not_defined.rb +108 -108
- data/lib/solargraph/diagnostics/update_errors.rb +38 -38
- data/lib/solargraph/language_server/completion_item_kinds.rb +33 -33
- data/lib/solargraph/language_server/error_codes.rb +18 -18
- data/lib/solargraph/language_server/host.rb +684 -681
- data/lib/solargraph/language_server/host/cataloger.rb +54 -79
- data/lib/solargraph/language_server/host/diagnoser.rb +80 -80
- data/lib/solargraph/language_server/host/dispatch.rb +112 -113
- data/lib/solargraph/language_server/host/sources.rb +138 -138
- data/lib/solargraph/language_server/message.rb +90 -90
- data/lib/solargraph/language_server/message/base.rb +83 -83
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +40 -40
- data/lib/solargraph/language_server/message/exit_notification.rb +11 -11
- data/lib/solargraph/language_server/message/extended.rb +19 -19
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +86 -86
- data/lib/solargraph/language_server/message/extended/document.rb +18 -18
- data/lib/solargraph/language_server/message/extended/document_gems.rb +30 -30
- data/lib/solargraph/language_server/message/extended/environment.rb +20 -20
- data/lib/solargraph/language_server/message/extended/search.rb +18 -18
- data/lib/solargraph/language_server/message/initialize.rb +141 -141
- data/lib/solargraph/language_server/message/initialized.rb +23 -23
- data/lib/solargraph/language_server/message/shutdown.rb +11 -11
- data/lib/solargraph/language_server/message/text_document.rb +25 -25
- data/lib/solargraph/language_server/message/text_document/completion.rb +51 -51
- data/lib/solargraph/language_server/message/text_document/definition.rb +18 -18
- data/lib/solargraph/language_server/message/text_document/did_change.rb +13 -13
- data/lib/solargraph/language_server/message/text_document/document_symbol.rb +21 -21
- data/lib/solargraph/language_server/message/text_document/folding_range.rb +24 -24
- data/lib/solargraph/language_server/message/text_document/formatting.rb +50 -50
- data/lib/solargraph/language_server/message/text_document/hover.rb +31 -31
- data/lib/solargraph/language_server/message/text_document/on_type_formatting.rb +32 -32
- data/lib/solargraph/language_server/message/text_document/prepare_rename.rb +9 -9
- data/lib/solargraph/language_server/message/text_document/references.rb +14 -14
- data/lib/solargraph/language_server/message/text_document/rename.rb +17 -17
- data/lib/solargraph/language_server/message/text_document/signature_help.rb +19 -19
- data/lib/solargraph/language_server/message/workspace.rb +12 -12
- data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +29 -29
- data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +29 -27
- data/lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb +24 -24
- data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +21 -21
- data/lib/solargraph/language_server/request.rb +22 -22
- data/lib/solargraph/language_server/symbol_kinds.rb +34 -34
- data/lib/solargraph/language_server/transport.rb +11 -11
- data/lib/solargraph/language_server/transport/adapter.rb +60 -60
- data/lib/solargraph/language_server/transport/data_reader.rb +66 -66
- data/lib/solargraph/language_server/uri_helpers.rb +25 -25
- data/lib/solargraph/library.rb +421 -419
- data/lib/solargraph/live_map.rb +126 -126
- data/lib/solargraph/live_map/cache.rb +38 -38
- data/lib/solargraph/location.rb +31 -31
- data/lib/solargraph/logging.rb +25 -25
- data/lib/solargraph/page.rb +68 -68
- data/lib/solargraph/pin.rb +50 -50
- data/lib/solargraph/pin/attribute.rb +41 -41
- data/lib/solargraph/pin/base.rb +280 -280
- data/lib/solargraph/pin/base_method.rb +76 -76
- data/lib/solargraph/pin/base_variable.rb +72 -72
- data/lib/solargraph/pin/block.rb +32 -32
- data/lib/solargraph/pin/block_parameter.rb +103 -103
- data/lib/solargraph/pin/class_variable.rb +9 -9
- data/lib/solargraph/pin/constant.rb +30 -30
- data/lib/solargraph/pin/conversions.rb +79 -79
- data/lib/solargraph/pin/documenting.rb +41 -41
- data/lib/solargraph/pin/duck_method.rb +14 -14
- data/lib/solargraph/pin/global_variable.rb +9 -9
- data/lib/solargraph/pin/instance_variable.rb +9 -9
- data/lib/solargraph/pin/keyword.rb +17 -17
- data/lib/solargraph/pin/local_variable.rb +23 -23
- data/lib/solargraph/pin/localized.rb +22 -22
- data/lib/solargraph/pin/method.rb +126 -126
- data/lib/solargraph/pin/method_alias.rb +30 -30
- data/lib/solargraph/pin/method_parameter.rb +40 -40
- data/lib/solargraph/pin/namespace.rb +54 -54
- data/lib/solargraph/pin/plugin/method.rb +25 -25
- data/lib/solargraph/pin/proxy_type.rb +35 -35
- data/lib/solargraph/pin/reference.rb +22 -22
- data/lib/solargraph/pin/reference/extend.rb +11 -11
- data/lib/solargraph/pin/reference/include.rb +11 -11
- data/lib/solargraph/pin/reference/require.rb +15 -15
- data/lib/solargraph/pin/reference/superclass.rb +11 -11
- data/lib/solargraph/pin/symbol.rb +44 -44
- data/lib/solargraph/pin/yard_pin.rb +10 -10
- data/lib/solargraph/pin/yard_pin/constant.rb +14 -14
- data/lib/solargraph/pin/yard_pin/method.rb +35 -35
- data/lib/solargraph/pin/yard_pin/namespace.rb +19 -19
- data/lib/solargraph/pin/yard_pin/yard_mixin.rb +14 -14
- data/lib/solargraph/plugin.rb +8 -8
- data/lib/solargraph/plugin/base.rb +41 -41
- data/lib/solargraph/plugin/canceler.rb +11 -11
- data/lib/solargraph/plugin/process.rb +172 -172
- data/lib/solargraph/plugin/runtime.rb +134 -134
- data/lib/solargraph/position.rb +110 -110
- data/lib/solargraph/range.rb +83 -83
- data/lib/solargraph/server_methods.rb +14 -14
- data/lib/solargraph/shell.rb +102 -102
- data/lib/solargraph/source.rb +521 -521
- data/lib/solargraph/source/chain.rb +120 -120
- data/lib/solargraph/source/chain/call.rb +107 -107
- data/lib/solargraph/source/chain/class_variable.rb +11 -11
- data/lib/solargraph/source/chain/constant.rb +30 -30
- data/lib/solargraph/source/chain/global_variable.rb +11 -11
- data/lib/solargraph/source/chain/head.rb +33 -33
- data/lib/solargraph/source/chain/instance_variable.rb +11 -11
- data/lib/solargraph/source/chain/link.rb +33 -33
- data/lib/solargraph/source/chain/literal.rb +21 -21
- data/lib/solargraph/source/chain/variable.rb +11 -11
- data/lib/solargraph/source/change.rb +77 -77
- data/lib/solargraph/source/cursor.rb +157 -157
- data/lib/solargraph/source/node_chainer.rb +96 -96
- data/lib/solargraph/source/node_methods.rb +225 -225
- data/lib/solargraph/source/source_chainer.rb +183 -183
- data/lib/solargraph/source_map.rb +169 -169
- data/lib/solargraph/source_map/clip.rb +145 -145
- data/lib/solargraph/source_map/completion.rb +21 -21
- data/lib/solargraph/source_map/mapper.rb +149 -149
- data/lib/solargraph/source_map/node_processor.rb +78 -78
- data/lib/solargraph/source_map/node_processor/alias_node.rb +19 -19
- data/lib/solargraph/source_map/node_processor/args_node.rb +28 -28
- data/lib/solargraph/source_map/node_processor/base.rb +68 -68
- data/lib/solargraph/source_map/node_processor/begin_node.rb +11 -11
- data/lib/solargraph/source_map/node_processor/block_node.rb +14 -14
- data/lib/solargraph/source_map/node_processor/casgn_node.rb +14 -14
- data/lib/solargraph/source_map/node_processor/cvasgn_node.rb +14 -14
- data/lib/solargraph/source_map/node_processor/def_node.rb +54 -54
- data/lib/solargraph/source_map/node_processor/defs_node.rb +21 -21
- data/lib/solargraph/source_map/node_processor/gvasgn_node.rb +12 -12
- data/lib/solargraph/source_map/node_processor/ivasgn_node.rb +18 -18
- data/lib/solargraph/source_map/node_processor/lvasgn_node.rb +16 -16
- data/lib/solargraph/source_map/node_processor/namespace_node.rb +26 -26
- data/lib/solargraph/source_map/node_processor/orasgn_node.rb +12 -12
- data/lib/solargraph/source_map/node_processor/sclass_node.rb +11 -11
- data/lib/solargraph/source_map/node_processor/send_node.rb +162 -162
- data/lib/solargraph/source_map/node_processor/sym_node.rb +11 -11
- data/lib/solargraph/source_map/region.rb +58 -58
- data/lib/solargraph/version.rb +3 -3
- data/lib/solargraph/views/environment.erb +53 -53
- data/lib/solargraph/workspace.rb +183 -183
- data/lib/solargraph/workspace/config.rb +170 -170
- data/lib/solargraph/yard_map.rb +298 -298
- data/lib/solargraph/yard_map/cache.rb +17 -17
- data/lib/solargraph/yard_map/core_docs.rb +163 -163
- data/lib/solargraph/yard_map/core_gen.rb +76 -76
- data/lib/yard-coregen.rb +16 -16
- data/lib/yard-solargraph.rb +18 -18
- data/solargraph.gemspec +37 -0
- data/travis-bundler.rb +10 -0
- metadata +19 -6
@@ -1,138 +1,138 @@
|
|
1
|
-
require 'observer'
|
2
|
-
|
3
|
-
module Solargraph
|
4
|
-
module LanguageServer
|
5
|
-
class Host
|
6
|
-
# A Host class for managing sources.
|
7
|
-
#
|
8
|
-
class Sources
|
9
|
-
include Observable
|
10
|
-
include UriHelpers
|
11
|
-
|
12
|
-
def initialize
|
13
|
-
@stopped = true
|
14
|
-
end
|
15
|
-
|
16
|
-
def stopped?
|
17
|
-
@stopped
|
18
|
-
end
|
19
|
-
|
20
|
-
# @return [void]
|
21
|
-
def start
|
22
|
-
return unless @stopped
|
23
|
-
@stopped = false
|
24
|
-
Thread.new do
|
25
|
-
until stopped?
|
26
|
-
tick
|
27
|
-
sleep 0.25 if queue.empty?
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# @return [void]
|
33
|
-
def tick
|
34
|
-
return if queue.empty?
|
35
|
-
uri = mutex.synchronize { queue.shift }
|
36
|
-
return if queue.include?(uri)
|
37
|
-
mutex.synchronize do
|
38
|
-
nxt = open_source_hash[uri].finish_synchronize
|
39
|
-
open_source_hash[uri] = nxt
|
40
|
-
changed
|
41
|
-
notify_observers uri
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
# @return [void]
|
46
|
-
def stop
|
47
|
-
@stopped = true
|
48
|
-
end
|
49
|
-
|
50
|
-
# Open a source.
|
51
|
-
#
|
52
|
-
# @param uri [String]
|
53
|
-
# @param text [String]
|
54
|
-
# @param version [Integer]
|
55
|
-
# @return [Source]
|
56
|
-
def open uri, text, version
|
57
|
-
filename = uri_to_file(uri)
|
58
|
-
source = Solargraph::Source.new(text, filename, version)
|
59
|
-
open_source_hash[uri] = source
|
60
|
-
end
|
61
|
-
|
62
|
-
# Update an existing source.
|
63
|
-
#
|
64
|
-
# @raise [FileNotFoundError] if the URI does not match an open source.
|
65
|
-
#
|
66
|
-
# @param uri [String]
|
67
|
-
# @param updater [Source::Updater]
|
68
|
-
# @return [Source]
|
69
|
-
def update uri, updater
|
70
|
-
src = find(uri)
|
71
|
-
mutex.synchronize { open_source_hash[uri] = src.synchronize(updater) }
|
72
|
-
changed
|
73
|
-
notify_observers uri
|
74
|
-
end
|
75
|
-
|
76
|
-
# @param uri [String]
|
77
|
-
# @param updater [Source::Updater]
|
78
|
-
# @return [Thread]
|
79
|
-
def async_update uri, updater
|
80
|
-
src = find(uri)
|
81
|
-
mutex.synchronize { open_source_hash[uri] = src.start_synchronize(updater) }
|
82
|
-
mutex.synchronize { queue.push uri }
|
83
|
-
changed
|
84
|
-
notify_observers uri
|
85
|
-
end
|
86
|
-
|
87
|
-
# Find the source with the given URI.
|
88
|
-
#
|
89
|
-
# @raise [FileNotFoundError] if the URI does not match an open source.
|
90
|
-
#
|
91
|
-
# @param uri [String]
|
92
|
-
# @return [Source]
|
93
|
-
def find uri
|
94
|
-
open_source_hash[uri] || raise(Solargraph::FileNotFoundError, "Host could not find #{uri}")
|
95
|
-
end
|
96
|
-
|
97
|
-
# Close the source with the given URI.
|
98
|
-
#
|
99
|
-
# @param uri [String]
|
100
|
-
# @return [void]
|
101
|
-
def close uri
|
102
|
-
open_source_hash.delete uri
|
103
|
-
end
|
104
|
-
|
105
|
-
# True if a source with given URI is currently open.
|
106
|
-
# @param uri [String]
|
107
|
-
# @return [Boolean]
|
108
|
-
def include? uri
|
109
|
-
open_source_hash.key? uri
|
110
|
-
end
|
111
|
-
|
112
|
-
# @return [void]
|
113
|
-
def clear
|
114
|
-
open_source_hash.clear
|
115
|
-
end
|
116
|
-
|
117
|
-
private
|
118
|
-
|
119
|
-
# @return [Array<Source>]
|
120
|
-
def open_source_hash
|
121
|
-
@open_source_hash ||= {}
|
122
|
-
end
|
123
|
-
|
124
|
-
# @return [Mutex]
|
125
|
-
def mutex
|
126
|
-
@mutex ||= Mutex.new
|
127
|
-
end
|
128
|
-
|
129
|
-
# An array of source URIs that are waiting to finish synchronizing.
|
130
|
-
#
|
131
|
-
# @return [Array<String>]
|
132
|
-
def queue
|
133
|
-
@queue ||= []
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
1
|
+
require 'observer'
|
2
|
+
|
3
|
+
module Solargraph
|
4
|
+
module LanguageServer
|
5
|
+
class Host
|
6
|
+
# A Host class for managing sources.
|
7
|
+
#
|
8
|
+
class Sources
|
9
|
+
include Observable
|
10
|
+
include UriHelpers
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@stopped = true
|
14
|
+
end
|
15
|
+
|
16
|
+
def stopped?
|
17
|
+
@stopped
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [void]
|
21
|
+
def start
|
22
|
+
return unless @stopped
|
23
|
+
@stopped = false
|
24
|
+
Thread.new do
|
25
|
+
until stopped?
|
26
|
+
tick
|
27
|
+
sleep 0.25 if queue.empty?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [void]
|
33
|
+
def tick
|
34
|
+
return if queue.empty?
|
35
|
+
uri = mutex.synchronize { queue.shift }
|
36
|
+
return if queue.include?(uri)
|
37
|
+
mutex.synchronize do
|
38
|
+
nxt = open_source_hash[uri].finish_synchronize
|
39
|
+
open_source_hash[uri] = nxt
|
40
|
+
changed
|
41
|
+
notify_observers uri
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# @return [void]
|
46
|
+
def stop
|
47
|
+
@stopped = true
|
48
|
+
end
|
49
|
+
|
50
|
+
# Open a source.
|
51
|
+
#
|
52
|
+
# @param uri [String]
|
53
|
+
# @param text [String]
|
54
|
+
# @param version [Integer]
|
55
|
+
# @return [Source]
|
56
|
+
def open uri, text, version
|
57
|
+
filename = uri_to_file(uri)
|
58
|
+
source = Solargraph::Source.new(text, filename, version)
|
59
|
+
open_source_hash[uri] = source
|
60
|
+
end
|
61
|
+
|
62
|
+
# Update an existing source.
|
63
|
+
#
|
64
|
+
# @raise [FileNotFoundError] if the URI does not match an open source.
|
65
|
+
#
|
66
|
+
# @param uri [String]
|
67
|
+
# @param updater [Source::Updater]
|
68
|
+
# @return [Source]
|
69
|
+
def update uri, updater
|
70
|
+
src = find(uri)
|
71
|
+
mutex.synchronize { open_source_hash[uri] = src.synchronize(updater) }
|
72
|
+
changed
|
73
|
+
notify_observers uri
|
74
|
+
end
|
75
|
+
|
76
|
+
# @param uri [String]
|
77
|
+
# @param updater [Source::Updater]
|
78
|
+
# @return [Thread]
|
79
|
+
def async_update uri, updater
|
80
|
+
src = find(uri)
|
81
|
+
mutex.synchronize { open_source_hash[uri] = src.start_synchronize(updater) }
|
82
|
+
mutex.synchronize { queue.push uri }
|
83
|
+
changed
|
84
|
+
notify_observers uri
|
85
|
+
end
|
86
|
+
|
87
|
+
# Find the source with the given URI.
|
88
|
+
#
|
89
|
+
# @raise [FileNotFoundError] if the URI does not match an open source.
|
90
|
+
#
|
91
|
+
# @param uri [String]
|
92
|
+
# @return [Source]
|
93
|
+
def find uri
|
94
|
+
open_source_hash[uri] || raise(Solargraph::FileNotFoundError, "Host could not find #{uri}")
|
95
|
+
end
|
96
|
+
|
97
|
+
# Close the source with the given URI.
|
98
|
+
#
|
99
|
+
# @param uri [String]
|
100
|
+
# @return [void]
|
101
|
+
def close uri
|
102
|
+
open_source_hash.delete uri
|
103
|
+
end
|
104
|
+
|
105
|
+
# True if a source with given URI is currently open.
|
106
|
+
# @param uri [String]
|
107
|
+
# @return [Boolean]
|
108
|
+
def include? uri
|
109
|
+
open_source_hash.key? uri
|
110
|
+
end
|
111
|
+
|
112
|
+
# @return [void]
|
113
|
+
def clear
|
114
|
+
open_source_hash.clear
|
115
|
+
end
|
116
|
+
|
117
|
+
private
|
118
|
+
|
119
|
+
# @return [Array<Source>]
|
120
|
+
def open_source_hash
|
121
|
+
@open_source_hash ||= {}
|
122
|
+
end
|
123
|
+
|
124
|
+
# @return [Mutex]
|
125
|
+
def mutex
|
126
|
+
@mutex ||= Mutex.new
|
127
|
+
end
|
128
|
+
|
129
|
+
# An array of source URIs that are waiting to finish synchronizing.
|
130
|
+
#
|
131
|
+
# @return [Array<String>]
|
132
|
+
def queue
|
133
|
+
@queue ||= []
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
@@ -1,90 +1,90 @@
|
|
1
|
-
require 'solargraph'
|
2
|
-
require 'uri'
|
3
|
-
|
4
|
-
module Solargraph
|
5
|
-
module LanguageServer
|
6
|
-
# The Message namespace contains classes that implement language server
|
7
|
-
# protocol methods.
|
8
|
-
#
|
9
|
-
module Message
|
10
|
-
autoload :Base, 'solargraph/language_server/message/base'
|
11
|
-
autoload :Initialize, 'solargraph/language_server/message/initialize'
|
12
|
-
autoload :Initialized, 'solargraph/language_server/message/initialized'
|
13
|
-
autoload :TextDocument, 'solargraph/language_server/message/text_document'
|
14
|
-
autoload :CompletionItem, 'solargraph/language_server/message/completion_item'
|
15
|
-
autoload :CancelRequest, 'solargraph/language_server/message/cancel_request'
|
16
|
-
autoload :MethodNotFound, 'solargraph/language_server/message/method_not_found'
|
17
|
-
autoload :MethodNotImplemented, 'solargraph/language_server/message/method_not_implemented'
|
18
|
-
autoload :Extended, 'solargraph/language_server/message/extended'
|
19
|
-
autoload :Shutdown, 'solargraph/language_server/message/shutdown'
|
20
|
-
autoload :ExitNotification, 'solargraph/language_server/message/exit_notification'
|
21
|
-
autoload :Workspace, 'solargraph/language_server/message/workspace'
|
22
|
-
|
23
|
-
class << self
|
24
|
-
# Register a method name and message for handling by the language
|
25
|
-
# server.
|
26
|
-
#
|
27
|
-
# @example
|
28
|
-
# Message.register 'initialize', Solargraph::Message::Initialize
|
29
|
-
#
|
30
|
-
# @param path [String] The method name
|
31
|
-
# @param message_class [Class<Message::Base>] The message class
|
32
|
-
# @return [void]
|
33
|
-
def register path, message_class
|
34
|
-
method_map[path] = message_class
|
35
|
-
end
|
36
|
-
|
37
|
-
# @param path [String]
|
38
|
-
# @return [Class<Solargraph::LanguageServer::Message::Base>]
|
39
|
-
def select path
|
40
|
-
if method_map.has_key?(path)
|
41
|
-
method_map[path]
|
42
|
-
elsif path.start_with?('$/')
|
43
|
-
MethodNotImplemented
|
44
|
-
else
|
45
|
-
MethodNotFound
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
# @return [Hash{String => Class<Message::Base>}]
|
52
|
-
def method_map
|
53
|
-
@method_map ||= {}
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
register 'initialize', Initialize
|
58
|
-
register 'initialized', Initialized
|
59
|
-
register 'textDocument/completion', TextDocument::Completion
|
60
|
-
register 'completionItem/resolve', CompletionItem::Resolve
|
61
|
-
register 'textDocument/signatureHelp', TextDocument::SignatureHelp
|
62
|
-
register 'textDocument/didOpen', TextDocument::DidOpen
|
63
|
-
register 'textDocument/didChange', TextDocument::DidChange
|
64
|
-
register 'textDocument/didSave', TextDocument::DidSave
|
65
|
-
register 'textDocument/didClose', TextDocument::DidClose
|
66
|
-
register 'textDocument/hover', TextDocument::Hover
|
67
|
-
register 'textDocument/definition', TextDocument::Definition
|
68
|
-
register 'textDocument/formatting', TextDocument::Formatting
|
69
|
-
register 'textDocument/onTypeFormatting', TextDocument::OnTypeFormatting
|
70
|
-
register 'textDocument/documentSymbol', TextDocument::DocumentSymbol
|
71
|
-
register 'textDocument/references', TextDocument::References
|
72
|
-
register 'textDocument/rename', TextDocument::Rename
|
73
|
-
register 'textDocument/prepareRename', TextDocument::PrepareRename
|
74
|
-
register 'textDocument/foldingRange', TextDocument::FoldingRange
|
75
|
-
register 'workspace/didChangeWatchedFiles', Workspace::DidChangeWatchedFiles
|
76
|
-
register 'workspace/didChangeConfiguration', Workspace::DidChangeConfiguration
|
77
|
-
register 'workspace/didChangeWorkspaceFolders', Workspace::DidChangeWorkspaceFolders
|
78
|
-
register 'workspace/symbol', Workspace::WorkspaceSymbol
|
79
|
-
register '$/cancelRequest', CancelRequest
|
80
|
-
register '$/solargraph/document', Extended::Document
|
81
|
-
register '$/solargraph/search', Extended::Search
|
82
|
-
register '$/solargraph/checkGemVersion', Extended::CheckGemVersion
|
83
|
-
register '$/solargraph/documentGems', Extended::DocumentGems
|
84
|
-
register '$/solargraph/downloadCore', Extended::DownloadCore
|
85
|
-
register '$/solargraph/environment', Extended::Environment
|
86
|
-
register 'shutdown', Shutdown
|
87
|
-
register 'exit', ExitNotification
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
1
|
+
require 'solargraph'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
module Solargraph
|
5
|
+
module LanguageServer
|
6
|
+
# The Message namespace contains classes that implement language server
|
7
|
+
# protocol methods.
|
8
|
+
#
|
9
|
+
module Message
|
10
|
+
autoload :Base, 'solargraph/language_server/message/base'
|
11
|
+
autoload :Initialize, 'solargraph/language_server/message/initialize'
|
12
|
+
autoload :Initialized, 'solargraph/language_server/message/initialized'
|
13
|
+
autoload :TextDocument, 'solargraph/language_server/message/text_document'
|
14
|
+
autoload :CompletionItem, 'solargraph/language_server/message/completion_item'
|
15
|
+
autoload :CancelRequest, 'solargraph/language_server/message/cancel_request'
|
16
|
+
autoload :MethodNotFound, 'solargraph/language_server/message/method_not_found'
|
17
|
+
autoload :MethodNotImplemented, 'solargraph/language_server/message/method_not_implemented'
|
18
|
+
autoload :Extended, 'solargraph/language_server/message/extended'
|
19
|
+
autoload :Shutdown, 'solargraph/language_server/message/shutdown'
|
20
|
+
autoload :ExitNotification, 'solargraph/language_server/message/exit_notification'
|
21
|
+
autoload :Workspace, 'solargraph/language_server/message/workspace'
|
22
|
+
|
23
|
+
class << self
|
24
|
+
# Register a method name and message for handling by the language
|
25
|
+
# server.
|
26
|
+
#
|
27
|
+
# @example
|
28
|
+
# Message.register 'initialize', Solargraph::Message::Initialize
|
29
|
+
#
|
30
|
+
# @param path [String] The method name
|
31
|
+
# @param message_class [Class<Message::Base>] The message class
|
32
|
+
# @return [void]
|
33
|
+
def register path, message_class
|
34
|
+
method_map[path] = message_class
|
35
|
+
end
|
36
|
+
|
37
|
+
# @param path [String]
|
38
|
+
# @return [Class<Solargraph::LanguageServer::Message::Base>]
|
39
|
+
def select path
|
40
|
+
if method_map.has_key?(path)
|
41
|
+
method_map[path]
|
42
|
+
elsif path.start_with?('$/')
|
43
|
+
MethodNotImplemented
|
44
|
+
else
|
45
|
+
MethodNotFound
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
# @return [Hash{String => Class<Message::Base>}]
|
52
|
+
def method_map
|
53
|
+
@method_map ||= {}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
register 'initialize', Initialize
|
58
|
+
register 'initialized', Initialized
|
59
|
+
register 'textDocument/completion', TextDocument::Completion
|
60
|
+
register 'completionItem/resolve', CompletionItem::Resolve
|
61
|
+
register 'textDocument/signatureHelp', TextDocument::SignatureHelp
|
62
|
+
register 'textDocument/didOpen', TextDocument::DidOpen
|
63
|
+
register 'textDocument/didChange', TextDocument::DidChange
|
64
|
+
register 'textDocument/didSave', TextDocument::DidSave
|
65
|
+
register 'textDocument/didClose', TextDocument::DidClose
|
66
|
+
register 'textDocument/hover', TextDocument::Hover
|
67
|
+
register 'textDocument/definition', TextDocument::Definition
|
68
|
+
register 'textDocument/formatting', TextDocument::Formatting
|
69
|
+
register 'textDocument/onTypeFormatting', TextDocument::OnTypeFormatting
|
70
|
+
register 'textDocument/documentSymbol', TextDocument::DocumentSymbol
|
71
|
+
register 'textDocument/references', TextDocument::References
|
72
|
+
register 'textDocument/rename', TextDocument::Rename
|
73
|
+
register 'textDocument/prepareRename', TextDocument::PrepareRename
|
74
|
+
register 'textDocument/foldingRange', TextDocument::FoldingRange
|
75
|
+
register 'workspace/didChangeWatchedFiles', Workspace::DidChangeWatchedFiles
|
76
|
+
register 'workspace/didChangeConfiguration', Workspace::DidChangeConfiguration
|
77
|
+
register 'workspace/didChangeWorkspaceFolders', Workspace::DidChangeWorkspaceFolders
|
78
|
+
register 'workspace/symbol', Workspace::WorkspaceSymbol
|
79
|
+
register '$/cancelRequest', CancelRequest
|
80
|
+
register '$/solargraph/document', Extended::Document
|
81
|
+
register '$/solargraph/search', Extended::Search
|
82
|
+
register '$/solargraph/checkGemVersion', Extended::CheckGemVersion
|
83
|
+
register '$/solargraph/documentGems', Extended::DocumentGems
|
84
|
+
register '$/solargraph/downloadCore', Extended::DownloadCore
|
85
|
+
register '$/solargraph/environment', Extended::Environment
|
86
|
+
register 'shutdown', Shutdown
|
87
|
+
register 'exit', ExitNotification
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|