prettier 2.0.0.pre.rc2 → 2.0.0.pre.rc3
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 +9 -1
- data/dist/parser/server.rb +3 -2
- data/dist/ruby/nodes/blocks.js +21 -2
- data/dist/ruby/parser.rb +16 -38
- data/dist/ruby/printer.js +4 -0
- data/package.json +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: 8aa6c76fdc06048c17f4ae26b2179b181e2e10f4210c6d840d8059c661becdb5
|
4
|
+
data.tar.gz: 186e3d071167018e2eeb16d50818be1a1684710a0007226f2b3b3c403a190cd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31b4ebe0dc6c6a382c858f1349f4de1161e311df22d122c2f8935d833417e2ed235e42f075ded605f5e6924d3d2a2fb545123b9a5f66bfb89615c4cde3216758
|
7
|
+
data.tar.gz: 81a4467f636867133da2a93c5fc2f9a595e54dae597f9cde5ba45e98c0485cb3e2ab890151ce6e2da765881b753f1ce140b758bba70f25dcd1e64e950326a6ba
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,13 @@ 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.0.0-rc3]
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
|
13
|
+
- [#987](https://github.com/prettier/plugin-ruby/pull/9870) - valscion - Ignore stderr when checking for node <-> ruby connection clients, restoring the behavior of v1.x
|
14
|
+
- [#989](https://github.com/prettier/plugin-ruby/issues/989) - hubertjakubiak, kddnewton - Make sure comments after the keyword/lbrace are not moved inside the body of the statements of do and brace blocks.
|
15
|
+
|
9
16
|
## [2.0.0-rc2]
|
10
17
|
|
11
18
|
### Added
|
@@ -1162,7 +1169,8 @@ would previously result in `array[]`, but now prints properly.
|
|
1162
1169
|
|
1163
1170
|
- Initial release 🎉
|
1164
1171
|
|
1165
|
-
[unreleased]: https://github.com/prettier/plugin-ruby/compare/v2.0.0-
|
1172
|
+
[unreleased]: https://github.com/prettier/plugin-ruby/compare/v2.0.0-rc3...HEAD
|
1173
|
+
[2.0.0-rc3]: https://github.com/prettier/plugin-ruby/compare/v2.0.0-rc2...v2.0.0-rc3
|
1166
1174
|
[2.0.0-rc2]: https://github.com/prettier/plugin-ruby/compare/v2.0.0-rc1...v2.0.0-rc2
|
1167
1175
|
[2.0.0-rc1]: https://github.com/prettier/plugin-ruby/compare/v1.6.1...v2.0.0-rc1
|
1168
1176
|
[1.6.1]: https://github.com/prettier/plugin-ruby/compare/v1.6.0...v1.6.1
|
data/dist/parser/server.rb
CHANGED
@@ -112,8 +112,9 @@ candidates.map! do |candidate|
|
|
112
112
|
Thread.new do
|
113
113
|
Thread.current.report_on_exception = false
|
114
114
|
|
115
|
-
|
116
|
-
|
115
|
+
# We do not care about stderr here, so throw it away
|
116
|
+
stdout, _stderr, status =
|
117
|
+
Open3.capture3("#{candidate} #{information}", stdin_data: 'ping')
|
117
118
|
|
118
119
|
candidate if JSON.parse(stdout) == 'pong' && status.exitstatus == 0
|
119
120
|
rescue StandardError
|
data/dist/ruby/nodes/blocks.js
CHANGED
@@ -17,6 +17,23 @@ const printBlockVar = (path, opts, print) => {
|
|
17
17
|
return parts;
|
18
18
|
};
|
19
19
|
exports.printBlockVar = printBlockVar;
|
20
|
+
// You have to go through the main print function if you could potentially have
|
21
|
+
// comments attached. So we're doing this weird reflection on the printed docs
|
22
|
+
// to retroactively change the printed keyword depending on if we're using
|
23
|
+
// braces or not. Ideally we wouldn't do this, we would instead do this
|
24
|
+
// reflection in the child printer, but this keeps the logic to just this file
|
25
|
+
// and contains it, so keeping it here for now.
|
26
|
+
function printBlockBeging(path, print, useBraces) {
|
27
|
+
let docs = print(path);
|
28
|
+
const doc = useBraces ? "{" : "do";
|
29
|
+
if (Array.isArray(docs)) {
|
30
|
+
docs[1] = doc;
|
31
|
+
}
|
32
|
+
else {
|
33
|
+
docs = doc;
|
34
|
+
}
|
35
|
+
return docs;
|
36
|
+
}
|
20
37
|
function printBlock(braces) {
|
21
38
|
return function printBlockWithBraces(path, opts, print) {
|
22
39
|
const [variables, statements] = path.getValue().body;
|
@@ -34,7 +51,8 @@ function printBlock(braces) {
|
|
34
51
|
// switch to using braces instead.
|
35
52
|
const useBraces = braces && (0, utils_1.hasAncestor)(path, ["command", "command_call"]);
|
36
53
|
const doBlock = [
|
37
|
-
|
54
|
+
" ",
|
55
|
+
path.call((begingPath) => printBlockBeging(begingPath, print, useBraces), "beging"),
|
38
56
|
variables ? [" ", path.call(print, "body", 0)] : "",
|
39
57
|
doBlockBody,
|
40
58
|
[softline, useBraces ? "}" : "end"]
|
@@ -54,7 +72,8 @@ function printBlock(braces) {
|
|
54
72
|
}
|
55
73
|
const hasBody = stmts.some(({ type }) => type !== "void_stmt");
|
56
74
|
const braceBlock = [
|
57
|
-
"
|
75
|
+
" ",
|
76
|
+
path.call((begingPath) => printBlockBeging(begingPath, print, true), "beging"),
|
58
77
|
hasBody || variables ? " " : "",
|
59
78
|
variables ? path.call(print, "body", 0) : "",
|
60
79
|
path.call(print, "body", 1),
|
data/dist/ruby/parser.rb
CHANGED
@@ -136,12 +136,6 @@ class Prettier::Parser < Ripper
|
|
136
136
|
# keyword.
|
137
137
|
@__end__ = nil
|
138
138
|
|
139
|
-
# Magic comments are a certain kind of comment that can impact the way the
|
140
|
-
# file is parsed (encoding/string frozen default/etc.). These scanner events
|
141
|
-
# are immediately followed by a comment scanner event, so we only need the
|
142
|
-
# one variable to set/unset it immediately.
|
143
|
-
@magic_comment = nil
|
144
|
-
|
145
139
|
# Heredocs can actually be nested together if you're using interpolation, so
|
146
140
|
# this is a stack of heredoc nodes that are currently being created. When we
|
147
141
|
# get to the scanner event that finishes off a heredoc node, we pop the top
|
@@ -799,11 +793,15 @@ class Prettier::Parser < Ripper
|
|
799
793
|
beging = find_scanner_event(:@lbrace)
|
800
794
|
ending = find_scanner_event(:@rbrace)
|
801
795
|
|
802
|
-
stmts.bind(
|
796
|
+
stmts.bind(
|
797
|
+
find_next_statement_start((block_var || beging)[:ec]),
|
798
|
+
ending[:sc]
|
799
|
+
)
|
803
800
|
|
804
801
|
{
|
805
802
|
type: :brace_block,
|
806
803
|
body: [block_var, stmts],
|
804
|
+
beging: beging,
|
807
805
|
sl: beging[:sl],
|
808
806
|
sc: beging[:sc],
|
809
807
|
el: [ending[:el], stmts[:el]].max,
|
@@ -970,22 +968,6 @@ class Prettier::Parser < Ripper
|
|
970
968
|
start_line = lineno
|
971
969
|
start_char = char_pos
|
972
970
|
|
973
|
-
# If we already had special handling of a magic comment, then we can just
|
974
|
-
# skip and return the value of that node.
|
975
|
-
if @magic_comment
|
976
|
-
comment = @magic_comment
|
977
|
-
@magic_comment = nil
|
978
|
-
|
979
|
-
# At the moment, merging in the value of the string being passed into
|
980
|
-
# here. In the next major version I'd like to remove this and just use the
|
981
|
-
# value of the magic comment. At the moment though that would change
|
982
|
-
# comments like -*- encoding: UTF-8 -*- into encoding: UTF-8 so need to
|
983
|
-
|
984
|
-
# wait for a major version to do that.
|
985
|
-
@comments << comment.merge(value: body, ec: start_char + value.length - 1)
|
986
|
-
return comment
|
987
|
-
end
|
988
|
-
|
989
971
|
@comments << {
|
990
972
|
type: :@comment,
|
991
973
|
value: body,
|
@@ -1208,11 +1190,15 @@ class Prettier::Parser < Ripper
|
|
1208
1190
|
beging = find_scanner_event(:@kw, 'do')
|
1209
1191
|
ending = find_scanner_event(:@kw, 'end')
|
1210
1192
|
|
1211
|
-
bodystmt.bind(
|
1193
|
+
bodystmt.bind(
|
1194
|
+
find_next_statement_start((block_var || beging)[:ec]),
|
1195
|
+
ending[:sc]
|
1196
|
+
)
|
1212
1197
|
|
1213
1198
|
{
|
1214
1199
|
type: :do_block,
|
1215
1200
|
body: [block_var, bodystmt],
|
1201
|
+
beging: beging,
|
1216
1202
|
sl: beging[:sl],
|
1217
1203
|
sc: beging[:sc],
|
1218
1204
|
el: ending[:el],
|
@@ -2012,20 +1998,12 @@ class Prettier::Parser < Ripper
|
|
2012
1998
|
# magic_comment is a scanner event that represents the use of a pragma at the
|
2013
1999
|
# beginning of the file. Usually it will inside something like
|
2014
2000
|
# frozen_string_literal (the key) with a value of true (the value). Both
|
2015
|
-
# children come is a string literals.
|
2016
|
-
|
2017
|
-
|
2018
|
-
|
2019
|
-
|
2020
|
-
|
2021
|
-
type: :@comment,
|
2022
|
-
value: " #{key}: #{value}",
|
2023
|
-
sl: start_line,
|
2024
|
-
el: start_line,
|
2025
|
-
sc: start_char,
|
2026
|
-
ec: start_char + @line_counts[start_line][-1]
|
2027
|
-
}
|
2028
|
-
end
|
2001
|
+
# children come is a string literals. We're going to leave these alone as they
|
2002
|
+
# come in all kinds of shapes and sizes.
|
2003
|
+
#
|
2004
|
+
# def on_magic_comment(key, value)
|
2005
|
+
# @magic_comment = { value: " #{key}: #{value}" }
|
2006
|
+
# end
|
2029
2007
|
|
2030
2008
|
# massign is a parser event that is a parent node of any kind of multiple
|
2031
2009
|
# assignment. This includes splitting out variables on the left like:
|
data/dist/ruby/printer.js
CHANGED
@@ -67,6 +67,10 @@ const printer = {
|
|
67
67
|
}
|
68
68
|
return parts;
|
69
69
|
}
|
70
|
+
case "brace_block":
|
71
|
+
return [node.body[0], node.body[1], node.beging];
|
72
|
+
case "do_block":
|
73
|
+
return [node.body[0], node.body[1], node.beging];
|
70
74
|
case "paren":
|
71
75
|
return [node.lparen, node.body[0]];
|
72
76
|
default: {
|
data/package.json
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prettier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.pre.
|
4
|
+
version: 2.0.0.pre.rc3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Newton
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|