prettier-plugin-solidity
Version:
A Prettier Plugin for automatically formatting your Solidity code.
39 lines (30 loc) • 1.16 kB
text/typescript
import { NonterminalKind } from '@nomicfoundation/slang/cst';
import { joinExisting } from '../slang-utils/join-existing.js';
import { SlangNode } from './SlangNode.js';
import { StorageLocation } from './StorageLocation.js';
import { TerminalNode } from './TerminalNode.js';
import type * as ast from '@nomicfoundation/slang/ast';
import type { AstPath, Doc } from 'prettier';
import type { CollectedMetadata, PrintFunction } from '../types.d.ts';
export class UntypedTupleMember extends SlangNode {
readonly kind = NonterminalKind.UntypedTupleMember;
storageLocation?: StorageLocation;
name: TerminalNode;
constructor(ast: ast.UntypedTupleMember, collected: CollectedMetadata) {
super(ast, collected);
if (ast.storageLocation) {
this.storageLocation = new StorageLocation(
ast.storageLocation,
collected
);
}
this.name = new TerminalNode(ast.name, collected);
this.updateMetadata(this.storageLocation);
}
print(path: AstPath<UntypedTupleMember>, print: PrintFunction): Doc {
return joinExisting(' ', [
path.call(print, 'storageLocation'),
path.call(print, 'name')
]);
}
}