ast-types icon indicating copy to clipboard operation
ast-types copied to clipboard

Automatically catch AbortRequest at n-th parent

Open adiba opened this issue 8 years ago • 1 comments

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.

adiba avatar Jun 27 '17 06:06 adiba

What if you provided the parent type name, and it's an error if a parent of that type is not found?

benjamn avatar Jul 10 '17 14:07 benjamn