benjamn / benjamn/ast-types

Automatically catch AbortRequest at n-th parent

Open
#223 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.2k
Forks
194
Avg merge
22h 43m
Merged PRs (30d)
10

Description

I am replacing a parent node and then visiting the new one explicitly. In order to not visit all children twice, I have to call `this.abort();`.
Catching the exception however is a bit cumbersome as I'd have to surround many `traverse` calls in the `visit...` methods of my visitor object with try-catch clauses and re-throw the exception if applicable.

Could you implement this in PathVisitor? I was thinking of something like this:
```
// jump up 2 levels
var abortLevels = 2;
this.abort(abortLevels);
```
The abort request should then automatically be canceled after stepping up n levels.
`abortLevels = 0;` would equivalent to `return false;` in this case.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading PathVisitor's abort behavior and the traverse calls in the visitor methods. Trace how an abort request propagates while replacing and revisiting a parent node. Done means abort(n) is canceled after stepping up n levels, while abort(0) behaves like return false.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.