@@ -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 } from '@nomicfoundation/slang/cst' ;
9
9
import type { Comment , StrictAstNode } from '../slang-nodes/types.d.ts' ;
10
10
import type { AstLocation , SlangAstNode } 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
return offset ;
33
33
}
34
- offset += child . textLength . utf16 ;
34
+ offset += node . textLength . utf16 ;
35
35
}
36
36
return offset ;
37
37
}
@@ -71,14 +71,14 @@ export class SlangNode {
71
71
return ;
72
72
}
73
73
const parent = ast . cst ;
74
- const children = parent . children ( ) . map ( ( child ) => child . node ) ;
74
+ const children = parent . children ( ) ;
75
75
76
76
const initialOffset = offsets . get ( parent . id ) || 0 ;
77
77
let offset = initialOffset ;
78
78
79
- for ( const child of children ) {
80
- const { id, kind, textLength } = child ;
81
- if ( child . isNonterminalNode ( ) ) {
79
+ for ( const { node } of children ) {
80
+ const { id, kind, textLength } = node ;
81
+ if ( node . isNonterminalNode ( ) ) {
82
82
offsets . set ( id , offset ) ;
83
83
} else {
84
84
switch ( kind ) {
@@ -87,16 +87,16 @@ export class SlangNode {
87
87
// offset, it's hard to separate these responsibilities into different
88
88
// functions without doing the iteration twice.
89
89
case TerminalKind . MultiLineComment :
90
- this . comments . push ( new MultiLineComment ( child , offset ) ) ;
90
+ this . comments . push ( new MultiLineComment ( node , offset ) ) ;
91
91
break ;
92
92
case TerminalKind . MultiLineNatSpecComment :
93
- this . comments . push ( new MultiLineNatSpecComment ( child , offset ) ) ;
93
+ this . comments . push ( new MultiLineNatSpecComment ( node , offset ) ) ;
94
94
break ;
95
95
case TerminalKind . SingleLineComment :
96
- this . comments . push ( new SingleLineComment ( child , offset ) ) ;
96
+ this . comments . push ( new SingleLineComment ( node , offset ) ) ;
97
97
break ;
98
98
case TerminalKind . SingleLineNatSpecComment :
99
- this . comments . push ( new SingleLineNatSpecComment ( child , offset ) ) ;
99
+ this . comments . push ( new SingleLineNatSpecComment ( node , offset ) ) ;
100
100
break ;
101
101
case TerminalKind . Identifier :
102
102
case TerminalKind . YulIdentifier :
0 commit comments