prettier-plugin-solidity
Version:
A Prettier Plugin for automatically formatting your Solidity code.
30 lines (20 loc) • 659 B
text/typescript
import { TerminalKind, TerminalNode } from '@nomicfoundation/slang/cst';
import { getNodeMetadata } from '../slang-utils/metadata.js';
import type { Doc } from 'prettier';
import type { Location, SlangNode } from '../types.d.ts';
import type { Comment } from './types.d.ts';
export class Identifier implements SlangNode {
readonly kind = TerminalKind.Identifier;
comments: Comment[];
loc: Location;
value: string;
constructor(ast: TerminalNode) {
const metadata = getNodeMetadata(ast);
this.value = ast.unparse();
this.comments = metadata.comments;
this.loc = metadata.loc;
}
print(): Doc {
return this.value;
}
}