UNPKG

prettier-plugin-solidity

Version:

A Prettier Plugin for automatically formatting your Solidity code.

35 lines (26 loc) 1.01 kB
import { NonterminalKind } from '@nomicfoundation/slang/cst'; import { SlangNode } from './SlangNode.js'; import { TerminalNode } from './TerminalNode.js'; import { ImportAlias } from './ImportAlias.js'; import type * as ast from '@nomicfoundation/slang/ast'; import type { AstPath, Doc } from 'prettier'; import type { CollectedMetadata, PrintFunction } from '../types.d.ts'; export class ImportDeconstructionSymbol extends SlangNode { readonly kind = NonterminalKind.ImportDeconstructionSymbol; name: TerminalNode; alias?: ImportAlias; constructor( ast: ast.ImportDeconstructionSymbol, collected: CollectedMetadata ) { super(ast, collected); this.name = new TerminalNode(ast.name, collected); if (ast.alias) { this.alias = new ImportAlias(ast.alias, collected); } this.updateMetadata(this.alias); } print(path: AstPath<ImportDeconstructionSymbol>, print: PrintFunction): Doc { return [path.call(print, 'name'), path.call(print, 'alias')]; } }