t-ruby 0.0.4 → 0.0.7
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/README.md +5 -2
- data/lib/t_ruby/error_handler.rb +2 -2
- data/lib/t_ruby/lsp_server.rb +17 -0
- data/lib/t_ruby/parser.rb +3 -3
- data/lib/t_ruby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 054211b0b7c63b2f1b66b3cfed976385174c1b3f5904ea04357599b3c7440e8f
|
|
4
|
+
data.tar.gz: 0aa86d48811cff1bc7d7652155055f5041c0bef8e372b9dcec4a06a716534799
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 73ba77dc237a8455dd60b0c098de4372cd6e9f76e00619a54669af04fd46deca80c8c6fb1c3322114442ea38a471f18f722fc66018ad14cf31469ed153c11bc8
|
|
7
|
+
data.tar.gz: 5b6c3d2d3a895f941949d79407cb2e0ce91c3d1b3a13d7e113cd02be1a8fbdd9a82fb86bf6ac1d99832d4e331861c8657b516836b334aa73c8175273835c6da5
|
data/README.md
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
<p align="center">
|
|
12
12
|
<img src="https://img.shields.io/badge/CI-passing-brightgreen" alt="CI: passing" />
|
|
13
13
|
<img src="https://img.shields.io/badge/ruby-3.0+-cc342d" alt="Ruby 3.0+" />
|
|
14
|
-
<img src="https://img.shields.io/
|
|
15
|
-
<img src="https://img.shields.io/
|
|
14
|
+
<a href="https://rubygems.org/gems/t-ruby"><img src="https://img.shields.io/gem/v/t-ruby" alt="Gem Version" /></a>
|
|
15
|
+
<img src="https://img.shields.io/gem/dt/t-ruby" alt="Downloads" />
|
|
16
16
|
<img src="https://img.shields.io/badge/coverage-90%25-brightgreen" alt="Coverage: 90%" />
|
|
17
17
|
</p>
|
|
18
18
|
|
|
@@ -30,6 +30,9 @@
|
|
|
30
30
|
<a href="./README.ja.md">日本語</a>
|
|
31
31
|
</p>
|
|
32
32
|
|
|
33
|
+
> [!NOTE]
|
|
34
|
+
> This project is still experimental. If you support this project, please give it a star! If you have suggestions for improvements, please open an issue. Pull requests are also welcome!
|
|
35
|
+
|
|
33
36
|
---
|
|
34
37
|
|
|
35
38
|
## What is T-Ruby?
|
data/lib/t_ruby/error_handler.rb
CHANGED
|
@@ -30,9 +30,9 @@ module TRuby
|
|
|
30
30
|
|
|
31
31
|
def check_interface_errors
|
|
32
32
|
@lines.each_with_index do |line, idx|
|
|
33
|
-
next unless line.match?(/^\s*interface\s
|
|
33
|
+
next unless line.match?(/^\s*interface\s+[\w:]+/)
|
|
34
34
|
|
|
35
|
-
match = line.match(/^\s*interface\s+(\w+)/)
|
|
35
|
+
match = line.match(/^\s*interface\s+([\w:]+)/)
|
|
36
36
|
next unless match
|
|
37
37
|
|
|
38
38
|
interface_name = match[1]
|
data/lib/t_ruby/lsp_server.rb
CHANGED
|
@@ -234,6 +234,8 @@ module TRuby
|
|
|
234
234
|
handle_definition(params)
|
|
235
235
|
when "textDocument/semanticTokens/full"
|
|
236
236
|
handle_semantic_tokens_full(params)
|
|
237
|
+
when "textDocument/diagnostic"
|
|
238
|
+
handle_diagnostic(params)
|
|
237
239
|
else
|
|
238
240
|
{ error: { code: ErrorCodes::METHOD_NOT_FOUND, message: "Method not found: #{method}" } }
|
|
239
241
|
end
|
|
@@ -342,6 +344,21 @@ module TRuby
|
|
|
342
344
|
|
|
343
345
|
# === Diagnostics ===
|
|
344
346
|
|
|
347
|
+
# Handle pull-based diagnostics (LSP 3.17+)
|
|
348
|
+
def handle_diagnostic(params)
|
|
349
|
+
uri = params.dig("textDocument", "uri")
|
|
350
|
+
return { "kind" => "full", "items" => [] } unless uri
|
|
351
|
+
|
|
352
|
+
doc = @documents[uri]
|
|
353
|
+
return { "kind" => "full", "items" => [] } unless doc
|
|
354
|
+
|
|
355
|
+
text = doc[:text]
|
|
356
|
+
return { "kind" => "full", "items" => [] } unless text
|
|
357
|
+
|
|
358
|
+
diagnostics = analyze_document(text)
|
|
359
|
+
{ "kind" => "full", "items" => diagnostics }
|
|
360
|
+
end
|
|
361
|
+
|
|
345
362
|
def publish_diagnostics(uri, text)
|
|
346
363
|
diagnostics = analyze_document(text)
|
|
347
364
|
|
data/lib/t_ruby/parser.rb
CHANGED
|
@@ -200,7 +200,7 @@ module TRuby
|
|
|
200
200
|
|
|
201
201
|
def parse_interface(start_index)
|
|
202
202
|
line = @lines[start_index]
|
|
203
|
-
match = line.match(/^\s*interface\s+(\w+)/)
|
|
203
|
+
match = line.match(/^\s*interface\s+([\w:]+)/)
|
|
204
204
|
return [nil, start_index] unless match
|
|
205
205
|
|
|
206
206
|
interface_name = match[1]
|
|
@@ -211,8 +211,8 @@ module TRuby
|
|
|
211
211
|
current_line = @lines[i]
|
|
212
212
|
break if current_line.match?(/^\s*end\s*$/)
|
|
213
213
|
|
|
214
|
-
if current_line.match?(/^\s
|
|
215
|
-
member_match = current_line.match(/^\s*(\w+)\s*:\s*(.+?)\s*$/)
|
|
214
|
+
if current_line.match?(/^\s*[\w!?]+\s*:\s*/)
|
|
215
|
+
member_match = current_line.match(/^\s*([\w!?]+)\s*:\s*(.+?)\s*$/)
|
|
216
216
|
if member_match
|
|
217
217
|
member = {
|
|
218
218
|
name: member_match[1],
|
data/lib/t_ruby/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: t-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Y. Fred Kim
|
|
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '0'
|
|
83
83
|
requirements: []
|
|
84
|
-
rubygems_version:
|
|
84
|
+
rubygems_version: 4.0.1
|
|
85
85
|
specification_version: 4
|
|
86
86
|
summary: T-Ruby - TypeScript-style types for Ruby
|
|
87
87
|
test_files: []
|