prettier-plugin-java 1.6.1 → 2.0.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 +4 -3
- package/dist/cst-printer.js +1 -0
- package/dist/index.js +1 -0
- package/dist/options.js +2 -0
- package/dist/parser.js +1 -0
- package/dist/printer.js +1 -0
- package/dist/printers/arrays.js +4 -3
- package/dist/printers/blocks-and-statements.js +107 -102
- package/dist/printers/classes.js +152 -151
- package/dist/printers/comments/comments-utils.js +1 -0
- package/dist/printers/comments/format-comments.js +22 -13
- package/dist/printers/comments/handle-comments.js +2 -1
- package/dist/printers/expressions.js +128 -105
- package/dist/printers/interfaces.js +57 -56
- package/dist/printers/lexical-structure.js +5 -4
- package/dist/printers/names.js +9 -8
- package/dist/printers/packages-and-modules.js +73 -59
- package/dist/printers/prettier-builder.js +21 -12
- package/dist/printers/printer-utils.js +64 -56
- package/dist/printers/types-values-and-variables.js +44 -39
- package/dist/src/base-cst-printer.js +77 -0
- package/dist/src/cst-printer.js +37 -0
- package/dist/src/index.js +67 -0
- package/dist/src/options.js +256 -0
- package/dist/src/parser.js +7 -0
- package/dist/src/printer.js +28 -0
- package/dist/src/printers/arrays.js +49 -0
- package/dist/src/printers/blocks-and-statements.js +493 -0
- package/dist/src/printers/classes.js +724 -0
- package/dist/src/printers/comments/comments-utils.js +29 -0
- package/dist/src/printers/comments/format-comments.js +187 -0
- package/dist/src/printers/comments/handle-comments.js +38 -0
- package/dist/src/printers/expressions.js +549 -0
- package/dist/src/printers/interfaces.js +251 -0
- package/dist/src/printers/lexical-structure.js +43 -0
- package/dist/src/printers/names.js +53 -0
- package/dist/src/printers/packages-and-modules.js +185 -0
- package/dist/src/printers/prettier-builder.js +47 -0
- package/dist/src/printers/printer-utils.js +577 -0
- package/dist/src/printers/types-values-and-variables.js +183 -0
- package/dist/src/types/utils.js +29 -0
- package/dist/src/utils/expressions-utils.js +29 -0
- package/dist/src/utils/index.js +10 -0
- package/dist/src/utils/printArgumentListWithBraces.js +21 -0
- package/dist/src/utils/printSingleLambdaInvocation.js +20 -0
- package/dist/test/babel-register.js +3 -0
- package/dist/test/repository-test/core-test.js +12 -0
- package/dist/test/repository-test/jhipster-1-test.js +17 -0
- package/dist/test/repository-test/jhipster-2-test.js +16 -0
- package/dist/test/test-utils.js +215 -0
- package/dist/test/unit-test/annotation_type_declaration/annotation_type_declaration-spec.js +6 -0
- package/dist/test/unit-test/args/args-spec.js +6 -0
- package/dist/test/unit-test/assert/assert-spec.js +6 -0
- package/dist/test/unit-test/binary_expressions/binary_expressions-spec.js +6 -0
- package/dist/test/unit-test/blank_lines/blank_lines-spec.js +6 -0
- package/dist/test/unit-test/bug-fixes/bug-fixes-spec.js +6 -0
- package/dist/test/unit-test/cast/cast-spec.js +6 -0
- package/dist/test/unit-test/char_literal/char_literal-spec.js +6 -0
- package/dist/test/unit-test/classes/multiple_classes-spec.js +6 -0
- package/dist/test/unit-test/comments/comments-spec.js +14 -0
- package/dist/test/unit-test/complex_generic_class/complex_generic_class-spec.js +6 -0
- package/dist/test/unit-test/constructors/constructors-spec.js +6 -0
- package/dist/test/unit-test/empty_statement/empty_statement-spec.js +6 -0
- package/dist/test/unit-test/enum/enum-spec.js +6 -0
- package/dist/test/unit-test/expressions/expressions-spec.js +6 -0
- package/dist/test/unit-test/extends_abstract_class/extends_abstract_class-spec.js +6 -0
- package/dist/test/unit-test/extends_abstract_class_and_implements_interfaces/extends_abstract_class_and_implements_interfaces-spec.js +6 -0
- package/dist/test/unit-test/for/for-spec.js +6 -0
- package/dist/test/unit-test/generic_class/generic_class-spec.js +6 -0
- package/dist/test/unit-test/generic_questionmark/generic_questionmark-spec.js +6 -0
- package/dist/test/unit-test/hello-world/hello-word-spec.js +6 -0
- package/dist/test/unit-test/if/if-spec.js +6 -0
- package/dist/test/unit-test/indent/indent-spec.js +6 -0
- package/dist/test/unit-test/instantiation/instantiation-spec.js +6 -0
- package/dist/test/unit-test/interface/interface-spec.js +6 -0
- package/dist/test/unit-test/lambda/lambda-spec.js +6 -0
- package/dist/test/unit-test/marker_annotations/marker_annotations-spec.js +6 -0
- package/dist/test/unit-test/member_chain/member_chain-spec.js +6 -0
- package/dist/test/unit-test/method_reference/method_reference-spec.js +6 -0
- package/dist/test/unit-test/modifiers/modifiers-spec.js +6 -0
- package/dist/test/unit-test/modules/modules-spec.js +6 -0
- package/dist/test/unit-test/package_and_imports/package_and_imports-spec.js +34 -0
- package/dist/test/unit-test/pattern-matching/pattern-matching-spec.js +6 -0
- package/dist/test/unit-test/prettier-ignore/prettier-ignore-spec.js +28 -0
- package/dist/test/unit-test/records/records-spec.js +6 -0
- package/dist/test/unit-test/return/return-spec.js +6 -0
- package/dist/test/unit-test/sealed/sealed-spec.js +6 -0
- package/dist/test/unit-test/snippets/arrays/array-initializer.spec.js +94 -0
- package/dist/test/unit-test/snippets/arrays/variable-initializer-list.spec.js +19 -0
- package/dist/test/unit-test/snippets/blocks-and-statements/switch.spec.js +26 -0
- package/dist/test/unit-test/snippets/classes/class-body.spec.js +181 -0
- package/dist/test/unit-test/snippets/classes/enum-body.spec.js +87 -0
- package/dist/test/unit-test/snippets/classes/variableDeclarator/test.spec.js +186 -0
- package/dist/test/unit-test/snippets/interfaces/element-value-array-initializer.spec.js +85 -0
- package/dist/test/unit-test/snippets/names/ambiguousName/test.spec.js +19 -0
- package/dist/test/unit-test/snippets/names/expressionName/test.spec.js +19 -0
- package/dist/test/unit-test/snippets/names/methodName/test.spec.js +12 -0
- package/dist/test/unit-test/snippets/names/packageOrTypeName/test.spec.js +19 -0
- package/dist/test/unit-test/snippets/types-values-and-variables/floatingPointType/test.spec.js +19 -0
- package/dist/test/unit-test/snippets/types-values-and-variables/integralType/test.spec.js +40 -0
- package/dist/test/unit-test/snippets/types-values-and-variables/numericType/test.spec.js +88 -0
- package/dist/test/unit-test/snippets/types-values-and-variables/wildcard/test.spec.js +112 -0
- package/dist/test/unit-test/snippets/types-values-and-variables/wildcardBounds/test.spec.js +81 -0
- package/dist/test/unit-test/switch/switch-spec.js +6 -0
- package/dist/test/unit-test/synchronized/synchronized-spec.js +6 -0
- package/dist/test/unit-test/text-blocks/text-block-spec.js +6 -0
- package/dist/test/unit-test/throws/throws-spec.js +6 -0
- package/dist/test/unit-test/try_catch/try_catch-spec.js +6 -0
- package/dist/test/unit-test/types/types-spec.js +6 -0
- package/dist/test/unit-test/variables/variables-spec.js +6 -0
- package/dist/test/unit-test/while/while-spec.js +6 -0
- package/dist/test/unit-test/yield-statement/yield-statement-spec.js +6 -0
- package/dist/types/utils.js +1 -0
- package/dist/utils/expressions-utils.js +1 -0
- package/dist/utils/index.js +4 -1
- package/dist/utils/isEmptyDoc.js +7 -0
- package/dist/utils/printArgumentListWithBraces.js +3 -2
- package/dist/utils/printSingleLambdaInvocation.js +5 -4
- package/package.json +21 -21
- package/dist/utils/constants.js +0 -4
|
@@ -14,10 +14,14 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
18
|
-
for (var i = 0,
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
18
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
19
|
+
if (ar || !(i in from)) {
|
|
20
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
21
|
+
ar[i] = from[i];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
25
|
};
|
|
22
26
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
27
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -40,16 +44,16 @@ var TypesValuesAndVariablesPrettierVisitor = /** @class */ (function (_super) {
|
|
|
40
44
|
var type = ctx.numericType
|
|
41
45
|
? this.visit(ctx.numericType)
|
|
42
46
|
: this.getSingle(ctx);
|
|
43
|
-
return printer_utils_1.rejectAndJoin(" ", [prettier_builder_1.join(" ", annotations), type]);
|
|
47
|
+
return (0, printer_utils_1.rejectAndJoin)(" ", [(0, prettier_builder_1.join)(" ", annotations), type]);
|
|
44
48
|
};
|
|
45
49
|
TypesValuesAndVariablesPrettierVisitor.prototype.numericType = function (ctx) {
|
|
46
50
|
return this.visitSingle(ctx);
|
|
47
51
|
};
|
|
48
52
|
TypesValuesAndVariablesPrettierVisitor.prototype.integralType = function (ctx) {
|
|
49
|
-
return format_comments_1.printTokenWithComments(this.getSingle(ctx));
|
|
53
|
+
return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
|
|
50
54
|
};
|
|
51
55
|
TypesValuesAndVariablesPrettierVisitor.prototype.floatingPointType = function (ctx) {
|
|
52
|
-
return format_comments_1.printTokenWithComments(this.getSingle(ctx));
|
|
56
|
+
return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
|
|
53
57
|
};
|
|
54
58
|
TypesValuesAndVariablesPrettierVisitor.prototype.referenceType = function (ctx) {
|
|
55
59
|
var annotations = this.mapVisit(ctx.annotation);
|
|
@@ -57,35 +61,35 @@ var TypesValuesAndVariablesPrettierVisitor = /** @class */ (function (_super) {
|
|
|
57
61
|
? this.visit(ctx.primitiveType)
|
|
58
62
|
: this.visit(ctx.classOrInterfaceType);
|
|
59
63
|
var dims = this.visit(ctx.dims);
|
|
60
|
-
return printer_utils_1.rejectAndJoin(" ", [prettier_builder_1.join(" ", annotations), prettier_builder_1.concat([type, dims])]);
|
|
64
|
+
return (0, printer_utils_1.rejectAndJoin)(" ", [(0, prettier_builder_1.join)(" ", annotations), (0, prettier_builder_1.concat)([type, dims])]);
|
|
61
65
|
};
|
|
62
66
|
TypesValuesAndVariablesPrettierVisitor.prototype.classOrInterfaceType = function (ctx) {
|
|
63
67
|
return this.visitSingle(ctx);
|
|
64
68
|
};
|
|
65
69
|
TypesValuesAndVariablesPrettierVisitor.prototype.classType = function (ctx) {
|
|
66
70
|
var _this = this;
|
|
67
|
-
var tokens = printer_utils_1.sortClassTypeChildren(ctx.annotation, ctx.typeArguments, ctx.Identifier);
|
|
71
|
+
var tokens = (0, printer_utils_1.sortClassTypeChildren)(ctx.annotation, ctx.typeArguments, ctx.Identifier);
|
|
68
72
|
var segments = [];
|
|
69
73
|
var currentSegment = [];
|
|
70
|
-
forEach_1.default(tokens, function (token, i) {
|
|
71
|
-
if (utils_1.isTypeArgumentsCstNode(token)) {
|
|
74
|
+
(0, forEach_1.default)(tokens, function (token, i) {
|
|
75
|
+
if ((0, utils_1.isTypeArgumentsCstNode)(token)) {
|
|
72
76
|
currentSegment.push(_this.visit([token]));
|
|
73
|
-
segments.push(printer_utils_1.rejectAndConcat(currentSegment));
|
|
77
|
+
segments.push((0, printer_utils_1.rejectAndConcat)(currentSegment));
|
|
74
78
|
currentSegment = [];
|
|
75
79
|
}
|
|
76
|
-
else if (utils_1.isAnnotationCstNode(token)) {
|
|
77
|
-
currentSegment.push(_this.visit([token]));
|
|
80
|
+
else if ((0, utils_1.isAnnotationCstNode)(token)) {
|
|
81
|
+
currentSegment.push(_this.visit([token]), " ");
|
|
78
82
|
}
|
|
79
83
|
else {
|
|
80
84
|
currentSegment.push(token);
|
|
81
|
-
if ((i + 1 < tokens.length && !utils_1.isTypeArgumentsCstNode(tokens[i + 1])) ||
|
|
85
|
+
if ((i + 1 < tokens.length && !(0, utils_1.isTypeArgumentsCstNode)(tokens[i + 1])) ||
|
|
82
86
|
i + 1 === tokens.length) {
|
|
83
|
-
segments.push(printer_utils_1.rejectAndConcat(currentSegment));
|
|
87
|
+
segments.push((0, printer_utils_1.rejectAndConcat)(currentSegment));
|
|
84
88
|
currentSegment = [];
|
|
85
89
|
}
|
|
86
90
|
}
|
|
87
91
|
});
|
|
88
|
-
return printer_utils_1.rejectAndJoinSeps(ctx.Dot, segments);
|
|
92
|
+
return (0, printer_utils_1.rejectAndJoinSeps)(ctx.Dot, segments);
|
|
89
93
|
};
|
|
90
94
|
TypesValuesAndVariablesPrettierVisitor.prototype.interfaceType = function (ctx) {
|
|
91
95
|
return this.visitSingle(ctx);
|
|
@@ -93,45 +97,45 @@ var TypesValuesAndVariablesPrettierVisitor = /** @class */ (function (_super) {
|
|
|
93
97
|
TypesValuesAndVariablesPrettierVisitor.prototype.typeVariable = function (ctx) {
|
|
94
98
|
var annotations = this.mapVisit(ctx.annotation);
|
|
95
99
|
var identifier = this.getSingle(ctx);
|
|
96
|
-
return printer_utils_1.rejectAndJoin(" ", [prettier_builder_1.join(" ", annotations), identifier]);
|
|
100
|
+
return (0, printer_utils_1.rejectAndJoin)(" ", [(0, prettier_builder_1.join)(" ", annotations), identifier]);
|
|
97
101
|
};
|
|
98
102
|
TypesValuesAndVariablesPrettierVisitor.prototype.dims = function (ctx) {
|
|
99
103
|
var _this = this;
|
|
100
|
-
var tokens = __spreadArray([], ctx.LSquare);
|
|
104
|
+
var tokens = __spreadArray([], ctx.LSquare, true);
|
|
101
105
|
if (ctx.annotation) {
|
|
102
|
-
tokens = __spreadArray(__spreadArray([], tokens), ctx.annotation);
|
|
106
|
+
tokens = __spreadArray(__spreadArray([], tokens, true), ctx.annotation, true);
|
|
103
107
|
}
|
|
104
108
|
tokens = tokens.sort(function (a, b) {
|
|
105
|
-
var startOffset1 = utils_1.isCstNode(a)
|
|
109
|
+
var startOffset1 = (0, utils_1.isCstNode)(a)
|
|
106
110
|
? a.children.At[0].startOffset
|
|
107
111
|
: a.startOffset;
|
|
108
|
-
var startOffset2 = utils_1.isCstNode(b)
|
|
112
|
+
var startOffset2 = (0, utils_1.isCstNode)(b)
|
|
109
113
|
? b.children.At[0].startOffset
|
|
110
114
|
: b.startOffset;
|
|
111
115
|
return startOffset1 - startOffset2;
|
|
112
116
|
});
|
|
113
117
|
var segments = [];
|
|
114
118
|
var currentSegment = [];
|
|
115
|
-
forEach_1.default(tokens, function (token) {
|
|
116
|
-
if (utils_1.isCstNode(token)) {
|
|
119
|
+
(0, forEach_1.default)(tokens, function (token) {
|
|
120
|
+
if ((0, utils_1.isCstNode)(token)) {
|
|
117
121
|
currentSegment.push(_this.visit([token]));
|
|
118
122
|
}
|
|
119
123
|
else {
|
|
120
|
-
segments.push(printer_utils_1.rejectAndConcat([
|
|
121
|
-
printer_utils_1.rejectAndJoin(" ", currentSegment),
|
|
122
|
-
prettier_builder_1.concat([ctx.LSquare[0], ctx.RSquare[0]])
|
|
124
|
+
segments.push((0, printer_utils_1.rejectAndConcat)([
|
|
125
|
+
(0, printer_utils_1.rejectAndJoin)(" ", currentSegment),
|
|
126
|
+
(0, prettier_builder_1.concat)([ctx.LSquare[0], ctx.RSquare[0]])
|
|
123
127
|
]));
|
|
124
128
|
currentSegment = [];
|
|
125
129
|
}
|
|
126
130
|
});
|
|
127
|
-
return printer_utils_1.rejectAndConcat(segments);
|
|
131
|
+
return (0, printer_utils_1.rejectAndConcat)(segments);
|
|
128
132
|
};
|
|
129
133
|
TypesValuesAndVariablesPrettierVisitor.prototype.typeParameter = function (ctx) {
|
|
130
134
|
var typeParameterModifiers = this.mapVisit(ctx.typeParameterModifier);
|
|
131
135
|
var typeIdentifier = this.visit(ctx.typeIdentifier);
|
|
132
136
|
var typeBound = this.visit(ctx.typeBound);
|
|
133
|
-
return printer_utils_1.rejectAndJoin(" ", [
|
|
134
|
-
prettier_builder_1.join(" ", typeParameterModifiers),
|
|
137
|
+
return (0, printer_utils_1.rejectAndJoin)(" ", [
|
|
138
|
+
(0, prettier_builder_1.join)(" ", typeParameterModifiers),
|
|
135
139
|
typeIdentifier,
|
|
136
140
|
typeBound
|
|
137
141
|
]);
|
|
@@ -142,24 +146,24 @@ var TypesValuesAndVariablesPrettierVisitor = /** @class */ (function (_super) {
|
|
|
142
146
|
TypesValuesAndVariablesPrettierVisitor.prototype.typeBound = function (ctx) {
|
|
143
147
|
var classOrInterfaceType = this.visit(ctx.classOrInterfaceType);
|
|
144
148
|
var additionalBound = this.mapVisit(ctx.additionalBound);
|
|
145
|
-
return printer_utils_1.rejectAndJoin(" ", [
|
|
149
|
+
return (0, printer_utils_1.rejectAndJoin)(" ", [
|
|
146
150
|
ctx.Extends[0],
|
|
147
151
|
classOrInterfaceType,
|
|
148
|
-
prettier_builder_1.join(" ", additionalBound)
|
|
152
|
+
(0, prettier_builder_1.join)(" ", additionalBound)
|
|
149
153
|
]);
|
|
150
154
|
};
|
|
151
155
|
TypesValuesAndVariablesPrettierVisitor.prototype.additionalBound = function (ctx) {
|
|
152
156
|
var interfaceType = this.visit(ctx.interfaceType);
|
|
153
|
-
return prettier_builder_1.join(" ", [ctx.And[0], interfaceType]);
|
|
157
|
+
return (0, prettier_builder_1.join)(" ", [ctx.And[0], interfaceType]);
|
|
154
158
|
};
|
|
155
159
|
TypesValuesAndVariablesPrettierVisitor.prototype.typeArguments = function (ctx) {
|
|
156
160
|
var typeArgumentList = this.visit(ctx.typeArgumentList);
|
|
157
|
-
return printer_utils_1.rejectAndConcat([ctx.Less[0], typeArgumentList, ctx.Greater[0]]);
|
|
161
|
+
return (0, printer_utils_1.rejectAndConcat)([ctx.Less[0], typeArgumentList, ctx.Greater[0]]);
|
|
158
162
|
};
|
|
159
163
|
TypesValuesAndVariablesPrettierVisitor.prototype.typeArgumentList = function (ctx) {
|
|
160
164
|
var typeArguments = this.mapVisit(ctx.typeArgument);
|
|
161
|
-
var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return prettier_builder_1.concat([elt, " "]); }) : [];
|
|
162
|
-
return printer_utils_1.rejectAndJoinSeps(commas, typeArguments);
|
|
165
|
+
var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return (0, prettier_builder_1.concat)([elt, " "]); }) : [];
|
|
166
|
+
return (0, printer_utils_1.rejectAndJoinSeps)(commas, typeArguments);
|
|
163
167
|
};
|
|
164
168
|
TypesValuesAndVariablesPrettierVisitor.prototype.typeArgument = function (ctx) {
|
|
165
169
|
return this.visitSingle(ctx);
|
|
@@ -167,8 +171,8 @@ var TypesValuesAndVariablesPrettierVisitor = /** @class */ (function (_super) {
|
|
|
167
171
|
TypesValuesAndVariablesPrettierVisitor.prototype.wildcard = function (ctx) {
|
|
168
172
|
var annotations = this.mapVisit(ctx.annotation);
|
|
169
173
|
var wildcardBounds = this.visit(ctx.wildcardBounds);
|
|
170
|
-
return printer_utils_1.rejectAndJoin(" ", [
|
|
171
|
-
prettier_builder_1.join(" ", annotations),
|
|
174
|
+
return (0, printer_utils_1.rejectAndJoin)(" ", [
|
|
175
|
+
(0, prettier_builder_1.join)(" ", annotations),
|
|
172
176
|
ctx.QuestionMark[0],
|
|
173
177
|
wildcardBounds
|
|
174
178
|
]);
|
|
@@ -176,8 +180,9 @@ var TypesValuesAndVariablesPrettierVisitor = /** @class */ (function (_super) {
|
|
|
176
180
|
TypesValuesAndVariablesPrettierVisitor.prototype.wildcardBounds = function (ctx) {
|
|
177
181
|
var keyWord = ctx.Extends ? ctx.Extends[0] : ctx.Super[0];
|
|
178
182
|
var referenceType = this.visit(ctx.referenceType);
|
|
179
|
-
return prettier_builder_1.join(" ", [keyWord, referenceType]);
|
|
183
|
+
return (0, prettier_builder_1.join)(" ", [keyWord, referenceType]);
|
|
180
184
|
};
|
|
181
185
|
return TypesValuesAndVariablesPrettierVisitor;
|
|
182
186
|
}(base_cst_printer_1.BaseCstPrettierPrinter));
|
|
183
187
|
exports.TypesValuesAndVariablesPrettierVisitor = TypesValuesAndVariablesPrettierVisitor;
|
|
188
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMtdmFsdWVzLWFuZC12YXJpYWJsZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcHJpbnRlcnMvdHlwZXMtdmFsdWVzLWFuZC12YXJpYWJsZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5nc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BQztJQUVELHlEQUFRLEdBQVIsVUFBUyxHQUFnQjtRQUN2QixJQUFNLFdBQVcsR0FBRyxJQUFJLENBQUMsUUFBUSxDQUFDLEdBQUcsQ0FBQyxVQUFVLENBQUMsQ0FBQztRQUNsRCxJQUFNLGNBQWMsR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxjQUFjLENBQUMsQ0FBQztRQUV0RCxPQUFPLElBQUEsNkJBQWEsRUFBQyxHQUFHLEVBQUU7WUFDeEIsSUFBQSx1QkFBSSxFQUFDLEdBQUcsRUFBRSxXQUFXLENBQUM7WUFDdEIsR0FBRyxDQUFDLFlBQVksQ0FBQyxDQUFDLENBQUM7WUFDbkIsY0FBYztTQUNmLENBQUMsQ0FBQztJQUNMLENBQUM7SUFFRCwrREFBYyxHQUFkLFVBQWUsR0FBc0I7UUFDbkMsSUFBTSxPQUFPLEdBQUcsR0FBRyxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUMsR0FBRyxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxDQUFDLEtBQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUM3RCxJQUFNLGFBQWEsR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxhQUFhLENBQUMsQ0FBQztRQUNwRCxPQUFPLElBQUEsdUJBQUksRUFBQyxHQUFHLEVBQUUsQ0FBQyxPQUFPLEVBQUUsYUFBYSxDQUFDLENBQUMsQ0FBQztJQUM3QyxDQUFDO0lBQ0gsNkNBQUM7QUFBRCxDQUFDLEFBeExELENBQTRELHlDQUFzQixHQXdMakY7QUF4TFksd0ZBQXNDIn0=
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.BaseCstPrettierPrinter = void 0;
|
|
19
|
+
var java_parser_1 = require("java-parser");
|
|
20
|
+
var format_comments_1 = require("./printers/comments/format-comments");
|
|
21
|
+
var BaseCstPrettierPrinter = /** @class */ (function (_super) {
|
|
22
|
+
__extends(BaseCstPrettierPrinter, _super);
|
|
23
|
+
function BaseCstPrettierPrinter() {
|
|
24
|
+
var _this = _super.call(this) || this;
|
|
25
|
+
_this.mapVisit = function (elements, params) {
|
|
26
|
+
if (elements === undefined) {
|
|
27
|
+
// TODO: can optimize this by returning an immutable empty array singleton.
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
return elements.map(function (element) { return _this.visit(element, params); });
|
|
31
|
+
};
|
|
32
|
+
_this.getSingle = function (ctx) {
|
|
33
|
+
var ctxKeys = Object.keys(ctx);
|
|
34
|
+
if (ctxKeys.length !== 1) {
|
|
35
|
+
throw Error("Expecting single key CST ctx but found: <" + ctxKeys.length + "> keys");
|
|
36
|
+
}
|
|
37
|
+
var singleElementKey = ctxKeys[0];
|
|
38
|
+
var singleElementValues = ctx[singleElementKey];
|
|
39
|
+
if ((singleElementValues === null || singleElementValues === void 0 ? void 0 : singleElementValues.length) !== 1) {
|
|
40
|
+
throw Error("Expecting single item in CST ctx key but found: <" + (singleElementValues === null || singleElementValues === void 0 ? void 0 : singleElementValues.length) + "> items");
|
|
41
|
+
}
|
|
42
|
+
return singleElementValues[0];
|
|
43
|
+
};
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
_this.orgVisit = _this.visit;
|
|
46
|
+
_this.visit = function (ctx, inParam) {
|
|
47
|
+
if (ctx === undefined) {
|
|
48
|
+
// empty Doc
|
|
49
|
+
return "";
|
|
50
|
+
}
|
|
51
|
+
var node = Array.isArray(ctx) ? ctx[0] : ctx;
|
|
52
|
+
if (node.ignore) {
|
|
53
|
+
try {
|
|
54
|
+
var startOffset = node.leadingComments !== undefined
|
|
55
|
+
? node.leadingComments[0].startOffset
|
|
56
|
+
: node.location.startOffset;
|
|
57
|
+
var endOffset = (node.trailingComments !== undefined
|
|
58
|
+
? node.trailingComments[node.trailingComments.length - 1].endOffset
|
|
59
|
+
: node.location.endOffset);
|
|
60
|
+
return this.prettierOptions.originalText.substring(startOffset, endOffset + 1);
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
throw Error(e +
|
|
64
|
+
"\nThere might be a problem with prettier-ignore, please report an issue on https://github.com/jhipster/prettier-java/issues");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return format_comments_1.printNodeWithComments(node, this.orgVisit.call(this, node, inParam));
|
|
68
|
+
};
|
|
69
|
+
_this.visitSingle = function (ctx, params) {
|
|
70
|
+
var singleElement = this.getSingle(ctx);
|
|
71
|
+
return this.visit(singleElement, params);
|
|
72
|
+
};
|
|
73
|
+
return _this;
|
|
74
|
+
}
|
|
75
|
+
return BaseCstPrettierPrinter;
|
|
76
|
+
}(java_parser_1.BaseJavaCstVisitor));
|
|
77
|
+
exports.BaseCstPrettierPrinter = BaseCstPrettierPrinter;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPrettierDoc = void 0;
|
|
4
|
+
var base_cst_printer_1 = require("./base-cst-printer");
|
|
5
|
+
var arrays_1 = require("./printers/arrays");
|
|
6
|
+
var blocks_and_statements_1 = require("./printers/blocks-and-statements");
|
|
7
|
+
var classes_1 = require("./printers/classes");
|
|
8
|
+
var expressions_1 = require("./printers/expressions");
|
|
9
|
+
var interfaces_1 = require("./printers/interfaces");
|
|
10
|
+
var lexical_structure_1 = require("./printers/lexical-structure");
|
|
11
|
+
var names_1 = require("./printers/names");
|
|
12
|
+
var types_values_and_variables_1 = require("./printers/types-values-and-variables");
|
|
13
|
+
var packages_and_modules_1 = require("./printers/packages-and-modules");
|
|
14
|
+
// Mixins for the win
|
|
15
|
+
mixInMethods(arrays_1.ArraysPrettierVisitor, blocks_and_statements_1.BlocksAndStatementPrettierVisitor, classes_1.ClassesPrettierVisitor, expressions_1.ExpressionsPrettierVisitor, interfaces_1.InterfacesPrettierVisitor, lexical_structure_1.LexicalStructurePrettierVisitor, names_1.NamesPrettierVisitor, types_values_and_variables_1.TypesValuesAndVariablesPrettierVisitor, packages_and_modules_1.PackagesAndModulesPrettierVisitor);
|
|
16
|
+
function mixInMethods() {
|
|
17
|
+
var classesToMix = [];
|
|
18
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
19
|
+
classesToMix[_i] = arguments[_i];
|
|
20
|
+
}
|
|
21
|
+
classesToMix.forEach(function (from) {
|
|
22
|
+
var fromMethodsNames = Object.getOwnPropertyNames(from.prototype);
|
|
23
|
+
var fromPureMethodsName = fromMethodsNames.filter(function (methodName) { return methodName !== "constructor"; });
|
|
24
|
+
fromPureMethodsName.forEach(function (methodName) {
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
base_cst_printer_1.BaseCstPrettierPrinter.prototype[methodName] = from.prototype[methodName];
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
var prettyPrinter = new base_cst_printer_1.BaseCstPrettierPrinter();
|
|
31
|
+
// TODO: do we need the "path" and "print" arguments passed by prettier
|
|
32
|
+
// see https://github.com/prettier/prettier/issues/5747
|
|
33
|
+
function createPrettierDoc(cstNode, options) {
|
|
34
|
+
prettyPrinter.prettierOptions = options;
|
|
35
|
+
return prettyPrinter.visit(cstNode);
|
|
36
|
+
}
|
|
37
|
+
exports.createPrettierDoc = createPrettierDoc;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var parse = require("./parser");
|
|
3
|
+
var print = require("./printer");
|
|
4
|
+
var options = require("./options");
|
|
5
|
+
var languages = [
|
|
6
|
+
{
|
|
7
|
+
name: "Java",
|
|
8
|
+
parsers: ["java"],
|
|
9
|
+
group: "Java",
|
|
10
|
+
tmScope: "text.html.vue",
|
|
11
|
+
aceMode: "html",
|
|
12
|
+
codemirrorMode: "clike",
|
|
13
|
+
codemirrorMimeType: "text/x-java",
|
|
14
|
+
extensions: [".java"],
|
|
15
|
+
linguistLanguageId: 181,
|
|
16
|
+
vscodeLanguageIds: ["java"]
|
|
17
|
+
}
|
|
18
|
+
];
|
|
19
|
+
function locStart( /* node */) {
|
|
20
|
+
return -1;
|
|
21
|
+
}
|
|
22
|
+
function locEnd( /* node */) {
|
|
23
|
+
return -1;
|
|
24
|
+
}
|
|
25
|
+
function hasPragma( /* text */) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
var parsers = {
|
|
29
|
+
java: {
|
|
30
|
+
parse: parse,
|
|
31
|
+
astFormat: "java",
|
|
32
|
+
locStart: locStart,
|
|
33
|
+
locEnd: locEnd,
|
|
34
|
+
hasPragma: hasPragma
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
function canAttachComment(node) {
|
|
38
|
+
return node.ast_type && node.ast_type !== "comment";
|
|
39
|
+
}
|
|
40
|
+
function printComment(commentPath) {
|
|
41
|
+
var comment = commentPath.getValue();
|
|
42
|
+
switch (comment.ast_type) {
|
|
43
|
+
case "comment":
|
|
44
|
+
return comment.value;
|
|
45
|
+
default:
|
|
46
|
+
throw new Error("Not a comment: " + JSON.stringify(comment));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function clean(ast, newObj) {
|
|
50
|
+
delete newObj.lineno;
|
|
51
|
+
delete newObj.col_offset;
|
|
52
|
+
}
|
|
53
|
+
var printers = {
|
|
54
|
+
java: {
|
|
55
|
+
print: print,
|
|
56
|
+
// hasPrettierIgnore,
|
|
57
|
+
printComment: printComment,
|
|
58
|
+
canAttachComment: canAttachComment,
|
|
59
|
+
massageAstNode: clean
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
module.exports = {
|
|
63
|
+
languages: languages,
|
|
64
|
+
printers: printers,
|
|
65
|
+
parsers: parsers,
|
|
66
|
+
options: options
|
|
67
|
+
};
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = {
|
|
3
|
+
entrypoint: {
|
|
4
|
+
type: "choice",
|
|
5
|
+
category: "Global",
|
|
6
|
+
default: "compilationUnit",
|
|
7
|
+
// sed -nr 's/.*\.RULE\(([^,]+),.*/\1/p' $(ls path/to/java-parser/rules/folder/*)
|
|
8
|
+
choices: [
|
|
9
|
+
{ value: "arrayInitializer" },
|
|
10
|
+
{ value: "variableInitializerList" },
|
|
11
|
+
{ value: "block" },
|
|
12
|
+
{ value: "blockStatements" },
|
|
13
|
+
{ value: "blockStatement" },
|
|
14
|
+
{ value: "localVariableDeclarationStatement" },
|
|
15
|
+
{ value: "localVariableDeclaration" },
|
|
16
|
+
{ value: "localVariableType" },
|
|
17
|
+
{ value: "statement" },
|
|
18
|
+
{ value: "statementWithoutTrailingSubstatement" },
|
|
19
|
+
{ value: "emptyStatement" },
|
|
20
|
+
{ value: "labeledStatement" },
|
|
21
|
+
{ value: "expressionStatement" },
|
|
22
|
+
{ value: "statementExpression" },
|
|
23
|
+
{ value: "ifStatement" },
|
|
24
|
+
{ value: "assertStatement" },
|
|
25
|
+
{ value: "switchStatement" },
|
|
26
|
+
{ value: "switchBlock" },
|
|
27
|
+
{ value: "switchBlockStatementGroup" },
|
|
28
|
+
{ value: "switchLabel" },
|
|
29
|
+
{ value: "caseOrDefaultLabel" },
|
|
30
|
+
{ value: "caseLabelElement" },
|
|
31
|
+
{ value: "switchRule" },
|
|
32
|
+
{ value: "caseConstant" },
|
|
33
|
+
{ value: "whileStatement" },
|
|
34
|
+
{ value: "doStatement" },
|
|
35
|
+
{ value: "forStatement" },
|
|
36
|
+
{ value: "basicForStatement" },
|
|
37
|
+
{ value: "forInit" },
|
|
38
|
+
{ value: "forUpdate" },
|
|
39
|
+
{ value: "statementExpressionList" },
|
|
40
|
+
{ value: "enhancedForStatement" },
|
|
41
|
+
{ value: "breakStatement" },
|
|
42
|
+
{ value: "continueStatement" },
|
|
43
|
+
{ value: "returnStatement" },
|
|
44
|
+
{ value: "throwStatement" },
|
|
45
|
+
{ value: "synchronizedStatement" },
|
|
46
|
+
{ value: "tryStatement" },
|
|
47
|
+
{ value: "catches" },
|
|
48
|
+
{ value: "catchClause" },
|
|
49
|
+
{ value: "catchFormalParameter" },
|
|
50
|
+
{ value: "catchType" },
|
|
51
|
+
{ value: "finally" },
|
|
52
|
+
{ value: "tryWithResourcesStatement" },
|
|
53
|
+
{ value: "resourceSpecification" },
|
|
54
|
+
{ value: "resourceList" },
|
|
55
|
+
{ value: "resource" },
|
|
56
|
+
{ value: "resourceInit" },
|
|
57
|
+
{ value: "yieldStatement" },
|
|
58
|
+
{ value: "variableAccess" },
|
|
59
|
+
{ value: "isBasicForStatement" },
|
|
60
|
+
{ value: "isLocalVariableDeclaration" },
|
|
61
|
+
{ value: "isClassicSwitchLabel" },
|
|
62
|
+
{ value: "classDeclaration" },
|
|
63
|
+
{ value: "normalClassDeclaration" },
|
|
64
|
+
{ value: "classModifier" },
|
|
65
|
+
{ value: "typeParameters" },
|
|
66
|
+
{ value: "typeParameterList" },
|
|
67
|
+
{ value: "superclass" },
|
|
68
|
+
{ value: "superinterfaces" },
|
|
69
|
+
{ value: "interfaceTypeList" },
|
|
70
|
+
{ value: "classPermits" },
|
|
71
|
+
{ value: "classBody" },
|
|
72
|
+
{ value: "classBodyDeclaration" },
|
|
73
|
+
{ value: "classMemberDeclaration" },
|
|
74
|
+
{ value: "fieldDeclaration" },
|
|
75
|
+
{ value: "fieldModifier" },
|
|
76
|
+
{ value: "variableDeclaratorList" },
|
|
77
|
+
{ value: "variableDeclarator" },
|
|
78
|
+
{ value: "variableDeclaratorId" },
|
|
79
|
+
{ value: "variableInitializer" },
|
|
80
|
+
{ value: "unannType" },
|
|
81
|
+
{ value: "unannPrimitiveTypeWithOptionalDimsSuffix" },
|
|
82
|
+
{ value: "unannPrimitiveType" },
|
|
83
|
+
{ value: "unannReferenceType" },
|
|
84
|
+
{ value: "unannClassOrInterfaceType" },
|
|
85
|
+
{ value: "unannClassType" },
|
|
86
|
+
{ value: "unannInterfaceType" },
|
|
87
|
+
{ value: "unannTypeVariable" },
|
|
88
|
+
{ value: "methodDeclaration" },
|
|
89
|
+
{ value: "methodModifier" },
|
|
90
|
+
{ value: "methodHeader" },
|
|
91
|
+
{ value: "result" },
|
|
92
|
+
{ value: "methodDeclarator" },
|
|
93
|
+
{ value: "receiverParameter" },
|
|
94
|
+
{ value: "formalParameterList" },
|
|
95
|
+
{ value: "formalParameter" },
|
|
96
|
+
{ value: "variableParaRegularParameter" },
|
|
97
|
+
{ value: "variableArityParameter" },
|
|
98
|
+
{ value: "variableModifier" },
|
|
99
|
+
{ value: "throws" },
|
|
100
|
+
{ value: "exceptionTypeList" },
|
|
101
|
+
{ value: "exceptionType" },
|
|
102
|
+
{ value: "methodBody" },
|
|
103
|
+
{ value: "instanceInitializer" },
|
|
104
|
+
{ value: "staticInitializer" },
|
|
105
|
+
{ value: "constructorDeclaration" },
|
|
106
|
+
{ value: "constructorModifier" },
|
|
107
|
+
{ value: "constructorDeclarator" },
|
|
108
|
+
{ value: "simpleTypeName" },
|
|
109
|
+
{ value: "constructorBody" },
|
|
110
|
+
{ value: "explicitConstructorInvocation" },
|
|
111
|
+
{ value: "unqualifiedExplicitConstructorInvocation" },
|
|
112
|
+
{ value: "qualifiedExplicitConstructorInvocation" },
|
|
113
|
+
{ value: "enumDeclaration" },
|
|
114
|
+
{ value: "enumBody" },
|
|
115
|
+
{ value: "enumConstantList" },
|
|
116
|
+
{ value: "enumConstant" },
|
|
117
|
+
{ value: "enumConstantModifier" },
|
|
118
|
+
{ value: "enumBodyDeclarations" },
|
|
119
|
+
{ value: "recordDeclaration" },
|
|
120
|
+
{ value: "recordHeader" },
|
|
121
|
+
{ value: "recordComponentList" },
|
|
122
|
+
{ value: "recordComponent" },
|
|
123
|
+
{ value: "variableArityRecordComponent" },
|
|
124
|
+
{ value: "recordComponentModifier" },
|
|
125
|
+
{ value: "recordBody" },
|
|
126
|
+
{ value: "recordBodyDeclaration" },
|
|
127
|
+
{ value: "compactConstructorDeclaration" },
|
|
128
|
+
{ value: "isClassDeclaration" },
|
|
129
|
+
{ value: "identifyClassBodyDeclarationType" },
|
|
130
|
+
{ value: "isDims" },
|
|
131
|
+
{ value: "isCompactConstructorDeclaration" },
|
|
132
|
+
{ value: "expression" },
|
|
133
|
+
{ value: "lambdaExpression" },
|
|
134
|
+
{ value: "lambdaParameters" },
|
|
135
|
+
{ value: "lambdaParametersWithBraces" },
|
|
136
|
+
{ value: "lambdaParameterList" },
|
|
137
|
+
{ value: "inferredLambdaParameterList" },
|
|
138
|
+
{ value: "explicitLambdaParameterList" },
|
|
139
|
+
{ value: "lambdaParameter" },
|
|
140
|
+
{ value: "regularLambdaParameter" },
|
|
141
|
+
{ value: "lambdaParameterType" },
|
|
142
|
+
{ value: "lambdaBody" },
|
|
143
|
+
{ value: "ternaryExpression" },
|
|
144
|
+
{ value: "binaryExpression" },
|
|
145
|
+
{ value: "unaryExpression" },
|
|
146
|
+
{ value: "unaryExpressionNotPlusMinus" },
|
|
147
|
+
{ value: "primary" },
|
|
148
|
+
{ value: "primaryPrefix" },
|
|
149
|
+
{ value: "primarySuffix" },
|
|
150
|
+
{ value: "fqnOrRefType" },
|
|
151
|
+
{ value: "fqnOrRefTypePartRest" },
|
|
152
|
+
{ value: "fqnOrRefTypePartCommon" },
|
|
153
|
+
{ value: "fqnOrRefTypePartFirst" },
|
|
154
|
+
{ value: "parenthesisExpression" },
|
|
155
|
+
{ value: "castExpression" },
|
|
156
|
+
{ value: "primitiveCastExpression" },
|
|
157
|
+
{ value: "referenceTypeCastExpression" },
|
|
158
|
+
{ value: "newExpression" },
|
|
159
|
+
{ value: "unqualifiedClassInstanceCreationExpression" },
|
|
160
|
+
{ value: "classOrInterfaceTypeToInstantiate" },
|
|
161
|
+
{ value: "typeArgumentsOrDiamond" },
|
|
162
|
+
{ value: "diamond" },
|
|
163
|
+
{ value: "methodInvocationSuffix" },
|
|
164
|
+
{ value: "argumentList" },
|
|
165
|
+
{ value: "arrayCreationExpression" },
|
|
166
|
+
{ value: "arrayCreationDefaultInitSuffix" },
|
|
167
|
+
{ value: "arrayCreationExplicitInitSuffix" },
|
|
168
|
+
{ value: "dimExprs" },
|
|
169
|
+
{ value: "dimExpr" },
|
|
170
|
+
{ value: "classLiteralSuffix" },
|
|
171
|
+
{ value: "arrayAccessSuffix" },
|
|
172
|
+
{ value: "methodReferenceSuffix" },
|
|
173
|
+
{ value: "pattern" },
|
|
174
|
+
{ value: "typePattern" },
|
|
175
|
+
{ value: "identifyNewExpressionType" },
|
|
176
|
+
{ value: "isLambdaExpression" },
|
|
177
|
+
{ value: "isCastExpression" },
|
|
178
|
+
{ value: "isPrimitiveCastExpression" },
|
|
179
|
+
{ value: "isReferenceTypeCastExpression" },
|
|
180
|
+
{ value: "isRefTypeInMethodRef" },
|
|
181
|
+
{ value: "interfaceDeclaration" },
|
|
182
|
+
{ value: "normalInterfaceDeclaration" },
|
|
183
|
+
{ value: "interfaceModifier" },
|
|
184
|
+
{ value: "extendsInterfaces" },
|
|
185
|
+
{ value: "interfacePermits" },
|
|
186
|
+
{ value: "interfaceBody" },
|
|
187
|
+
{ value: "interfaceMemberDeclaration" },
|
|
188
|
+
{ value: "constantDeclaration" },
|
|
189
|
+
{ value: "constantModifier" },
|
|
190
|
+
{ value: "interfaceMethodDeclaration" },
|
|
191
|
+
{ value: "interfaceMethodModifier" },
|
|
192
|
+
{ value: "annotationTypeDeclaration" },
|
|
193
|
+
{ value: "annotationTypeBody" },
|
|
194
|
+
{ value: "annotationTypeMemberDeclaration" },
|
|
195
|
+
{ value: "annotationTypeElementDeclaration" },
|
|
196
|
+
{ value: "annotationTypeElementModifier" },
|
|
197
|
+
{ value: "defaultValue" },
|
|
198
|
+
{ value: "annotation" },
|
|
199
|
+
{ value: "elementValuePairList" },
|
|
200
|
+
{ value: "elementValuePair" },
|
|
201
|
+
{ value: "elementValue" },
|
|
202
|
+
{ value: "elementValueArrayInitializer" },
|
|
203
|
+
{ value: "elementValueList" },
|
|
204
|
+
{ value: "identifyInterfaceBodyDeclarationType" },
|
|
205
|
+
{ value: "identifyAnnotationBodyDeclarationType" },
|
|
206
|
+
{ value: "isSimpleElementValueAnnotation" },
|
|
207
|
+
{ value: "literal" },
|
|
208
|
+
{ value: "integerLiteral" },
|
|
209
|
+
{ value: "floatingPointLiteral" },
|
|
210
|
+
{ value: "booleanLiteral" },
|
|
211
|
+
{ value: "moduleName" },
|
|
212
|
+
{ value: "packageName" },
|
|
213
|
+
{ value: "typeName" },
|
|
214
|
+
{ value: "expressionName" },
|
|
215
|
+
{ value: "methodName" },
|
|
216
|
+
{ value: "packageOrTypeName" },
|
|
217
|
+
{ value: "ambiguousName" },
|
|
218
|
+
{ value: "compilationUnit" },
|
|
219
|
+
{ value: "ordinaryCompilationUnit" },
|
|
220
|
+
{ value: "modularCompilationUnit" },
|
|
221
|
+
{ value: "packageDeclaration" },
|
|
222
|
+
{ value: "packageModifier" },
|
|
223
|
+
{ value: "importDeclaration" },
|
|
224
|
+
{ value: "typeDeclaration" },
|
|
225
|
+
{ value: "moduleDeclaration" },
|
|
226
|
+
{ value: "moduleDirective" },
|
|
227
|
+
{ value: "requiresModuleDirective" },
|
|
228
|
+
{ value: "exportsModuleDirective" },
|
|
229
|
+
{ value: "opensModuleDirective" },
|
|
230
|
+
{ value: "usesModuleDirective" },
|
|
231
|
+
{ value: "providesModuleDirective" },
|
|
232
|
+
{ value: "requiresModifier" },
|
|
233
|
+
{ value: "isModuleCompilationUnit" },
|
|
234
|
+
{ value: "primitiveType" },
|
|
235
|
+
{ value: "numericType" },
|
|
236
|
+
{ value: "integralType" },
|
|
237
|
+
{ value: "floatingPointType" },
|
|
238
|
+
{ value: "referenceType" },
|
|
239
|
+
{ value: "classOrInterfaceType" },
|
|
240
|
+
{ value: "classType" },
|
|
241
|
+
{ value: "interfaceType" },
|
|
242
|
+
{ value: "typeVariable" },
|
|
243
|
+
{ value: "dims" },
|
|
244
|
+
{ value: "typeParameter" },
|
|
245
|
+
{ value: "typeParameterModifier" },
|
|
246
|
+
{ value: "typeBound" },
|
|
247
|
+
{ value: "additionalBound" },
|
|
248
|
+
{ value: "typeArguments" },
|
|
249
|
+
{ value: "typeArgumentList" },
|
|
250
|
+
{ value: "typeArgument" },
|
|
251
|
+
{ value: "wildcard" },
|
|
252
|
+
{ value: "wildcardBounds" }
|
|
253
|
+
],
|
|
254
|
+
description: "Prettify from the entrypoint, allowing to use prettier on snippet."
|
|
255
|
+
}
|
|
256
|
+
};
|