prettier-plugin-solidity
Version:
A Prettier Plugin for automatically formatting your Solidity code.
43 lines (34 loc) • 1.29 kB
text/typescript
import { NonterminalKind } from '@nomicfoundation/slang/cst';
import { extractVariant } from '../slang-utils/extract-variant.js';
import { SlangNode } from './SlangNode.js';
import { YulExpression } from './YulExpression.js';
import { YulArguments } from './YulArguments.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';
export class YulFunctionCallExpression extends SlangNode {
readonly kind = NonterminalKind.YulFunctionCallExpression;
operand: YulExpression['variant'];
arguments: YulArguments;
constructor(
ast: ast.YulFunctionCallExpression,
collected: CollectedMetadata,
options: ParserOptions<AstNode>
) {
super(ast, collected);
this.operand = extractVariant(
new YulExpression(ast.operand, collected, options)
);
this.arguments = new YulArguments(ast.arguments, collected, options);
this.updateMetadata(this.operand, this.arguments);
}
print(path: AstPath<YulFunctionCallExpression>, print: PrintFunction): Doc {
return [
path.call(print, 'operand'),
'(',
path.call(print, 'arguments'),
')'
];
}
}