prettier-plugin-java 2.4.0 → 2.6.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.
Files changed (120) hide show
  1. package/LICENSE +1 -1
  2. package/dist/base-cst-printer.js +22 -44
  3. package/dist/cst-printer.js +19 -27
  4. package/dist/index.js +19 -20
  5. package/dist/options.js +16 -21
  6. package/dist/parser.js +2 -4
  7. package/dist/printer.js +3 -5
  8. package/dist/printers/arrays.js +17 -41
  9. package/dist/printers/blocks-and-statements.js +289 -356
  10. package/dist/printers/classes.js +451 -495
  11. package/dist/printers/comments/comments-utils.js +5 -13
  12. package/dist/printers/comments/format-comments.js +34 -50
  13. package/dist/printers/comments/handle-comments.js +17 -23
  14. package/dist/printers/expressions.js +378 -386
  15. package/dist/printers/interfaces.js +148 -181
  16. package/dist/printers/lexical-structure.js +26 -58
  17. package/dist/printers/names.js +29 -53
  18. package/dist/printers/packages-and-modules.js +116 -143
  19. package/dist/printers/prettier-builder.js +21 -31
  20. package/dist/printers/printer-utils.js +173 -221
  21. package/dist/printers/types-values-and-variables.js +111 -149
  22. package/dist/types/utils.js +6 -15
  23. package/dist/utils/expressions-utils.js +7 -11
  24. package/dist/utils/index.js +2 -12
  25. package/dist/utils/isEmptyDoc.js +2 -4
  26. package/dist/utils/printArgumentListWithBraces.js +29 -19
  27. package/dist/utils/printSingleLambdaInvocation.js +15 -17
  28. package/package.json +10 -13
  29. package/dist/src/base-cst-printer.js +0 -77
  30. package/dist/src/cst-printer.js +0 -37
  31. package/dist/src/index.js +0 -67
  32. package/dist/src/options.js +0 -256
  33. package/dist/src/parser.js +0 -7
  34. package/dist/src/printer.js +0 -28
  35. package/dist/src/printers/arrays.js +0 -49
  36. package/dist/src/printers/blocks-and-statements.js +0 -493
  37. package/dist/src/printers/classes.js +0 -724
  38. package/dist/src/printers/comments/comments-utils.js +0 -29
  39. package/dist/src/printers/comments/format-comments.js +0 -187
  40. package/dist/src/printers/comments/handle-comments.js +0 -38
  41. package/dist/src/printers/expressions.js +0 -549
  42. package/dist/src/printers/interfaces.js +0 -251
  43. package/dist/src/printers/lexical-structure.js +0 -43
  44. package/dist/src/printers/names.js +0 -53
  45. package/dist/src/printers/packages-and-modules.js +0 -185
  46. package/dist/src/printers/prettier-builder.js +0 -47
  47. package/dist/src/printers/printer-utils.js +0 -577
  48. package/dist/src/printers/types-values-and-variables.js +0 -183
  49. package/dist/src/types/utils.js +0 -29
  50. package/dist/src/utils/expressions-utils.js +0 -29
  51. package/dist/src/utils/index.js +0 -10
  52. package/dist/src/utils/printArgumentListWithBraces.js +0 -21
  53. package/dist/src/utils/printSingleLambdaInvocation.js +0 -20
  54. package/dist/test/babel-register.js +0 -3
  55. package/dist/test/repository-test/core-test.js +0 -12
  56. package/dist/test/repository-test/jhipster-1-test.js +0 -17
  57. package/dist/test/repository-test/jhipster-2-test.js +0 -16
  58. package/dist/test/test-utils.js +0 -215
  59. package/dist/test/unit-test/annotation_type_declaration/annotation_type_declaration-spec.js +0 -6
  60. package/dist/test/unit-test/args/args-spec.js +0 -6
  61. package/dist/test/unit-test/assert/assert-spec.js +0 -6
  62. package/dist/test/unit-test/binary_expressions/binary_expressions-spec.js +0 -6
  63. package/dist/test/unit-test/blank_lines/blank_lines-spec.js +0 -6
  64. package/dist/test/unit-test/bug-fixes/bug-fixes-spec.js +0 -6
  65. package/dist/test/unit-test/cast/cast-spec.js +0 -6
  66. package/dist/test/unit-test/char_literal/char_literal-spec.js +0 -6
  67. package/dist/test/unit-test/classes/multiple_classes-spec.js +0 -6
  68. package/dist/test/unit-test/comments/comments-spec.js +0 -14
  69. package/dist/test/unit-test/complex_generic_class/complex_generic_class-spec.js +0 -6
  70. package/dist/test/unit-test/constructors/constructors-spec.js +0 -6
  71. package/dist/test/unit-test/empty_statement/empty_statement-spec.js +0 -6
  72. package/dist/test/unit-test/enum/enum-spec.js +0 -6
  73. package/dist/test/unit-test/expressions/expressions-spec.js +0 -6
  74. package/dist/test/unit-test/extends_abstract_class/extends_abstract_class-spec.js +0 -6
  75. package/dist/test/unit-test/extends_abstract_class_and_implements_interfaces/extends_abstract_class_and_implements_interfaces-spec.js +0 -6
  76. package/dist/test/unit-test/for/for-spec.js +0 -6
  77. package/dist/test/unit-test/generic_class/generic_class-spec.js +0 -6
  78. package/dist/test/unit-test/generic_questionmark/generic_questionmark-spec.js +0 -6
  79. package/dist/test/unit-test/hello-world/hello-word-spec.js +0 -6
  80. package/dist/test/unit-test/if/if-spec.js +0 -6
  81. package/dist/test/unit-test/indent/indent-spec.js +0 -6
  82. package/dist/test/unit-test/instantiation/instantiation-spec.js +0 -6
  83. package/dist/test/unit-test/interface/interface-spec.js +0 -6
  84. package/dist/test/unit-test/lambda/lambda-spec.js +0 -6
  85. package/dist/test/unit-test/marker_annotations/marker_annotations-spec.js +0 -6
  86. package/dist/test/unit-test/member_chain/member_chain-spec.js +0 -6
  87. package/dist/test/unit-test/method_reference/method_reference-spec.js +0 -6
  88. package/dist/test/unit-test/modifiers/modifiers-spec.js +0 -6
  89. package/dist/test/unit-test/modules/modules-spec.js +0 -6
  90. package/dist/test/unit-test/package_and_imports/package_and_imports-spec.js +0 -34
  91. package/dist/test/unit-test/pattern-matching/pattern-matching-spec.js +0 -6
  92. package/dist/test/unit-test/prettier-ignore/prettier-ignore-spec.js +0 -28
  93. package/dist/test/unit-test/records/records-spec.js +0 -6
  94. package/dist/test/unit-test/return/return-spec.js +0 -6
  95. package/dist/test/unit-test/sealed/sealed-spec.js +0 -6
  96. package/dist/test/unit-test/snippets/arrays/array-initializer.spec.js +0 -94
  97. package/dist/test/unit-test/snippets/arrays/variable-initializer-list.spec.js +0 -19
  98. package/dist/test/unit-test/snippets/blocks-and-statements/switch.spec.js +0 -26
  99. package/dist/test/unit-test/snippets/classes/class-body.spec.js +0 -181
  100. package/dist/test/unit-test/snippets/classes/enum-body.spec.js +0 -87
  101. package/dist/test/unit-test/snippets/classes/variableDeclarator/test.spec.js +0 -186
  102. package/dist/test/unit-test/snippets/interfaces/element-value-array-initializer.spec.js +0 -85
  103. package/dist/test/unit-test/snippets/names/ambiguousName/test.spec.js +0 -19
  104. package/dist/test/unit-test/snippets/names/expressionName/test.spec.js +0 -19
  105. package/dist/test/unit-test/snippets/names/methodName/test.spec.js +0 -12
  106. package/dist/test/unit-test/snippets/names/packageOrTypeName/test.spec.js +0 -19
  107. package/dist/test/unit-test/snippets/types-values-and-variables/floatingPointType/test.spec.js +0 -19
  108. package/dist/test/unit-test/snippets/types-values-and-variables/integralType/test.spec.js +0 -40
  109. package/dist/test/unit-test/snippets/types-values-and-variables/numericType/test.spec.js +0 -88
  110. package/dist/test/unit-test/snippets/types-values-and-variables/wildcard/test.spec.js +0 -112
  111. package/dist/test/unit-test/snippets/types-values-and-variables/wildcardBounds/test.spec.js +0 -81
  112. package/dist/test/unit-test/switch/switch-spec.js +0 -6
  113. package/dist/test/unit-test/synchronized/synchronized-spec.js +0 -6
  114. package/dist/test/unit-test/text-blocks/text-block-spec.js +0 -6
  115. package/dist/test/unit-test/throws/throws-spec.js +0 -6
  116. package/dist/test/unit-test/try_catch/try_catch-spec.js +0 -6
  117. package/dist/test/unit-test/types/types-spec.js +0 -6
  118. package/dist/test/unit-test/variables/variables-spec.js +0 -6
  119. package/dist/test/unit-test/while/while-spec.js +0 -6
  120. package/dist/test/unit-test/yield-statement/yield-statement-spec.js +0 -6
@@ -1,198 +1,171 @@
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.PackagesAndModulesPrettierVisitor = void 0;
19
- var prettier_builder_1 = require("./prettier-builder");
20
- var format_comments_1 = require("./comments/format-comments");
21
- var printer_utils_1 = require("./printer-utils");
22
- var doc_1 = require("prettier/doc");
23
- var base_cst_printer_1 = require("../base-cst-printer");
24
- var utils_1 = require("../types/utils");
25
- var line = doc_1.builders.line, hardline = doc_1.builders.hardline, indent = doc_1.builders.indent, group = doc_1.builders.group;
26
- var PackagesAndModulesPrettierVisitor = /** @class */ (function (_super) {
27
- __extends(PackagesAndModulesPrettierVisitor, _super);
28
- function PackagesAndModulesPrettierVisitor() {
29
- return _super !== null && _super.apply(this, arguments) || this;
30
- }
31
- PackagesAndModulesPrettierVisitor.prototype.compilationUnit = function (ctx) {
32
- var compilationUnit = (0, utils_1.isOrdinaryCompilationUnitCtx)(ctx)
1
+ import { concat, join } from "./prettier-builder.js";
2
+ import { printTokenWithComments } from "./comments/format-comments.js";
3
+ import { buildFqn, displaySemicolon, getBlankLinesSeparator, putIntoBraces, rejectAndConcat, rejectAndJoin, rejectAndJoinSeps, sortImports } from "./printer-utils.js";
4
+ import { builders } from "prettier/doc";
5
+ import { BaseCstPrettierPrinter } from "../base-cst-printer.js";
6
+ import { isOrdinaryCompilationUnitCtx } from "../types/utils.js";
7
+ const { line, hardline, indent, group } = builders;
8
+ export class PackagesAndModulesPrettierVisitor extends BaseCstPrettierPrinter {
9
+ compilationUnit(ctx) {
10
+ const compilationUnit = isOrdinaryCompilationUnitCtx(ctx)
33
11
  ? ctx.ordinaryCompilationUnit
34
12
  : ctx.modularCompilationUnit;
35
- return (0, prettier_builder_1.concat)([this.visit(compilationUnit[0]), line]);
36
- };
37
- PackagesAndModulesPrettierVisitor.prototype.ordinaryCompilationUnit = function (ctx) {
38
- var packageDecl = this.visit(ctx.packageDeclaration);
39
- var sortedImportsDecl = (0, printer_utils_1.sortImports)(ctx.importDeclaration);
40
- var nonStaticImports = this.mapVisit(sortedImportsDecl.nonStaticImports);
41
- var staticImports = this.mapVisit(sortedImportsDecl.staticImports);
42
- var typesDecl = this.mapVisit(ctx.typeDeclaration);
13
+ return concat([this.visit(compilationUnit[0]), line]);
14
+ }
15
+ ordinaryCompilationUnit(ctx) {
16
+ const packageDecl = this.visit(ctx.packageDeclaration);
17
+ const sortedImportsDecl = sortImports(ctx.importDeclaration);
18
+ const nonStaticImports = this.mapVisit(sortedImportsDecl.nonStaticImports);
19
+ const staticImports = this.mapVisit(sortedImportsDecl.staticImports);
20
+ const typesDecl = this.mapVisit(ctx.typeDeclaration);
43
21
  // TODO: utility to add item+line (or multiple lines) but only if an item exists
44
- return (0, printer_utils_1.rejectAndConcat)([
45
- (0, printer_utils_1.rejectAndJoin)((0, prettier_builder_1.concat)([hardline, hardline]), [
22
+ return rejectAndConcat([
23
+ rejectAndJoin(concat([hardline, hardline]), [
46
24
  packageDecl,
47
- (0, printer_utils_1.rejectAndJoin)(hardline, staticImports),
48
- (0, printer_utils_1.rejectAndJoin)(hardline, nonStaticImports),
49
- (0, printer_utils_1.rejectAndJoin)((0, prettier_builder_1.concat)([hardline, hardline]), typesDecl)
25
+ rejectAndJoin(hardline, staticImports),
26
+ rejectAndJoin(hardline, nonStaticImports),
27
+ rejectAndJoin(concat([hardline, hardline]), typesDecl)
50
28
  ])
51
29
  ]);
52
- };
53
- PackagesAndModulesPrettierVisitor.prototype.modularCompilationUnit = function (ctx) {
54
- var sortedImportsDecl = (0, printer_utils_1.sortImports)(ctx.importDeclaration);
55
- var nonStaticImports = this.mapVisit(sortedImportsDecl.nonStaticImports);
56
- var staticImports = this.mapVisit(sortedImportsDecl.staticImports);
57
- var moduleDeclaration = this.visit(ctx.moduleDeclaration);
58
- return (0, printer_utils_1.rejectAndConcat)([
59
- (0, printer_utils_1.rejectAndJoin)((0, prettier_builder_1.concat)([hardline, hardline]), [
60
- (0, printer_utils_1.rejectAndJoin)(hardline, staticImports),
61
- (0, printer_utils_1.rejectAndJoin)(hardline, nonStaticImports),
30
+ }
31
+ modularCompilationUnit(ctx) {
32
+ const sortedImportsDecl = sortImports(ctx.importDeclaration);
33
+ const nonStaticImports = this.mapVisit(sortedImportsDecl.nonStaticImports);
34
+ const staticImports = this.mapVisit(sortedImportsDecl.staticImports);
35
+ const moduleDeclaration = this.visit(ctx.moduleDeclaration);
36
+ return rejectAndConcat([
37
+ rejectAndJoin(concat([hardline, hardline]), [
38
+ rejectAndJoin(hardline, staticImports),
39
+ rejectAndJoin(hardline, nonStaticImports),
62
40
  moduleDeclaration
63
41
  ])
64
42
  ]);
65
- };
66
- PackagesAndModulesPrettierVisitor.prototype.packageDeclaration = function (ctx) {
67
- var modifiers = this.mapVisit(ctx.packageModifier);
68
- var name = (0, printer_utils_1.buildFqn)(ctx.Identifier, ctx.Dot);
69
- return (0, printer_utils_1.rejectAndJoin)(hardline, [
70
- (0, printer_utils_1.rejectAndJoin)(hardline, modifiers),
71
- (0, prettier_builder_1.concat)([ctx.Package[0], " ", name, ctx.Semicolon[0]])
43
+ }
44
+ packageDeclaration(ctx) {
45
+ const modifiers = this.mapVisit(ctx.packageModifier);
46
+ const name = buildFqn(ctx.Identifier, ctx.Dot);
47
+ return rejectAndJoin(hardline, [
48
+ rejectAndJoin(hardline, modifiers),
49
+ concat([ctx.Package[0], " ", name, ctx.Semicolon[0]])
72
50
  ]);
73
- };
74
- PackagesAndModulesPrettierVisitor.prototype.packageModifier = function (ctx) {
51
+ }
52
+ packageModifier(ctx) {
75
53
  return this.visitSingle(ctx);
76
- };
77
- PackagesAndModulesPrettierVisitor.prototype.importDeclaration = function (ctx) {
54
+ }
55
+ importDeclaration(ctx) {
78
56
  if (ctx.emptyStatement !== undefined) {
79
57
  return this.visit(ctx.emptyStatement);
80
58
  }
81
- var optionalStatic = ctx.Static ? ctx.Static[0] : "";
82
- var packageOrTypeName = this.visit(ctx.packageOrTypeName);
83
- var optionalDotStar = ctx.Dot ? (0, prettier_builder_1.concat)([ctx.Dot[0], ctx.Star[0]]) : "";
84
- return (0, printer_utils_1.rejectAndJoin)(" ", [
59
+ const optionalStatic = ctx.Static ? ctx.Static[0] : "";
60
+ const packageOrTypeName = this.visit(ctx.packageOrTypeName);
61
+ const optionalDotStar = ctx.Dot ? concat([ctx.Dot[0], ctx.Star[0]]) : "";
62
+ return rejectAndJoin(" ", [
85
63
  ctx.Import[0],
86
64
  optionalStatic,
87
- (0, printer_utils_1.rejectAndConcat)([packageOrTypeName, optionalDotStar, ctx.Semicolon[0]])
65
+ rejectAndConcat([packageOrTypeName, optionalDotStar, ctx.Semicolon[0]])
88
66
  ]);
89
- };
90
- PackagesAndModulesPrettierVisitor.prototype.typeDeclaration = function (ctx) {
67
+ }
68
+ typeDeclaration(ctx) {
91
69
  if (ctx.Semicolon) {
92
- return (0, printer_utils_1.displaySemicolon)(ctx.Semicolon[0]);
70
+ return displaySemicolon(ctx.Semicolon[0]);
93
71
  }
94
72
  return this.visitSingle(ctx);
95
- };
96
- PackagesAndModulesPrettierVisitor.prototype.moduleDeclaration = function (ctx) {
97
- var annotations = this.mapVisit(ctx.annotation);
98
- var optionalOpen = ctx.Open ? ctx.Open[0] : "";
99
- var name = (0, printer_utils_1.buildFqn)(ctx.Identifier, ctx.Dot);
100
- var moduleDirectives = this.mapVisit(ctx.moduleDirective);
101
- var content = (0, printer_utils_1.rejectAndJoinSeps)((0, printer_utils_1.getBlankLinesSeparator)(ctx.moduleDirective), moduleDirectives);
102
- return (0, printer_utils_1.rejectAndJoin)(" ", [
103
- (0, prettier_builder_1.join)(" ", annotations),
73
+ }
74
+ moduleDeclaration(ctx) {
75
+ const annotations = this.mapVisit(ctx.annotation);
76
+ const optionalOpen = ctx.Open ? ctx.Open[0] : "";
77
+ const name = buildFqn(ctx.Identifier, ctx.Dot);
78
+ const moduleDirectives = this.mapVisit(ctx.moduleDirective);
79
+ const content = rejectAndJoinSeps(getBlankLinesSeparator(ctx.moduleDirective), moduleDirectives);
80
+ return rejectAndJoin(" ", [
81
+ join(" ", annotations),
104
82
  optionalOpen,
105
83
  ctx.Module[0],
106
84
  name,
107
- (0, printer_utils_1.putIntoBraces)(content, hardline, ctx.LCurly[0], ctx.RCurly[0])
85
+ putIntoBraces(content, hardline, ctx.LCurly[0], ctx.RCurly[0])
108
86
  ]);
109
- };
110
- PackagesAndModulesPrettierVisitor.prototype.moduleDirective = function (ctx) {
87
+ }
88
+ moduleDirective(ctx) {
111
89
  return this.visitSingle(ctx);
112
- };
113
- PackagesAndModulesPrettierVisitor.prototype.requiresModuleDirective = function (ctx) {
114
- var modifiers = this.mapVisit(ctx.requiresModifier);
115
- var moduleName = this.visit(ctx.moduleName);
116
- return (0, printer_utils_1.rejectAndJoin)(" ", [
90
+ }
91
+ requiresModuleDirective(ctx) {
92
+ const modifiers = this.mapVisit(ctx.requiresModifier);
93
+ const moduleName = this.visit(ctx.moduleName);
94
+ return rejectAndJoin(" ", [
117
95
  ctx.Requires[0],
118
- (0, prettier_builder_1.join)(" ", modifiers),
119
- (0, prettier_builder_1.concat)([moduleName, ctx.Semicolon[0]])
96
+ join(" ", modifiers),
97
+ concat([moduleName, ctx.Semicolon[0]])
120
98
  ]);
121
- };
122
- PackagesAndModulesPrettierVisitor.prototype.exportsModuleDirective = function (ctx) {
123
- var packageName = this.visit(ctx.packageName);
124
- var moduleNames = this.mapVisit(ctx.moduleName);
125
- var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return (0, prettier_builder_1.concat)([elt, line]); }) : [];
99
+ }
100
+ exportsModuleDirective(ctx) {
101
+ const packageName = this.visit(ctx.packageName);
102
+ const moduleNames = this.mapVisit(ctx.moduleName);
103
+ const commas = ctx.Comma ? ctx.Comma.map(elt => concat([elt, line])) : [];
126
104
  if (ctx.To) {
127
- return group((0, printer_utils_1.rejectAndConcat)([
128
- indent((0, printer_utils_1.rejectAndJoin)(line, [
129
- (0, printer_utils_1.rejectAndJoin)(" ", [ctx.Exports[0], packageName]),
130
- group(indent((0, printer_utils_1.rejectAndJoin)(line, [
105
+ return group(rejectAndConcat([
106
+ indent(rejectAndJoin(line, [
107
+ rejectAndJoin(" ", [ctx.Exports[0], packageName]),
108
+ group(indent(rejectAndJoin(line, [
131
109
  ctx.To[0],
132
- (0, printer_utils_1.rejectAndJoinSeps)(commas, moduleNames)
110
+ rejectAndJoinSeps(commas, moduleNames)
133
111
  ])))
134
112
  ])),
135
113
  ctx.Semicolon[0]
136
114
  ]));
137
115
  }
138
- return (0, printer_utils_1.rejectAndConcat)([
139
- (0, prettier_builder_1.concat)([ctx.Exports[0], " "]),
116
+ return rejectAndConcat([
117
+ concat([ctx.Exports[0], " "]),
140
118
  packageName,
141
119
  ctx.Semicolon[0]
142
120
  ]);
143
- };
144
- PackagesAndModulesPrettierVisitor.prototype.opensModuleDirective = function (ctx) {
145
- var packageName = this.visit(ctx.packageName);
146
- var to = ctx.To ? ctx.To[0] : "";
147
- var moduleNames = this.mapVisit(ctx.moduleName);
148
- var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return (0, prettier_builder_1.concat)([elt, line]); }) : [];
121
+ }
122
+ opensModuleDirective(ctx) {
123
+ const packageName = this.visit(ctx.packageName);
124
+ const to = ctx.To ? ctx.To[0] : "";
125
+ const moduleNames = this.mapVisit(ctx.moduleName);
126
+ const commas = ctx.Comma ? ctx.Comma.map(elt => concat([elt, line])) : [];
149
127
  if (ctx.To) {
150
- return group((0, printer_utils_1.rejectAndConcat)([
151
- indent((0, printer_utils_1.rejectAndJoin)(line, [
152
- (0, printer_utils_1.rejectAndJoin)(" ", [ctx.Opens[0], packageName]),
153
- group(indent((0, printer_utils_1.rejectAndJoin)(line, [
128
+ return group(rejectAndConcat([
129
+ indent(rejectAndJoin(line, [
130
+ rejectAndJoin(" ", [ctx.Opens[0], packageName]),
131
+ group(indent(rejectAndJoin(line, [
154
132
  ctx.To[0],
155
- (0, printer_utils_1.rejectAndJoinSeps)(commas, moduleNames)
133
+ rejectAndJoinSeps(commas, moduleNames)
156
134
  ])))
157
135
  ])),
158
136
  ctx.Semicolon[0]
159
137
  ]));
160
138
  }
161
- return (0, printer_utils_1.rejectAndConcat)([
162
- (0, prettier_builder_1.concat)([ctx.Opens[0], " "]),
139
+ return rejectAndConcat([
140
+ concat([ctx.Opens[0], " "]),
163
141
  packageName,
164
142
  ctx.Semicolon[0]
165
143
  ]);
166
- };
167
- PackagesAndModulesPrettierVisitor.prototype.usesModuleDirective = function (ctx) {
168
- var typeName = this.visit(ctx.typeName);
169
- return (0, printer_utils_1.rejectAndConcat)([
170
- (0, prettier_builder_1.concat)([ctx.Uses[0], " "]),
144
+ }
145
+ usesModuleDirective(ctx) {
146
+ const typeName = this.visit(ctx.typeName);
147
+ return rejectAndConcat([
148
+ concat([ctx.Uses[0], " "]),
171
149
  typeName,
172
150
  ctx.Semicolon[0]
173
151
  ]);
174
- };
175
- PackagesAndModulesPrettierVisitor.prototype.providesModuleDirective = function (ctx) {
176
- var firstTypeName = this.visit(ctx.typeName[0]);
177
- var otherTypeNames = this.mapVisit(ctx.typeName.slice(1));
178
- var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return (0, prettier_builder_1.concat)([elt, line]); }) : [];
179
- return group((0, printer_utils_1.rejectAndConcat)([
180
- indent((0, printer_utils_1.rejectAndJoin)(line, [
181
- (0, printer_utils_1.rejectAndJoin)(" ", [ctx.Provides[0], firstTypeName]),
182
- group(indent((0, printer_utils_1.rejectAndJoin)(line, [
152
+ }
153
+ providesModuleDirective(ctx) {
154
+ const firstTypeName = this.visit(ctx.typeName[0]);
155
+ const otherTypeNames = this.mapVisit(ctx.typeName.slice(1));
156
+ const commas = ctx.Comma ? ctx.Comma.map(elt => concat([elt, line])) : [];
157
+ return group(rejectAndConcat([
158
+ indent(rejectAndJoin(line, [
159
+ rejectAndJoin(" ", [ctx.Provides[0], firstTypeName]),
160
+ group(indent(rejectAndJoin(line, [
183
161
  ctx.With[0],
184
- (0, printer_utils_1.rejectAndJoinSeps)(commas, otherTypeNames)
162
+ rejectAndJoinSeps(commas, otherTypeNames)
185
163
  ])))
186
164
  ])),
187
165
  ctx.Semicolon[0]
188
166
  ]));
189
- };
190
- PackagesAndModulesPrettierVisitor.prototype.requiresModifier = function (ctx) {
191
- return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
192
- };
193
- PackagesAndModulesPrettierVisitor.prototype.isModuleCompilationUnit = function () {
194
- return "isModuleCompilationUnit";
195
- };
196
- return PackagesAndModulesPrettierVisitor;
197
- }(base_cst_printer_1.BaseCstPrettierPrinter));
198
- exports.PackagesAndModulesPrettierVisitor = PackagesAndModulesPrettierVisitor;
167
+ }
168
+ requiresModifier(ctx) {
169
+ return printTokenWithComments(this.getSingle(ctx));
170
+ }
171
+ }
@@ -1,55 +1,45 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.indentIfBreak = exports.ifBreak = exports.dedent = exports.indent = exports.fill = exports.group = exports.join = exports.concat = void 0;
4
- var doc_1 = require("prettier/doc");
5
- var processComments = require("./comments/format-comments").processComments;
1
+ import { builders } from "prettier/doc";
2
+ import * as formatComments from "./comments/format-comments.js";
3
+ const processComments = formatComments.processComments;
6
4
  /*
7
5
  * ------------------------------------------------------------------
8
6
  * Wraps the Prettier builder functions to print tokens with comments
9
7
  * ------------------------------------------------------------------
10
8
  */
11
- function concat(docs) {
12
- var concatenation = processComments(docs);
9
+ export function concat(docs) {
10
+ const concatenation = processComments(docs);
13
11
  if (!Array.isArray(docs)) {
14
12
  return "";
15
13
  }
16
14
  return concatenation;
17
15
  }
18
- exports.concat = concat;
19
- function join(sep, docs) {
20
- return doc_1.builders.join(processComments(sep), processComments(docs));
16
+ export function join(sep, docs) {
17
+ return builders.join(processComments(sep), processComments(docs));
21
18
  }
22
- exports.join = join;
23
- function group(docs, opts) {
24
- var group = doc_1.builders.group(processComments(docs), opts);
19
+ export function group(docs, opts) {
20
+ const group = builders.group(processComments(docs), opts);
25
21
  return group.contents === undefined ? "" : group;
26
22
  }
27
- exports.group = group;
28
- function fill(docs) {
29
- return doc_1.builders.fill(processComments(docs));
23
+ export function fill(docs) {
24
+ return builders.fill(processComments(docs));
30
25
  }
31
- exports.fill = fill;
32
- function indent(doc) {
33
- var processedDoc = processComments(doc);
26
+ export function indent(doc) {
27
+ const processedDoc = processComments(doc);
34
28
  if (processedDoc.length === 0) {
35
29
  return "";
36
30
  }
37
- return doc_1.builders.indent(processedDoc);
31
+ return builders.indent(processedDoc);
38
32
  }
39
- exports.indent = indent;
40
- function dedent(doc) {
41
- var processedDoc = processComments(doc);
33
+ export function dedent(doc) {
34
+ const processedDoc = processComments(doc);
42
35
  if (processedDoc.length === 0) {
43
36
  return "";
44
37
  }
45
- return doc_1.builders.dedent(processComments(doc));
38
+ return builders.dedent(processComments(doc));
46
39
  }
47
- exports.dedent = dedent;
48
- function ifBreak(breakContents, flatContents) {
49
- return doc_1.builders.ifBreak(processComments(breakContents), processComments(flatContents));
40
+ export function ifBreak(breakContents, flatContents) {
41
+ return builders.ifBreak(processComments(breakContents), processComments(flatContents));
50
42
  }
51
- exports.ifBreak = ifBreak;
52
- function indentIfBreak(contents, opts) {
53
- return doc_1.builders.indentIfBreak(processComments(contents), opts);
43
+ export function indentIfBreak(contents, opts) {
44
+ return builders.indentIfBreak(processComments(contents), opts);
54
45
  }
55
- exports.indentIfBreak = indentIfBreak;