prettier-plugin-solidity
Version:
A Prettier Plugin for automatically formatting your Solidity code.
23 lines • 1.16 kB
JavaScript
import { NonterminalKind } from '@nomicfoundation/slang/cst';
import { getNodeMetadata, updateMetadata } from '../slang-utils/metadata.js';
import { isBlockComment } from '../slang-utils/is-comment.js';
import { PositionalArguments } from './PositionalArguments.js';
export class PositionalArgumentsDeclaration {
constructor(ast, options) {
this.kind = NonterminalKind.PositionalArgumentsDeclaration;
let metadata = getNodeMetadata(ast);
this.arguments = new PositionalArguments(ast.arguments, options);
metadata = updateMetadata(metadata, [this.arguments]);
this.comments = metadata.comments;
this.loc = metadata.loc;
// We need to check the comments at this point because they will be removed
// from this node into the root node.
const empty = this.arguments.items.length === 0 && // no arguments
!this.comments.some((comment) => isBlockComment(comment)); // no block comments
this.isEmpty = () => empty;
}
print(path, print) {
return ['(', path.call(print, 'arguments'), ')'];
}
}
//# sourceMappingURL=PositionalArgumentsDeclaration.js.map