@@ -10,19 +10,18 @@ import { TerminalNode } from './TerminalNode.js';
1010import type * as ast from '@nomicfoundation/slang/ast' ;
1111import type { AstPath , Doc , ParserOptions } from 'prettier' ;
1212import type { CollectedMetadata , PrintFunction } from '../types.d.ts' ;
13- import type { AstNode } from './types.d.ts' ;
13+ import type { AstNode , ChainableExpression } from './types.d.ts' ;
1414
1515const { group, indent, label, softline } = doc . builders ;
1616
1717function isEndOfChain (
18- node : MemberAccessExpression ,
18+ node : ChainableExpression ,
1919 path : AstPath < Expression [ 'variant' ] >
2020) : boolean {
21- for (
22- let i = 1 , current : Expression [ 'variant' ] = node , parent = path . getNode ( i ) ;
23- parent && isChainableExpression ( parent ) ;
24- i ++ , current = parent , parent = path . getNode ( i )
25- ) {
21+ for ( let i = 1 , current = node , parent ; ; i ++ , current = parent ) {
22+ parent = path . getNode ( i ) ! ;
23+ if ( ! isChainableExpression ( parent ) ) break ;
24+
2625 switch ( parent . kind ) {
2726 case NonterminalKind . MemberAccessExpression :
2827 // If `parent` is a MemberAccessExpression we are not at the end
0 commit comments