File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,15 +2,15 @@ import {
22 NonterminalKind ,
33 TerminalNode as SlangTerminalNode
44} from '@nomicfoundation/slang/cst' ;
5- import { PolymorphicNode } from './PolymorphicNode .js' ;
5+ import { SlangNode } from './SlangNode .js' ;
66import { StringLiteral } from './StringLiteral.js' ;
77import { TerminalNode } from './TerminalNode.js' ;
88
99import type * as ast from '@nomicfoundation/slang/ast' ;
1010import type { ParserOptions } from 'prettier' ;
1111import type { AstNode } from './types.d.ts' ;
1212
13- export class ExperimentalFeature extends PolymorphicNode {
13+ export class ExperimentalFeature extends SlangNode {
1414 readonly kind = NonterminalKind . ExperimentalFeature ;
1515
1616 variant : StringLiteral | TerminalNode ;
Original file line number Diff line number Diff line change 11import { NonterminalKind } from '@nomicfoundation/slang/cst' ;
2- import { printVariant } from '../slang-printers/print -variant.js' ;
2+ import { extractVariant } from '../slang-utils/extract -variant.js' ;
33import { SlangNode } from './SlangNode.js' ;
44import { ExperimentalFeature } from './ExperimentalFeature.js' ;
55
@@ -11,17 +11,19 @@ import type { AstNode } from './types.d.ts';
1111export class ExperimentalPragma extends SlangNode {
1212 readonly kind = NonterminalKind . ExperimentalPragma ;
1313
14- feature : ExperimentalFeature ;
14+ feature : ExperimentalFeature [ 'variant' ] ;
1515
1616 constructor ( ast : ast . ExperimentalPragma , options : ParserOptions < AstNode > ) {
1717 super ( ast ) ;
1818
19- this . feature = new ExperimentalFeature ( ast . feature , options ) ;
19+ this . feature = extractVariant (
20+ new ExperimentalFeature ( ast . feature , options )
21+ ) ;
2022
2123 this . updateMetadata ( this . feature ) ;
2224 }
2325
2426 print ( path : AstPath < ExperimentalPragma > , print : PrintFunction ) : Doc {
25- return [ 'experimental ' , path . call ( printVariant ( print ) , 'feature' ) ] ;
27+ return [ 'experimental ' , path . call ( print , 'feature' ) ] ;
2628 }
2729}
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import type { Statement } from './slang-nodes/Statement.js';
1919import type { YulStatement } from './slang-nodes/YulStatement.js' ;
2020import type { ContractSpecifier } from './slang-nodes/ContractSpecifier.js' ;
2121import type { ElementaryType } from './slang-nodes/ElementaryType.js' ;
22+ import type { ExperimentalFeature } from './slang-nodes/ExperimentalFeature.js' ;
2223
2324function hasNodeIgnoreComment ( { comments } : StrictAstNode ) : boolean {
2425 // Prettier sets SourceUnit's comments to undefined after assigning comments
@@ -86,6 +87,7 @@ function genericPrint(
8687 | YulStatement
8788 | ContractSpecifier
8889 | ElementaryType
90+ | ExperimentalFeature
8991 >
9092 > ,
9193 options : ParserOptions < AstNode > ,
You can’t perform that action at this time.
0 commit comments