syntax_tree-rbs 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e0550ed09644f60c85734f0633143c5fa621356c9fada7f073446070037ca2e
4
- data.tar.gz: fbad990727e58695a58c37cbf31eea3a0f5ed418b4666d38416a8b4fe2aecdaf
3
+ metadata.gz: 22d2b985f00c4722c74fad681a8ee586a6bebbf3fbc2aa0a6476fce331379bed
4
+ data.tar.gz: 9d077e966f23b4777f0d4a8d41ff4a6cde08493c8759f8b399d2f494cc3abc2f
5
5
  SHA512:
6
- metadata.gz: 1c95de371dba5bbffb0b8d78251f77c6143de8db74c17576ae674125b46173db0b35d65ab97eb6ebd8cf44e91311e33a138c78ff84ab5b17c13d0cb914217af9
7
- data.tar.gz: d4bf5bc46aa49848425f119937e45e9e15f131e0dc623b8f6bc4c3f93863cb21a5ce824fbca5aa6fbcf9f34129dd1093eb1ee16806cc27003b3b3b21382d3021
6
+ metadata.gz: fc9cc4ff0703d4ade8295ff7784082f1d4372340ba2bb5094c9f928d5c11726c08437669a8a3b9fb001715b859f2085ce2ca543176541fbebf9ad61ee3fd249b
7
+ data.tar.gz: ad7b5984c280199385c501a743587c06455db0a0d86ffc7072971597113bf3aad4b9a6de794d5d3f2577fba26a95d682a53ccb40d4facbafc767d9f45834e59c
@@ -26,7 +26,9 @@ jobs:
26
26
  bundler-cache: true
27
27
  ruby-version: ${{ matrix.ruby }}
28
28
  - name: Test
29
- run: bundle exec rake test
29
+ run: |
30
+ bundle exec rake test
31
+ bundle exec rake stree:check
30
32
  automerge:
31
33
  name: AutoMerge
32
34
  needs: ci
data/CHANGELOG.md CHANGED
@@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.5.0] - 2022-07-07
10
+
11
+ ### Added
12
+
13
+ - A new `SyntaxTree::RBS::Visitor` class that can be used to walk the tree. All `RBS` nodes now respond to `accept(visitor)` which will delegate to the appropriate methods.
14
+
15
+ ### Changed
16
+
17
+ - Ensure optional proc types have parentheses around them.
18
+
9
19
  ## [0.4.0] - 2022-05-13
10
20
 
11
21
  ### Added
@@ -32,7 +42,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
32
42
 
33
43
  - 🎉 Initial release! 🎉
34
44
 
35
- [unreleased]: https://github.com/ruby-syntax-tree/syntax_tree-rbs/compare/v0.4.0...HEAD
45
+ [unreleased]: https://github.com/ruby-syntax-tree/syntax_tree-rbs/compare/v0.5.0...HEAD
46
+ [0.5.0]: https://github.com/ruby-syntax-tree/syntax_tree-rbs/compare/v0.4.0...v0.5.0
36
47
  [0.4.0]: https://github.com/ruby-syntax-tree/syntax_tree-rbs/compare/v0.3.0...v0.4.0
37
48
  [0.3.0]: https://github.com/ruby-syntax-tree/syntax_tree-rbs/compare/v0.2.0...v0.3.0
38
49
  [0.2.0]: https://github.com/ruby-syntax-tree/syntax_tree-rbs/compare/v0.1.0...v0.2.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- syntax_tree-rbs (0.4.0)
4
+ syntax_tree-rbs (0.5.0)
5
5
  prettier_print
6
6
  rbs
7
7
  syntax_tree (>= 2.0.1)
@@ -10,17 +10,17 @@ GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  docile (1.4.0)
13
- minitest (5.15.0)
13
+ minitest (5.16.2)
14
14
  prettier_print (0.1.0)
15
15
  rake (13.0.6)
16
- rbs (2.4.0)
16
+ rbs (2.6.0)
17
17
  simplecov (0.21.2)
18
18
  docile (~> 1.1)
19
19
  simplecov-html (~> 0.11)
20
20
  simplecov_json_formatter (~> 0.1)
21
21
  simplecov-html (0.12.3)
22
22
  simplecov_json_formatter (0.1.4)
23
- syntax_tree (2.5.0)
23
+ syntax_tree (3.0.0)
24
24
  prettier_print
25
25
 
26
26
  PLATFORMS
data/Rakefile CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "bundler/gem_tasks"
4
4
  require "rake/testtask"
5
+ require "syntax_tree/rake_tasks"
5
6
 
6
7
  Rake::TestTask.new(:test) do |t|
7
8
  t.libs << "test"
@@ -9,4 +10,10 @@ Rake::TestTask.new(:test) do |t|
9
10
  t.test_files = FileList["test/**/*_test.rb"]
10
11
  end
11
12
 
13
+ SOURCE_FILES =
14
+ FileList[%w[Gemfile Rakefile syntax_tree-rbs.gemspec lib/**/*.rb test/*.rb]]
15
+
16
+ SyntaxTree::Rake::CheckTask.new { |t| t.source_files = SOURCE_FILES }
17
+ SyntaxTree::Rake::WriteTask.new { |t| t.source_files = SOURCE_FILES }
18
+
12
19
  task default: :test
@@ -0,0 +1,392 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SyntaxTree
4
+ module RBS
5
+ # These are the methods that are going to be defined on each node of the
6
+ # AST. They each will create a visitor and enter into the visitor's walking
7
+ # algorithm.
8
+ module Entrypoints
9
+ def format(q)
10
+ accept(Format.new(q))
11
+ end
12
+
13
+ def pretty_print(q)
14
+ accept(PrettyPrint.new(q))
15
+ end
16
+ end
17
+
18
+ # This is the root node of the entire tree. It contains all of the top-level
19
+ # declarations within the file.
20
+ class Root
21
+ include Entrypoints
22
+
23
+ attr_reader :declarations
24
+
25
+ def initialize(declarations)
26
+ @declarations = declarations
27
+ end
28
+
29
+ def accept(visitor)
30
+ visitor.visit_root(self)
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ module RBS
37
+ class TypeName
38
+ include SyntaxTree::RBS::Entrypoints
39
+
40
+ def accept(visitor)
41
+ visitor.visit_type_name(self)
42
+ end
43
+ end
44
+
45
+ module AST
46
+ module Declarations
47
+ class Base
48
+ include SyntaxTree::RBS::Entrypoints
49
+ end
50
+
51
+ # type foo = String
52
+ class Alias
53
+ def accept(visitor)
54
+ visitor.visit_alias_declaration(self)
55
+ end
56
+ end
57
+
58
+ # class Foo end
59
+ class Class
60
+ def accept(visitor)
61
+ visitor.visit_class_declaration(self)
62
+ end
63
+ end
64
+
65
+ # Foo: String
66
+ class Constant
67
+ def accept(visitor)
68
+ visitor.visit_constant_declaration(self)
69
+ end
70
+ end
71
+
72
+ # $foo: String
73
+ class Global
74
+ def accept(visitor)
75
+ visitor.visit_global_declaration(self)
76
+ end
77
+ end
78
+
79
+ # interface _Foo end
80
+ class Interface
81
+ def accept(visitor)
82
+ visitor.visit_interface_declaration(self)
83
+ end
84
+ end
85
+
86
+ # module Foo end
87
+ class Module
88
+ def accept(visitor)
89
+ visitor.visit_module_declaration(self)
90
+ end
91
+ end
92
+ end
93
+
94
+ module Members
95
+ class Base
96
+ include SyntaxTree::RBS::Entrypoints
97
+ end
98
+
99
+ # alias foo bar
100
+ # alias self.foo self.bar
101
+ class Alias
102
+ def accept(visitor)
103
+ visitor.visit_alias_member(self)
104
+ end
105
+ end
106
+
107
+ # attr_accessor foo: Foo
108
+ class AttrAccessor
109
+ def accept(visitor)
110
+ visitor.visit_attr_accessor_member(self)
111
+ end
112
+ end
113
+
114
+ # attr_reader foo: Foo
115
+ class AttrReader
116
+ def accept(visitor)
117
+ visitor.visit_attr_reader_member(self)
118
+ end
119
+ end
120
+
121
+ # attr_writer foo: Foo
122
+ class AttrWriter
123
+ def accept(visitor)
124
+ visitor.visit_attr_writer_member(self)
125
+ end
126
+ end
127
+
128
+ # self.@foo: String
129
+ class ClassInstanceVariable
130
+ def accept(visitor)
131
+ visitor.visit_class_instance_variable_member(self)
132
+ end
133
+ end
134
+
135
+ # @@foo: String
136
+ class ClassVariable
137
+ def accept(visitor)
138
+ visitor.visit_class_variable_member(self)
139
+ end
140
+ end
141
+
142
+ # extend Foo
143
+ class Extend
144
+ def accept(visitor)
145
+ visitor.visit_extend_member(self)
146
+ end
147
+ end
148
+
149
+ # include Foo
150
+ class Include
151
+ def accept(visitor)
152
+ visitor.visit_include_member(self)
153
+ end
154
+ end
155
+
156
+ # @foo: String
157
+ class InstanceVariable
158
+ def accept(visitor)
159
+ visitor.visit_instance_variable_member(self)
160
+ end
161
+ end
162
+
163
+ # def t: (T t) -> void
164
+ class MethodDefinition
165
+ def accept(visitor)
166
+ visitor.visit_method_definition_member(self)
167
+ end
168
+ end
169
+
170
+ # prepend Foo
171
+ class Prepend
172
+ def accept(visitor)
173
+ visitor.visit_prepend_member(self)
174
+ end
175
+ end
176
+
177
+ # private
178
+ class Private
179
+ def accept(visitor)
180
+ visitor.visit_private_member(self)
181
+ end
182
+ end
183
+
184
+ # public
185
+ class Public
186
+ def accept(visitor)
187
+ visitor.visit_public_member(self)
188
+ end
189
+ end
190
+ end
191
+ end
192
+
193
+ module Types
194
+ # Foo
195
+ class Alias
196
+ include SyntaxTree::RBS::Entrypoints
197
+
198
+ def accept(visitor)
199
+ visitor.visit_alias_type(self)
200
+ end
201
+ end
202
+
203
+ # any
204
+ class Bases::Any
205
+ include SyntaxTree::RBS::Entrypoints
206
+
207
+ def accept(visitor)
208
+ visitor.visit_any_type(self)
209
+ end
210
+ end
211
+
212
+ # bool
213
+ class Bases::Bool
214
+ include SyntaxTree::RBS::Entrypoints
215
+
216
+ def accept(visitor)
217
+ visitor.visit_bool_type(self)
218
+ end
219
+ end
220
+
221
+ # bottom
222
+ class Bases::Bottom
223
+ include SyntaxTree::RBS::Entrypoints
224
+
225
+ def accept(visitor)
226
+ visitor.visit_bottom_type(self)
227
+ end
228
+ end
229
+
230
+ # class
231
+ class Bases::Class
232
+ include SyntaxTree::RBS::Entrypoints
233
+
234
+ def accept(visitor)
235
+ visitor.visit_class_type(self)
236
+ end
237
+ end
238
+
239
+ # instance
240
+ class Bases::Instance
241
+ include SyntaxTree::RBS::Entrypoints
242
+
243
+ def accept(visitor)
244
+ visitor.visit_instance_type(self)
245
+ end
246
+ end
247
+
248
+ # nil
249
+ class Bases::Nil
250
+ include SyntaxTree::RBS::Entrypoints
251
+
252
+ def accept(visitor)
253
+ visitor.visit_nil_type(self)
254
+ end
255
+ end
256
+
257
+ # self
258
+ class Bases::Self
259
+ include SyntaxTree::RBS::Entrypoints
260
+
261
+ def accept(visitor)
262
+ visitor.visit_self_type(self)
263
+ end
264
+ end
265
+
266
+ # top
267
+ class Bases::Top
268
+ include SyntaxTree::RBS::Entrypoints
269
+
270
+ def accept(visitor)
271
+ visitor.visit_top_type(self)
272
+ end
273
+ end
274
+
275
+ # void
276
+ class Bases::Void
277
+ include SyntaxTree::RBS::Entrypoints
278
+
279
+ def accept(visitor)
280
+ visitor.visit_void_type(self)
281
+ end
282
+ end
283
+
284
+ # Foo
285
+ class ClassInstance
286
+ include SyntaxTree::RBS::Entrypoints
287
+
288
+ def accept(visitor)
289
+ visitor.visit_class_instance_type(self)
290
+ end
291
+ end
292
+
293
+ # singleton(Foo)
294
+ class ClassSingleton
295
+ include SyntaxTree::RBS::Entrypoints
296
+
297
+ def accept(visitor)
298
+ visitor.visit_class_singleton_type(self)
299
+ end
300
+ end
301
+
302
+ # Foo foo
303
+ class Function::Param
304
+ include SyntaxTree::RBS::Entrypoints
305
+
306
+ def accept(visitor)
307
+ visitor.visit_function_param_type(self)
308
+ end
309
+ end
310
+
311
+ # _Foo
312
+ class Interface
313
+ include SyntaxTree::RBS::Entrypoints
314
+
315
+ def accept(visitor)
316
+ visitor.visit_interface_type(self)
317
+ end
318
+ end
319
+
320
+ # foo & bar
321
+ class Intersection
322
+ include SyntaxTree::RBS::Entrypoints
323
+
324
+ def accept(visitor)
325
+ visitor.visit_intersection_type(self)
326
+ end
327
+ end
328
+
329
+ # 1
330
+ class Literal
331
+ include SyntaxTree::RBS::Entrypoints
332
+
333
+ def accept(visitor)
334
+ visitor.visit_literal_type(self)
335
+ end
336
+ end
337
+
338
+ # foo?
339
+ class Optional
340
+ include SyntaxTree::RBS::Entrypoints
341
+
342
+ def accept(visitor)
343
+ visitor.visit_optional_type(self)
344
+ end
345
+ end
346
+
347
+ # ^-> void
348
+ class Proc
349
+ include SyntaxTree::RBS::Entrypoints
350
+
351
+ def accept(visitor)
352
+ visitor.visit_proc_type(self)
353
+ end
354
+ end
355
+
356
+ # { foo: bar }
357
+ class Record
358
+ include SyntaxTree::RBS::Entrypoints
359
+
360
+ def accept(visitor)
361
+ visitor.visit_record_type(self)
362
+ end
363
+ end
364
+
365
+ # [foo, bar]
366
+ class Tuple
367
+ include SyntaxTree::RBS::Entrypoints
368
+
369
+ def accept(visitor)
370
+ visitor.visit_tuple_type(self)
371
+ end
372
+ end
373
+
374
+ # foo | bar
375
+ class Union
376
+ include SyntaxTree::RBS::Entrypoints
377
+
378
+ def accept(visitor)
379
+ visitor.visit_union_type(self)
380
+ end
381
+ end
382
+
383
+ # foo
384
+ class Variable
385
+ include SyntaxTree::RBS::Entrypoints
386
+
387
+ def accept(visitor)
388
+ visitor.visit_variable_type(self)
389
+ end
390
+ end
391
+ end
392
+ end