IRecursiveElementProcessor usage
In order to analyse method calls in my R# plugin, I create a StageProcess that implements both IDaemonStageProcess and IRecursiveElementProcessor.
Implementation looks like this:
public bool InteriorShouldBeProcessed(IElement element) { return true; }
public void ProcessAfterInterior(IElement element) { }
public void ProcessBeforeInterior(IElement element)
{
var checker = ...
if (checker.IsInvocationAllowed) return;
//else add highlighting
}
Now a few questions:
- Is that the recommended approach?
- How should one decide whether to put such analysis in the "ProcessBefore" or "ProcessAfter"?
- Is it correct to simply return "true" from InteriorShouldBeProcessed?
Thanks,
Andrew
Please sign in to leave a comment.
1) Yes, this is desired approach
2) "ProcessBeforeInterior" is executed BEFORE visitng the subtree, and "ProcessAfterInterior" - after.
Usually, there is no difference where you process syntax constructs. These methods are requesred when you need pre- and post- processing of a subtree (for example, before visitng code block push something into stack, and after visiting - pop)
3) Using "InteriorShouldBeProcessed" you can skip some subtrees from iteration. When you return "true", the whole AST will be visited