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:

  1. Is that the recommended approach?
  2. How should one decide whether to put such analysis in the "ProcessBefore" or "ProcessAfter"?
  3. Is it correct to simply return "true" from InteriorShouldBeProcessed?



Thanks,
Andrew

1 comment
Comment actions Permalink

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

0

Please sign in to leave a comment.