add builder for ClassPrivateMethod
MODIFY
packages/@romejs/js-formatter/builders/classes/ClassPrivateMethod.ts
packages/@romejs/js-formatter/builders/classes/ClassPrivateMethod.ts
* LICENSE file in the root directory of this source tree.
*/
-import {Token} from '../../tokens';
+import {Token, concat, space} from '../../tokens';
+import { Builder } from '@romejs/js-formatter';
+import { ClassPrivateMethod } from '@romejs/js-ast';
+import { printMethod } from '../utils';
-export default function ClassPrivateMethod(): Token {
- throw new Error('unimplemented');
+export default function ClassPrivateMethod(
+ builder: Builder,
+ node: ClassPrivateMethod
+): Token {
+ const printed = printMethod(builder, node);
+ if (node.meta.static === true) {
+ return concat(['static', space, printed]);
+ } else {
+ return printed;
+ }
}

MODIFY
packages/@romejs/js-formatter/builders/utils.ts
packages/@romejs/js-formatter/builders/utils.ts
@@ -16,6 +16,7 @@ import {
ReturnStatement,
TSDeclareMethod,
ThrowStatement,
+ ClassPrivateMethod,
} from '@romejs/js-ast';
import {isBinary} from '@romejs/js-ast-utils';
import Builder, {BuilderMethod} from '../Builder';
@@ -86,7 +87,7 @@ export function buildThrowAndReturnStatementBuilder(
export function printMethod(
builder: Builder,
- node: TSDeclareMethod | ClassMethod | ObjectMethod,
+ node: TSDeclareMethod | ClassMethod | ObjectMethod | ClassPrivateMethod,
): Token {
const kind = node.kind;

ADD
packages/@romejs/js-formatter/test-fixtures/class/classPrivateMethod/input.js
+class Foo {
+ a = 1;
+
+ *#a() {
+ yield bar();
+ }
+
+ #b = 2;
+
+ get b() { return 9999; }
+ set #c(x) { return x; }
+
+ static #d() {
+ return Math.random();
+ }
+}
\ No newline at end of file

ADD
packages/@romejs/js-formatter/test-fixtures/class/classPrivateMethod/input.test.md
+# `index.test.ts`
+
+**DO NOT MODIFY**. This file has been autogenerated. Run `rome test packages/@romejs/js-formatter/index.test.ts --update-snapshots` to update.
+
+## `class > classPrivateMethod`
+
+### `Input`
+
+```javascript
+class Foo {
+ a = 1;
+
+ *#a() {
+ yield bar();
+ }
+
+ #b = 2;
+
+ get b() { return 9999; }
+ set #c(x) { return x; }
+
+ static #d() {
+ return Math.random();
+ }
+}
+```
+
+### `Output`
+
+```javascript
+class Foo {
+ a = 1;
+
+ *#a() {
+ yield bar();
+ }
+
+ #b = 2;
+
+ get b() {
+ return 9_999;
+ }
+ set #c(x) {
+ return x;
+ }
+
+ static #d() {
+ return Math.random();
+ }
+}
+
+```

add builder for ClassPrivateMethod