syntax_tree 5.0.0 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +51 -0
- data/CHANGELOG.md +24 -1
- data/Gemfile.lock +9 -9
- data/README.md +5 -5
- data/lib/syntax_tree/cli.rb +8 -6
- data/lib/syntax_tree/dsl.rb +1004 -0
- data/lib/syntax_tree/formatter.rb +2 -2
- data/lib/syntax_tree/language_server.rb +2 -0
- data/lib/syntax_tree/node.rb +7 -7
- data/lib/syntax_tree/parser.rb +20 -21
- data/lib/syntax_tree/version.rb +1 -1
- data/lib/syntax_tree/yarv/assembler.rb +459 -0
- data/lib/syntax_tree/yarv/bf.rb +179 -0
- data/lib/syntax_tree/yarv/compiler.rb +2287 -0
- data/lib/syntax_tree/yarv/decompiler.rb +254 -0
- data/lib/syntax_tree/yarv/disassembler.rb +211 -0
- data/lib/syntax_tree/yarv/instruction_sequence.rb +1171 -0
- data/lib/syntax_tree/yarv/instructions.rb +5203 -0
- data/lib/syntax_tree/yarv/legacy.rb +192 -0
- data/lib/syntax_tree/yarv/local_table.rb +89 -0
- data/lib/syntax_tree/yarv.rb +287 -0
- data/lib/syntax_tree.rb +23 -1
- data/syntax_tree.gemspec +1 -1
- metadata +15 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0adfab4347f7d3abda07479e427b2df975e98fb9dafa731cb8b2188da42ab18b
|
4
|
+
data.tar.gz: 4d730d2eaadfa61585e683f6ad444b40336787a561ac7f08c630d5aef857d3d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 890fdc12c1d6d0643231a908bb0f1a503d365fc56d1349f36dc99497eff6a30e51309ecce2cb19e10159e3dd1a1f811a8fd8c3904c94943992ff069811f85ced
|
7
|
+
data.tar.gz: f1e546cd8397b62f4c518103b18c712fead74c82e23ecb527909727a91f7556cddc9886c730be8a968e957b64addb79c9665869e6fcb57b1d26b1b7f13f5bfa5
|
data/.rubocop.yml
CHANGED
@@ -16,6 +16,15 @@ Layout/LineLength:
|
|
16
16
|
Lint/AmbiguousBlockAssociation:
|
17
17
|
Enabled: false
|
18
18
|
|
19
|
+
Lint/AmbiguousOperatorPrecedence:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Lint/AmbiguousRange:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Lint/BooleanSymbol:
|
26
|
+
Enabled: false
|
27
|
+
|
19
28
|
Lint/DuplicateBranch:
|
20
29
|
Enabled: false
|
21
30
|
|
@@ -28,9 +37,18 @@ Lint/InterpolationCheck:
|
|
28
37
|
Lint/MissingSuper:
|
29
38
|
Enabled: false
|
30
39
|
|
40
|
+
Lint/NonLocalExitFromIterator:
|
41
|
+
Enabled: false
|
42
|
+
|
31
43
|
Lint/RedundantRequireStatement:
|
32
44
|
Enabled: false
|
33
45
|
|
46
|
+
Lint/SuppressedException:
|
47
|
+
Enabled: false
|
48
|
+
|
49
|
+
Lint/UnderscorePrefixedVariableName:
|
50
|
+
Enabled: false
|
51
|
+
|
34
52
|
Lint/UnusedMethodArgument:
|
35
53
|
AllowUnusedKeywordArguments: true
|
36
54
|
|
@@ -46,15 +64,42 @@ Naming/MethodParameterName:
|
|
46
64
|
Naming/RescuedExceptionsVariableName:
|
47
65
|
PreferredName: error
|
48
66
|
|
67
|
+
Naming/VariableNumber:
|
68
|
+
Enabled: false
|
69
|
+
|
70
|
+
Security/Eval:
|
71
|
+
Enabled: false
|
72
|
+
|
73
|
+
Style/AccessorGrouping:
|
74
|
+
Enabled: false
|
75
|
+
|
49
76
|
Style/CaseEquality:
|
50
77
|
Enabled: false
|
51
78
|
|
79
|
+
Style/CaseLikeIf:
|
80
|
+
Enabled: false
|
81
|
+
|
82
|
+
Style/ClassVars:
|
83
|
+
Enabled: false
|
84
|
+
|
85
|
+
Style/DocumentDynamicEvalDefinition:
|
86
|
+
Enabled: false
|
87
|
+
|
88
|
+
Style/Documentation:
|
89
|
+
Enabled: false
|
90
|
+
|
91
|
+
Style/EndBlock:
|
92
|
+
Enabled: false
|
93
|
+
|
52
94
|
Style/ExplicitBlockArgument:
|
53
95
|
Enabled: false
|
54
96
|
|
55
97
|
Style/FormatString:
|
56
98
|
Enabled: false
|
57
99
|
|
100
|
+
Style/FormatStringToken:
|
101
|
+
Enabled: false
|
102
|
+
|
58
103
|
Style/GuardClause:
|
59
104
|
Enabled: false
|
60
105
|
|
@@ -79,6 +124,9 @@ Style/MutableConstant:
|
|
79
124
|
Style/NegatedIfElseCondition:
|
80
125
|
Enabled: false
|
81
126
|
|
127
|
+
Style/Next:
|
128
|
+
Enabled: false
|
129
|
+
|
82
130
|
Style/NumericPredicate:
|
83
131
|
Enabled: false
|
84
132
|
|
@@ -88,6 +136,9 @@ Style/ParallelAssignment:
|
|
88
136
|
Style/PerlBackrefs:
|
89
137
|
Enabled: false
|
90
138
|
|
139
|
+
Style/SafeNavigation:
|
140
|
+
Enabled: false
|
141
|
+
|
91
142
|
Style/SpecialGlobalVars:
|
92
143
|
Enabled: false
|
93
144
|
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,27 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [5.1.0] - 2022-12-28
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- An experiment in working with instruction sequences has been added to Syntax Tree. This is subject to change, so it is not well documented or tested at the moment. It does not impact other functionality.
|
14
|
+
- You can now format at a different base layer of indentation. This is an optional third argument to `SyntaxTree::format`.
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
|
18
|
+
- Support forwarding anonymous keyword arguments with `**`.
|
19
|
+
- The `BodyStmt` node now has a more correct location information.
|
20
|
+
- Ignore the `textDocument/documentColor` request coming into the language server to support clients that require that request be received.
|
21
|
+
- Do not attempt to convert `if..else` into ternaries if the predicate has a `Binary` node.
|
22
|
+
- Properly handle nested pattern matching when a rightward assignment is inside a `when` clause.
|
23
|
+
|
24
|
+
## [5.0.1] - 2022-11-10
|
25
|
+
|
26
|
+
### Changed
|
27
|
+
|
28
|
+
- Fix the plugin parsing on the CLI so that they are respected.
|
29
|
+
|
9
30
|
## [5.0.0] - 2022-11-09
|
10
31
|
|
11
32
|
### Added
|
@@ -450,7 +471,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
450
471
|
|
451
472
|
- 🎉 Initial release! 🎉
|
452
473
|
|
453
|
-
[unreleased]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v5.
|
474
|
+
[unreleased]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v5.1.0...HEAD
|
475
|
+
[5.1.0]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v5.0.1...v5.1.0
|
476
|
+
[5.0.1]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v5.0.0...v5.0.1
|
454
477
|
[5.0.0]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v4.3.0...v5.0.0
|
455
478
|
[4.3.0]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v4.2.0...v4.3.0
|
456
479
|
[4.2.0]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v4.1.0...v4.2.0
|
data/Gemfile.lock
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
syntax_tree (5.
|
5
|
-
prettier_print (>= 1.
|
4
|
+
syntax_tree (5.1.0)
|
5
|
+
prettier_print (>= 1.2.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
ast (2.4.2)
|
11
11
|
docile (1.4.0)
|
12
|
-
json (2.6.
|
12
|
+
json (2.6.3)
|
13
13
|
minitest (5.16.3)
|
14
14
|
parallel (1.22.1)
|
15
|
-
parser (3.1.
|
15
|
+
parser (3.1.3.0)
|
16
16
|
ast (~> 2.4.1)
|
17
|
-
prettier_print (1.
|
17
|
+
prettier_print (1.2.0)
|
18
18
|
rainbow (3.1.1)
|
19
19
|
rake (13.0.6)
|
20
|
-
regexp_parser (2.6.
|
20
|
+
regexp_parser (2.6.1)
|
21
21
|
rexml (3.2.5)
|
22
|
-
rubocop (1.
|
22
|
+
rubocop (1.41.1)
|
23
23
|
json (~> 2.3)
|
24
24
|
parallel (~> 1.10)
|
25
25
|
parser (>= 3.1.2.1)
|
@@ -29,10 +29,10 @@ GEM
|
|
29
29
|
rubocop-ast (>= 1.23.0, < 2.0)
|
30
30
|
ruby-progressbar (~> 1.7)
|
31
31
|
unicode-display_width (>= 1.4.0, < 3.0)
|
32
|
-
rubocop-ast (1.
|
32
|
+
rubocop-ast (1.24.0)
|
33
33
|
parser (>= 3.1.1.0)
|
34
34
|
ruby-progressbar (1.11.0)
|
35
|
-
simplecov (0.
|
35
|
+
simplecov (0.22.0)
|
36
36
|
docile (~> 1.1)
|
37
37
|
simplecov-html (~> 0.11)
|
38
38
|
simplecov_json_formatter (~> 0.1)
|
data/README.md
CHANGED
@@ -324,11 +324,11 @@ stree write "**/{[!schema]*,*}.rb"
|
|
324
324
|
|
325
325
|
## Library
|
326
326
|
|
327
|
-
Syntax Tree can be used as a library to access the syntax tree underlying Ruby source code.
|
327
|
+
Syntax Tree can be used as a library to access the syntax tree underlying Ruby source code. The API is described below. For the full library documentation, see the [RDoc documentation](https://ruby-syntax-tree.github.io/syntax_tree/).
|
328
328
|
|
329
329
|
### SyntaxTree.read(filepath)
|
330
330
|
|
331
|
-
This function takes a filepath and returns a string associated with the content of that file. It is similar in functionality to `File.read`, except
|
331
|
+
This function takes a filepath and returns a string associated with the content of that file. It is similar in functionality to `File.read`, except that it takes into account Ruby-level file encoding (through magic comments at the top of the file).
|
332
332
|
|
333
333
|
### SyntaxTree.parse(source)
|
334
334
|
|
@@ -570,7 +570,7 @@ SyntaxTree::Formatter.format(source, program.accept(visitor))
|
|
570
570
|
### WithEnvironment
|
571
571
|
|
572
572
|
The `WithEnvironment` module can be included in visitors to automatically keep track of local variables and arguments
|
573
|
-
defined inside each environment. A `current_environment` accessor is made
|
573
|
+
defined inside each environment. A `current_environment` accessor is made available to the request, allowing it to find
|
574
574
|
all usages and definitions of a local.
|
575
575
|
|
576
576
|
```ruby
|
@@ -611,7 +611,7 @@ The language server also responds to the relatively new inlay hints request. Thi
|
|
611
611
|
1 + 2 * 3
|
612
612
|
```
|
613
613
|
|
614
|
-
|
614
|
+
Implicitly, the `2 * 3` is going to be executed first because the `*` operator has higher precedence than the `+` operator. To ease mental overhead, our language server includes small parentheses to make this explicit, as in:
|
615
615
|
|
616
616
|
```ruby
|
617
617
|
1 + ₍2 * 3₎
|
@@ -686,7 +686,7 @@ Below are listed all of the "official" language plugins hosted under the same Gi
|
|
686
686
|
|
687
687
|
## Integration
|
688
688
|
|
689
|
-
Syntax Tree's goal is to
|
689
|
+
Syntax Tree's goal is to seamlessly integrate into your workflow. To this end, it provides a couple of additional tools beyond the CLI and the Ruby library.
|
690
690
|
|
691
691
|
### Rake
|
692
692
|
|
data/lib/syntax_tree/cli.rb
CHANGED
@@ -377,14 +377,19 @@ module SyntaxTree
|
|
377
377
|
:plugins,
|
378
378
|
:print_width,
|
379
379
|
:scripts,
|
380
|
-
:
|
380
|
+
:target_ruby_version
|
381
381
|
|
382
382
|
def initialize
|
383
383
|
@ignore_files = []
|
384
384
|
@plugins = []
|
385
385
|
@print_width = DEFAULT_PRINT_WIDTH
|
386
386
|
@scripts = []
|
387
|
-
@
|
387
|
+
@target_ruby_version = DEFAULT_RUBY_VERSION
|
388
|
+
end
|
389
|
+
|
390
|
+
def formatter_options
|
391
|
+
@formatter_options ||=
|
392
|
+
Formatter::Options.new(target_ruby_version: target_ruby_version)
|
388
393
|
end
|
389
394
|
|
390
395
|
def parse(arguments)
|
@@ -430,10 +435,7 @@ module SyntaxTree
|
|
430
435
|
# If there is a target ruby version specified on the command line,
|
431
436
|
# parse that out and use it when formatting.
|
432
437
|
opts.on("--target-ruby-version=VERSION") do |version|
|
433
|
-
@
|
434
|
-
Formatter::Options.new(
|
435
|
-
target_ruby_version: Formatter::SemanticVersion.new(version)
|
436
|
-
)
|
438
|
+
@target_ruby_version = Formatter::SemanticVersion.new(version)
|
437
439
|
end
|
438
440
|
end
|
439
441
|
end
|