-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathVersionExpressionSets.ts
More file actions
35 lines (24 loc) · 1.02 KB
/
VersionExpressionSets.ts
File metadata and controls
35 lines (24 loc) · 1.02 KB
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
34
35
import { NonterminalKind } from '@nomicfoundation/slang/cst';
import { doc } from 'prettier';
import { getNodeMetadata, updateMetadata } from '../slang-utils/metadata.js';
import { VersionExpressionSet } from './VersionExpressionSet.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 VersionExpressionSets implements SlangNode {
readonly kind = NonterminalKind.VersionExpressionSets;
comments;
loc;
items: VersionExpressionSet[];
constructor(ast: ast.VersionExpressionSets) {
let metadata = getNodeMetadata(ast, true);
this.items = ast.items.map((item) => new VersionExpressionSet(item));
metadata = updateMetadata(metadata, [this.items]);
this.comments = metadata.comments;
this.loc = metadata.loc;
}
print(path: AstPath<VersionExpressionSets>, print: PrintFunction): Doc {
return join(' || ', path.map(print, 'items'));
}
}