prettier-plugin-java 2.7.6 → 2.7.7

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.
@@ -61,7 +61,7 @@ declare const _default: {
61
61
  }>, print: JavaPrintFn): builders.Doc;
62
62
  parenthesisExpression(path: AstPath<import("java-parser").ParenthesisExpressionCstNode & {
63
63
  comments?: JavaComment[];
64
- }>, print: JavaPrintFn): builders.Group | "()" | (string | builders.Indent)[];
64
+ }>, print: JavaPrintFn): builders.Group | builders.Doc[] | "()";
65
65
  castExpression: typeof printSingle;
66
66
  primitiveCastExpression(path: AstPath<import("java-parser").PrimitiveCastExpressionCstNode & {
67
67
  comments?: JavaComment[];
@@ -269,13 +269,16 @@ export default {
269
269
  const expression = call(path, print, "expression");
270
270
  const ancestorName = (_a = path.getNode(14)) === null || _a === void 0 ? void 0 : _a.name;
271
271
  const binaryExpression = path.getNode(8);
272
+ const { conditionalExpression, lambdaExpression } = path.node.children.expression[0].children;
273
+ const hasLambda = lambdaExpression !== undefined;
274
+ const hasTernary = (conditionalExpression === null || conditionalExpression === void 0 ? void 0 : conditionalExpression[0].children.QuestionMark) !== undefined;
272
275
  return ancestorName &&
273
276
  ["guard", "returnStatement"].includes(ancestorName) &&
274
277
  binaryExpression &&
275
278
  binaryExpression.name === "binaryExpression" &&
276
279
  Object.keys(binaryExpression.children).length === 1
277
280
  ? indentInParentheses(expression)
278
- : ["(", indent(expression), ")"];
281
+ : ["(", hasLambda || hasTernary ? expression : indent(expression), ")"];
279
282
  },
280
283
  castExpression: printSingle,
281
284
  primitiveCastExpression(path, print) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prettier-plugin-java",
3
- "version": "2.7.6",
3
+ "version": "2.7.7",
4
4
  "description": "Prettier Java Plugin",
5
5
  "type": "module",
6
6
  "exports": {
@@ -41,5 +41,5 @@
41
41
  "peerDependencies": {
42
42
  "prettier": "^3.0.0"
43
43
  },
44
- "gitHead": "9f2ba5e304a7e2d744fa20f1f3617cc4a4651f88"
44
+ "gitHead": "dc42509e151ec718e2cb9812669906035a63a09b"
45
45
  }