prettier-plugin-solidity
Version:
A Prettier Plugin for automatically formatting your Solidity code.
37 lines (29 loc) • 1.1 kB
text/typescript
import { NonterminalKind } from '@nomicfoundation/slang/cst';
import { doc } from 'prettier';
import { printSeparatedList } from '../slang-printers/print-separated-list.js';
import { SlangNode } from './SlangNode.js';
import { InheritanceType } from './InheritanceType.js';
import type * as ast from '@nomicfoundation/slang/ast';
import type { AstPath, Doc, ParserOptions } from 'prettier';
import type { CollectedMetadata, PrintFunction } from '../types.d.ts';
import type { AstNode } from './types.d.ts';
const { line } = doc.builders;
export class InheritanceTypes extends SlangNode {
readonly kind = NonterminalKind.InheritanceTypes;
items: InheritanceType[];
constructor(
ast: ast.InheritanceTypes,
collected: CollectedMetadata,
options: ParserOptions<AstNode>
) {
super(ast, collected, true);
this.items = ast.items.map(
(item) => new InheritanceType(item, collected, options)
);
}
print(path: AstPath<InheritanceTypes>, print: PrintFunction): Doc {
return printSeparatedList(path.map(print, 'items'), {
firstSeparator: line
});
}
}