@@ -24,30 +24,32 @@ export function extractAnnotationsFromCode(code: Code) {
24
24
const focusList = [ ] as string [ ]
25
25
while ( lineNumber <= lines . length ) {
26
26
const line = lines [ lineNumber - 1 ]
27
- const { key, focus, data } = getCommentData (
28
- line ,
29
- lineNumber
30
- )
27
+ const { key, focusString, data } = getCommentData ( line )
31
28
32
29
const Component = annotationsMap [ key ! ]
33
30
34
31
if ( Component ) {
32
+ const focus = relativeToAbsolute (
33
+ focusString ,
34
+ lineNumber
35
+ )
35
36
lines . splice ( lineNumber - 1 , 1 )
36
- annotations . push ( { Component, focus : focus ! , data } )
37
+ annotations . push ( { Component, focus, data } )
37
38
} else if ( key === "focus" ) {
39
+ const focus = relativeToAbsolute (
40
+ focusString ,
41
+ lineNumber
42
+ )
38
43
lines . splice ( lineNumber - 1 , 1 )
39
- focusList . push ( focus ! )
44
+ focusList . push ( focus )
40
45
} else {
41
46
lineNumber ++
42
47
}
43
48
}
44
49
return [ annotations , focusList . join ( "," ) ] as const
45
50
}
46
51
47
- function getCommentData (
48
- line : Code [ "lines" ] [ 0 ] ,
49
- lineNumber : number
50
- ) {
52
+ function getCommentData ( line : Code [ "lines" ] [ 0 ] ) {
51
53
const comment = line . tokens . find ( t =>
52
54
t . content . startsWith ( "//" )
53
55
) ?. content
@@ -63,7 +65,7 @@ function getCommentData(
63
65
64
66
return {
65
67
key,
66
- focus : relativeToAbsolute ( focusString , lineNumber ) ,
68
+ focusString,
67
69
data,
68
70
}
69
71
}
0 commit comments