Package com.iizigo.java.parser.type
Class TypeFileProcessor
java.lang.Object
com.iizigo.java.parser.JavaSourceFileProcessor<TypesContainer>
com.iizigo.java.parser.type.TypeFileProcessor
Class parsing a Java source file to syntax-check and reference validation of classes and methods to the IIZI property tree as well as re-factoring of the Java source code when properties are changed.
- Author:
- Christopher Mindus
Field Summary
Fields inherited from class com.iizigo.java.parser.JavaSourceFileProcessor
container, javaSourceMethod Summary
Modifier and TypeMethodDescriptioncreatePropertyContainer(ParsedJavaSource javaSource) Creates the property container for the data required by the processor when no saved XML is present at load-time.voiddispose()Called when the Java source is disposed of.protected voidgetAvailableMethods(ArrayList<String> list, org.eclipse.jdt.core.IType clazz, String instanceAnnotation, String staticAnnotation) Gets the list of methods that can match the specified annotations.getTypes()Gets all types.booleanChecks if reparsing is required at startup.voidCalled when the property container has been loaded from XML and should be initiated for specialized data for the processor, e.g.voidCalled when a cloned property container has been restored because a Java source file has been edited and then closed without saving.voidparse(org.eclipse.jdt.core.dom.CompilationUnit cu) 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.voidreconcile(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.validateClass(org.eclipse.jdt.core.IType type, String implementsInterface, String requiredAnnotation, String annotationParam, String annotationValue) Validates the class for the interface and annotation.protected MethodLookupvalidateMethod(org.eclipse.jdt.core.IType type, String method, boolean isStatic, String requiredAnnotation, String annotationParam, String annotationValue, boolean allowAll) Validates the method for the annotation.Methods inherited from class com.iizigo.java.parser.JavaSourceFileProcessor
getEngine, initialize, internalRestoreContainerClone, isRefactorRequired, onJavaSourceMoved, onJavaSourceRemoved, onRefactorCommit, onRefactoringChange, onRestoredState
Method Details
dispose
public void dispose()Called when the Java source is disposed of.- Specified by:
disposein classJavaSourceFileProcessor<TypesContainer>
createPropertyContainer
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
JavaSourcein this call.- Specified by:
createPropertyContainerin classJavaSourceFileProcessor<TypesContainer>- 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
JavaSourcein this call.- Specified by:
onInitializein classJavaSourceFileProcessor<TypesContainer>
onRestoreContainerClone
public void onRestoreContainerClone()Called when a cloned property container has been restored because a Java source file has been edited and then closed without saving. This is done in order to revert the reconciled changes that may apply after the original parsing.- Overrides:
onRestoreContainerClonein classJavaSourceFileProcessor<TypesContainer>
isReparseRequired
public boolean isReparseRequired()Checks if reparsing is required at startup.- Overrides:
isReparseRequiredin classJavaSourceFileProcessor<TypesContainer>- Returns:
- false by default, override to process and return true as required.
getTypes
Gets all types.parse
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:
parsein classJavaSourceFileProcessor<TypesContainer>- Parameters:
cu- The compilation unit.- Throws:
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:
reconcilein classJavaSourceFileProcessor<TypesContainer>- Parameters:
context- The reconcile context to act on.
validateClass
public String validateClass(org.eclipse.jdt.core.IType type, String implementsInterface, String requiredAnnotation, String annotationParam, String annotationValue) Validates the class for the interface and annotation.- Overrides:
validateClassin classJavaSourceFileProcessor<TypesContainer>- Parameters:
implementsInterface- The interface required, or null for none.requiredAnnotation- The required annotation, or null for none.annotationParam- Parameter member value pair to verify the value with for back-referencing, null for none.annotationValue- The value to match for back-referencing, null for none.- Returns:
- null for OK, otherwise an error message, or NOT_PROCESSED.
validateMethod
protected MethodLookup validateMethod(org.eclipse.jdt.core.IType type, String method, boolean isStatic, String requiredAnnotation, String annotationParam, String annotationValue, boolean allowAll) Validates the method for the annotation.- Overrides:
validateMethodin classJavaSourceFileProcessor<TypesContainer>- Parameters:
type- The class.method- The method name.isStatic- Method must be static flag.requiredAnnotation- The required annotation, or null for none.annotationParam- Parameter member value pair to verify the value with for back-referencing, null for none.annotationValue- The value to match for back-referencing, null for none.allowAll- Flag to allow a ref "*" as back-reference.- Returns:
- The MethodLookup instance.
getAvailableMethods
protected void getAvailableMethods(ArrayList<String> list, org.eclipse.jdt.core.IType clazz, String instanceAnnotation, String staticAnnotation) Gets the list of methods that can match the specified annotations.- Overrides:
getAvailableMethodsin classJavaSourceFileProcessor<TypesContainer>- Parameters:
list- List filled in with info upon return.clazz- The class to search in for theinstanceAnnotation.instanceAnnotation- The instance annotation to search the class for, null for none.staticAnnotation- Static annotation to search classes for static methods.