prettier-plugin-solidity
Version:
A Prettier Plugin for automatically formatting your Solidity code.
28 lines • 1.05 kB
JavaScript
import { NonterminalKind } from '@nomicfoundation/slang/cst';
import { getNodeMetadata, updateMetadata } from '../slang-utils/metadata.js';
import { TypeName } from './TypeName.js';
import { Identifier } from './Identifier.js';
import { Expression } from './Expression.js';
export class ConstantDefinition {
constructor(ast, options) {
this.kind = NonterminalKind.ConstantDefinition;
let metadata = getNodeMetadata(ast);
this.typeName = new TypeName(ast.typeName, options);
this.name = new Identifier(ast.name);
this.value = new Expression(ast.value, options);
metadata = updateMetadata(metadata, [this.typeName, this.value]);
this.comments = metadata.comments;
this.loc = metadata.loc;
}
print(path, print) {
return [
path.call(print, 'typeName'),
' constant ',
path.call(print, 'name'),
' = ',
path.call(print, 'value'),
';'
];
}
}
//# sourceMappingURL=ConstantDefinition.js.map