prettier-plugin-java 2.4.0 → 2.5.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/dist/options.js +3 -4
- package/dist/printers/blocks-and-statements.js +20 -42
- package/dist/printers/classes.js +3 -0
- package/dist/printers/expressions.js +12 -6
- package/package.json +3 -3
- 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,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var test_utils_1 = require("../../../test-utils");
|
|
4
|
-
describe("Enum Body", function () {
|
|
5
|
-
it("Remove trailing comma by default", function () {
|
|
6
|
-
var snippet = "{ONE,TWO,THREE,}";
|
|
7
|
-
// prettier-ignore
|
|
8
|
-
var expectedOutput = "{\n" +
|
|
9
|
-
" ONE,\n" +
|
|
10
|
-
" TWO,\n" +
|
|
11
|
-
" THREE\n" +
|
|
12
|
-
"}";
|
|
13
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
14
|
-
snippet: snippet,
|
|
15
|
-
expectedOutput: expectedOutput,
|
|
16
|
-
entryPoint: "enumBody"
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
it("Add trailing comma when specified", function () {
|
|
20
|
-
var snippet = "{ONE,TWO,THREE}";
|
|
21
|
-
// prettier-ignore
|
|
22
|
-
var expectedOutput = "{\n" +
|
|
23
|
-
" ONE,\n" +
|
|
24
|
-
" TWO,\n" +
|
|
25
|
-
" THREE,\n" +
|
|
26
|
-
"}";
|
|
27
|
-
var prettierOptions = {
|
|
28
|
-
trailingComma: "all"
|
|
29
|
-
};
|
|
30
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
31
|
-
snippet: snippet,
|
|
32
|
-
expectedOutput: expectedOutput,
|
|
33
|
-
entryPoint: "enumBody",
|
|
34
|
-
prettierOptions: prettierOptions
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
it("Keep one trailing comma if there is already one", function () {
|
|
38
|
-
var snippet = "{" + "\n ONE," + "\n TWO," + "\n THREE," + "\n}";
|
|
39
|
-
// prettier-ignore
|
|
40
|
-
var expectedOutput = "{\n" +
|
|
41
|
-
" ONE,\n" +
|
|
42
|
-
" TWO,\n" +
|
|
43
|
-
" THREE,\n" +
|
|
44
|
-
"}";
|
|
45
|
-
var prettierOptions = {
|
|
46
|
-
trailingComma: "all"
|
|
47
|
-
};
|
|
48
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
49
|
-
snippet: snippet,
|
|
50
|
-
expectedOutput: expectedOutput,
|
|
51
|
-
entryPoint: "enumBody",
|
|
52
|
-
prettierOptions: prettierOptions
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
it("Remove trailing comma in enum constant list with semicolon by default", function () {
|
|
56
|
-
var snippet = "{ONE,TWO,THREE,;}";
|
|
57
|
-
// prettier-ignore
|
|
58
|
-
var expectedOutput = "{\n" +
|
|
59
|
-
" ONE,\n" +
|
|
60
|
-
" TWO,\n" +
|
|
61
|
-
" THREE\n" +
|
|
62
|
-
"}";
|
|
63
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
64
|
-
snippet: snippet,
|
|
65
|
-
expectedOutput: expectedOutput,
|
|
66
|
-
entryPoint: "enumBody"
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
it("Add trailing comma in enum constant list with semicolon when specified", function () {
|
|
70
|
-
var snippet = "{ONE,TWO,THREE;}";
|
|
71
|
-
// prettier-ignore
|
|
72
|
-
var expectedOutput = "{\n" +
|
|
73
|
-
" ONE,\n" +
|
|
74
|
-
" TWO,\n" +
|
|
75
|
-
" THREE,\n" +
|
|
76
|
-
"}";
|
|
77
|
-
var prettierOptions = {
|
|
78
|
-
trailingComma: "all"
|
|
79
|
-
};
|
|
80
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
81
|
-
snippet: snippet,
|
|
82
|
-
expectedOutput: expectedOutput,
|
|
83
|
-
entryPoint: "enumBody",
|
|
84
|
-
prettierOptions: prettierOptions
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
});
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
var chai_1 = require("chai");
|
|
40
|
-
var test_utils_1 = require("../../../../test-utils");
|
|
41
|
-
describe("VariableDeclarator", function () {
|
|
42
|
-
it("should format a variable declaration", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
43
|
-
var snippet, entryPoint, formattedText, expectedContents;
|
|
44
|
-
return __generator(this, function (_a) {
|
|
45
|
-
switch (_a.label) {
|
|
46
|
-
case 0:
|
|
47
|
-
snippet = "i=1";
|
|
48
|
-
entryPoint = "variableDeclarator";
|
|
49
|
-
return [4 /*yield*/, test_utils_1.formatJavaSnippet({ snippet: snippet, entryPoint: entryPoint })];
|
|
50
|
-
case 1:
|
|
51
|
-
formattedText = _a.sent();
|
|
52
|
-
expectedContents = "i = 1";
|
|
53
|
-
chai_1.expect(formattedText).to.equal(expectedContents);
|
|
54
|
-
return [2 /*return*/];
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}); });
|
|
58
|
-
it("should format a variable declaration with an array initialisation", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
59
|
-
var snippet, entryPoint, formattedText, expectedContents;
|
|
60
|
-
return __generator(this, function (_a) {
|
|
61
|
-
switch (_a.label) {
|
|
62
|
-
case 0:
|
|
63
|
-
snippet = "i={alpha}";
|
|
64
|
-
entryPoint = "variableDeclarator";
|
|
65
|
-
return [4 /*yield*/, test_utils_1.formatJavaSnippet({ snippet: snippet, entryPoint: entryPoint })];
|
|
66
|
-
case 1:
|
|
67
|
-
formattedText = _a.sent();
|
|
68
|
-
expectedContents = "i = { alpha }";
|
|
69
|
-
chai_1.expect(formattedText).to.equal(expectedContents);
|
|
70
|
-
return [2 /*return*/];
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}); });
|
|
74
|
-
it("should not add a blank line with an array initialisation that break", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
75
|
-
var snippet, entryPoint, formattedText, expectedContents;
|
|
76
|
-
return __generator(this, function (_a) {
|
|
77
|
-
switch (_a.label) {
|
|
78
|
-
case 0:
|
|
79
|
-
snippet = "i={alpha, beta, gamma, delta, epsilon, zeta, eta, theta, iota, kappa, lambda, mu, nu, xi}";
|
|
80
|
-
entryPoint = "variableDeclarator";
|
|
81
|
-
return [4 /*yield*/, test_utils_1.formatJavaSnippet({ snippet: snippet, entryPoint: entryPoint })];
|
|
82
|
-
case 1:
|
|
83
|
-
formattedText = _a.sent();
|
|
84
|
-
expectedContents = "i = {\n alpha,\n beta,\n gamma,\n delta,\n epsilon,\n zeta,\n eta,\n theta,\n iota,\n kappa,\n lambda,\n mu,\n nu,\n xi\n}";
|
|
85
|
-
chai_1.expect(formattedText).to.equal(expectedContents);
|
|
86
|
-
return [2 /*return*/];
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
}); });
|
|
90
|
-
it("should format a variable declaration with a lambda", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
91
|
-
var snippet, entryPoint, formattedText, expectedContents;
|
|
92
|
-
return __generator(this, function (_a) {
|
|
93
|
-
switch (_a.label) {
|
|
94
|
-
case 0:
|
|
95
|
-
snippet = "lambda= test -> {}";
|
|
96
|
-
entryPoint = "variableDeclarator";
|
|
97
|
-
return [4 /*yield*/, test_utils_1.formatJavaSnippet({ snippet: snippet, entryPoint: entryPoint })];
|
|
98
|
-
case 1:
|
|
99
|
-
formattedText = _a.sent();
|
|
100
|
-
expectedContents = "lambda = test -> {}";
|
|
101
|
-
chai_1.expect(formattedText).to.equal(expectedContents);
|
|
102
|
-
return [2 /*return*/];
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}); });
|
|
106
|
-
it("should not add a blank line with a lambda that break", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
107
|
-
var snippet, entryPoint, formattedText, expectedContents;
|
|
108
|
-
return __generator(this, function (_a) {
|
|
109
|
-
switch (_a.label) {
|
|
110
|
-
case 0:
|
|
111
|
-
snippet = "lambda= test -> {int i;}";
|
|
112
|
-
entryPoint = "variableDeclarator";
|
|
113
|
-
return [4 /*yield*/, test_utils_1.formatJavaSnippet({ snippet: snippet, entryPoint: entryPoint })];
|
|
114
|
-
case 1:
|
|
115
|
-
formattedText = _a.sent();
|
|
116
|
-
expectedContents = "lambda = test -> {\n int i;\n}";
|
|
117
|
-
chai_1.expect(formattedText).to.equal(expectedContents);
|
|
118
|
-
return [2 /*return*/];
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}); });
|
|
122
|
-
it("should format a variable declaration with a ternary expression", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
123
|
-
var snippet, entryPoint, formattedText, expectedContents;
|
|
124
|
-
return __generator(this, function (_a) {
|
|
125
|
-
switch (_a.label) {
|
|
126
|
-
case 0:
|
|
127
|
-
snippet = "value= bool ? one : two";
|
|
128
|
-
entryPoint = "variableDeclarator";
|
|
129
|
-
return [4 /*yield*/, test_utils_1.formatJavaSnippet({ snippet: snippet, entryPoint: entryPoint })];
|
|
130
|
-
case 1:
|
|
131
|
-
formattedText = _a.sent();
|
|
132
|
-
expectedContents = "value = bool ? one : two";
|
|
133
|
-
chai_1.expect(formattedText).to.equal(expectedContents);
|
|
134
|
-
return [2 /*return*/];
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
}); });
|
|
138
|
-
it("should not add a blank line with a ternary expression that break", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
139
|
-
var snippet, entryPoint, formattedText, expectedContents;
|
|
140
|
-
return __generator(this, function (_a) {
|
|
141
|
-
switch (_a.label) {
|
|
142
|
-
case 0:
|
|
143
|
-
snippet = "value = thisIsAnotherVeryLongIntegerThatIsEvenLongerThanFirstOne ? thisIsAnotherVeryLongIntegerThatIsEvenLongerThanFirstOne : thisIsAShortInteger";
|
|
144
|
-
entryPoint = "variableDeclarator";
|
|
145
|
-
return [4 /*yield*/, test_utils_1.formatJavaSnippet({ snippet: snippet, entryPoint: entryPoint })];
|
|
146
|
-
case 1:
|
|
147
|
-
formattedText = _a.sent();
|
|
148
|
-
expectedContents = "value = thisIsAnotherVeryLongIntegerThatIsEvenLongerThanFirstOne\n ? thisIsAnotherVeryLongIntegerThatIsEvenLongerThanFirstOne\n : thisIsAShortInteger";
|
|
149
|
-
chai_1.expect(formattedText).to.equal(expectedContents);
|
|
150
|
-
return [2 /*return*/];
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}); });
|
|
154
|
-
it("should format comment on its own line between equal and variable initializer", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
155
|
-
var snippet, entryPoint, formattedText, expectedContents;
|
|
156
|
-
return __generator(this, function (_a) {
|
|
157
|
-
switch (_a.label) {
|
|
158
|
-
case 0:
|
|
159
|
-
snippet = "value = \n// comment2\n 1";
|
|
160
|
-
entryPoint = "variableDeclarator";
|
|
161
|
-
return [4 /*yield*/, test_utils_1.formatJavaSnippet({ snippet: snippet, entryPoint: entryPoint })];
|
|
162
|
-
case 1:
|
|
163
|
-
formattedText = _a.sent();
|
|
164
|
-
expectedContents = "value =\n // comment2\n 1";
|
|
165
|
-
chai_1.expect(formattedText).to.equal(expectedContents);
|
|
166
|
-
return [2 /*return*/];
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
}); });
|
|
170
|
-
it("should format comments on several lines between equal and variable initializer", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
171
|
-
var snippet, entryPoint, formattedText, expectedContents;
|
|
172
|
-
return __generator(this, function (_a) {
|
|
173
|
-
switch (_a.label) {
|
|
174
|
-
case 0:
|
|
175
|
-
snippet = "value = // comment1\n// comment2\n 1";
|
|
176
|
-
entryPoint = "variableDeclarator";
|
|
177
|
-
return [4 /*yield*/, test_utils_1.formatJavaSnippet({ snippet: snippet, entryPoint: entryPoint })];
|
|
178
|
-
case 1:
|
|
179
|
-
formattedText = _a.sent();
|
|
180
|
-
expectedContents = "value = // comment1\n // comment2\n 1";
|
|
181
|
-
chai_1.expect(formattedText).to.equal(expectedContents);
|
|
182
|
-
return [2 /*return*/];
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
}); });
|
|
186
|
-
});
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var test_utils_1 = require("../../../test-utils");
|
|
4
|
-
describe("element Value Array Initializer", function () {
|
|
5
|
-
it("can format a elementValueArrayInitializer", function () {
|
|
6
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
7
|
-
snippet: "{alpha}",
|
|
8
|
-
expectedOutput: "{ alpha }",
|
|
9
|
-
entryPoint: "elementValueArrayInitializer"
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
describe("Trailing Commas", function () {
|
|
13
|
-
it("should remove extra comma in elementValueArrayInitializer by default", function () {
|
|
14
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
15
|
-
snippet: "{alpha,}",
|
|
16
|
-
expectedOutput: "{ alpha }",
|
|
17
|
-
entryPoint: "elementValueArrayInitializer"
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
it("should remove extra comma in elementValueArrayInitializer by default", function () {
|
|
21
|
-
// prettier-ignore
|
|
22
|
-
var expectedOutput = "{\n" +
|
|
23
|
-
" oneVeryLongArrayValue\n" +
|
|
24
|
-
"}";
|
|
25
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
26
|
-
snippet: "{oneVeryLongArrayValue,}",
|
|
27
|
-
expectedOutput: expectedOutput,
|
|
28
|
-
entryPoint: "elementValueArrayInitializer",
|
|
29
|
-
prettierOptions: {
|
|
30
|
-
printWidth: 15
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
it("should remove extra comma in elementValueArrayInitializer if it fit in one line and --trailing-comma='all'", function () {
|
|
35
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
36
|
-
snippet: "{oneVeryLongArrayValue,}",
|
|
37
|
-
expectedOutput: "{ oneVeryLongArrayValue }",
|
|
38
|
-
entryPoint: "elementValueArrayInitializer",
|
|
39
|
-
prettierOptions: {
|
|
40
|
-
trailingComma: "all"
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
it("should not add extra comma in elementValueArrayInitializer if it fit in one line and --trailing-comma='all'", function () {
|
|
45
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
46
|
-
snippet: "{oneVeryLongArrayValue}",
|
|
47
|
-
expectedOutput: "{ oneVeryLongArrayValue }",
|
|
48
|
-
entryPoint: "elementValueArrayInitializer",
|
|
49
|
-
prettierOptions: {
|
|
50
|
-
trailingComma: "all"
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
it("should keep extra comma in elementValueArrayInitializer if it does not fit in one line and --trailing-comma='all'", function () {
|
|
55
|
-
// prettier-ignore
|
|
56
|
-
var expectedOutput = "{\n" +
|
|
57
|
-
" oneVeryLongArrayValue/* COMMA */,\n" +
|
|
58
|
-
"}";
|
|
59
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
60
|
-
snippet: "{oneVeryLongArrayValue /* COMMA */,}",
|
|
61
|
-
expectedOutput: expectedOutput,
|
|
62
|
-
entryPoint: "elementValueArrayInitializer",
|
|
63
|
-
prettierOptions: {
|
|
64
|
-
printWidth: 15,
|
|
65
|
-
trailingComma: "all"
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
it("should add extra comma in elementValueArrayInitializer if it does not fit in one line and --trailing-comma='all'", function () {
|
|
70
|
-
// prettier-ignore
|
|
71
|
-
var expectedOutput = "{\n" +
|
|
72
|
-
" oneVeryLongArrayValue,\n" +
|
|
73
|
-
"}";
|
|
74
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
75
|
-
snippet: "{oneVeryLongArrayValue}",
|
|
76
|
-
expectedOutput: expectedOutput,
|
|
77
|
-
entryPoint: "elementValueArrayInitializer",
|
|
78
|
-
prettierOptions: {
|
|
79
|
-
printWidth: 15,
|
|
80
|
-
trailingComma: "all"
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var test_utils_1 = require("../../../../test-utils");
|
|
4
|
-
describe("AmbiguousName", function () {
|
|
5
|
-
it("can format a AmbiguousName without dots", function () {
|
|
6
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
7
|
-
snippet: "myAmbiguousName",
|
|
8
|
-
expectedOutput: "myAmbiguousName",
|
|
9
|
-
entryPoint: "ambiguousName"
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
it("can format a AmbiguousName with dots", function () {
|
|
13
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
14
|
-
snippet: "myAmbiguousName.with.lot.of.dots",
|
|
15
|
-
expectedOutput: "myAmbiguousName.with.lot.of.dots",
|
|
16
|
-
entryPoint: "ambiguousName"
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var test_utils_1 = require("../../../../test-utils");
|
|
4
|
-
describe("expressionName", function () {
|
|
5
|
-
it("can format a ExpressionName without dots", function () {
|
|
6
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
7
|
-
snippet: "myExpression",
|
|
8
|
-
expectedOutput: "myExpression",
|
|
9
|
-
entryPoint: "expressionName"
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
it("can format a ExpressionName with dots", function () {
|
|
13
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
14
|
-
snippet: "myExpression.with.lot.of.dots",
|
|
15
|
-
expectedOutput: "myExpression.with.lot.of.dots",
|
|
16
|
-
entryPoint: "expressionName"
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var test_utils_1 = require("../../../../test-utils");
|
|
4
|
-
describe("MethodName", function () {
|
|
5
|
-
it("can format a MethodName", function () {
|
|
6
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
7
|
-
snippet: "test",
|
|
8
|
-
expectedOutput: "test",
|
|
9
|
-
entryPoint: "methodName"
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var test_utils_1 = require("../../../../test-utils");
|
|
4
|
-
describe("PackageOrTypeName", function () {
|
|
5
|
-
it("can format a PackageOrTypeName without dots", function () {
|
|
6
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
7
|
-
snippet: "com",
|
|
8
|
-
expectedOutput: "com",
|
|
9
|
-
entryPoint: "packageOrTypeName"
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
it("can format a PackageOrTypeName with dots", function () {
|
|
13
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
14
|
-
snippet: "com.iluwatar.abstractdocument",
|
|
15
|
-
expectedOutput: "com.iluwatar.abstractdocument",
|
|
16
|
-
entryPoint: "packageOrTypeName"
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
});
|
package/dist/test/unit-test/snippets/types-values-and-variables/floatingPointType/test.spec.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var test_utils_1 = require("../../../../test-utils");
|
|
4
|
-
describe("floatingPointType", function () {
|
|
5
|
-
it("can format float keyword", function () {
|
|
6
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
7
|
-
snippet: "float",
|
|
8
|
-
expectedOutput: "float",
|
|
9
|
-
entryPoint: "floatingPointType"
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
it("can format double keyword", function () {
|
|
13
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
14
|
-
snippet: "double",
|
|
15
|
-
expectedOutput: "double",
|
|
16
|
-
entryPoint: "floatingPointType"
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var test_utils_1 = require("../../../../test-utils");
|
|
4
|
-
describe("integralType", function () {
|
|
5
|
-
it("can format byte keyword", function () {
|
|
6
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
7
|
-
snippet: "byte",
|
|
8
|
-
expectedOutput: "byte",
|
|
9
|
-
entryPoint: "integralType"
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
it("can format short keyword", function () {
|
|
13
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
14
|
-
snippet: "short",
|
|
15
|
-
expectedOutput: "short",
|
|
16
|
-
entryPoint: "integralType"
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
it("can format int keyword", function () {
|
|
20
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
21
|
-
snippet: "int",
|
|
22
|
-
expectedOutput: "int",
|
|
23
|
-
entryPoint: "integralType"
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
it("can format long keyword", function () {
|
|
27
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
28
|
-
snippet: "long",
|
|
29
|
-
expectedOutput: "long",
|
|
30
|
-
entryPoint: "integralType"
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
it("can format char keyword", function () {
|
|
34
|
-
test_utils_1.expectSnippetToBeFormatted({
|
|
35
|
-
snippet: "char",
|
|
36
|
-
expectedOutput: "char",
|
|
37
|
-
entryPoint: "integralType"
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
});
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
var base_cst_printer_1 = require("../../../../../src/base-cst-printer");
|
|
40
|
-
var sinon_1 = require("sinon");
|
|
41
|
-
var test_utils_1 = require("../../../../test-utils");
|
|
42
|
-
describe("numericType", function () {
|
|
43
|
-
var integralTypeSpy;
|
|
44
|
-
var floatingPointTypeSpy;
|
|
45
|
-
// eslint-disable-next-line no-undef
|
|
46
|
-
beforeEach(function () {
|
|
47
|
-
if (integralTypeSpy !== undefined) {
|
|
48
|
-
integralTypeSpy.restore();
|
|
49
|
-
}
|
|
50
|
-
if (floatingPointTypeSpy !== undefined) {
|
|
51
|
-
floatingPointTypeSpy.restore();
|
|
52
|
-
}
|
|
53
|
-
integralTypeSpy = sinon_1.spy(base_cst_printer_1.BaseCstPrettierPrinter.prototype, "integralType");
|
|
54
|
-
floatingPointTypeSpy = sinon_1.spy(base_cst_printer_1.BaseCstPrettierPrinter.prototype, "floatingPointType");
|
|
55
|
-
});
|
|
56
|
-
it("can format byte keyword", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
57
|
-
var snippet, entryPoint;
|
|
58
|
-
return __generator(this, function (_a) {
|
|
59
|
-
switch (_a.label) {
|
|
60
|
-
case 0:
|
|
61
|
-
snippet = "byte";
|
|
62
|
-
entryPoint = "numericType";
|
|
63
|
-
return [4 /*yield*/, test_utils_1.formatJavaSnippet({ snippet: snippet, entryPoint: entryPoint })];
|
|
64
|
-
case 1:
|
|
65
|
-
_a.sent();
|
|
66
|
-
sinon_1.assert.callCount(integralTypeSpy, 1);
|
|
67
|
-
sinon_1.assert.callCount(floatingPointTypeSpy, 0);
|
|
68
|
-
return [2 /*return*/];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}); });
|
|
72
|
-
it("can format double keyword", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
73
|
-
var snippet, entryPoint;
|
|
74
|
-
return __generator(this, function (_a) {
|
|
75
|
-
switch (_a.label) {
|
|
76
|
-
case 0:
|
|
77
|
-
snippet = "double";
|
|
78
|
-
entryPoint = "numericType";
|
|
79
|
-
return [4 /*yield*/, test_utils_1.formatJavaSnippet({ snippet: snippet, entryPoint: entryPoint })];
|
|
80
|
-
case 1:
|
|
81
|
-
_a.sent();
|
|
82
|
-
sinon_1.assert.callCount(integralTypeSpy, 0);
|
|
83
|
-
sinon_1.assert.callCount(floatingPointTypeSpy, 1);
|
|
84
|
-
return [2 /*return*/];
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}); });
|
|
88
|
-
});
|