Package com.iizigo.java.parser.type
Class TypeFileProcessor
- java.lang.Object
-
- com.iizigo.java.parser.JavaSourceFileProcessor<TypesContainer>
-
- com.iizigo.java.parser.type.TypeFileProcessor
-
public class TypeFileProcessor extends JavaSourceFileProcessor<TypesContainer>
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, javaSource
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TypesContainer
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.protected void
getAvailableMethods(java.util.ArrayList<java.lang.String> list, org.eclipse.jdt.core.IType clazz, java.lang.String instanceAnnotation, java.lang.String staticAnnotation)
Gets the list of methods that can match the specified annotations.IzTypeDeclaration[]
getTypes()
Gets all types.boolean
isReparseRequired()
Checks if reparsing is required at startup.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
onRestoreContainerClone()
Called when a cloned property container has been restored because a Java source file has been edited and then closed without saving.void
parse(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.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.java.lang.String
validateClass(org.eclipse.jdt.core.IType type, java.lang.String implementsInterface, java.lang.String requiredAnnotation, java.lang.String annotationParam, java.lang.String annotationValue)
Validates the class for the interface and annotation.protected MethodLookup
validateMethod(org.eclipse.jdt.core.IType type, java.lang.String method, boolean isStatic, java.lang.String requiredAnnotation, java.lang.String annotationParam, java.lang.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 Detail
-
dispose
public void dispose()
Called when the Java source is disposed of.- Specified by:
dispose
in classJavaSourceFileProcessor<TypesContainer>
-
createPropertyContainer
public TypesContainer 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<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
JavaSource
in this call.- Specified by:
onInitialize
in 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:
onRestoreContainerClone
in classJavaSourceFileProcessor<TypesContainer>
-
isReparseRequired
public boolean isReparseRequired()
Checks if reparsing is required at startup.- Overrides:
isReparseRequired
in classJavaSourceFileProcessor<TypesContainer>
- Returns:
- false by default, override to process and return true as required.
-
getTypes
public IzTypeDeclaration[] getTypes()
Gets all types.
-
parse
public void parse(org.eclipse.jdt.core.dom.CompilationUnit cu) 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<TypesContainer>
- Parameters:
cu
- 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<TypesContainer>
- Parameters:
context
- The reconcile context to act on.
-
validateClass
public java.lang.String validateClass(org.eclipse.jdt.core.IType type, java.lang.String implementsInterface, java.lang.String requiredAnnotation, java.lang.String annotationParam, java.lang.String annotationValue)
Validates the class for the interface and annotation.- Overrides:
validateClass
in 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, java.lang.String method, boolean isStatic, java.lang.String requiredAnnotation, java.lang.String annotationParam, java.lang.String annotationValue, boolean allowAll)
Validates the method for the annotation.- Overrides:
validateMethod
in classJavaSourceFileProcessor<TypesContainer>
- Parameters:
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.type
- The class.- Returns:
- The MethodLookup instance.
-
getAvailableMethods
protected void getAvailableMethods(java.util.ArrayList<java.lang.String> list, org.eclipse.jdt.core.IType clazz, java.lang.String instanceAnnotation, java.lang.String staticAnnotation)
Gets the list of methods that can match the specified annotations.- Overrides:
getAvailableMethods
in 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.
-
-