prettier-plugin-java 2.3.1 → 2.4.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 CHANGED
@@ -171,8 +171,10 @@ module.exports = {
171
171
  { value: "arrayAccessSuffix" },
172
172
  { value: "methodReferenceSuffix" },
173
173
  { value: "pattern" },
174
- { value: "primaryPattern" },
175
174
  { value: "typePattern" },
175
+ { value: "recordPattern" },
176
+ { value: "patternList" },
177
+ { value: "guard" },
176
178
  { value: "identifyNewExpressionType" },
177
179
  { value: "isLambdaExpression" },
178
180
  { value: "isCastExpression" },
@@ -221,7 +221,12 @@ var BlocksAndStatementPrettierVisitor = /** @class */ (function (_super) {
221
221
  if (ctx.Default || ctx.Null) {
222
222
  return this.getSingle(ctx);
223
223
  }
224
- return this.visitSingle(ctx);
224
+ else if (ctx.pattern) {
225
+ var pattern = this.visit(ctx.pattern);
226
+ var guard = this.visit(ctx.guard);
227
+ return (0, printer_utils_1.rejectAndJoin)(" ", [(0, prettier_builder_1.dedent)(pattern), guard]);
228
+ }
229
+ return this.visit(ctx.caseConstant);
225
230
  };
226
231
  BlocksAndStatementPrettierVisitor.prototype.switchRule = function (ctx) {
227
232
  var switchLabel = this.visit(ctx.switchLabel);
@@ -235,7 +240,7 @@ var BlocksAndStatementPrettierVisitor = /** @class */ (function (_super) {
235
240
  else {
236
241
  caseInstruction = (0, prettier_builder_1.concat)([this.visit(ctx.expression), ctx.Semicolon[0]]);
237
242
  }
238
- return (0, prettier_builder_1.join)(" ", [switchLabel, ctx.Arrow[0], caseInstruction]);
243
+ return (0, prettier_builder_1.concat)([switchLabel, " ", ctx.Arrow[0], " ", caseInstruction]);
239
244
  };
240
245
  BlocksAndStatementPrettierVisitor.prototype.caseConstant = function (ctx) {
241
246
  return this.visitSingle(ctx);
@@ -503,29 +503,31 @@ var ExpressionsPrettierVisitor = /** @class */ (function (_super) {
503
503
  return (0, printer_utils_1.rejectAndConcat)([ctx.ColonColon[0], typeArguments, identifierOrNew]);
504
504
  };
505
505
  ExpressionsPrettierVisitor.prototype.pattern = function (ctx) {
506
- var primaryPattern = this.visit(ctx.primaryPattern);
507
- if (ctx.AndAnd === undefined) {
508
- return primaryPattern;
509
- }
510
- var binaryExpression = this.visit(ctx.binaryExpression);
511
- return (0, printer_utils_1.rejectAndConcat)([
512
- primaryPattern,
513
- " ",
514
- ctx.AndAnd[0],
515
- line,
516
- binaryExpression
517
- ]);
518
- };
519
- ExpressionsPrettierVisitor.prototype.primaryPattern = function (ctx) {
520
- if (ctx.LBrace === undefined) {
521
- return this.visitSingle(ctx);
522
- }
523
- var pattern = this.visit(ctx.pattern);
524
- return (0, printer_utils_1.putIntoBraces)(pattern, softline, ctx.LBrace[0], ctx.RBrace[0]);
506
+ return this.visitSingle(ctx);
525
507
  };
526
508
  ExpressionsPrettierVisitor.prototype.typePattern = function (ctx) {
527
509
  return this.visitSingle(ctx);
528
510
  };
511
+ ExpressionsPrettierVisitor.prototype.recordPattern = function (ctx) {
512
+ var referenceType = this.visit(ctx.referenceType);
513
+ var patternList = this.visit(ctx.patternList);
514
+ return (0, prettier_builder_1.concat)([
515
+ referenceType,
516
+ (0, printer_utils_1.putIntoBraces)(patternList, softline, ctx.LBrace[0], ctx.RBrace[0])
517
+ ]);
518
+ };
519
+ ExpressionsPrettierVisitor.prototype.patternList = function (ctx) {
520
+ var _a, _b;
521
+ var patterns = this.mapVisit(ctx.pattern);
522
+ var commas = (_b = (_a = ctx.Comma) === null || _a === void 0 ? void 0 : _a.map(function (elt) { return (0, prettier_builder_1.concat)([elt, line]); })) !== null && _b !== void 0 ? _b : [];
523
+ return (0, printer_utils_1.rejectAndJoinSeps)(commas, patterns);
524
+ };
525
+ ExpressionsPrettierVisitor.prototype.guard = function (ctx) {
526
+ var expression = this.visit(ctx.expression, {
527
+ addParenthesisToWrapStatement: true
528
+ });
529
+ return (0, prettier_builder_1.concat)([ctx.When[0], " ", (0, prettier_builder_1.dedent)(expression)]);
530
+ };
529
531
  ExpressionsPrettierVisitor.prototype.identifyNewExpressionType = function () {
530
532
  return "identifyNewExpressionType";
531
533
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prettier-plugin-java",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "description": "Prettier Java Plugin",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -9,7 +9,7 @@
9
9
  "repository": "https://github.com/jhipster/prettier-java",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
- "java-parser": "2.0.5",
12
+ "java-parser": "2.1.0",
13
13
  "lodash": "4.17.21",
14
14
  "prettier": "3.0.3"
15
15
  },
@@ -41,5 +41,5 @@
41
41
  "ts-node": "10.9.1",
42
42
  "typescript": "4.9.3"
43
43
  },
44
- "gitHead": "a7f9a5f795a87ccfd7910118b0856b449dedb957"
44
+ "gitHead": "acdd5e7f28d08c4fb0351cfaf43d4ff9524b90ba"
45
45
  }