-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathIdentifierPath.ts
More file actions
33 lines (23 loc) · 893 Bytes
/
IdentifierPath.ts
File metadata and controls
33 lines (23 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { NonterminalKind } from '@nomicfoundation/slang/cst';
import { doc } from 'prettier';
import { getNodeMetadata } from '../slang-utils/metadata.js';
import { Identifier } from './Identifier.js';
import type * as ast from '@nomicfoundation/slang/ast';
import type { AstPath, Doc } from 'prettier';
import type { PrintFunction, SlangNode } from '../types.d.ts';
const { join } = doc.builders;
export class IdentifierPath implements SlangNode {
readonly kind = NonterminalKind.IdentifierPath;
comments;
loc;
items: Identifier[];
constructor(ast: ast.IdentifierPath) {
const metadata = getNodeMetadata(ast);
this.items = ast.items.map((item) => new Identifier(item));
this.comments = metadata.comments;
this.loc = metadata.loc;
}
print(path: AstPath<IdentifierPath>, print: PrintFunction): Doc {
return join('.', path.map(print, 'items'));
}
}