UNPKG

prettier-plugin-solidity

Version:

A Prettier Plugin for automatically formatting your Solidity code.

28 lines 1.39 kB
import { NonterminalKind } from '@nomicfoundation/slang/cst'; import { doc } from 'prettier'; import { getNodeMetadata, updateMetadata } from '../slang-utils/metadata.js'; import { TupleDeconstructionElements } from './TupleDeconstructionElements.js'; import { Expression } from './Expression.js'; const { group, indentIfBreak } = doc.builders; export class TupleDeconstructionStatement { constructor(ast, options) { var _a; this.kind = NonterminalKind.TupleDeconstructionStatement; let metadata = getNodeMetadata(ast); this.varKeyword = (_a = ast.varKeyword) === null || _a === void 0 ? void 0 : _a.unparse(); this.elements = new TupleDeconstructionElements(ast.elements, options); this.expression = new Expression(ast.expression, options); metadata = updateMetadata(metadata, [this.elements, this.expression]); this.comments = metadata.comments; this.loc = metadata.loc; } print(path, print) { const groupId = Symbol('Slang.VariableDeclarationStatement.variables'); const declarationDoc = group([this.varKeyword ? 'var (' : '(', path.call(print, 'elements'), ')'], { id: groupId }); return [ declarationDoc, indentIfBreak([' = ', path.call(print, 'expression'), ';'], { groupId }) ]; } } //# sourceMappingURL=TupleDeconstructionStatement.js.map