prettier-plugin-java 2.7.3 → 2.7.4

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.
@@ -104,7 +104,7 @@ declare const _default: {
104
104
  }>, print: import("./helpers.js").JavaPrintFn): builders.Doc[];
105
105
  resourceSpecification(path: import("prettier").AstPath<import("java-parser").ResourceSpecificationCstNode & {
106
106
  comments?: import("../comments.js").JavaComment[];
107
- }>, print: import("./helpers.js").JavaPrintFn, options: import("./helpers.js").JavaParserOptions): builders.Group | "()";
107
+ }>, print: import("./helpers.js").JavaPrintFn): builders.Group | "()";
108
108
  resourceList(path: import("prettier").AstPath<import("java-parser").ResourceListCstNode & {
109
109
  comments?: import("../comments.js").JavaComment[];
110
110
  }>, print: import("./helpers.js").JavaPrintFn): builders.Doc[];
@@ -318,9 +318,9 @@ export default {
318
318
  }
319
319
  return join(" ", blocks);
320
320
  },
321
- resourceSpecification(path, print, options) {
321
+ resourceSpecification(path, print) {
322
322
  const resources = [call(path, print, "resourceList")];
323
- if (options.trailingComma !== "none") {
323
+ if (path.node.children.Semicolon) {
324
324
  resources.push(ifBreak(";"));
325
325
  }
326
326
  return indentInParentheses(resources);
@@ -30,7 +30,7 @@ export declare function printList<T extends JavaNonTerminal, P extends IterPrope
30
30
  export declare function printClassPermits(path: AstPath<ClassPermitsCstNode | InterfacePermitsCstNode>, print: JavaPrintFn): builders.Group;
31
31
  export declare function printClassType(path: AstPath<JavaNonTerminal & {
32
32
  children: ClassTypeCtx;
33
- }>, print: JavaPrintFn): builders.Doc[][];
33
+ }>, print: JavaPrintFn): builders.Doc[];
34
34
  export declare function isBinaryExpression(expression: ExpressionCstNode): boolean;
35
35
  export declare function findBaseIndent(lines: string[]): number;
36
36
  export declare function isEmptyStatement(statement: StatementCstNode): boolean;
@@ -181,23 +181,29 @@ export function printClassPermits(path, print) {
181
181
  ]);
182
182
  }
183
183
  export function printClassType(path, print) {
184
- return flatMap(path, childPath => {
185
- const { node, isLast } = childPath;
186
- const child = [print(childPath)];
187
- if (isTerminal(node)) {
188
- if (!isLast) {
189
- child.push(".");
184
+ const { children } = path.node;
185
+ return definedKeys(children, ["annotation", "Identifier", "typeArguments"])
186
+ .flatMap(child => children[child].map((node, index) => ({
187
+ child,
188
+ index,
189
+ startOffset: parser.locStart(node)
190
+ })))
191
+ .sort((a, b) => a.startOffset - b.startOffset)
192
+ .flatMap(({ child, index: childIndex }, index, array) => {
193
+ const node = children[child][childIndex];
194
+ const next = array.at(index + 1);
195
+ const nextNode = next && children[next.child][next.index];
196
+ const docs = [call(path, print, child, childIndex)];
197
+ if (nextNode) {
198
+ if (isNonTerminal(node)) {
199
+ docs.push(node.name === "annotation" ? " " : ".");
200
+ }
201
+ else if (isTerminal(nextNode) || nextNode.name === "annotation") {
202
+ docs.push(".");
190
203
  }
191
204
  }
192
- else if (node.name === "annotation") {
193
- child.push(" ");
194
- }
195
- return child;
196
- }, definedKeys(path.node.children, [
197
- "annotation",
198
- "Identifier",
199
- "typeArguments"
200
- ]));
205
+ return docs;
206
+ });
201
207
  }
202
208
  export function isBinaryExpression(expression) {
203
209
  var _a;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prettier-plugin-java",
3
- "version": "2.7.3",
3
+ "version": "2.7.4",
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": "ec18b2fe1bcecd353d32cdcba7483cd0f88cb8a2"
44
+ "gitHead": "306a608c6ff6aee2010120ffb47a8c8a13fe7ef1"
45
45
  }