syntax_tree 2.8.0 → 2.9.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/CHANGELOG.md +6 -1
- data/Gemfile.lock +6 -4
- data/lib/syntax_tree/language_server/inlay_hints.rb +26 -4
- data/lib/syntax_tree/language_server.rb +21 -6
- data/lib/syntax_tree/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8818212d64fea80bd776267ea9dac3a10c454e789b47ed72f4cf715dc087b30
|
4
|
+
data.tar.gz: ac90d097d6cbd8b50427c5ead994021448732022ce680a809c17e5e7fe9b427f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfe0af3c52f742ed24f5643710df53fd09b761f428c007ac9434d0e96828bc75c8e082884685173e6b7ea5cf5343d264219c5f5d2c9eb0a90a1fd58d2bec70c8
|
7
|
+
data.tar.gz: 0ee8b8362d6d18945f5bca0a0bfef1d1dc85e2fa5f27c61e807d7c4aa15b23cbb70fe6a8ebe4b1d6e73fd26e473c6fbb158287de2ee7343d0231e75b3529329b
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [2.9.0] - 2022-07-04
|
10
|
+
|
11
|
+
- [#106](https://github.com/ruby-syntax-tree/syntax_tree/pull/106) - Add inlay hint support to match the LSP specification.
|
12
|
+
|
9
13
|
## [2.8.0] - 2022-06-21
|
10
14
|
|
11
15
|
### Added
|
@@ -272,7 +276,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
272
276
|
|
273
277
|
- 🎉 Initial release! 🎉
|
274
278
|
|
275
|
-
[unreleased]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v2.
|
279
|
+
[unreleased]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v2.1.0...HEAD
|
280
|
+
[2.1.0]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v2.8.0...v2.1.0
|
276
281
|
[2.8.0]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v2.7.1...v2.8.0
|
277
282
|
[2.7.1]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v2.7.0...v2.7.1
|
278
283
|
[2.7.0]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v2.6.0...v2.7.0
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
syntax_tree (2.
|
4
|
+
syntax_tree (2.9.0)
|
5
5
|
prettier_print
|
6
6
|
|
7
7
|
GEM
|
@@ -9,7 +9,8 @@ GEM
|
|
9
9
|
specs:
|
10
10
|
ast (2.4.2)
|
11
11
|
docile (1.4.0)
|
12
|
-
|
12
|
+
json (2.6.2)
|
13
|
+
minitest (5.16.2)
|
13
14
|
parallel (1.22.1)
|
14
15
|
parser (3.1.2.0)
|
15
16
|
ast (~> 2.4.1)
|
@@ -18,7 +19,8 @@ GEM
|
|
18
19
|
rake (13.0.6)
|
19
20
|
regexp_parser (2.5.0)
|
20
21
|
rexml (3.2.5)
|
21
|
-
rubocop (1.
|
22
|
+
rubocop (1.31.1)
|
23
|
+
json (~> 2.3)
|
22
24
|
parallel (~> 1.10)
|
23
25
|
parser (>= 3.1.0.0)
|
24
26
|
rainbow (>= 2.2.2, < 4.0)
|
@@ -36,7 +38,7 @@ GEM
|
|
36
38
|
simplecov_json_formatter (~> 0.1)
|
37
39
|
simplecov-html (0.12.3)
|
38
40
|
simplecov_json_formatter (0.1.4)
|
39
|
-
unicode-display_width (2.
|
41
|
+
unicode-display_width (2.2.0)
|
40
42
|
|
41
43
|
PLATFORMS
|
42
44
|
arm64-darwin-21
|
@@ -2,18 +2,19 @@
|
|
2
2
|
|
3
3
|
module SyntaxTree
|
4
4
|
class LanguageServer
|
5
|
-
# This class provides inlay hints for the language server. It
|
6
|
-
#
|
7
|
-
#
|
5
|
+
# This class provides inlay hints for the language server. It existed
|
6
|
+
# before the spec was finalized so, so it provides two result formats:
|
7
|
+
# aligned with the spec (`#all`) and proprietary (`#before` and `#after`).
|
8
8
|
#
|
9
9
|
# For more information, see the spec here:
|
10
10
|
# https://github.com/microsoft/language-server-protocol/issues/956.
|
11
11
|
#
|
12
12
|
class InlayHints < Visitor
|
13
|
-
attr_reader :stack, :before, :after
|
13
|
+
attr_reader :stack, :all, :before, :after
|
14
14
|
|
15
15
|
def initialize
|
16
16
|
@stack = []
|
17
|
+
@all = []
|
17
18
|
@before = Hash.new { |hash, key| hash[key] = +"" }
|
18
19
|
@after = Hash.new { |hash, key| hash[key] = +"" }
|
19
20
|
end
|
@@ -98,6 +99,13 @@ module SyntaxTree
|
|
98
99
|
def visit_rescue(node)
|
99
100
|
if node.exception.nil?
|
100
101
|
after[node.location.start_char + "rescue".length] << " StandardError"
|
102
|
+
all << {
|
103
|
+
position: {
|
104
|
+
line: node.location.start_line - 1,
|
105
|
+
character: node.location.start_column + "rescue".length
|
106
|
+
},
|
107
|
+
label: " StandardError"
|
108
|
+
}
|
101
109
|
end
|
102
110
|
|
103
111
|
super
|
@@ -129,6 +137,20 @@ module SyntaxTree
|
|
129
137
|
private
|
130
138
|
|
131
139
|
def parentheses(location)
|
140
|
+
all << {
|
141
|
+
position: {
|
142
|
+
line: location.start_line - 1,
|
143
|
+
character: location.start_column
|
144
|
+
},
|
145
|
+
label: "₍"
|
146
|
+
}
|
147
|
+
all << {
|
148
|
+
position: {
|
149
|
+
line: location.end_line - 1,
|
150
|
+
character: location.end_column
|
151
|
+
},
|
152
|
+
label: "₎"
|
153
|
+
}
|
132
154
|
before[location.start_char] << "₍"
|
133
155
|
after[location.end_char] << "₎"
|
134
156
|
end
|
@@ -61,11 +61,19 @@ module SyntaxTree
|
|
61
61
|
}
|
62
62
|
write(id: id, result: [format(store[uri])])
|
63
63
|
in {
|
64
|
+
# official RPC in LSP spec 3.17
|
65
|
+
method: "textDocument/inlayHint",
|
66
|
+
id:,
|
67
|
+
params: { textDocument: { uri: } }
|
68
|
+
}
|
69
|
+
write(id: id, result: inlay_hints(store[uri], false))
|
70
|
+
in {
|
71
|
+
# proprietary RPC (deprecated) between this gem and vscode-syntax-tree
|
64
72
|
method: "textDocument/inlayHints",
|
65
73
|
id:,
|
66
74
|
params: { textDocument: { uri: } }
|
67
75
|
}
|
68
|
-
write(id: id, result: inlay_hints(store[uri]))
|
76
|
+
write(id: id, result: inlay_hints(store[uri], true))
|
69
77
|
in {
|
70
78
|
method: "syntaxTree/visualizing",
|
71
79
|
id:,
|
@@ -85,6 +93,9 @@ module SyntaxTree
|
|
85
93
|
def capabilities
|
86
94
|
{
|
87
95
|
documentFormattingProvider: true,
|
96
|
+
inlayHintProvider: {
|
97
|
+
resolveProvider: false
|
98
|
+
},
|
88
99
|
textDocumentSync: {
|
89
100
|
change: 1,
|
90
101
|
openClose: true
|
@@ -108,14 +119,18 @@ module SyntaxTree
|
|
108
119
|
}
|
109
120
|
end
|
110
121
|
|
111
|
-
def inlay_hints(source)
|
122
|
+
def inlay_hints(source, proprietary)
|
112
123
|
inlay_hints = InlayHints.find(SyntaxTree.parse(source))
|
113
124
|
serialize = ->(position, text) { { position: position, text: text } }
|
114
125
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
126
|
+
if proprietary
|
127
|
+
{
|
128
|
+
before: inlay_hints.before.map(&serialize),
|
129
|
+
after: inlay_hints.after.map(&serialize)
|
130
|
+
}
|
131
|
+
else
|
132
|
+
inlay_hints.all
|
133
|
+
end
|
119
134
|
rescue Parser::ParseError
|
120
135
|
# If there is a parse error, then we're not going to return any inlay
|
121
136
|
# hints for this source.
|
data/lib/syntax_tree/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: syntax_tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Newton
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: prettier_print
|
@@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
160
|
- !ruby/object:Gem::Version
|
161
161
|
version: '0'
|
162
162
|
requirements: []
|
163
|
-
rubygems_version: 3.
|
163
|
+
rubygems_version: 3.4.0.dev
|
164
164
|
signing_key:
|
165
165
|
specification_version: 4
|
166
166
|
summary: A parser based on ripper
|