rblean 0.0.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 +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +130 -0
- data/exe/rblean +6 -0
- data/lib/rblean/batch.rb +104 -0
- data/lib/rblean/checker.rb +80 -0
- data/lib/rblean/cli.rb +168 -0
- data/lib/rblean/document.rb +243 -0
- data/lib/rblean/errors.rb +72 -0
- data/lib/rblean/internal/positions.rb +53 -0
- data/lib/rblean/internal/protocol.rb +127 -0
- data/lib/rblean/internal/transport.rb +129 -0
- data/lib/rblean/server.rb +231 -0
- data/lib/rblean/toolchain.rb +112 -0
- data/lib/rblean/values.rb +126 -0
- data/lib/rblean/version.rb +5 -0
- data/lib/rblean.rb +51 -0
- data/sig/rblean.rbs +266 -0
- metadata +62 -0
data/sig/rblean.rbs
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# Public API of rblean. RbLean::Internal is not covered by compatibility promises.
|
|
2
|
+
module RbLean
|
|
3
|
+
VERSION: String
|
|
4
|
+
|
|
5
|
+
def self?.open: (?project: String?, ?lean: String?, ?strict: bool, ?timeout: Numeric, ?scratch: Integer, ?logger: untyped) -> Server
|
|
6
|
+
| [T] (?project: String?, ?lean: String?, ?strict: bool, ?timeout: Numeric, ?scratch: Integer, ?logger: untyped) { (Server) -> T } -> T
|
|
7
|
+
def self?.elaborate: (String source, ?project: String?, ?lean: String?, ?strict: bool, ?timeout: Numeric?) -> Result
|
|
8
|
+
def self?.elaborate_file: (String path, ?project: String?, ?lean: String?, ?strict: bool, ?timeout: Numeric?) -> Result
|
|
9
|
+
def self?.check: (project: String, ?paranoid: bool, ?lean: String?, ?timeout: Numeric?) -> CheckReport
|
|
10
|
+
def self?.toolchain: (?project: String?, ?lean: String?) -> Toolchain
|
|
11
|
+
|
|
12
|
+
type severity = :error | :warning | :information | :hint
|
|
13
|
+
|
|
14
|
+
class Position
|
|
15
|
+
include Comparable
|
|
16
|
+
|
|
17
|
+
attr_reader line: Integer
|
|
18
|
+
attr_reader column: Integer
|
|
19
|
+
def self.new: (line: Integer, column: Integer) -> instance
|
|
20
|
+
def initialize: (line: Integer, column: Integer) -> void
|
|
21
|
+
def <=>: (untyped other) -> Integer?
|
|
22
|
+
def with: (?line: Integer, ?column: Integer) -> Position
|
|
23
|
+
def to_h: () -> { line: Integer, column: Integer }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
class Span
|
|
27
|
+
attr_reader start: Position
|
|
28
|
+
attr_reader stop: Position
|
|
29
|
+
def self.new: (start: Position, stop: Position) -> instance
|
|
30
|
+
def initialize: (start: Position, stop: Position) -> void
|
|
31
|
+
def with: (?start: Position, ?stop: Position) -> Span
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
class Message
|
|
35
|
+
attr_reader severity: severity
|
|
36
|
+
attr_reader text: String
|
|
37
|
+
attr_reader span: Span
|
|
38
|
+
def self.new: (severity: severity, text: String, span: Span) -> instance
|
|
39
|
+
def initialize: (severity: severity, text: String, span: Span) -> void
|
|
40
|
+
def line: () -> Integer
|
|
41
|
+
def column: () -> Integer
|
|
42
|
+
def error?: () -> bool
|
|
43
|
+
def warning?: () -> bool
|
|
44
|
+
def info?: () -> bool
|
|
45
|
+
def with: (?severity: severity, ?text: String, ?span: Span) -> Message
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
class Goal
|
|
49
|
+
attr_reader text: String
|
|
50
|
+
def self.new: (text: String) -> instance
|
|
51
|
+
def initialize: (text: String) -> void
|
|
52
|
+
def target: () -> String
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
class Hover
|
|
56
|
+
attr_reader markdown: String
|
|
57
|
+
attr_reader span: Span?
|
|
58
|
+
def self.new: (markdown: String, span: Span?) -> instance
|
|
59
|
+
def initialize: (markdown: String, span: Span?) -> void
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
class Result
|
|
63
|
+
include Enumerable[Message]
|
|
64
|
+
|
|
65
|
+
attr_reader messages: Array[Message]
|
|
66
|
+
attr_reader source: String
|
|
67
|
+
|
|
68
|
+
def initialize: (messages: Array[Message], source: String, ?document: Document?, ?version: Integer?) -> void
|
|
69
|
+
def each: () { (Message) -> void } -> Array[Message]
|
|
70
|
+
| () -> Enumerator[Message, Array[Message]]
|
|
71
|
+
def errors: () -> Array[Message]
|
|
72
|
+
def warnings: () -> Array[Message]
|
|
73
|
+
def infos: () -> Array[Message]
|
|
74
|
+
def success?: () -> bool
|
|
75
|
+
def goals: (line: Integer, column: Integer) -> Array[Goal]
|
|
76
|
+
def hover: (line: Integer, column: Integer) -> Hover?
|
|
77
|
+
def ==: (untyped other) -> bool
|
|
78
|
+
def eql?: (untyped other) -> bool
|
|
79
|
+
def hash: () -> Integer
|
|
80
|
+
|
|
81
|
+
private
|
|
82
|
+
|
|
83
|
+
@document: Document?
|
|
84
|
+
@version: Integer?
|
|
85
|
+
def document!: () -> Document
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
class CheckReport
|
|
89
|
+
class Step
|
|
90
|
+
attr_reader judgement: String
|
|
91
|
+
attr_reader output: String
|
|
92
|
+
def self.new: (judgement: String, output: String) -> instance
|
|
93
|
+
def initialize: (judgement: String, output: String) -> void
|
|
94
|
+
def success?: () -> bool
|
|
95
|
+
def skipped?: () -> bool
|
|
96
|
+
def failure?: () -> bool
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
attr_reader judgement: String
|
|
100
|
+
attr_reader sandboxed: bool
|
|
101
|
+
attr_reader steps: Hash[String, Step | Hash[String, Step]]
|
|
102
|
+
attr_reader raw: Hash[String, untyped]
|
|
103
|
+
def self.new: (judgement: String, sandboxed: bool, steps: Hash[String, Step | Hash[String, Step]], raw: Hash[String, untyped]) -> instance
|
|
104
|
+
def initialize: (judgement: String, sandboxed: bool, steps: Hash[String, Step | Hash[String, Step]], raw: Hash[String, untyped]) -> void
|
|
105
|
+
def success?: () -> bool
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
interface _Env
|
|
109
|
+
def []: (String) -> String?
|
|
110
|
+
def fetch: (String, String) -> String
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
class Toolchain
|
|
114
|
+
attr_reader lean: String
|
|
115
|
+
attr_reader lake: String?
|
|
116
|
+
attr_reader project: String?
|
|
117
|
+
|
|
118
|
+
def self.detect: (?project: String?, ?lean: String?, ?need_lake: bool, ?env: _Env) -> Toolchain
|
|
119
|
+
def initialize: (lean: String, lake: String?, ?project: String?) -> void
|
|
120
|
+
def chdir: () -> String
|
|
121
|
+
def version: () -> String
|
|
122
|
+
def lake!: () -> String
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
class Server
|
|
126
|
+
SERVER_ARGS: Array[String]
|
|
127
|
+
STRICT_ARGS: Array[String]
|
|
128
|
+
|
|
129
|
+
attr_reader toolchain: Toolchain
|
|
130
|
+
attr_reader root: String
|
|
131
|
+
attr_reader timeout: Numeric
|
|
132
|
+
attr_reader protocol: Internal::Protocol
|
|
133
|
+
|
|
134
|
+
def initialize: (?project: String?, ?lean: String?, ?strict: bool, ?timeout: Numeric, ?scratch: Integer, ?logger: untyped) -> void
|
|
135
|
+
def elaborate: (String source, ?timeout: Numeric?) -> Result
|
|
136
|
+
def document: (String | _ToS name, ?String? text) -> Document
|
|
137
|
+
def open_file: (String path) -> Document
|
|
138
|
+
def documents: () -> Array[Document]
|
|
139
|
+
def version: () -> String
|
|
140
|
+
def close: () -> nil
|
|
141
|
+
def closed?: () -> bool
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
class Document
|
|
145
|
+
attr_reader name: String
|
|
146
|
+
attr_reader uri: String
|
|
147
|
+
|
|
148
|
+
def initialize: (Server server, String name, String uri, String text, ?scratch: bool) -> void
|
|
149
|
+
def text: () -> String
|
|
150
|
+
def version: () -> Integer
|
|
151
|
+
def scratch?: () -> bool
|
|
152
|
+
def closed?: () -> bool
|
|
153
|
+
def update: (String text) -> self
|
|
154
|
+
def elaborate: (?timeout: Numeric?) -> Result
|
|
155
|
+
def goals: (line: Integer, column: Integer, ?timeout: Numeric?) -> Array[Goal]
|
|
156
|
+
def hover: (line: Integer, column: Integer, ?timeout: Numeric?) -> Hover?
|
|
157
|
+
def close: () -> nil
|
|
158
|
+
def goals_at: (Integer? version, String source, line: Integer, column: Integer) -> Array[Goal]
|
|
159
|
+
def hover_at: (Integer? version, String source, line: Integer, column: Integer) -> Hover?
|
|
160
|
+
def receive_diagnostics: (Integer? version, Array[Hash[String, untyped]] diagnostics) -> void
|
|
161
|
+
def mark_for_resend!: () -> void
|
|
162
|
+
def self.message_from_lsp: (Array[String] lines, Hash[String, untyped] diagnostic) -> Message
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
class Error < StandardError
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
class ToolchainNotFound < Error
|
|
169
|
+
INSTALL_HINT: String
|
|
170
|
+
attr_reader searched: Array[String]
|
|
171
|
+
def initialize: (?String? message, ?searched: Array[String]) -> void
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
class TimeoutError < Error
|
|
175
|
+
attr_reader method_name: String
|
|
176
|
+
attr_reader seconds: Numeric?
|
|
177
|
+
def initialize: (String method_name, Numeric? seconds) -> void
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
class ServerError < Error
|
|
181
|
+
attr_reader code: Integer?
|
|
182
|
+
def initialize: (Integer? code, String message) -> void
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
class ServerCrashed < Error
|
|
186
|
+
attr_reader status: Process::Status?
|
|
187
|
+
attr_reader stderr: String
|
|
188
|
+
def initialize: (Process::Status? status, String stderr) -> void
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
class ClosedError < Error
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
class NoServerError < Error
|
|
195
|
+
def initialize: (?String message) -> void
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
class CheckerUnavailable < Error
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
module Batch
|
|
202
|
+
def self?.elaborate: (String source, ?project: String?, ?lean: String?, ?strict: bool, ?timeout: Numeric?) -> Result
|
|
203
|
+
def self?.elaborate_file: (String path, ?project: String?, ?lean: String?, ?strict: bool, ?timeout: Numeric?) -> Result
|
|
204
|
+
def self.run: (String path, String source, project: String?, lean: String?, strict: bool, timeout: Numeric?) -> Result
|
|
205
|
+
def self.parse: (String stdout) -> Array[Message]
|
|
206
|
+
def self.capture: (Array[String] command, chdir: String, timeout: Numeric?, ?method_name: String) -> [String, String, Process::Status]
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
module Checker
|
|
210
|
+
def self?.check: (project: String, ?paranoid: bool, ?lean: String?, ?timeout: Numeric?) -> CheckReport
|
|
211
|
+
def self.parse_report: (String stdout) -> Hash[String, untyped]?
|
|
212
|
+
def self.report: (Hash[String, untyped] raw) -> CheckReport
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
module Internal
|
|
216
|
+
module Positions
|
|
217
|
+
def self.lines: (String text) -> Array[String]
|
|
218
|
+
def self.char_to_utf16: (String? line, Integer column) -> Integer
|
|
219
|
+
def self.utf16_to_char: (String? line, Integer units) -> Integer
|
|
220
|
+
def self.to_lsp: (Array[String] lines, Integer line, Integer column) -> Hash[String, Integer]
|
|
221
|
+
def self.from_lsp: (Array[String] lines, Hash[String, Integer] pos) -> Position
|
|
222
|
+
def self.span_from_lsp: (Array[String] lines, Hash[String, Hash[String, Integer]] range) -> Span
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
class Transport
|
|
226
|
+
def initialize: (IO | untyped input, IO | untyped output, ?logger: untyped, ?debug: bool) -> void
|
|
227
|
+
def write: (Hash[String, untyped] message) -> void
|
|
228
|
+
def read: () -> Hash[String, untyped]?
|
|
229
|
+
def close_write: () -> void
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
class ChildProcess
|
|
233
|
+
STDERR_TAIL: Integer
|
|
234
|
+
attr_reader pid: Integer
|
|
235
|
+
attr_reader stdin: IO
|
|
236
|
+
attr_reader stdout: IO
|
|
237
|
+
def initialize: (Array[String] command, chdir: String, ?logger: untyped) -> void
|
|
238
|
+
def stderr_tail: () -> String
|
|
239
|
+
def alive?: () -> bool
|
|
240
|
+
def status: (?timeout: Numeric) -> Process::Status?
|
|
241
|
+
def wait: (Numeric timeout) -> bool
|
|
242
|
+
def signal: (String sig) -> void
|
|
243
|
+
def terminate: (?grace: Numeric, ?term_grace: Numeric) -> void
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
class Protocol
|
|
247
|
+
def initialize: (Transport transport, on_notification: ^(String, untyped) -> void, on_eof: ^() -> Error, ?logger: untyped) -> void
|
|
248
|
+
def request: (String method, untyped params, ?timeout: Numeric?) -> untyped
|
|
249
|
+
def notify: (String method, untyped params) -> void
|
|
250
|
+
def failed?: () -> bool
|
|
251
|
+
def failure: () -> Error?
|
|
252
|
+
def join: (?Numeric? timeout) -> untyped
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
class CLI
|
|
257
|
+
EXIT_OK: Integer
|
|
258
|
+
EXIT_FAILED: Integer
|
|
259
|
+
EXIT_USAGE: Integer
|
|
260
|
+
EXIT_TOOLCHAIN: Integer
|
|
261
|
+
USAGE: String
|
|
262
|
+
def self.start: (?Array[String] argv, ?out: IO | untyped, ?err: IO | untyped) -> Integer
|
|
263
|
+
def initialize: (?out: IO | untyped, ?err: IO | untyped) -> void
|
|
264
|
+
def run: (Array[String] argv) -> Integer
|
|
265
|
+
end
|
|
266
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: rblean
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- dak2
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: |
|
|
13
|
+
rblean talks LSP to the language server that ships with Lean 4 (lean --server,
|
|
14
|
+
or lake serve in a Lake project) and returns messages, tactic goals and hover
|
|
15
|
+
information as Ruby objects. It can also verify a Lake project with lake check.
|
|
16
|
+
Runtime dependencies: the Ruby standard library only.
|
|
17
|
+
executables:
|
|
18
|
+
- rblean
|
|
19
|
+
extensions: []
|
|
20
|
+
extra_rdoc_files: []
|
|
21
|
+
files:
|
|
22
|
+
- LICENSE.txt
|
|
23
|
+
- README.md
|
|
24
|
+
- exe/rblean
|
|
25
|
+
- lib/rblean.rb
|
|
26
|
+
- lib/rblean/batch.rb
|
|
27
|
+
- lib/rblean/checker.rb
|
|
28
|
+
- lib/rblean/cli.rb
|
|
29
|
+
- lib/rblean/document.rb
|
|
30
|
+
- lib/rblean/errors.rb
|
|
31
|
+
- lib/rblean/internal/positions.rb
|
|
32
|
+
- lib/rblean/internal/protocol.rb
|
|
33
|
+
- lib/rblean/internal/transport.rb
|
|
34
|
+
- lib/rblean/server.rb
|
|
35
|
+
- lib/rblean/toolchain.rb
|
|
36
|
+
- lib/rblean/values.rb
|
|
37
|
+
- lib/rblean/version.rb
|
|
38
|
+
- sig/rblean.rbs
|
|
39
|
+
homepage: https://github.com/dak2/rblean
|
|
40
|
+
licenses:
|
|
41
|
+
- MIT
|
|
42
|
+
metadata:
|
|
43
|
+
source_code_uri: https://github.com/dak2/rblean
|
|
44
|
+
rubygems_mfa_required: 'true'
|
|
45
|
+
rdoc_options: []
|
|
46
|
+
require_paths:
|
|
47
|
+
- lib
|
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
49
|
+
requirements:
|
|
50
|
+
- - ">="
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: '4.0'
|
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
|
+
requirements:
|
|
55
|
+
- - ">="
|
|
56
|
+
- !ruby/object:Gem::Version
|
|
57
|
+
version: '0'
|
|
58
|
+
requirements: []
|
|
59
|
+
rubygems_version: 4.0.20
|
|
60
|
+
specification_version: 4
|
|
61
|
+
summary: Drive Lean 4 from Ruby through the language server built into Lean
|
|
62
|
+
test_files: []
|