prettier-plugin-java 2.4.0 → 2.6.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.
- package/LICENSE +1 -1
- package/dist/base-cst-printer.js +22 -44
- package/dist/cst-printer.js +19 -27
- package/dist/index.js +19 -20
- package/dist/options.js +16 -21
- package/dist/parser.js +2 -4
- package/dist/printer.js +3 -5
- package/dist/printers/arrays.js +17 -41
- package/dist/printers/blocks-and-statements.js +289 -356
- package/dist/printers/classes.js +451 -495
- package/dist/printers/comments/comments-utils.js +5 -13
- package/dist/printers/comments/format-comments.js +34 -50
- package/dist/printers/comments/handle-comments.js +17 -23
- package/dist/printers/expressions.js +378 -386
- package/dist/printers/interfaces.js +148 -181
- package/dist/printers/lexical-structure.js +26 -58
- package/dist/printers/names.js +29 -53
- package/dist/printers/packages-and-modules.js +116 -143
- package/dist/printers/prettier-builder.js +21 -31
- package/dist/printers/printer-utils.js +173 -221
- package/dist/printers/types-values-and-variables.js +111 -149
- package/dist/types/utils.js +6 -15
- package/dist/utils/expressions-utils.js +7 -11
- package/dist/utils/index.js +2 -12
- package/dist/utils/isEmptyDoc.js +2 -4
- package/dist/utils/printArgumentListWithBraces.js +29 -19
- package/dist/utils/printSingleLambdaInvocation.js +15 -17
- package/package.json +10 -13
- package/dist/src/base-cst-printer.js +0 -77
- package/dist/src/cst-printer.js +0 -37
- package/dist/src/index.js +0 -67
- package/dist/src/options.js +0 -256
- package/dist/src/parser.js +0 -7
- package/dist/src/printer.js +0 -28
- package/dist/src/printers/arrays.js +0 -49
- package/dist/src/printers/blocks-and-statements.js +0 -493
- package/dist/src/printers/classes.js +0 -724
- package/dist/src/printers/comments/comments-utils.js +0 -29
- package/dist/src/printers/comments/format-comments.js +0 -187
- package/dist/src/printers/comments/handle-comments.js +0 -38
- package/dist/src/printers/expressions.js +0 -549
- package/dist/src/printers/interfaces.js +0 -251
- package/dist/src/printers/lexical-structure.js +0 -43
- package/dist/src/printers/names.js +0 -53
- package/dist/src/printers/packages-and-modules.js +0 -185
- package/dist/src/printers/prettier-builder.js +0 -47
- package/dist/src/printers/printer-utils.js +0 -577
- package/dist/src/printers/types-values-and-variables.js +0 -183
- package/dist/src/types/utils.js +0 -29
- package/dist/src/utils/expressions-utils.js +0 -29
- package/dist/src/utils/index.js +0 -10
- package/dist/src/utils/printArgumentListWithBraces.js +0 -21
- package/dist/src/utils/printSingleLambdaInvocation.js +0 -20
- package/dist/test/babel-register.js +0 -3
- package/dist/test/repository-test/core-test.js +0 -12
- package/dist/test/repository-test/jhipster-1-test.js +0 -17
- package/dist/test/repository-test/jhipster-2-test.js +0 -16
- package/dist/test/test-utils.js +0 -215
- package/dist/test/unit-test/annotation_type_declaration/annotation_type_declaration-spec.js +0 -6
- package/dist/test/unit-test/args/args-spec.js +0 -6
- package/dist/test/unit-test/assert/assert-spec.js +0 -6
- package/dist/test/unit-test/binary_expressions/binary_expressions-spec.js +0 -6
- package/dist/test/unit-test/blank_lines/blank_lines-spec.js +0 -6
- package/dist/test/unit-test/bug-fixes/bug-fixes-spec.js +0 -6
- package/dist/test/unit-test/cast/cast-spec.js +0 -6
- package/dist/test/unit-test/char_literal/char_literal-spec.js +0 -6
- package/dist/test/unit-test/classes/multiple_classes-spec.js +0 -6
- package/dist/test/unit-test/comments/comments-spec.js +0 -14
- package/dist/test/unit-test/complex_generic_class/complex_generic_class-spec.js +0 -6
- package/dist/test/unit-test/constructors/constructors-spec.js +0 -6
- package/dist/test/unit-test/empty_statement/empty_statement-spec.js +0 -6
- package/dist/test/unit-test/enum/enum-spec.js +0 -6
- package/dist/test/unit-test/expressions/expressions-spec.js +0 -6
- package/dist/test/unit-test/extends_abstract_class/extends_abstract_class-spec.js +0 -6
- package/dist/test/unit-test/extends_abstract_class_and_implements_interfaces/extends_abstract_class_and_implements_interfaces-spec.js +0 -6
- package/dist/test/unit-test/for/for-spec.js +0 -6
- package/dist/test/unit-test/generic_class/generic_class-spec.js +0 -6
- package/dist/test/unit-test/generic_questionmark/generic_questionmark-spec.js +0 -6
- package/dist/test/unit-test/hello-world/hello-word-spec.js +0 -6
- package/dist/test/unit-test/if/if-spec.js +0 -6
- package/dist/test/unit-test/indent/indent-spec.js +0 -6
- package/dist/test/unit-test/instantiation/instantiation-spec.js +0 -6
- package/dist/test/unit-test/interface/interface-spec.js +0 -6
- package/dist/test/unit-test/lambda/lambda-spec.js +0 -6
- package/dist/test/unit-test/marker_annotations/marker_annotations-spec.js +0 -6
- package/dist/test/unit-test/member_chain/member_chain-spec.js +0 -6
- package/dist/test/unit-test/method_reference/method_reference-spec.js +0 -6
- package/dist/test/unit-test/modifiers/modifiers-spec.js +0 -6
- package/dist/test/unit-test/modules/modules-spec.js +0 -6
- package/dist/test/unit-test/package_and_imports/package_and_imports-spec.js +0 -34
- package/dist/test/unit-test/pattern-matching/pattern-matching-spec.js +0 -6
- package/dist/test/unit-test/prettier-ignore/prettier-ignore-spec.js +0 -28
- package/dist/test/unit-test/records/records-spec.js +0 -6
- package/dist/test/unit-test/return/return-spec.js +0 -6
- package/dist/test/unit-test/sealed/sealed-spec.js +0 -6
- package/dist/test/unit-test/snippets/arrays/array-initializer.spec.js +0 -94
- package/dist/test/unit-test/snippets/arrays/variable-initializer-list.spec.js +0 -19
- package/dist/test/unit-test/snippets/blocks-and-statements/switch.spec.js +0 -26
- package/dist/test/unit-test/snippets/classes/class-body.spec.js +0 -181
- package/dist/test/unit-test/snippets/classes/enum-body.spec.js +0 -87
- package/dist/test/unit-test/snippets/classes/variableDeclarator/test.spec.js +0 -186
- package/dist/test/unit-test/snippets/interfaces/element-value-array-initializer.spec.js +0 -85
- package/dist/test/unit-test/snippets/names/ambiguousName/test.spec.js +0 -19
- package/dist/test/unit-test/snippets/names/expressionName/test.spec.js +0 -19
- package/dist/test/unit-test/snippets/names/methodName/test.spec.js +0 -12
- package/dist/test/unit-test/snippets/names/packageOrTypeName/test.spec.js +0 -19
- package/dist/test/unit-test/snippets/types-values-and-variables/floatingPointType/test.spec.js +0 -19
- package/dist/test/unit-test/snippets/types-values-and-variables/integralType/test.spec.js +0 -40
- package/dist/test/unit-test/snippets/types-values-and-variables/numericType/test.spec.js +0 -88
- package/dist/test/unit-test/snippets/types-values-and-variables/wildcard/test.spec.js +0 -112
- package/dist/test/unit-test/snippets/types-values-and-variables/wildcardBounds/test.spec.js +0 -81
- package/dist/test/unit-test/switch/switch-spec.js +0 -6
- package/dist/test/unit-test/synchronized/synchronized-spec.js +0 -6
- package/dist/test/unit-test/text-blocks/text-block-spec.js +0 -6
- package/dist/test/unit-test/throws/throws-spec.js +0 -6
- package/dist/test/unit-test/try_catch/try_catch-spec.js +0 -6
- package/dist/test/unit-test/types/types-spec.js +0 -6
- package/dist/test/unit-test/variables/variables-spec.js +0 -6
- package/dist/test/unit-test/while/while-spec.js +0 -6
- package/dist/test/unit-test/yield-statement/yield-statement-spec.js +0 -6
|
@@ -1,29 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasComments = exports.hasTrailingLineComments = exports.hasLeadingLineComments = exports.hasTrailingComments = exports.hasLeadingComments = void 0;
|
|
4
|
-
function hasLeadingComments(token) {
|
|
1
|
+
export function hasLeadingComments(token) {
|
|
5
2
|
return token.leadingComments !== undefined;
|
|
6
3
|
}
|
|
7
|
-
|
|
8
|
-
function hasTrailingComments(token) {
|
|
4
|
+
export function hasTrailingComments(token) {
|
|
9
5
|
return token.trailingComments !== undefined;
|
|
10
6
|
}
|
|
11
|
-
|
|
12
|
-
function hasLeadingLineComments(token) {
|
|
7
|
+
export function hasLeadingLineComments(token) {
|
|
13
8
|
return (token.leadingComments !== undefined &&
|
|
14
9
|
token.leadingComments.length !== 0 &&
|
|
15
10
|
token.leadingComments[token.leadingComments.length - 1].tokenType.name ===
|
|
16
11
|
"LineComment");
|
|
17
12
|
}
|
|
18
|
-
|
|
19
|
-
function hasTrailingLineComments(token) {
|
|
13
|
+
export function hasTrailingLineComments(token) {
|
|
20
14
|
return (token.trailingComments !== undefined &&
|
|
21
15
|
token.trailingComments.length !== 0 &&
|
|
22
16
|
token.trailingComments[token.trailingComments.length - 1].tokenType.name ===
|
|
23
17
|
"LineComment");
|
|
24
18
|
}
|
|
25
|
-
|
|
26
|
-
function hasComments(token) {
|
|
19
|
+
export function hasComments(token) {
|
|
27
20
|
return hasLeadingComments(token) || hasTrailingComments(token);
|
|
28
21
|
}
|
|
29
|
-
exports.hasComments = hasComments;
|
|
@@ -1,22 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
ar[i] = from[i];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.processComments = exports.getTokenLeadingComments = exports.printNodeWithComments = exports.printTokenWithComments = void 0;
|
|
16
|
-
var doc_1 = require("prettier/doc");
|
|
17
|
-
var utils_1 = require("../../types/utils");
|
|
18
|
-
var isEmptyDoc_1 = __importDefault(require("../../utils/isEmptyDoc"));
|
|
19
|
-
var hardline = doc_1.builders.hardline, lineSuffix = doc_1.builders.lineSuffix, breakParent = doc_1.builders.breakParent, literalline = doc_1.builders.literalline;
|
|
1
|
+
import { builders } from "prettier/doc";
|
|
2
|
+
import { isCstElementOrUndefinedIToken } from "../../types/utils.js";
|
|
3
|
+
import { doc } from "prettier";
|
|
4
|
+
import isEmptyDoc from "../../utils/isEmptyDoc.js";
|
|
5
|
+
const { hardline, lineSuffix, breakParent, literalline } = builders;
|
|
20
6
|
/**
|
|
21
7
|
* Takes a token and return a doc with:
|
|
22
8
|
* - concatenated leading comments
|
|
@@ -26,10 +12,11 @@ var hardline = doc_1.builders.hardline, lineSuffix = doc_1.builders.lineSuffix,
|
|
|
26
12
|
* @param {IToken} token
|
|
27
13
|
* @return a doc with the token and its comments
|
|
28
14
|
*/
|
|
29
|
-
function printTokenWithComments(token) {
|
|
30
|
-
return printWithComments(token, token.image
|
|
15
|
+
export function printTokenWithComments(token) {
|
|
16
|
+
return printWithComments(token, token.image.includes("\n")
|
|
17
|
+
? doc.utils.replaceEndOfLine(token.image)
|
|
18
|
+
: token.image, getTokenLeadingComments, getTokenTrailingComments);
|
|
31
19
|
}
|
|
32
|
-
exports.printTokenWithComments = printTokenWithComments;
|
|
33
20
|
/**
|
|
34
21
|
* Takes a node and return a doc with:
|
|
35
22
|
* - concatenated leading comments
|
|
@@ -40,25 +27,23 @@ exports.printTokenWithComments = printTokenWithComments;
|
|
|
40
27
|
* @param {Doc} value - the converted node value
|
|
41
28
|
* @return a doc with the token and its comments
|
|
42
29
|
*/
|
|
43
|
-
function printNodeWithComments(node, value) {
|
|
30
|
+
export function printNodeWithComments(node, value) {
|
|
44
31
|
return printWithComments(node, value, getNodeLeadingComments, getNodeTrailingComments);
|
|
45
32
|
}
|
|
46
|
-
exports.printNodeWithComments = printNodeWithComments;
|
|
47
33
|
function printWithComments(nodeOrToken, value, getLeadingComments, getTrailingComments) {
|
|
48
|
-
|
|
49
|
-
|
|
34
|
+
const leadingComments = getLeadingComments(nodeOrToken);
|
|
35
|
+
const trailingComments = getTrailingComments(nodeOrToken, value);
|
|
50
36
|
return leadingComments.length === 0 && trailingComments.length === 0
|
|
51
37
|
? value
|
|
52
|
-
:
|
|
38
|
+
: [...leadingComments, value, ...trailingComments];
|
|
53
39
|
}
|
|
54
40
|
/**
|
|
55
41
|
* @param {IToken} token
|
|
56
42
|
* @return an array containing processed leading comments and separators
|
|
57
43
|
*/
|
|
58
|
-
function getTokenLeadingComments(token) {
|
|
44
|
+
export function getTokenLeadingComments(token) {
|
|
59
45
|
return getLeadingComments(token, token);
|
|
60
46
|
}
|
|
61
|
-
exports.getTokenLeadingComments = getTokenLeadingComments;
|
|
62
47
|
/**
|
|
63
48
|
* @param {CstNode} node
|
|
64
49
|
* @return an array containing processed leading comments and separators
|
|
@@ -67,12 +52,12 @@ function getNodeLeadingComments(node) {
|
|
|
67
52
|
return getLeadingComments(node, node.location);
|
|
68
53
|
}
|
|
69
54
|
function getLeadingComments(nodeOrToken, location) {
|
|
70
|
-
|
|
55
|
+
const arr = [];
|
|
71
56
|
if (nodeOrToken.leadingComments !== undefined) {
|
|
72
|
-
|
|
73
|
-
|
|
57
|
+
let previousEndLine = nodeOrToken.leadingComments[0].endLine;
|
|
58
|
+
let step;
|
|
74
59
|
arr.push(formatComment(nodeOrToken.leadingComments[0]));
|
|
75
|
-
for (
|
|
60
|
+
for (let i = 1; i < nodeOrToken.leadingComments.length; i++) {
|
|
76
61
|
step = nodeOrToken.leadingComments[i].startLine - previousEndLine;
|
|
77
62
|
if (step === 1 ||
|
|
78
63
|
nodeOrToken.leadingComments[i].startOffset > location.startOffset) {
|
|
@@ -112,15 +97,15 @@ function getNodeTrailingComments(node, value) {
|
|
|
112
97
|
return getTrailingComments(node, value, node.location);
|
|
113
98
|
}
|
|
114
99
|
function getTrailingComments(nodeOrToken, value, location) {
|
|
115
|
-
|
|
116
|
-
|
|
100
|
+
const arr = [];
|
|
101
|
+
let previousEndLine = location.endLine;
|
|
117
102
|
if (nodeOrToken.trailingComments !== undefined) {
|
|
118
|
-
nodeOrToken.trailingComments.forEach(
|
|
119
|
-
|
|
103
|
+
nodeOrToken.trailingComments.forEach((comment, idx) => {
|
|
104
|
+
let separator = "";
|
|
120
105
|
if (comment.startLine !== previousEndLine) {
|
|
121
106
|
arr.push(hardline);
|
|
122
107
|
}
|
|
123
|
-
else if (!(
|
|
108
|
+
else if (!isEmptyDoc(value) && idx === 0) {
|
|
124
109
|
separator = " ";
|
|
125
110
|
}
|
|
126
111
|
if (comment.tokenType.name === "LineComment") {
|
|
@@ -135,9 +120,9 @@ function getTrailingComments(nodeOrToken, value, location) {
|
|
|
135
120
|
return arr;
|
|
136
121
|
}
|
|
137
122
|
function isJavaDoc(comment, lines) {
|
|
138
|
-
|
|
123
|
+
let isJavaDoc = true;
|
|
139
124
|
if (comment.tokenType.name === "TraditionalComment" && lines.length > 1) {
|
|
140
|
-
for (
|
|
125
|
+
for (let i = 1; i < lines.length; i++) {
|
|
141
126
|
if (lines[i].trim().charAt(0) !== "*") {
|
|
142
127
|
isJavaDoc = false;
|
|
143
128
|
break;
|
|
@@ -150,38 +135,37 @@ function isJavaDoc(comment, lines) {
|
|
|
150
135
|
return isJavaDoc;
|
|
151
136
|
}
|
|
152
137
|
function formatJavaDoc(lines) {
|
|
153
|
-
|
|
154
|
-
for (
|
|
138
|
+
const res = [lines[0].trim()];
|
|
139
|
+
for (let i = 1; i < lines.length; i++) {
|
|
155
140
|
res.push(hardline);
|
|
156
141
|
res.push(" " + lines[i].trim());
|
|
157
142
|
}
|
|
158
143
|
return res;
|
|
159
144
|
}
|
|
160
145
|
function formatComment(comment) {
|
|
161
|
-
|
|
162
|
-
|
|
146
|
+
const res = [];
|
|
147
|
+
const lines = comment.image.split("\n");
|
|
163
148
|
if (isJavaDoc(comment, lines)) {
|
|
164
149
|
return formatJavaDoc(lines);
|
|
165
150
|
}
|
|
166
|
-
lines.forEach(
|
|
151
|
+
lines.forEach(line => {
|
|
167
152
|
res.push(line);
|
|
168
153
|
res.push(literalline);
|
|
169
154
|
});
|
|
170
155
|
res.pop();
|
|
171
156
|
return res;
|
|
172
157
|
}
|
|
173
|
-
function processComments(docs) {
|
|
158
|
+
export function processComments(docs) {
|
|
174
159
|
if (!Array.isArray(docs)) {
|
|
175
|
-
if (
|
|
160
|
+
if (isCstElementOrUndefinedIToken(docs)) {
|
|
176
161
|
return printTokenWithComments(docs);
|
|
177
162
|
}
|
|
178
163
|
return docs;
|
|
179
164
|
}
|
|
180
|
-
return docs.map(
|
|
181
|
-
if (
|
|
165
|
+
return docs.map(elt => {
|
|
166
|
+
if (isCstElementOrUndefinedIToken(elt)) {
|
|
182
167
|
return printTokenWithComments(elt);
|
|
183
168
|
}
|
|
184
169
|
return elt;
|
|
185
170
|
});
|
|
186
171
|
}
|
|
187
|
-
exports.processComments = processComments;
|
|
@@ -1,29 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.handleCommentsBinaryExpression = void 0;
|
|
4
|
-
var comments_utils_1 = require("./comments-utils");
|
|
5
|
-
function handleCommentsBinaryExpression(ctx) {
|
|
1
|
+
import { hasLeadingComments, hasTrailingComments } from "./comments-utils.js";
|
|
2
|
+
export function handleCommentsBinaryExpression(ctx) {
|
|
6
3
|
moveOperatorLeadingCommentsToNextExpression(ctx);
|
|
7
4
|
moveExpressionTrailingCommentsToNextOperator(ctx);
|
|
8
5
|
}
|
|
9
|
-
exports.handleCommentsBinaryExpression = handleCommentsBinaryExpression;
|
|
10
6
|
function moveOperatorLeadingCommentsToNextExpression(ctx) {
|
|
11
7
|
var _a;
|
|
12
|
-
|
|
13
|
-
(_a = ctx.BinaryOperator) === null || _a === void 0 ? void 0 : _a.forEach(
|
|
14
|
-
|
|
15
|
-
if ((0, comments_utils_1.hasLeadingComments)(binaryOperator)) {
|
|
8
|
+
let unaryExpressionIndex = 1;
|
|
9
|
+
(_a = ctx.BinaryOperator) === null || _a === void 0 ? void 0 : _a.forEach(binaryOperator => {
|
|
10
|
+
if (hasLeadingComments(binaryOperator)) {
|
|
16
11
|
while (ctx.unaryExpression[unaryExpressionIndex].location.startOffset <
|
|
17
12
|
binaryOperator.endOffset) {
|
|
18
13
|
unaryExpressionIndex++;
|
|
19
14
|
}
|
|
20
15
|
// Adapt the position of the operator and its leading comments
|
|
21
|
-
|
|
16
|
+
const shiftUp = binaryOperator.leadingComments[0].startLine -
|
|
22
17
|
1 -
|
|
23
18
|
binaryOperator.startLine;
|
|
24
19
|
if (binaryOperator.startLine !==
|
|
25
20
|
ctx.unaryExpression[unaryExpressionIndex].location.startLine) {
|
|
26
|
-
binaryOperator.leadingComments.forEach(
|
|
21
|
+
binaryOperator.leadingComments.forEach(comment => {
|
|
27
22
|
comment.startLine += 1;
|
|
28
23
|
comment.endLine += 1;
|
|
29
24
|
});
|
|
@@ -34,32 +29,31 @@ function moveOperatorLeadingCommentsToNextExpression(ctx) {
|
|
|
34
29
|
// unaryExpression
|
|
35
30
|
ctx.unaryExpression[unaryExpressionIndex].leadingComments =
|
|
36
31
|
ctx.unaryExpression[unaryExpressionIndex].leadingComments || [];
|
|
37
|
-
|
|
32
|
+
ctx.unaryExpression[unaryExpressionIndex].leadingComments.unshift(...binaryOperator.leadingComments);
|
|
38
33
|
delete binaryOperator.leadingComments;
|
|
39
34
|
}
|
|
40
35
|
});
|
|
41
36
|
}
|
|
42
37
|
function moveExpressionTrailingCommentsToNextOperator(ctx) {
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
const binaryOperators = ctx.BinaryOperator;
|
|
39
|
+
let binaryOperatorIndex = 1;
|
|
45
40
|
if (binaryOperators === null || binaryOperators === void 0 ? void 0 : binaryOperators.length) {
|
|
46
|
-
ctx.unaryExpression.forEach(
|
|
41
|
+
ctx.unaryExpression.forEach(unaryExpression => {
|
|
47
42
|
var _a;
|
|
48
|
-
|
|
49
|
-
if ((0, comments_utils_1.hasTrailingComments)(unaryExpression)) {
|
|
43
|
+
if (hasTrailingComments(unaryExpression)) {
|
|
50
44
|
while (binaryOperatorIndex < binaryOperators.length &&
|
|
51
45
|
unaryExpression.location.endOffset &&
|
|
52
46
|
binaryOperators[binaryOperatorIndex].startOffset <
|
|
53
47
|
unaryExpression.location.endOffset) {
|
|
54
48
|
binaryOperatorIndex++;
|
|
55
49
|
}
|
|
56
|
-
|
|
50
|
+
const binaryOperator = binaryOperators[binaryOperatorIndex];
|
|
57
51
|
// Adapt the position of the expression and its trailing comments
|
|
58
|
-
|
|
52
|
+
const shiftUp = unaryExpression.trailingComments[0].startLine -
|
|
59
53
|
1 -
|
|
60
54
|
unaryExpression.location.startLine;
|
|
61
55
|
if (unaryExpression.location.startLine !== binaryOperator.startLine) {
|
|
62
|
-
unaryExpression.trailingComments.forEach(
|
|
56
|
+
unaryExpression.trailingComments.forEach(comment => {
|
|
63
57
|
comment.startLine += 1;
|
|
64
58
|
comment.endLine += 1;
|
|
65
59
|
});
|
|
@@ -70,8 +64,8 @@ function moveExpressionTrailingCommentsToNextOperator(ctx) {
|
|
|
70
64
|
}
|
|
71
65
|
// Move unaryExpression's trailing comments to the following
|
|
72
66
|
// binaryOperator
|
|
73
|
-
binaryOperator.trailingComments = (
|
|
74
|
-
|
|
67
|
+
binaryOperator.trailingComments = (_a = binaryOperator.trailingComments) !== null && _a !== void 0 ? _a : [];
|
|
68
|
+
binaryOperator.trailingComments.unshift(...unaryExpression.trailingComments);
|
|
75
69
|
delete unaryExpression.trailingComments;
|
|
76
70
|
}
|
|
77
71
|
});
|