(code: string, errorLoc: Position)
| 244 | return new ExpressionError(errorMessage, loc, token); |
| 245 | } |
| 246 | function getTokenAtLoc(code: string, errorLoc: Position): Token | undefined { |
| 247 | const tokens = tokenizer(code, { |
| 248 | ecmaVersion: 'latest', |
| 249 | locations: true, |
| 250 | }); |
| 251 | |
| 252 | try { |
| 253 | for (const token of tokens) { |
| 254 | if (!token.loc) { |
| 255 | continue; |
| 256 | } |
| 257 | |
| 258 | const { start, end } = token.loc; |
| 259 | |
| 260 | const onSameLine = errorLoc.line === start.line; |
| 261 | const inColumnRange = errorLoc.column >= start.column && errorLoc.column < end.column; |
| 262 | |
| 263 | if (onSameLine && inColumnRange) { |
| 264 | return token; |
| 265 | } |
| 266 | } |
| 267 | } catch (_error) { |
| 268 | return undefined; |
| 269 | } |
| 270 | |
| 271 | return undefined; |
| 272 | } |
| 273 | |
| 274 | function isParsedExpressionStatement( |
| 275 | statement: Program['body'][number] |
no outgoing calls
no test coverage detected
searching dependent graphs…