-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathInterfaceMembers.ts
More file actions
37 lines (30 loc) · 1.23 KB
/
InterfaceMembers.ts
File metadata and controls
37 lines (30 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { doc } from 'prettier';
import { NonterminalKind } from '@nomicfoundation/slang/cst';
import { printSeparatedItem } from '../slang-printers/print-separated-item.js';
import { printPreservingEmptyLines } from '../slang-printers/print-preserving-empty-lines.js';
import { SlangNode } from './SlangNode.js';
import { ContractMember } from './ContractMember.js';
import type * as ast from '@nomicfoundation/slang/ast';
import type { AstPath, Doc, ParserOptions } from 'prettier';
import type { AstNode } from './types.d.ts';
import type { PrintFunction } from '../types.d.ts';
const { hardline } = doc.builders;
export class InterfaceMembers extends SlangNode {
readonly kind = NonterminalKind.InterfaceMembers;
items: ContractMember[];
constructor(ast: ast.InterfaceMembers, options: ParserOptions<AstNode>) {
super(ast, true);
this.items = ast.items.map((item) => new ContractMember(item, options));
}
print(
path: AstPath<InterfaceMembers>,
print: PrintFunction,
options: ParserOptions<AstNode>
): Doc {
return this.items.length > 0 || (this.comments?.length || 0) > 0
? printSeparatedItem(printPreservingEmptyLines(path, print, options), {
firstSeparator: hardline
})
: '';
}
}