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
ConstructorDescriptionEmpty constructor only for all processors (invoked by Spoon). -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addProcessedElementType(Class<? extends CtElement> elementType)
Adds a processed element type.protected void
Clears 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
).void
init()
This method is called to initialize the processor before each processing round.void
initProperties(ProcessorProperties properties)
Helper method to initialize the properties of a given processor.void
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 theProcessingManager
.boolean
isToBeProcessed(E candidate)
Tells if this element is to be processed (returnstrue
in the default implementation).Helper method to load the properties of the given processor (usesEnvironment.getProcessorProperties(String)
).void
process()
The manual meta-model processing cannot be overridden (useAbstractManualProcessor
) to do so.void
This method is called by theProcessingManager
when this processor has finished a full processing round on the program's model.protected void
removeProcessedElementType(Class<? extends CtElement> elementType)
Removes a processed element type.void
setFactory(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:Processor
Gets the environment of this processor.- Specified by:
getEnvironment
in interfaceProcessor<E extends CtElement>
-
getFactory
Description copied from interface:FactoryAccessor
Gets the factory of this object.- Specified by:
getFactory
in interfaceFactoryAccessor
-
getProcessedElementTypes
Description copied from interface:Processor
Gets all the element types than need to be processed.- Specified by:
getProcessedElementTypes
in interfaceProcessor<E extends CtElement>
-
loadProperties
Helper method to load the properties of the given processor (usesEnvironment.getProcessorProperties(String)
). -
getTraversalStrategy
Description copied from interface:Processor
Gets 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:
getTraversalStrategy
in interfaceProcessor<E extends CtElement>
-
init
public void init()Description copied from interface:Processor
This 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:Processor
Tells if this element is to be processed (returnstrue
in the default implementation).- Specified by:
isToBeProcessed
in 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:
initProperties
in 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:Processor
This method is called by theProcessingManager
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 (seeProcessingManager.addProcessor(Class)
). Does nothing by default.- Specified by:
processingDone
in interfaceProcessor<E extends CtElement>
-
removeProcessedElementType
Removes a processed element type. -
setFactory
Description copied from interface:FactoryAccessor
Sets the factory object.- Specified by:
setFactory
in interfaceFactoryAccessor
-
interrupt
public void interrupt()Description copied from interface:Processor
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 theProcessingManager
.
-