UNPKG

prettier-plugin-solidity

Version:

A Prettier Plugin for automatically formatting your Solidity code.

27 lines 1.43 kB
import { NonterminalKind } from '@nomicfoundation/slang/cst'; import { util } from 'prettier'; import { locEnd } from '../../slang-utils/loc.js'; import addCollectionNodeFirstComment from './add-collection-node-first-comment.js'; const { addTrailingComment } = util; export default function handleModifierInvocationComments({ text, precedingNode, enclosingNode, followingNode, comment }) { if ((enclosingNode === null || enclosingNode === void 0 ? void 0 : enclosingNode.kind) !== NonterminalKind.ModifierInvocation) { return false; } const nextCharacter = util.getNextNonSpaceNonCommentCharacter(text, locEnd(comment)); // The last comments before the body. if ((precedingNode === null || precedingNode === void 0 ? void 0 : precedingNode.kind) === NonterminalKind.IdentifierPath && nextCharacter === '(' && (followingNode === null || followingNode === void 0 ? void 0 : followingNode.kind) === NonterminalKind.ArgumentsDeclaration && followingNode.variant.kind === NonterminalKind.PositionalArgumentsDeclaration) { if (followingNode.variant.arguments.items.length === 0) { addTrailingComment(enclosingNode, comment); } else { addCollectionNodeFirstComment(followingNode.variant.arguments, comment); } return true; } return false; } //# sourceMappingURL=handle-modifier-invocation-comments.js.map