@@ -5,7 +5,7 @@ import { MultiLineNatSpecComment } from '../slang-nodes/MultiLineNatSpecComment.
5
5
import { SingleLineComment } from '../slang-nodes/SingleLineComment.js' ;
6
6
import { SingleLineNatSpecComment } from '../slang-nodes/SingleLineNatSpecComment.js' ;
7
7
8
- import type { Node } from '@nomicfoundation/slang/cst' ;
8
+ import type { Edge , Node } from '@nomicfoundation/slang/cst' ;
9
9
import type { Comment , StrictAstNode } from '../slang-nodes/types.d.ts' ;
10
10
import type { AstLocation } from '../types.d.ts' ;
11
11
@@ -23,15 +23,15 @@ export function clearOffsets(): void {
23
23
offsets . clear ( ) ;
24
24
}
25
25
26
- function getLeadingOffset ( children : Node [ ] ) : number {
26
+ function getLeadingOffset ( children : Edge [ ] ) : number {
27
27
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 ) ) {
30
30
// The node's content starts when we find the first non-terminal token,
31
31
// or if we find a non-comment, non-whitespace token.
32
32
break ;
33
33
}
34
- offset += child . textLength . utf16 ;
34
+ offset += node . textLength . utf16 ;
35
35
}
36
36
return offset ;
37
37
}
@@ -67,14 +67,14 @@ export class SlangNode {
67
67
} ;
68
68
return ;
69
69
}
70
- const children = cst . children ( ) . map ( ( child ) => child . node ) ;
70
+ const children = cst . children ( ) ;
71
71
72
72
const initialOffset = offsets . get ( cst . id ) || 0 ;
73
73
let offset = initialOffset ;
74
74
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 ( ) ) {
78
78
offsets . set ( id , offset ) ;
79
79
} else {
80
80
switch ( kind ) {
@@ -83,16 +83,16 @@ export class SlangNode {
83
83
// offset, it's hard to separate these responsibilities into different
84
84
// functions without doing the iteration twice.
85
85
case TerminalKind . MultiLineComment :
86
- this . comments . push ( new MultiLineComment ( child , offset ) ) ;
86
+ this . comments . push ( new MultiLineComment ( node , offset ) ) ;
87
87
break ;
88
88
case TerminalKind . MultiLineNatSpecComment :
89
- this . comments . push ( new MultiLineNatSpecComment ( child , offset ) ) ;
89
+ this . comments . push ( new MultiLineNatSpecComment ( node , offset ) ) ;
90
90
break ;
91
91
case TerminalKind . SingleLineComment :
92
- this . comments . push ( new SingleLineComment ( child , offset ) ) ;
92
+ this . comments . push ( new SingleLineComment ( node , offset ) ) ;
93
93
break ;
94
94
case TerminalKind . SingleLineNatSpecComment :
95
- this . comments . push ( new SingleLineNatSpecComment ( child , offset ) ) ;
95
+ this . comments . push ( new SingleLineNatSpecComment ( node , offset ) ) ;
96
96
break ;
97
97
case TerminalKind . Identifier :
98
98
case TerminalKind . YulIdentifier :
0 commit comments