prettier-plugin-solidity
Version:
A Prettier Plugin for automatically formatting your Solidity code.
37 lines (26 loc) • 1.09 kB
text/typescript
import { NonterminalKind } from '@nomicfoundation/slang/cst';
import { getNodeMetadata, updateMetadata } from '../slang-utils/metadata.js';
import { EventParameters } from './EventParameters.js';
import type * as ast from '@nomicfoundation/slang/ast';
import type { AstPath, Doc, ParserOptions } from 'prettier';
import type { AstNode } from './types.d.ts';
import type { PrintFunction, SlangNode } from '../types.d.ts';
export class EventParametersDeclaration implements SlangNode {
readonly kind = NonterminalKind.EventParametersDeclaration;
comments;
loc;
parameters: EventParameters;
constructor(
ast: ast.EventParametersDeclaration,
options: ParserOptions<AstNode>
) {
let metadata = getNodeMetadata(ast);
this.parameters = new EventParameters(ast.parameters, options);
metadata = updateMetadata(metadata, [this.parameters]);
this.comments = metadata.comments;
this.loc = metadata.loc;
}
print(path: AstPath<EventParametersDeclaration>, print: PrintFunction): Doc {
return ['(', path.call(print, 'parameters'), ')'];
}
}