prettier 2.0.0 → 2.1.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 +23 -1
- data/dist/haml/parser.rb +6 -0
- data/dist/parser/getInfo.js +9 -2
- data/dist/parser/server.rb +6 -2
- data/dist/rbs/parser.rb +59 -2
- data/dist/rbs/printer.js +14 -6
- data/dist/ruby/embed.js +10 -5
- data/dist/ruby/location.js +19 -0
- data/dist/ruby/nodes/alias.js +6 -5
- data/dist/ruby/nodes/aref.js +4 -6
- data/dist/ruby/nodes/args.js +29 -56
- data/dist/ruby/nodes/arrays.js +31 -35
- data/dist/ruby/nodes/assign.js +19 -23
- data/dist/ruby/nodes/blocks.js +18 -15
- data/dist/ruby/nodes/calls.js +33 -30
- data/dist/ruby/nodes/case.js +8 -8
- data/dist/ruby/nodes/class.js +13 -13
- data/dist/ruby/nodes/commands.js +36 -22
- data/dist/ruby/nodes/conditionals.js +56 -52
- data/dist/ruby/nodes/constants.js +10 -13
- data/dist/ruby/nodes/flow.js +39 -46
- data/dist/ruby/nodes/hashes.js +26 -30
- data/dist/ruby/nodes/heredocs.js +9 -9
- data/dist/ruby/nodes/hooks.js +2 -2
- data/dist/ruby/nodes/ints.js +5 -5
- data/dist/ruby/nodes/lambdas.js +7 -6
- data/dist/ruby/nodes/loops.js +26 -24
- data/dist/ruby/nodes/massign.js +22 -35
- data/dist/ruby/nodes/methods.js +20 -40
- data/dist/ruby/nodes/operators.js +26 -28
- data/dist/ruby/nodes/params.js +31 -25
- data/dist/ruby/nodes/patterns.js +34 -37
- data/dist/ruby/nodes/regexp.js +6 -6
- data/dist/ruby/nodes/rescue.js +23 -22
- data/dist/ruby/nodes/return.js +61 -36
- data/dist/ruby/nodes/statements.js +24 -25
- data/dist/ruby/nodes/strings.js +36 -34
- data/dist/ruby/nodes/super.js +6 -10
- data/dist/ruby/nodes/undef.js +19 -14
- data/dist/ruby/nodes.js +47 -21
- data/dist/ruby/parser.js +3 -2
- data/dist/ruby/parser.rb +8470 -2972
- data/dist/ruby/printer.js +9 -71
- data/dist/ruby/toProc.js +33 -35
- data/dist/types.js +5 -1
- data/dist/utils/containsAssignment.js +5 -2
- data/dist/utils/getChildNodes.js +305 -0
- data/dist/utils/inlineEnsureParens.js +1 -1
- data/dist/utils/isEmptyBodyStmt.js +1 -1
- data/dist/utils/isEmptyParams.js +12 -0
- data/dist/utils/isEmptyStmts.js +1 -1
- data/dist/utils/makeCall.js +5 -4
- data/dist/utils/printEmptyCollection.js +3 -1
- data/dist/utils/skipAssignIndent.js +6 -2
- data/dist/utils.js +5 -3
- data/lib/prettier.rb +2 -1
- data/node_modules/prettier/bin-prettier.js +48 -18924
- data/node_modules/prettier/cli.js +12335 -0
- data/node_modules/prettier/doc.js +1306 -4755
- data/node_modules/prettier/index.js +37468 -57614
- data/node_modules/prettier/package.json +3 -2
- data/node_modules/prettier/parser-angular.js +2 -66
- data/node_modules/prettier/parser-babel.js +27 -22
- data/node_modules/prettier/parser-espree.js +26 -22
- data/node_modules/prettier/parser-flow.js +26 -22
- data/node_modules/prettier/parser-glimmer.js +27 -1
- data/node_modules/prettier/parser-graphql.js +15 -1
- data/node_modules/prettier/parser-html.js +21 -117
- data/node_modules/prettier/parser-markdown.js +61 -19
- data/node_modules/prettier/parser-meriyah.js +19 -22
- data/node_modules/prettier/parser-postcss.js +76 -22
- data/node_modules/prettier/parser-typescript.js +280 -22
- data/node_modules/prettier/parser-yaml.js +150 -15
- data/node_modules/prettier/third-party.js +8660 -11030
- data/package.json +7 -7
- metadata +7 -3
data/dist/ruby/nodes/strings.js
CHANGED
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.printXStringLiteral = exports.printSymbolLiteral = exports.printStringLiteral = exports.printStringEmbExpr = exports.printStringDVar = exports.printStringConcat = exports.printDynaSymbol = exports.printChar = void 0;
|
7
7
|
const prettier_1 = __importDefault(require("../../prettier"));
|
8
|
+
const location_1 = require("../location");
|
8
9
|
const { group, hardline, indent, literalline, removeLines, softline, join } = prettier_1.default;
|
9
10
|
// If there is some part of this string that matches an escape sequence or that
|
10
11
|
// contains the interpolation pattern ("#{"), then we are locked into whichever
|
@@ -12,13 +13,13 @@ const { group, hardline, indent, literalline, removeLines, softline, join } = pr
|
|
12
13
|
// would activate the escape sequence, and if they chose double quotes, then
|
13
14
|
// single quotes would deactivate it.)
|
14
15
|
function isQuoteLocked(node) {
|
15
|
-
return node.
|
16
|
-
(part.
|
16
|
+
return node.parts.some((part) => part.type === "tstring_content" &&
|
17
|
+
(part.value.includes("#{") || part.value.includes("\\")));
|
17
18
|
}
|
18
19
|
// A string is considered to be able to use single quotes if it contains only
|
19
20
|
// plain string content and that content does not contain a single quote.
|
20
21
|
function isSingleQuotable(node) {
|
21
|
-
return node.
|
22
|
+
return node.parts.every((part) => part.type === "tstring_content" && !part.value.includes("'"));
|
22
23
|
}
|
23
24
|
const quotePattern = new RegExp("\\\\([\\s\\S])|(['\"])", "g");
|
24
25
|
function normalizeQuotes(content, enclosingQuote) {
|
@@ -55,12 +56,12 @@ function getClosingQuote(quote) {
|
|
55
56
|
// are strings of length 1. If they're any longer than we'll try to apply the
|
56
57
|
// correct quotes.
|
57
58
|
const printChar = (path, opts) => {
|
58
|
-
const {
|
59
|
-
if (
|
60
|
-
return
|
59
|
+
const { value } = path.getValue();
|
60
|
+
if (value.length !== 2) {
|
61
|
+
return value;
|
61
62
|
}
|
62
63
|
const quote = opts.rubySingleQuote ? "'" : '"';
|
63
|
-
return [quote,
|
64
|
+
return [quote, value.slice(1), quote];
|
64
65
|
};
|
65
66
|
exports.printChar = printChar;
|
66
67
|
const printPercentSDynaSymbol = (path, opts, print) => {
|
@@ -70,15 +71,15 @@ const printPercentSDynaSymbol = (path, opts, print) => {
|
|
70
71
|
parts.push(node.quote);
|
71
72
|
path.each((childPath) => {
|
72
73
|
const childNode = childPath.getValue();
|
73
|
-
if (childNode.type !== "
|
74
|
+
if (childNode.type !== "tstring_content") {
|
74
75
|
// Here we are printing an embedded variable or expression.
|
75
76
|
parts.push(print(childPath));
|
76
77
|
}
|
77
78
|
else {
|
78
79
|
// Here we are printing plain string content.
|
79
|
-
parts.push(join(literalline, childNode.
|
80
|
+
parts.push(join(literalline, childNode.value.split("\n")));
|
80
81
|
}
|
81
|
-
}, "
|
82
|
+
}, "parts");
|
82
83
|
// Push on the closing character, which is the opposite of the third
|
83
84
|
// character from the opening.
|
84
85
|
parts.push(quotePairs[node.quote[2]]);
|
@@ -97,11 +98,11 @@ function shouldPrintPercentSDynaSymbol(node) {
|
|
97
98
|
// quote in the content of the dyna symbol. If there is, then quoting could
|
98
99
|
// get weird, so just bail out and stick to the original bounds in the source.
|
99
100
|
const closing = quotePairs[node.quote[2]];
|
100
|
-
return node.
|
101
|
-
(child.
|
102
|
-
child.
|
103
|
-
child.
|
104
|
-
child.
|
101
|
+
return node.parts.some((child) => child.type === "tstring_content" &&
|
102
|
+
(child.value.includes("\n") ||
|
103
|
+
child.value.includes(closing) ||
|
104
|
+
child.value.includes("'") ||
|
105
|
+
child.value.includes('"')));
|
105
106
|
}
|
106
107
|
// Prints a dynamic symbol. Assumes there's a quote property attached to the
|
107
108
|
// node that will tell us which quote to use when printing. We're just going to
|
@@ -133,44 +134,45 @@ const printDynaSymbol = (path, opts, print) => {
|
|
133
134
|
parts.push(quote);
|
134
135
|
path.each((childPath) => {
|
135
136
|
const child = childPath.getValue();
|
136
|
-
if (child.type !== "
|
137
|
+
if (child.type !== "tstring_content") {
|
137
138
|
parts.push(print(childPath));
|
138
139
|
}
|
139
140
|
else {
|
140
|
-
parts.push(join(literalline, normalizeQuotes(child.
|
141
|
+
parts.push(join(literalline, normalizeQuotes(child.value, quote).split("\n")));
|
141
142
|
}
|
142
|
-
}, "
|
143
|
+
}, "parts");
|
143
144
|
parts.push(quote);
|
144
145
|
// If we're inside of an assoc_new node as the key, then it will handle
|
145
146
|
// printing the : on its own since it could change sides.
|
146
147
|
const parentNode = path.getParentNode();
|
147
|
-
if (parentNode.type !== "
|
148
|
+
if (parentNode.type !== "assoc" || parentNode.key !== node) {
|
148
149
|
parts.unshift(":");
|
149
150
|
}
|
150
151
|
return parts;
|
151
152
|
};
|
152
153
|
exports.printDynaSymbol = printDynaSymbol;
|
153
154
|
const printStringConcat = (path, opts, print) => {
|
154
|
-
|
155
|
-
|
155
|
+
return group([
|
156
|
+
path.call(print, "left"),
|
157
|
+
" \\",
|
158
|
+
indent([hardline, path.call(print, "right")])
|
159
|
+
]);
|
156
160
|
};
|
157
161
|
exports.printStringConcat = printStringConcat;
|
158
162
|
// Prints out an interpolated variable in the string by converting it into an
|
159
163
|
// embedded expression.
|
160
|
-
const printStringDVar = (path, opts, print) => {
|
161
|
-
return ["#{", path.call(print, "body", 0), "}"];
|
162
|
-
};
|
164
|
+
const printStringDVar = (path, opts, print) => ["#{", path.call(print, "var"), "}"];
|
163
165
|
exports.printStringDVar = printStringDVar;
|
164
166
|
const printStringEmbExpr = (path, opts, print) => {
|
165
167
|
const node = path.getValue();
|
166
|
-
const
|
168
|
+
const doc = path.call(print, "stmts");
|
167
169
|
// If the contents of this embedded expression were originally on the same
|
168
170
|
// line in the source, then we're going to leave them in place and assume
|
169
171
|
// that's the way the developer wanted this expression represented.
|
170
|
-
if (node.
|
171
|
-
return ["#{", removeLines(
|
172
|
+
if ((0, location_1.getStartLine)(node.loc) === (0, location_1.getEndLine)(node.loc)) {
|
173
|
+
return ["#{", removeLines(doc), "}"];
|
172
174
|
}
|
173
|
-
return group(["#{", indent([softline,
|
175
|
+
return group(["#{", indent([softline, doc]), [softline, "}"]]);
|
174
176
|
};
|
175
177
|
exports.printStringEmbExpr = printStringEmbExpr;
|
176
178
|
// Prints out a literal string. This function does its best to respect the
|
@@ -181,7 +183,7 @@ const printStringLiteral = (path, { rubySingleQuote }, print) => {
|
|
181
183
|
const node = path.getValue();
|
182
184
|
// If the string is empty, it will not have any parts, so just print out the
|
183
185
|
// quotes corresponding to the config
|
184
|
-
if (node.
|
186
|
+
if (node.parts.length === 0) {
|
185
187
|
return rubySingleQuote ? "''" : '""';
|
186
188
|
}
|
187
189
|
// Determine the quote that should enclose the new string
|
@@ -195,24 +197,24 @@ const printStringLiteral = (path, { rubySingleQuote }, print) => {
|
|
195
197
|
const parts = path.map((partPath) => {
|
196
198
|
const part = partPath.getValue();
|
197
199
|
// In this case, the part of the string is an embedded expression
|
198
|
-
if (part.type !== "
|
200
|
+
if (part.type !== "tstring_content") {
|
199
201
|
return print(partPath);
|
200
202
|
}
|
201
203
|
// In this case, the part of the string is just regular string content
|
202
|
-
return join(literalline, normalizeQuotes(part.
|
203
|
-
}, "
|
204
|
+
return join(literalline, normalizeQuotes(part.value, quote).split("\n"));
|
205
|
+
}, "parts");
|
204
206
|
return [quote, ...parts, getClosingQuote(quote)];
|
205
207
|
};
|
206
208
|
exports.printStringLiteral = printStringLiteral;
|
207
209
|
// Prints out a symbol literal. Its child will always be the ident that
|
208
210
|
// represents the string content of the symbol.
|
209
211
|
const printSymbolLiteral = (path, opts, print) => {
|
210
|
-
return [":", path.call(print, "
|
212
|
+
return [":", path.call(print, "value")];
|
211
213
|
};
|
212
214
|
exports.printSymbolLiteral = printSymbolLiteral;
|
213
215
|
// Prints out an xstring literal. Its child is an array of string parts,
|
214
216
|
// including plain string content and interpolated content.
|
215
217
|
const printXStringLiteral = (path, opts, print) => {
|
216
|
-
return ["`", ...path.map(print, "
|
218
|
+
return ["`", ...path.map(print, "parts"), "`"];
|
217
219
|
};
|
218
220
|
exports.printXStringLiteral = printXStringLiteral;
|
data/dist/ruby/nodes/super.js
CHANGED
@@ -5,26 +5,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.printZSuper = exports.printSuper = void 0;
|
7
7
|
const prettier_1 = __importDefault(require("../../prettier"));
|
8
|
-
const utils_1 = require("../../utils");
|
9
8
|
const { align, group, join, line } = prettier_1.default;
|
10
9
|
const printSuper = (path, opts, print) => {
|
11
|
-
const args = path.getValue()
|
10
|
+
const { args } = path.getValue();
|
12
11
|
if (args.type === "arg_paren") {
|
13
12
|
// In case there are explicitly no arguments but they are using parens,
|
14
|
-
// we assume they are attempting to override
|
13
|
+
// we assume they are attempting to override a parent method and pass no
|
15
14
|
// arguments up.
|
16
|
-
|
17
|
-
return "super()";
|
18
|
-
}
|
19
|
-
return ["super", path.call(print, "body", 0)];
|
15
|
+
return args.args === null ? "super()" : ["super", path.call(print, "args")];
|
20
16
|
}
|
21
17
|
const keyword = "super ";
|
22
|
-
const argsDocs = path.call(print, "body", 0);
|
23
18
|
return group([
|
24
19
|
keyword,
|
25
|
-
align(keyword.length, group(join([",", line],
|
20
|
+
align(keyword.length, group(join([",", line], path.call(print, "args"))))
|
26
21
|
]);
|
27
22
|
};
|
28
23
|
exports.printSuper = printSuper;
|
29
24
|
// Version of super without any parens or args.
|
30
|
-
|
25
|
+
const printZSuper = (path) => path.getValue().value;
|
26
|
+
exports.printZSuper = printZSuper;
|
data/dist/ruby/nodes/undef.js
CHANGED
@@ -6,21 +6,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.printUndef = void 0;
|
7
7
|
const prettier_1 = __importDefault(require("../../prettier"));
|
8
8
|
const { addTrailingComment, align, group, join, line } = prettier_1.default;
|
9
|
-
const printUndefSymbol = (path, opts, print) => {
|
10
|
-
const node = path.getValue();
|
11
|
-
// Since we're going to descend into the symbol literal to grab out the ident
|
12
|
-
// node, then we need to make sure we copy over any comments as well,
|
13
|
-
// otherwise we could accidentally skip printing them.
|
14
|
-
if (node.comments) {
|
15
|
-
node.comments.forEach((comment) => {
|
16
|
-
addTrailingComment(node.body[0], comment);
|
17
|
-
});
|
18
|
-
}
|
19
|
-
return path.call(print, "body", 0);
|
20
|
-
};
|
21
9
|
const printUndef = (path, opts, print) => {
|
10
|
+
const symsDocs = path.map((symbolPath) => {
|
11
|
+
const symbolNode = symbolPath.getValue();
|
12
|
+
// If we're not printing a symbol literal then it's a dyna symbol, so
|
13
|
+
// we're just going to print that node on its own.
|
14
|
+
if (symbolNode.type !== "symbol_literal") {
|
15
|
+
return print(symbolPath);
|
16
|
+
}
|
17
|
+
// We need to make sure we copy over any comments before we do the
|
18
|
+
// printing so they get printed as well.
|
19
|
+
if (symbolNode.comments) {
|
20
|
+
symbolNode.comments.forEach((comment) => {
|
21
|
+
addTrailingComment(symbolNode.value, comment);
|
22
|
+
});
|
23
|
+
}
|
24
|
+
// If we're printing a symbol literal, then we want to descend into it and
|
25
|
+
// just print the underlying contents so that it prints as a bare word.
|
26
|
+
return symbolPath.call(print, "value");
|
27
|
+
}, "syms");
|
22
28
|
const keyword = "undef ";
|
23
|
-
|
24
|
-
return group([keyword, align(keyword.length, join([",", line], argNodes))]);
|
29
|
+
return group([keyword, align(keyword.length, join([",", line], symsDocs))]);
|
25
30
|
};
|
26
31
|
exports.printUndef = printUndef;
|
data/dist/ruby/nodes.js
CHANGED
@@ -31,11 +31,13 @@ const statements_1 = require("./nodes/statements");
|
|
31
31
|
const strings_1 = require("./nodes/strings");
|
32
32
|
const super_1 = require("./nodes/super");
|
33
33
|
const undef_1 = require("./nodes/undef");
|
34
|
+
const printToken = (path) => path.getValue().value;
|
35
|
+
const printVoidStmt = () => "";
|
34
36
|
const nodes = {
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
BEGIN: hooks_1.printBEGIN,
|
38
|
+
CHAR: strings_1.printChar,
|
39
|
+
END: hooks_1.printEND,
|
40
|
+
__end__: statements_1.printEndContent,
|
39
41
|
access_ctrl: methods_1.printAccessControl,
|
40
42
|
alias: alias_1.printAlias,
|
41
43
|
aref: aref_1.printAref,
|
@@ -43,20 +45,21 @@ const nodes = {
|
|
43
45
|
arg_paren: args_1.printArgParen,
|
44
46
|
args: args_1.printArgs,
|
45
47
|
args_add_block: args_1.printArgsAddBlock,
|
46
|
-
args_add_star: args_1.printArgsAddStar,
|
47
48
|
args_forward: params_1.printArgsForward,
|
49
|
+
arg_star: args_1.printArgStar,
|
48
50
|
array: arrays_1.printArray,
|
49
51
|
aryptn: patterns_1.printAryPtn,
|
50
52
|
assign: assign_1.printAssign,
|
51
|
-
|
53
|
+
assoc: hashes_1.printAssoc,
|
52
54
|
assoc_splat: hashes_1.printAssocSplat,
|
53
55
|
assoclist_from_args: hashes_1.printHashContents,
|
56
|
+
backref: printToken,
|
57
|
+
backtick: printToken,
|
54
58
|
bare_assoc_hash: hashes_1.printHashContents,
|
55
|
-
BEGIN: hooks_1.printBEGIN,
|
56
59
|
begin: rescue_1.printBegin,
|
57
60
|
binary: operators_1.printBinary,
|
58
|
-
blockarg: args_1.printBlockArg,
|
59
61
|
block_var: blocks_1.printBlockVar,
|
62
|
+
blockarg: args_1.printBlockArg,
|
60
63
|
bodystmt: statements_1.printBodyStmt,
|
61
64
|
brace_block: blocks_1.printBraceBlock,
|
62
65
|
break: flow_1.printBreak,
|
@@ -65,51 +68,70 @@ const nodes = {
|
|
65
68
|
class: class_1.printClass,
|
66
69
|
command: commands_1.printCommand,
|
67
70
|
command_call: commands_1.printCommandCall,
|
71
|
+
comment: statements_1.printComment,
|
72
|
+
const: printToken,
|
68
73
|
const_path_field: constants_1.printConstPath,
|
69
74
|
const_path_ref: constants_1.printConstPath,
|
70
75
|
const_ref: constants_1.printConstRef,
|
76
|
+
cvar: printToken,
|
71
77
|
def: methods_1.printDef,
|
72
|
-
|
73
|
-
defsl: methods_1.printSingleLineMethod,
|
78
|
+
def_endless: methods_1.printDefEndless,
|
74
79
|
defined: constants_1.printDefined,
|
80
|
+
defs: methods_1.printDef,
|
75
81
|
do_block: blocks_1.printDoBlock,
|
76
82
|
dot2: operators_1.printDot2,
|
77
83
|
dot3: operators_1.printDot3,
|
78
84
|
dyna_symbol: strings_1.printDynaSymbol,
|
79
85
|
else: conditionals_1.printElse,
|
80
86
|
elsif: conditionals_1.printElsif,
|
81
|
-
|
87
|
+
embdoc: statements_1.printComment,
|
82
88
|
ensure: rescue_1.printEnsure,
|
89
|
+
excessed_comma: params_1.printExcessedComma,
|
83
90
|
fcall: calls_1.printCallContainer,
|
84
|
-
fndptn: patterns_1.printFndPtn,
|
85
91
|
field: constants_1.printField,
|
92
|
+
float: printToken,
|
93
|
+
fndptn: patterns_1.printFndPtn,
|
86
94
|
for: loops_1.printFor,
|
95
|
+
gvar: printToken,
|
87
96
|
hash: hashes_1.printHash,
|
88
97
|
heredoc: heredocs_1.printHeredoc,
|
98
|
+
heredoc_beg: printToken,
|
89
99
|
hshptn: patterns_1.printHshPtn,
|
100
|
+
ident: printToken,
|
90
101
|
if: conditionals_1.printIf,
|
91
|
-
ifop: conditionals_1.printTernary,
|
92
102
|
if_mod: conditionals_1.printIfModifier,
|
103
|
+
ifop: conditionals_1.printTernary,
|
104
|
+
imaginary: printToken,
|
93
105
|
in: patterns_1.printIn,
|
106
|
+
int: ints_1.printInt,
|
107
|
+
ivar: printToken,
|
108
|
+
kw: printToken,
|
94
109
|
kwrest_param: params_1.printKeywordRestParam,
|
110
|
+
label: printToken,
|
95
111
|
lambda: lambdas_1.printLambda,
|
112
|
+
lbrace: printToken,
|
113
|
+
lparen: printToken,
|
96
114
|
massign: massign_1.printMAssign,
|
97
115
|
method_add_arg: calls_1.printMethodAddArg,
|
98
116
|
method_add_block: calls_1.printMethodAddBlock,
|
99
117
|
mlhs: massign_1.printMLHS,
|
100
|
-
mlhs_add_post: massign_1.printMLHSAddPost,
|
101
|
-
mlhs_add_star: massign_1.printMLHSAddStar,
|
102
118
|
mlhs_paren: massign_1.printMLHSParen,
|
119
|
+
module: class_1.printModule,
|
103
120
|
mrhs: massign_1.printMRHS,
|
104
121
|
mrhs_add_star: massign_1.printMRHSAddStar,
|
105
122
|
mrhs_new_from_args: massign_1.printMRHSNewFromArgs,
|
106
|
-
module: class_1.printModule,
|
107
123
|
next: flow_1.printNext,
|
124
|
+
not: operators_1.printNot,
|
125
|
+
op: printToken,
|
108
126
|
opassign: assign_1.printOpAssign,
|
109
127
|
params: params_1.printParams,
|
110
128
|
paren: statements_1.printParen,
|
129
|
+
period: printToken,
|
111
130
|
program: statements_1.printProgram,
|
131
|
+
qsymbols: arrays_1.printQsymbols,
|
132
|
+
qwords: arrays_1.printQwords,
|
112
133
|
rassign: patterns_1.printRAssign,
|
134
|
+
rational: printToken,
|
113
135
|
redo: rescue_1.printRedo,
|
114
136
|
regexp_literal: regexp_1.printRegexpLiteral,
|
115
137
|
rescue: rescue_1.printRescue,
|
@@ -117,35 +139,39 @@ const nodes = {
|
|
117
139
|
rescue_mod: rescue_1.printRescueMod,
|
118
140
|
rest_param: params_1.printRestParam,
|
119
141
|
retry: rescue_1.printRetry,
|
120
|
-
return: return_1.printReturn,
|
121
142
|
return0: return_1.printReturn0,
|
143
|
+
return: return_1.printReturn,
|
122
144
|
sclass: class_1.printSClass,
|
123
|
-
|
145
|
+
statements: statements_1.printStatements,
|
124
146
|
string_concat: strings_1.printStringConcat,
|
125
147
|
string_dvar: strings_1.printStringDVar,
|
126
148
|
string_embexpr: strings_1.printStringEmbExpr,
|
127
149
|
string_literal: strings_1.printStringLiteral,
|
128
150
|
super: super_1.printSuper,
|
129
151
|
symbol_literal: strings_1.printSymbolLiteral,
|
152
|
+
symbols: arrays_1.printSymbols,
|
130
153
|
top_const_field: constants_1.printTopConst,
|
131
154
|
top_const_ref: constants_1.printTopConst,
|
155
|
+
tstring_content: printToken,
|
132
156
|
unary: operators_1.printUnary,
|
133
157
|
undef: undef_1.printUndef,
|
134
158
|
unless: conditionals_1.printUnless,
|
135
159
|
unless_mod: conditionals_1.printUnlessModifier,
|
136
160
|
until: loops_1.printUntil,
|
137
|
-
until_mod: loops_1.
|
161
|
+
until_mod: loops_1.printUntil,
|
138
162
|
var_alias: alias_1.printAlias,
|
139
163
|
var_field: assign_1.printVarField,
|
140
164
|
var_ref: assign_1.printVarRef,
|
141
165
|
vcall: calls_1.printCallContainer,
|
166
|
+
void_stmt: printVoidStmt,
|
142
167
|
when: case_1.printWhen,
|
143
168
|
while: loops_1.printWhile,
|
144
|
-
while_mod: loops_1.
|
169
|
+
while_mod: loops_1.printWhile,
|
145
170
|
word: arrays_1.printWord,
|
171
|
+
words: arrays_1.printWords,
|
146
172
|
xstring_literal: strings_1.printXStringLiteral,
|
147
|
-
yield: flow_1.printYield,
|
148
173
|
yield0: flow_1.printYield0,
|
174
|
+
yield: flow_1.printYield,
|
149
175
|
zsuper: super_1.printZSuper
|
150
176
|
};
|
151
177
|
exports.default = nodes;
|
data/dist/ruby/parser.js
CHANGED
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
const parseSync_1 = __importDefault(require("../parser/parseSync"));
|
7
|
+
const location_1 = require("./location");
|
7
8
|
const parser = {
|
8
9
|
// This function is responsible for taking an input string of text and
|
9
10
|
// returning to prettier a JavaScript object that is the equivalent AST that
|
@@ -22,13 +23,13 @@ const parser = {
|
|
22
23
|
// responsible for returning the index of the character within the source
|
23
24
|
// string that is the beginning of the given node.
|
24
25
|
locStart(node) {
|
25
|
-
return node.
|
26
|
+
return (0, location_1.getStartChar)(node.loc);
|
26
27
|
},
|
27
28
|
// This function is critical for comments and cursor support, and is
|
28
29
|
// responsible for returning the index of the character within the source
|
29
30
|
// string that is the ending of the given node.
|
30
31
|
locEnd(node) {
|
31
|
-
return node.
|
32
|
+
return (0, location_1.getEndChar)(node.loc);
|
32
33
|
}
|
33
34
|
};
|
34
35
|
exports.default = parser;
|