Interface Processor<E extends CtElement>

    • Method Detail

      • getTraversalStrategy

        TraversalStrategy getTraversalStrategy()
        Gets the model's traversal strategy for this processor (default is TraversalStrategy.POST_ORDER). Programmers should override this method to return another strategy if needed.
      • getEnvironment

        Environment getEnvironment()
        Gets the environment of this processor.
      • isToBeProcessed

        boolean isToBeProcessed​(E candidate)
        Tells if this element is to be processed (returns true in the default implementation).
        Parameters:
        candidate - the candidate
        Returns:
        true if the candidate is to be processed by the process(CtElement)
      • process

        void process​(E element)
        A callback method upcalled by the meta-model scanner to perform a dedicated job on the currently scanned element. The way Spoon upcalls this method depends on the processed element types ( getProcessedElementTypes()), the traversal strategy ( getTraversalStrategy()), and the used processing manager ( Environment.getManager(). Also, this method is upcalled only if the method isToBeProcessed(CtElement) returns true for a given scanned element. In order to manually scan the meta-model, one can define the process() method instead.
        Parameters:
        element - the element that is currently being scanned
      • process

        void process()
        A callback method upcalled by the manager so that this processor can manually implement a processing job. On contrary to process(CtElement), this method does not rely on a built-in meta-model scanner and has to implement its own traversal strategy on the meta-model, which is stored in the factory ( FactoryAccessor.getFactory()). Note that if a processor implements both process methods, this one is upcalled first. This method does nothing in default implementations ( AbstractProcessor).
      • getProcessedElementTypes

        Set<Class<? extends CtElement>> getProcessedElementTypes()
        Gets all the element types than need to be processed.
      • processingDone

        void processingDone()
        This method is upcalled by the ProcessingManager when this processor has finished a full processing round on the program's model. It is convenient to override this method to tune the application's strategy of a set of processors, for instance by dynamically adding processors to the processing manager when a processing round ends (see ProcessingManager.addProcessor(Class)). Does nothing by default.
      • init

        void init()
        This method is upcalled to initialize the processor before each processing round. It is convenient to override this method rather than using a default constructor to initialize the processor, since the factory is not initialized at construction time. When overriding, do not forget to call super.init() first so that all the initializations performed by superclasses are also applied.
      • interrupt

        void interrupt()
        Interrupts the processing of this processor but changes on your AST are kept and the invocation of this method doesn't interrupt the processing of all processors specified in the ProcessingManager.