Class 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
  • Method Details

    • dispose

      public void dispose()
      Called when the Java source is disposed of.
      Specified by:
      dispose in class JavaSourceFileProcessor<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 class JavaSourceFileProcessor<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 class JavaSourceFileProcessor<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 class JavaSourceFileProcessor<TypesContainer>
    • isReparseRequired

      public boolean isReparseRequired()
      Checks if reparsing is required at startup.
      Overrides:
      isReparseRequired in class JavaSourceFileProcessor<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 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 class JavaSourceFileProcessor<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:
      reconcile in class JavaSourceFileProcessor<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:
      validateClass in class JavaSourceFileProcessor<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:
      validateMethod in class JavaSourceFileProcessor<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:
      getAvailableMethods in class JavaSourceFileProcessor<TypesContainer>
      Parameters:
      list - List filled in with info upon return.
      clazz - The class to search in for the instanceAnnotation.
      instanceAnnotation - The instance annotation to search the class for, null for none.
      staticAnnotation - Static annotation to search classes for static methods.