@@ -5,7 +5,7 @@ import { MultiLineNatSpecComment } from '../slang-nodes/MultiLineNatSpecComment.
55import { SingleLineComment } from '../slang-nodes/SingleLineComment.js' ;
66import { SingleLineNatSpecComment } from '../slang-nodes/SingleLineNatSpecComment.js' ;
77
8- import type { Node } from '@nomicfoundation/slang/cst' ;
8+ import type { Edge , Node } from '@nomicfoundation/slang/cst' ;
99import type { Comment , StrictAstNode } from '../slang-nodes/types.d.ts' ;
1010import type { AstLocation } from '../types.d.ts' ;
1111
@@ -23,15 +23,15 @@ export function clearOffsets(): void {
2323 offsets . clear ( ) ;
2424}
2525
26- function getLeadingOffset ( children : Node [ ] ) : number {
26+ function getLeadingOffset ( children : Edge [ ] ) : number {
2727 let offset = 0 ;
28- for ( const child of children ) {
29- if ( child . isNonterminalNode ( ) || ! isCommentOrWhiteSpace ( child ) ) {
28+ for ( const { node } of children ) {
29+ if ( node . isNonterminalNode ( ) || ! isCommentOrWhiteSpace ( node ) ) {
3030 // The node's content starts when we find the first non-terminal token,
3131 // or if we find a non-comment, non-whitespace token.
3232 break ;
3333 }
34- offset += child . textLength . utf16 ;
34+ offset += node . textLength . utf16 ;
3535 }
3636 return offset ;
3737}
@@ -67,14 +67,14 @@ export class SlangNode {
6767 } ;
6868 return ;
6969 }
70- const children = cst . children ( ) . map ( ( child ) => child . node ) ;
70+ const children = cst . children ( ) ;
7171
7272 const initialOffset = offsets . get ( cst . id ) || 0 ;
7373 let offset = initialOffset ;
7474
75- for ( const child of children ) {
76- const { id, kind, textLength } = child ;
77- if ( child . isNonterminalNode ( ) ) {
75+ for ( const { node } of children ) {
76+ const { id, kind, textLength } = node ;
77+ if ( node . isNonterminalNode ( ) ) {
7878 offsets . set ( id , offset ) ;
7979 } else {
8080 switch ( kind ) {
@@ -83,16 +83,16 @@ export class SlangNode {
8383 // offset, it's hard to separate these responsibilities into different
8484 // functions without doing the iteration twice.
8585 case TerminalKind . MultiLineComment :
86- this . comments . push ( new MultiLineComment ( child , offset ) ) ;
86+ this . comments . push ( new MultiLineComment ( node , offset ) ) ;
8787 break ;
8888 case TerminalKind . MultiLineNatSpecComment :
89- this . comments . push ( new MultiLineNatSpecComment ( child , offset ) ) ;
89+ this . comments . push ( new MultiLineNatSpecComment ( node , offset ) ) ;
9090 break ;
9191 case TerminalKind . SingleLineComment :
92- this . comments . push ( new SingleLineComment ( child , offset ) ) ;
92+ this . comments . push ( new SingleLineComment ( node , offset ) ) ;
9393 break ;
9494 case TerminalKind . SingleLineNatSpecComment :
95- this . comments . push ( new SingleLineNatSpecComment ( child , offset ) ) ;
95+ this . comments . push ( new SingleLineNatSpecComment ( node , offset ) ) ;
9696 break ;
9797 case TerminalKind . Identifier :
9898 case TerminalKind . YulIdentifier :
0 commit comments