solargraph 0.59.1 → 0.60.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/linting.yml +6 -0
- data/.github/workflows/plugins.yml +8 -0
- data/.github/workflows/rspec.yml +4 -1
- data/.github/workflows/typecheck.yml +2 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +1 -1
- data/CHANGELOG.md +18 -0
- data/Gemfile +3 -0
- data/lib/solargraph/api_map/index.rb +13 -2
- data/lib/solargraph/api_map/store.rb +22 -8
- data/lib/solargraph/api_map.rb +38 -8
- data/lib/solargraph/complex_type/type_methods.rb +1 -0
- data/lib/solargraph/complex_type/unique_type.rb +16 -13
- data/lib/solargraph/complex_type.rb +5 -0
- data/lib/solargraph/convention/active_support_concern.rb +111 -111
- data/lib/solargraph/convention/base.rb +50 -50
- data/lib/solargraph/diagnostics.rb +55 -55
- data/lib/solargraph/doc_map.rb +1 -0
- data/lib/solargraph/environ.rb +52 -52
- data/lib/solargraph/gem_pins.rb +0 -11
- data/lib/solargraph/language_server/message/extended/environment.rb +25 -25
- data/lib/solargraph/language_server/message/initialized.rb +28 -28
- data/lib/solargraph/language_server/message/text_document.rb +28 -28
- data/lib/solargraph/language_server/progress.rb +143 -143
- data/lib/solargraph/language_server/transport/adapter.rb +68 -68
- data/lib/solargraph/language_server.rb +20 -20
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_methods.rb +42 -0
- data/lib/solargraph/parser/parser_gem/node_processors/alias_node.rb +24 -24
- 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/gvasgn_node.rb +24 -24
- data/lib/solargraph/parser/parser_gem/node_processors/namespace_node.rb +29 -5
- data/lib/solargraph/parser/parser_gem/node_processors/sym_node.rb +20 -20
- data/lib/solargraph/pin/base.rb +31 -3
- data/lib/solargraph/pin/callable.rb +2 -2
- data/lib/solargraph/pin/common.rb +12 -0
- data/lib/solargraph/pin/method.rb +56 -16
- data/lib/solargraph/pin/reference/require.rb +14 -14
- data/lib/solargraph/pin/singleton.rb +11 -11
- data/lib/solargraph/rbs_map/conversions.rb +103 -145
- data/lib/solargraph/rbs_translator.rb +206 -0
- data/lib/solargraph/shell.rb +131 -64
- data/lib/solargraph/source/chain/array.rb +1 -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 +8 -76
- data/lib/solargraph/source/chain/head.rb +19 -19
- data/lib/solargraph/source/chain/literal.rb +18 -14
- data/lib/solargraph/source/source_chainer.rb +4 -4
- data/lib/solargraph/source_map/mapper.rb +5 -135
- data/lib/solargraph/source_map.rb +14 -0
- data/lib/solargraph/version.rb +19 -1
- data/lib/solargraph/yard_map/cache.rb +25 -25
- data/lib/solargraph/yard_map/directives/attribute_directive.rb +65 -0
- data/lib/solargraph/yard_map/directives/domain_directive.rb +30 -0
- data/lib/solargraph/yard_map/directives/method_directive.rb +51 -0
- data/lib/solargraph/yard_map/directives/override_directive.rb +30 -0
- data/lib/solargraph/yard_map/directives/parse_directive.rb +53 -0
- data/lib/solargraph/yard_map/directives/visibility_directive.rb +70 -0
- data/lib/solargraph/yard_map/directives.rb +35 -0
- data/lib/solargraph/yard_map/macro.rb +113 -0
- data/lib/solargraph/yard_map/mapper/to_constant.rb +28 -28
- data/lib/solargraph/yard_map/mapper.rb +19 -1
- data/lib/solargraph/yard_map.rb +2 -0
- data/lib/solargraph.rb +1 -0
- data/solargraph.gemspec +1 -0
- metadata +24 -2
- data/rbs/fills/tuple/tuple.rbs +0 -177
|
@@ -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
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module LanguageServer
|
|
5
|
-
module Message
|
|
6
|
-
module TextDocument
|
|
7
|
-
autoload :Base, 'solargraph/language_server/message/text_document/base'
|
|
8
|
-
autoload :Completion, 'solargraph/language_server/message/text_document/completion'
|
|
9
|
-
autoload :DidOpen, 'solargraph/language_server/message/text_document/did_open'
|
|
10
|
-
autoload :DidChange, 'solargraph/language_server/message/text_document/did_change'
|
|
11
|
-
autoload :DidClose, 'solargraph/language_server/message/text_document/did_close'
|
|
12
|
-
autoload :DidSave, 'solargraph/language_server/message/text_document/did_save'
|
|
13
|
-
autoload :Hover, 'solargraph/language_server/message/text_document/hover'
|
|
14
|
-
autoload :SignatureHelp, 'solargraph/language_server/message/text_document/signature_help'
|
|
15
|
-
autoload :OnTypeFormatting, 'solargraph/language_server/message/text_document/on_type_formatting'
|
|
16
|
-
autoload :Definition, 'solargraph/language_server/message/text_document/definition'
|
|
17
|
-
autoload :TypeDefinition, 'solargraph/language_server/message/text_document/type_definition'
|
|
18
|
-
autoload :DocumentSymbol, 'solargraph/language_server/message/text_document/document_symbol'
|
|
19
|
-
autoload :Formatting, 'solargraph/language_server/message/text_document/formatting'
|
|
20
|
-
autoload :References, 'solargraph/language_server/message/text_document/references'
|
|
21
|
-
autoload :Rename, 'solargraph/language_server/message/text_document/rename'
|
|
22
|
-
autoload :PrepareRename, 'solargraph/language_server/message/text_document/prepare_rename'
|
|
23
|
-
autoload :FoldingRange, 'solargraph/language_server/message/text_document/folding_range'
|
|
24
|
-
autoload :DocumentHighlight, 'solargraph/language_server/message/text_document/document_highlight'
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module LanguageServer
|
|
5
|
+
module Message
|
|
6
|
+
module TextDocument
|
|
7
|
+
autoload :Base, 'solargraph/language_server/message/text_document/base'
|
|
8
|
+
autoload :Completion, 'solargraph/language_server/message/text_document/completion'
|
|
9
|
+
autoload :DidOpen, 'solargraph/language_server/message/text_document/did_open'
|
|
10
|
+
autoload :DidChange, 'solargraph/language_server/message/text_document/did_change'
|
|
11
|
+
autoload :DidClose, 'solargraph/language_server/message/text_document/did_close'
|
|
12
|
+
autoload :DidSave, 'solargraph/language_server/message/text_document/did_save'
|
|
13
|
+
autoload :Hover, 'solargraph/language_server/message/text_document/hover'
|
|
14
|
+
autoload :SignatureHelp, 'solargraph/language_server/message/text_document/signature_help'
|
|
15
|
+
autoload :OnTypeFormatting, 'solargraph/language_server/message/text_document/on_type_formatting'
|
|
16
|
+
autoload :Definition, 'solargraph/language_server/message/text_document/definition'
|
|
17
|
+
autoload :TypeDefinition, 'solargraph/language_server/message/text_document/type_definition'
|
|
18
|
+
autoload :DocumentSymbol, 'solargraph/language_server/message/text_document/document_symbol'
|
|
19
|
+
autoload :Formatting, 'solargraph/language_server/message/text_document/formatting'
|
|
20
|
+
autoload :References, 'solargraph/language_server/message/text_document/references'
|
|
21
|
+
autoload :Rename, 'solargraph/language_server/message/text_document/rename'
|
|
22
|
+
autoload :PrepareRename, 'solargraph/language_server/message/text_document/prepare_rename'
|
|
23
|
+
autoload :FoldingRange, 'solargraph/language_server/message/text_document/folding_range'
|
|
24
|
+
autoload :DocumentHighlight, 'solargraph/language_server/message/text_document/document_highlight'
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -1,143 +1,143 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'securerandom'
|
|
4
|
-
|
|
5
|
-
module Solargraph
|
|
6
|
-
module LanguageServer
|
|
7
|
-
# Progress notification handling for language server hosts.
|
|
8
|
-
#
|
|
9
|
-
class Progress
|
|
10
|
-
WAITING = :waiting
|
|
11
|
-
CREATED = :created
|
|
12
|
-
FINISHED = :finished
|
|
13
|
-
|
|
14
|
-
# @return [String]
|
|
15
|
-
attr_reader :uuid
|
|
16
|
-
|
|
17
|
-
# @return [String]
|
|
18
|
-
attr_reader :title
|
|
19
|
-
|
|
20
|
-
# @return [String, nil]
|
|
21
|
-
attr_reader :kind
|
|
22
|
-
|
|
23
|
-
# @return [String, nil]
|
|
24
|
-
attr_reader :message
|
|
25
|
-
|
|
26
|
-
# @return [Integer]
|
|
27
|
-
attr_reader :percentage
|
|
28
|
-
|
|
29
|
-
# @return [Symbol]
|
|
30
|
-
attr_reader :status
|
|
31
|
-
|
|
32
|
-
# @param title [String]
|
|
33
|
-
def initialize title
|
|
34
|
-
@title = title
|
|
35
|
-
@uuid = SecureRandom.uuid
|
|
36
|
-
@percentage = 0
|
|
37
|
-
@status = WAITING
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
# @param message [String]
|
|
41
|
-
# @param percentage [Integer]
|
|
42
|
-
# @return [void]
|
|
43
|
-
def begin message, percentage
|
|
44
|
-
@kind = 'begin'
|
|
45
|
-
@message = message
|
|
46
|
-
@percentage = percentage
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# @param message [String]
|
|
50
|
-
# @param percentage [Integer]
|
|
51
|
-
# @return [void]
|
|
52
|
-
def report message, percentage
|
|
53
|
-
@kind = 'report'
|
|
54
|
-
@message = message
|
|
55
|
-
@percentage = percentage
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
# @param message [String]
|
|
59
|
-
# @return [void]
|
|
60
|
-
def finish message
|
|
61
|
-
@kind = 'end'
|
|
62
|
-
@message = message
|
|
63
|
-
@percentage = 100
|
|
64
|
-
true
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
# @param host [Solargraph::LanguageServer::Host]
|
|
68
|
-
# @return [void]
|
|
69
|
-
def send host
|
|
70
|
-
return unless host.client_supports_progress? && !finished?
|
|
71
|
-
|
|
72
|
-
message = build
|
|
73
|
-
create(host)
|
|
74
|
-
host.send_notification '$/progress', message
|
|
75
|
-
@status = FINISHED if kind == 'end'
|
|
76
|
-
keep_alive host
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def created?
|
|
80
|
-
[CREATED, FINISHED].include?(status)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def finished?
|
|
84
|
-
status == FINISHED
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
private
|
|
88
|
-
|
|
89
|
-
# @param host [Solargraph::LanguageServer::Host]
|
|
90
|
-
# @return [void]
|
|
91
|
-
def create host
|
|
92
|
-
return if created?
|
|
93
|
-
|
|
94
|
-
host.send_request 'window/workDoneProgress/create', { token: uuid }
|
|
95
|
-
@status = CREATED
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
# @return [Hash]
|
|
99
|
-
def build
|
|
100
|
-
{
|
|
101
|
-
token: uuid,
|
|
102
|
-
value: {
|
|
103
|
-
kind: kind,
|
|
104
|
-
cancellable: false
|
|
105
|
-
}.merge(build_value)
|
|
106
|
-
}
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
# @return [Hash]
|
|
110
|
-
def build_value
|
|
111
|
-
case kind
|
|
112
|
-
when 'begin'
|
|
113
|
-
{ title: title, message: message, percentage: percentage }
|
|
114
|
-
when 'report'
|
|
115
|
-
{ message: message, percentage: percentage }
|
|
116
|
-
when 'end'
|
|
117
|
-
{ message: message }
|
|
118
|
-
else
|
|
119
|
-
raise "Invalid progress kind #{kind}"
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
# @param host [Host]
|
|
124
|
-
# @return [void]
|
|
125
|
-
def keep_alive host
|
|
126
|
-
mutex.synchronize { @last = Time.now }
|
|
127
|
-
@keep_alive ||= Thread.new do
|
|
128
|
-
until finished?
|
|
129
|
-
sleep 10
|
|
130
|
-
break if finished?
|
|
131
|
-
next if mutex.synchronize { Time.now - @last < 10 }
|
|
132
|
-
send host
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
# @return [Thread::Mutex]
|
|
138
|
-
def mutex
|
|
139
|
-
@mutex ||= Mutex.new
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'securerandom'
|
|
4
|
+
|
|
5
|
+
module Solargraph
|
|
6
|
+
module LanguageServer
|
|
7
|
+
# Progress notification handling for language server hosts.
|
|
8
|
+
#
|
|
9
|
+
class Progress
|
|
10
|
+
WAITING = :waiting
|
|
11
|
+
CREATED = :created
|
|
12
|
+
FINISHED = :finished
|
|
13
|
+
|
|
14
|
+
# @return [String]
|
|
15
|
+
attr_reader :uuid
|
|
16
|
+
|
|
17
|
+
# @return [String]
|
|
18
|
+
attr_reader :title
|
|
19
|
+
|
|
20
|
+
# @return [String, nil]
|
|
21
|
+
attr_reader :kind
|
|
22
|
+
|
|
23
|
+
# @return [String, nil]
|
|
24
|
+
attr_reader :message
|
|
25
|
+
|
|
26
|
+
# @return [Integer]
|
|
27
|
+
attr_reader :percentage
|
|
28
|
+
|
|
29
|
+
# @return [Symbol]
|
|
30
|
+
attr_reader :status
|
|
31
|
+
|
|
32
|
+
# @param title [String]
|
|
33
|
+
def initialize title
|
|
34
|
+
@title = title
|
|
35
|
+
@uuid = SecureRandom.uuid
|
|
36
|
+
@percentage = 0
|
|
37
|
+
@status = WAITING
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# @param message [String]
|
|
41
|
+
# @param percentage [Integer]
|
|
42
|
+
# @return [void]
|
|
43
|
+
def begin message, percentage
|
|
44
|
+
@kind = 'begin'
|
|
45
|
+
@message = message
|
|
46
|
+
@percentage = percentage
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# @param message [String]
|
|
50
|
+
# @param percentage [Integer]
|
|
51
|
+
# @return [void]
|
|
52
|
+
def report message, percentage
|
|
53
|
+
@kind = 'report'
|
|
54
|
+
@message = message
|
|
55
|
+
@percentage = percentage
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# @param message [String]
|
|
59
|
+
# @return [void]
|
|
60
|
+
def finish message
|
|
61
|
+
@kind = 'end'
|
|
62
|
+
@message = message
|
|
63
|
+
@percentage = 100
|
|
64
|
+
true
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# @param host [Solargraph::LanguageServer::Host]
|
|
68
|
+
# @return [void]
|
|
69
|
+
def send host
|
|
70
|
+
return unless host.client_supports_progress? && !finished?
|
|
71
|
+
|
|
72
|
+
message = build
|
|
73
|
+
create(host)
|
|
74
|
+
host.send_notification '$/progress', message
|
|
75
|
+
@status = FINISHED if kind == 'end'
|
|
76
|
+
keep_alive host
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def created?
|
|
80
|
+
[CREATED, FINISHED].include?(status)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def finished?
|
|
84
|
+
status == FINISHED
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
private
|
|
88
|
+
|
|
89
|
+
# @param host [Solargraph::LanguageServer::Host]
|
|
90
|
+
# @return [void]
|
|
91
|
+
def create host
|
|
92
|
+
return if created?
|
|
93
|
+
|
|
94
|
+
host.send_request 'window/workDoneProgress/create', { token: uuid }
|
|
95
|
+
@status = CREATED
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# @return [Hash]
|
|
99
|
+
def build
|
|
100
|
+
{
|
|
101
|
+
token: uuid,
|
|
102
|
+
value: {
|
|
103
|
+
kind: kind,
|
|
104
|
+
cancellable: false
|
|
105
|
+
}.merge(build_value)
|
|
106
|
+
}
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# @return [Hash]
|
|
110
|
+
def build_value
|
|
111
|
+
case kind
|
|
112
|
+
when 'begin'
|
|
113
|
+
{ title: title, message: message, percentage: percentage }
|
|
114
|
+
when 'report'
|
|
115
|
+
{ message: message, percentage: percentage }
|
|
116
|
+
when 'end'
|
|
117
|
+
{ message: message }
|
|
118
|
+
else
|
|
119
|
+
raise "Invalid progress kind #{kind}"
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# @param host [Host]
|
|
124
|
+
# @return [void]
|
|
125
|
+
def keep_alive host
|
|
126
|
+
mutex.synchronize { @last = Time.now }
|
|
127
|
+
@keep_alive ||= Thread.new do
|
|
128
|
+
until finished?
|
|
129
|
+
sleep 10
|
|
130
|
+
break if finished?
|
|
131
|
+
next if mutex.synchronize { Time.now - @last < 10 }
|
|
132
|
+
send host
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# @return [Thread::Mutex]
|
|
138
|
+
def mutex
|
|
139
|
+
@mutex ||= Mutex.new
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'backport'
|
|
4
|
-
|
|
5
|
-
module Solargraph
|
|
6
|
-
module LanguageServer
|
|
7
|
-
module Transport
|
|
8
|
-
# A common module for running language servers in Backport.
|
|
9
|
-
#
|
|
10
|
-
module Adapter
|
|
11
|
-
# This runs in the context of Backport::Adapter, which
|
|
12
|
-
# provides write() - but if we didn't hide this behind a parse
|
|
13
|
-
# tag, it would override the one in the class.
|
|
14
|
-
#
|
|
15
|
-
# @!method write(text)
|
|
16
|
-
# @abstract
|
|
17
|
-
# Write the change to the specified text.
|
|
18
|
-
# @param text [String] The text to be changed.
|
|
19
|
-
# @return [String] The updated text.
|
|
20
|
-
|
|
21
|
-
# @return [void]
|
|
22
|
-
def opening
|
|
23
|
-
@host = Solargraph::LanguageServer::Host.new
|
|
24
|
-
@host.add_observer self
|
|
25
|
-
@host.start
|
|
26
|
-
@data_reader = Solargraph::LanguageServer::Transport::DataReader.new
|
|
27
|
-
@data_reader.set_message_handler do |message|
|
|
28
|
-
process message
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# @return [void]
|
|
33
|
-
def closing
|
|
34
|
-
@host.stop
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# @param data [String]
|
|
38
|
-
# @return [void]
|
|
39
|
-
def receiving data
|
|
40
|
-
@data_reader.receive data
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# @return [void]
|
|
44
|
-
def update
|
|
45
|
-
if @host.stopped?
|
|
46
|
-
shutdown
|
|
47
|
-
else
|
|
48
|
-
tmp = @host.flush
|
|
49
|
-
write tmp unless tmp.empty?
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
private
|
|
54
|
-
|
|
55
|
-
# @param request [Hash]
|
|
56
|
-
# @return [void]
|
|
57
|
-
def process request
|
|
58
|
-
@host.process(request)
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
# @return [void]
|
|
62
|
-
def shutdown
|
|
63
|
-
Backport.stop unless @host.options['transport'] == 'external'
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'backport'
|
|
4
|
+
|
|
5
|
+
module Solargraph
|
|
6
|
+
module LanguageServer
|
|
7
|
+
module Transport
|
|
8
|
+
# A common module for running language servers in Backport.
|
|
9
|
+
#
|
|
10
|
+
module Adapter
|
|
11
|
+
# This runs in the context of Backport::Adapter, which
|
|
12
|
+
# provides write() - but if we didn't hide this behind a parse
|
|
13
|
+
# tag, it would override the one in the class.
|
|
14
|
+
#
|
|
15
|
+
# @!method write(text)
|
|
16
|
+
# @abstract
|
|
17
|
+
# Write the change to the specified text.
|
|
18
|
+
# @param text [String] The text to be changed.
|
|
19
|
+
# @return [String] The updated text.
|
|
20
|
+
|
|
21
|
+
# @return [void]
|
|
22
|
+
def opening
|
|
23
|
+
@host = Solargraph::LanguageServer::Host.new
|
|
24
|
+
@host.add_observer self
|
|
25
|
+
@host.start
|
|
26
|
+
@data_reader = Solargraph::LanguageServer::Transport::DataReader.new
|
|
27
|
+
@data_reader.set_message_handler do |message|
|
|
28
|
+
process message
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# @return [void]
|
|
33
|
+
def closing
|
|
34
|
+
@host.stop
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# @param data [String]
|
|
38
|
+
# @return [void]
|
|
39
|
+
def receiving data
|
|
40
|
+
@data_reader.receive data
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# @return [void]
|
|
44
|
+
def update
|
|
45
|
+
if @host.stopped?
|
|
46
|
+
shutdown
|
|
47
|
+
else
|
|
48
|
+
tmp = @host.flush
|
|
49
|
+
write tmp unless tmp.empty?
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
# @param request [Hash]
|
|
56
|
+
# @return [void]
|
|
57
|
+
def process request
|
|
58
|
+
@host.process(request)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# @return [void]
|
|
62
|
+
def shutdown
|
|
63
|
+
Backport.stop unless @host.options['transport'] == 'external'
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'solargraph/language_server/error_codes'
|
|
4
|
-
require 'solargraph/language_server/completion_item_kinds'
|
|
5
|
-
require 'solargraph/language_server/symbol_kinds'
|
|
6
|
-
|
|
7
|
-
module Solargraph
|
|
8
|
-
# The LanguageServer namespace contains the classes and modules that compose
|
|
9
|
-
# concrete implementations of language servers.
|
|
10
|
-
#
|
|
11
|
-
module LanguageServer
|
|
12
|
-
autoload :Host, 'solargraph/language_server/host'
|
|
13
|
-
autoload :Message, 'solargraph/language_server/message'
|
|
14
|
-
autoload :UriHelpers, 'solargraph/language_server/uri_helpers'
|
|
15
|
-
autoload :MessageTypes, 'solargraph/language_server/message_types'
|
|
16
|
-
autoload :Request, 'solargraph/language_server/request'
|
|
17
|
-
autoload :Transport, 'solargraph/language_server/transport'
|
|
18
|
-
autoload :Progress, 'solargraph/language_server/progress'
|
|
19
|
-
end
|
|
20
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'solargraph/language_server/error_codes'
|
|
4
|
+
require 'solargraph/language_server/completion_item_kinds'
|
|
5
|
+
require 'solargraph/language_server/symbol_kinds'
|
|
6
|
+
|
|
7
|
+
module Solargraph
|
|
8
|
+
# The LanguageServer namespace contains the classes and modules that compose
|
|
9
|
+
# concrete implementations of language servers.
|
|
10
|
+
#
|
|
11
|
+
module LanguageServer
|
|
12
|
+
autoload :Host, 'solargraph/language_server/host'
|
|
13
|
+
autoload :Message, 'solargraph/language_server/message'
|
|
14
|
+
autoload :UriHelpers, 'solargraph/language_server/uri_helpers'
|
|
15
|
+
autoload :MessageTypes, 'solargraph/language_server/message_types'
|
|
16
|
+
autoload :Request, 'solargraph/language_server/request'
|
|
17
|
+
autoload :Transport, 'solargraph/language_server/transport'
|
|
18
|
+
autoload :Progress, 'solargraph/language_server/progress'
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -102,6 +102,48 @@ module Solargraph
|
|
|
102
102
|
signature
|
|
103
103
|
end
|
|
104
104
|
|
|
105
|
+
# Convert a DSL method call argument with directly inferrable simple params.
|
|
106
|
+
# @param node [Parser::AST::Node]
|
|
107
|
+
# @return [String, Integer, Float, Symbol, Array, Hash, Source::Chain, nil]
|
|
108
|
+
# @sg-ignore "does not match inferred type ::String, ::Parser::AST::Node" - this probably comes from the
|
|
109
|
+
# `.children[0]` call, which is not recognized as returning a literal value.
|
|
110
|
+
def simple_convert node
|
|
111
|
+
return nil unless Parser.is_ast_node?(node)
|
|
112
|
+
|
|
113
|
+
case node.type
|
|
114
|
+
when :const
|
|
115
|
+
unpack_name(node)
|
|
116
|
+
when :str, :dstr, :int, :float, :sym, true, false
|
|
117
|
+
node.children[0]
|
|
118
|
+
when :array
|
|
119
|
+
simple_convert_array(node)
|
|
120
|
+
when :hash
|
|
121
|
+
simple_convert_hash(node)
|
|
122
|
+
else
|
|
123
|
+
Solargraph::Parser.chain(node)
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# @param node [Parser::AST::Node]
|
|
128
|
+
# @return [Array]
|
|
129
|
+
def simple_convert_array node
|
|
130
|
+
return [] unless Parser.is_ast_node?(node) && node.type == :array
|
|
131
|
+
node.children.compact.map { |c| simple_convert(c) }
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# @param node [Parser::AST::Node]
|
|
135
|
+
# @return [Hash]
|
|
136
|
+
def simple_convert_hash node
|
|
137
|
+
return {} unless Parser.is_ast_node?(node) && node.type == :hash
|
|
138
|
+
result = {}
|
|
139
|
+
# @param pair [Parser::AST::Node]
|
|
140
|
+
node.children.each do |pair|
|
|
141
|
+
next unless Parser.is_ast_node?(pair) && pair.children[0]
|
|
142
|
+
result[pair.children[0].children[0]] = simple_convert(pair.children[1])
|
|
143
|
+
end
|
|
144
|
+
result
|
|
145
|
+
end
|
|
146
|
+
|
|
105
147
|
# @param node [Parser::AST::Node, nil]
|
|
106
148
|
# @return [Hash{Symbol => Chain}]
|
|
107
149
|
def convert_hash node
|