Skip to content

Commit 2c29d42

Browse files
committed
path.call(print, 'selector') can be called like print('selector')
1 parent 57a1097 commit 2c29d42

109 files changed

Lines changed: 175 additions & 262 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import { locEnd, locStart } from './slang-utils/loc.js';
1212
import { hasPrettierIgnore } from './slang-utils/has-prettier-ignore.js';
1313

1414
import type {
15+
AstPath,
16+
Doc,
1517
Parser,
18+
ParserOptions,
1619
Printer,
1720
RequiredOptions,
1821
SupportLanguage
@@ -77,7 +80,12 @@ const slangPrinter: Printer<PrintableNode | undefined> = {
7780
handleComments,
7881
isBlockComment,
7982
massageAstNode,
80-
print: slangPrint,
83+
print: slangPrint as (
84+
path: AstPath<PrintableNode | undefined>,
85+
options: ParserOptions<PrintableNode | undefined>,
86+
print: (path: AstPath<PrintableNode | undefined>) => Doc,
87+
args?: unknown
88+
) => Doc,
8189
hasPrettierIgnore,
8290
printComment
8391
};

src/slang-nodes/AbicoderPragma.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ export class AbicoderPragma extends SlangNode {
2020
}
2121

2222
print(path: AstPath<AbicoderPragma>, print: PrintFunction): Doc {
23-
return ['abicoder ', path.call(print, 'version')];
23+
return ['abicoder ', print('version')];
2424
}
2525
}

src/slang-nodes/ArrayExpression.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ export class ArrayExpression extends SlangNode {
2525
}
2626

2727
print(path: AstPath<ArrayExpression>, print: PrintFunction): Doc {
28-
return ['[', path.call(print, 'items'), ']'];
28+
return ['[', print('items'), ']'];
2929
}
3030
}

src/slang-nodes/ArrayTypeName.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ export class ArrayTypeName extends SlangNode {
3636
}
3737

3838
print(path: AstPath<ArrayTypeName>, print: PrintFunction): Doc {
39-
return [path.call(print, 'operand'), '[', path.call(print, 'index'), ']'];
39+
return [print('operand'), '[', print('index'), ']'];
4040
}
4141
}

src/slang-nodes/AssemblyFlagsDeclaration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ export class AssemblyFlagsDeclaration extends SlangNode {
2525
}
2626

2727
print(path: AstPath<AssemblyFlagsDeclaration>, print: PrintFunction): Doc {
28-
return ['(', path.call(print, 'flags'), ')'];
28+
return ['(', print('flags'), ')'];
2929
}
3030
}

src/slang-nodes/AssemblyStatement.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ export class AssemblyStatement extends SlangNode {
4040
print(path: AstPath<AssemblyStatement>, print: PrintFunction): Doc {
4141
return joinExisting(' ', [
4242
'assembly',
43-
path.call(print, 'label'),
44-
path.call(print, 'flags'),
45-
path.call(print, 'body')
43+
print('label'),
44+
print('flags'),
45+
print('body')
4646
]);
4747
}
4848
}

src/slang-nodes/AssignmentExpression.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,9 @@ export class AssignmentExpression extends SlangNode {
3838

3939
print(path: AstPath<AssignmentExpression>, print: PrintFunction): Doc {
4040
return [
41-
path.call(print, 'leftOperand'),
41+
print('leftOperand'),
4242
` ${this.operator}`,
43-
printAssignmentRightSide(
44-
path.call(print, 'rightOperand'),
45-
this.rightOperand
46-
)
43+
printAssignmentRightSide(print('rightOperand'), this.rightOperand)
4744
];
4845
}
4946
}

src/slang-nodes/Block.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ export class Block extends SlangNode {
2525
}
2626

2727
print(path: AstPath<Block>, print: PrintFunction): Doc {
28-
return ['{', path.call(print, 'statements'), '}'];
28+
return ['{', print('statements'), '}'];
2929
}
3030
}

src/slang-nodes/CallOptionsExpression.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ export class CallOptionsExpression extends SlangNode {
3232
}
3333

3434
print(path: AstPath<CallOptionsExpression>, print: PrintFunction): Doc {
35-
return [path.call(print, 'operand'), '{', path.call(print, 'options'), '}'];
35+
return [print('operand'), '{', print('options'), '}'];
3636
}
3737
}

src/slang-nodes/CatchClause.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ export class CatchClause extends SlangNode {
3131
}
3232

3333
print(path: AstPath<CatchClause>, print: PrintFunction): Doc {
34-
return ['catch ', path.call(print, 'error'), path.call(print, 'body')];
34+
return ['catch ', print('error'), print('body')];
3535
}
3636
}

0 commit comments

Comments
 (0)