| 249 | } |
| 250 | |
| 251 | class TcbEventHandlerTranslator extends TcbExpressionTranslator { |
| 252 | protected override resolve(ast: AST): TcbExpr | null { |
| 253 | // Recognize a property read on the implicit receiver corresponding with the event parameter |
| 254 | // that is available in event bindings. Since this variable is a parameter of the handler |
| 255 | // function that the converted expression becomes a child of, just create a reference to the |
| 256 | // parameter by its name. |
| 257 | if ( |
| 258 | ast instanceof PropertyRead && |
| 259 | ast.receiver instanceof ImplicitReceiver && |
| 260 | ast.name === EVENT_PARAMETER |
| 261 | ) { |
| 262 | return new TcbExpr(EVENT_PARAMETER).addParseSpanInfo(ast.nameSpan); |
| 263 | } |
| 264 | |
| 265 | return super.resolve(ast); |
| 266 | } |
| 267 | |
| 268 | protected override isValidLetDeclarationAccess(): boolean { |
| 269 | // Event listeners are allowed to read `@let` declarations before |
| 270 | // they're declared since the callback won't be executed immediately. |
| 271 | return true; |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | /** |
| 276 | * Creates an arrow function to be used as handler function for event bindings. The handler |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…