File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { SlangNode } from './SlangNode.js' ;
22
3- import type { SlangAstNode } from '../types.d.ts' ;
3+ import type { AstPath , Doc } from 'prettier' ;
4+ import type { PrintFunction , SlangAstNode } from '../types.d.ts' ;
5+ import type { StrictPolymorphicNode } from './types.js' ;
6+
7+ export abstract class PolymorphicNode extends SlangNode {
8+ abstract variant : StrictPolymorphicNode [ 'variant' ] ;
49
5- export class PolymorphicNode extends SlangNode {
610 constructor ( ast : SlangAstNode ) {
711 super ( ast ) ;
812 }
13+
14+ print ( path : AstPath < PolymorphicNode > , print : PrintFunction ) : Doc {
15+ return path . call ( print , 'variant' ) ;
16+ }
917}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11import { isBlockComment } from './slang-utils/is-comment.js' ;
22import { locEnd , locStart } from './slang-utils/loc.js' ;
3- import { isPolymorphicNode } from './slang-utils/is-polymorphic-node.js' ;
43
54import type { AstPath , Doc , ParserOptions } from 'prettier' ;
65import type { AstNode , StrictAstNode } from './slang-nodes/types.d.ts' ;
@@ -29,6 +28,7 @@ function ignoreComments(path: AstPath<AstNode>): void {
2928 // parser. `updateMetadata` is an internal function.
3029 case 'kind' :
3130 case 'loc' :
31+ case 'print' :
3232 case 'updateMetadata' :
3333 break ;
3434 // The key `comments` will contain every comment for this node.
@@ -64,7 +64,6 @@ function genericPrint(
6464 return options . originalText . slice ( locStart ( node ) , locEnd ( node ) ) ;
6565 }
6666
67- if ( isPolymorphicNode ( node ) ) return path . call ( print , 'variant' ) ;
6867 // Since each node has a print function with a specific AstPath, the union of
6968 // all nodes into AstNode creates a print function with an AstPath of the
7069 // intersection of all nodes. This forces us to cast this with a never type.
You can’t perform that action at this time.
0 commit comments