UNPKG

prettier-plugin-solidity

Version:

A Prettier Plugin for automatically formatting your Solidity code.

34 lines 1.32 kB
import { doc } from 'prettier'; import { NonterminalKind } from '@nomicfoundation/slang/cst'; import { getNodeMetadata, updateMetadata } from '../slang-utils/metadata.js'; import { Identifier } from './Identifier.js'; import { InheritanceSpecifier } from './InheritanceSpecifier.js'; import { InterfaceMembers } from './InterfaceMembers.js'; const { group, line } = doc.builders; export class InterfaceDefinition { constructor(ast, options) { this.kind = NonterminalKind.InterfaceDefinition; let metadata = getNodeMetadata(ast); this.name = new Identifier(ast.name); if (ast.inheritance) { this.inheritance = new InheritanceSpecifier(ast.inheritance, options); } this.members = new InterfaceMembers(ast.members, options); metadata = updateMetadata(metadata, [this.inheritance, this.members]); this.comments = metadata.comments; this.loc = metadata.loc; } print(path, print) { return [ group([ 'interface ', path.call(print, 'name'), this.inheritance ? [' ', path.call(print, 'inheritance')] : line, '{' ]), path.call(print, 'members'), '}' ]; } } //# sourceMappingURL=InterfaceDefinition.js.map