UNPKG

prettier-plugin-solidity

Version:

A Prettier Plugin for automatically formatting your Solidity code.

29 lines (23 loc) 768 B
import { NonterminalKind } from '@nomicfoundation/slang/cst'; import addCollectionFirstComment from './add-collection-first-comment.js'; import addCollectionLastComment from './add-collection-last-comment.js'; import type { HandlerParams } from './types.d.ts'; export default function handleBlockComments({ precedingNode, enclosingNode, followingNode, comment }: HandlerParams): boolean { if (enclosingNode?.kind !== NonterminalKind.Block) { return false; } if (precedingNode?.kind === NonterminalKind.Statements) { addCollectionLastComment(precedingNode, comment); return true; } if (followingNode?.kind === NonterminalKind.Statements) { addCollectionFirstComment(followingNode, comment); return true; } return false; }