Package com.iizigo.java.parser.test
Class TestProcessor
- java.lang.Object
- com.iizigo.java.parser.JavaSourceFileProcessor<TestProcessorContainer>
- com.iizigo.java.parser.test.TestProcessor
public class TestProcessor extends JavaSourceFileProcessor<TestProcessorContainer>
Field Summary
Fields inherited from class com.iizigo.java.parser.JavaSourceFileProcessor
container, javaSource
Constructor Summary
Constructors Constructor Description TestProcessor(IJavaSourceParser<TestProcessorContainer> engine)
Default constructor.
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TestProcessorContainer
createPropertyContainer(ParsedJavaSource javaSource)
Creates the property container for the data required by the processor when no saved XML is present at load-time.void
dispose()
Called when the Java source is disposed of.static void
initialize()
boolean
isRefactorRequired()
Checks if this parser needs to refactor something.void
onInitialize()
Called when the property container has been loaded from XML and should be initiated for specialized data for the processor, e.g.void
onJavaSourceMoved(org.eclipse.core.resources.IFile oldFile, org.eclipse.core.resources.IFile newFile, java.lang.String oldPKG, java.lang.String newPKG)
Called when a Java source has been moved or renamed.void
onJavaSourceRemoved(org.eclipse.core.resources.IFile file)
Called when a Java source has been removed.void
onRefactorCommit(org.eclipse.text.edits.MultiTextEdit fileChangeRootEdit)
Called when the refactoring on each source is to be performed.void
parse(org.eclipse.jdt.core.dom.CompilationUnit compilationUnit)
Called to parse the Java source at load and when the Java compiler runs, using an AST compilation unit and a flag indicating if the compilation unit contains annotations.void
reconcile(org.eclipse.jdt.core.compiler.ReconcileContext context, org.eclipse.jdt.core.dom.CompilationUnit cu)
Called by the Java compilation participant let the processor handle the reconciled working copy.Methods inherited from class com.iizigo.java.parser.JavaSourceFileProcessor
getAvailableMethods, getEngine, initialize, internalRestoreContainerClone, isReparseRequired, onRefactoringChange, onRestoreContainerClone, onRestoredState, validateClass, validateMethod
Constructor Detail
TestProcessor
public TestProcessor(IJavaSourceParser<TestProcessorContainer> engine)
Default constructor.
Method Detail
initialize
public static void initialize()
createPropertyContainer
public TestProcessorContainer createPropertyContainer(ParsedJavaSource javaSource)
Creates the property container for the data required by the processor when no saved XML is present at load-time. The container should NOT be added to any other property container, it should remain orphan, and it is NOT required to have an Atom name, i.e. it can be unnamed.The processor should save the reference to
JavaSource
in this call.- Specified by:
createPropertyContainer
in classJavaSourceFileProcessor<TestProcessorContainer>
- Parameters:
javaSource
- The Java source.- Returns:
- The container instance, or null if non is required.
onInitialize
public void onInitialize()
Called when the property container has been loaded from XML and should be initiated for specialized data for the processor, e.g. setting up instance references to the children properties, reference to the processor itself.The processor should save the reference to
JavaSource
in this call.- Specified by:
onInitialize
in classJavaSourceFileProcessor<TestProcessorContainer>
dispose
public void dispose()
Called when the Java source is disposed of.- Specified by:
dispose
in classJavaSourceFileProcessor<TestProcessorContainer>
onJavaSourceMoved
public void onJavaSourceMoved(org.eclipse.core.resources.IFile oldFile, org.eclipse.core.resources.IFile newFile, java.lang.String oldPKG, java.lang.String newPKG)
Called when a Java source has been moved or renamed. ThegetSourceFile()
method in JavaSource is already moved or renamed when this method is called.Subclasses can override this method to perform reference updates.
- Overrides:
onJavaSourceMoved
in classJavaSourceFileProcessor<TestProcessorContainer>
- Parameters:
oldFile
- The old file name.newFile
- The new file name.oldPKG
- The old package name of the main class.newPKG
- The new package name of the main class.
onJavaSourceRemoved
public void onJavaSourceRemoved(org.eclipse.core.resources.IFile file)
Called when a Java source has been removed.Subclasses can override this method to perform reference updates.
- Overrides:
onJavaSourceRemoved
in classJavaSourceFileProcessor<TestProcessorContainer>
- Parameters:
file
- The file.
parse
public void parse(org.eclipse.jdt.core.dom.CompilationUnit compilationUnit) throws org.eclipse.core.runtime.CoreException
Called to parse the Java source at load and when the Java compiler runs, using an AST compilation unit and a flag indicating if the compilation unit contains annotations.- Overrides:
parse
in classJavaSourceFileProcessor<TestProcessorContainer>
- Parameters:
compilationUnit
- The compilation unit.- Throws:
org.eclipse.core.runtime.CoreException
- For errors with e.g. removing markers.
reconcile
public void reconcile(org.eclipse.jdt.core.compiler.ReconcileContext context, org.eclipse.jdt.core.dom.CompilationUnit cu)
Called by the Java compilation participant let the processor handle the reconciled working copy.- Overrides:
reconcile
in classJavaSourceFileProcessor<TestProcessorContainer>
- Parameters:
context
- The reconcile context to act on.
isRefactorRequired
public boolean isRefactorRequired()
Checks if this parser needs to refactor something.- Overrides:
isRefactorRequired
in classJavaSourceFileProcessor<TestProcessorContainer>
- Returns:
- true to let the framework perform a grouped refactoring when the RefactorCommit event is received and processed by it.
onRefactorCommit
public void onRefactorCommit(org.eclipse.text.edits.MultiTextEdit fileChangeRootEdit)
Called when the refactoring on each source is to be performed.When this method is called, refactoring the code for a plain text file using positions would look like:
ReplaceEdit edit=new ReplaceEdit(offset,length,string); fileChangeRootEdit.addChild(edit);
- Overrides:
onRefactorCommit
in classJavaSourceFileProcessor<TestProcessorContainer>
- Parameters:
fileChangeRootEdit
- The root edit of the Java file change.