Package spoon.processing
Class AbstractProcessor<E extends CtElement>
java.lang.Object
spoon.processing.AbstractProcessor<E>
- All Implemented Interfaces:
FactoryAccessor,Processor<E>
- Direct Known Subclasses:
AbstractAnnotationProcessor,AbstractParallelProcessor,ForceFullyQualifiedProcessor,ForceImportProcessor,ImportCleaner,ImportConflictDetector,JavaOutputProcessor
This class defines an abstract processor to be subclassed by the user for
defining new processors.
-
Constructor Summary
ConstructorsConstructorDescriptionEmpty constructor only for all processors (invoked by Spoon). -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddProcessedElementType(Class<? extends CtElement> elementType)Adds a processed element type.protected voidClears the processed element types.Gets the environment of this processor.Gets the factory of this object.Gets all the element types than need to be processed.Gets the model's traversal strategy for this processor (default isTraversalStrategy.POST_ORDER).voidinit()This method is called to initialize the processor before each processing round.voidinitProperties(ProcessorProperties properties)Helper method to initialize the properties of a given processor.voidInterrupts 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 theProcessingManager.booleanisToBeProcessed(E candidate)Tells if this element is to be processed (returnstruein the default implementation).Helper method to load the properties of the given processor (usesEnvironment.getProcessorProperties(String)).voidprocess()The manual meta-model processing cannot be overridden (useAbstractManualProcessor) to do so.voidThis method is called by theProcessingManagerwhen this processor has finished a full processing round on the program's model.protected voidremoveProcessedElementType(Class<? extends CtElement> elementType)Removes a processed element type.voidsetFactory(Factory factory)Sets the factory object.
-
Constructor Details
-
AbstractProcessor
public AbstractProcessor()Empty constructor only for all processors (invoked by Spoon).
-
-
Method Details
-
addProcessedElementType
Adds a processed element type. This method is typically invoked in subclasses' constructors. -
clearProcessedElementType
protected void clearProcessedElementType()Clears the processed element types. -
getEnvironment
Description copied from interface:ProcessorGets the environment of this processor.- Specified by:
getEnvironmentin interfaceProcessor<E extends CtElement>
-
getFactory
Description copied from interface:FactoryAccessorGets the factory of this object.- Specified by:
getFactoryin interfaceFactoryAccessor
-
getProcessedElementTypes
Description copied from interface:ProcessorGets all the element types than need to be processed.- Specified by:
getProcessedElementTypesin interfaceProcessor<E extends CtElement>
-
loadProperties
Helper method to load the properties of the given processor (usesEnvironment.getProcessorProperties(String)). -
getTraversalStrategy
Description copied from interface:ProcessorGets the model's traversal strategy for this processor (default isTraversalStrategy.POST_ORDER). Programmers should override this method to return another strategy if needed.- Specified by:
getTraversalStrategyin interfaceProcessor<E extends CtElement>
-
init
public void init()Description copied from interface:ProcessorThis method is called 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. -
isToBeProcessed
Description copied from interface:ProcessorTells if this element is to be processed (returnstruein the default implementation).- Specified by:
isToBeProcessedin interfaceProcessor<E extends CtElement>- Parameters:
candidate- the candidate- Returns:
- true if the candidate is to be processed by the
Processor.process(CtElement)
-
initProperties
Helper method to initialize the properties of a given processor.- Specified by:
initPropertiesin interfaceProcessor<E extends CtElement>- See Also:
Environment.getProcessorProperties(String)
-
process
public final void process()The manual meta-model processing cannot be overridden (useAbstractManualProcessor) to do so. -
processingDone
public void processingDone()Description copied from interface:ProcessorThis method is called by theProcessingManagerwhen 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 (seeProcessingManager.addProcessor(Class)). Does nothing by default.- Specified by:
processingDonein interfaceProcessor<E extends CtElement>
-
removeProcessedElementType
Removes a processed element type. -
setFactory
Description copied from interface:FactoryAccessorSets the factory object.- Specified by:
setFactoryin interfaceFactoryAccessor
-
interrupt
public void interrupt()Description copied from interface:ProcessorInterrupts 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 theProcessingManager.
-