UNPKG

prettier-plugin-solidity

Version:

A Prettier Plugin for automatically formatting your Solidity code.

32 lines 1.25 kB
import { NonterminalKind } from '@nomicfoundation/slang/cst'; import { doc } from 'prettier'; import { getNodeMetadata, updateMetadata } from '../slang-utils/metadata.js'; import { joinExisting } from '../slang-utils/join-existing.js'; import { TypeName } from './TypeName.js'; import { StorageLocation } from './StorageLocation.js'; import { Identifier } from './Identifier.js'; const { group } = doc.builders; export class Parameter { constructor(ast, options) { this.kind = NonterminalKind.Parameter; let metadata = getNodeMetadata(ast); this.typeName = new TypeName(ast.typeName, options); if (ast.storageLocation) { this.storageLocation = new StorageLocation(ast.storageLocation); } if (ast.name) { this.name = new Identifier(ast.name); } metadata = updateMetadata(metadata, [this.typeName, this.storageLocation]); this.comments = metadata.comments; this.loc = metadata.loc; } print(path, print) { return group(joinExisting(' ', [ path.call(print, 'typeName'), path.call(print, 'storageLocation'), path.call(print, 'name') ])); } } //# sourceMappingURL=Parameter.js.map