Class ParsedJavaSource

  • All Implemented Interfaces:
    org.eclipse.jdt.core.IBufferChangedListener

    public class ParsedJavaSource
    extends JavaSource
    implements org.eclipse.jdt.core.IBufferChangedListener
    Class used for Parsed Java Source type.
    Author:
    Christopher Mindus
    • Constructor Detail

      • ParsedJavaSource

        public ParsedJavaSource​(org.eclipse.core.resources.IFile sourceFile,
                                ModuleModel model,
                                ParsedJavaSourceContainer container,
                                java.util.ArrayList<IJavaSourceParser<?>> parsers)
        Creates a Java source instance for PARSED.
        Parameters:
        sourceFile - The file.
        model - The Module model (can be null if not a Module project).
        container - The parsed Java source container.
        parsers - The array of parsers.
    • Method Detail

      • restoreState

        public boolean restoreState​(org.eclipse.jdt.core.ICompilationUnit icu,
                                    org.eclipse.core.runtime.IProgressMonitor monitor)
        Restores the states of the processors.
        Parameters:
        icu - The compilation unit.
        monitor - Progress monitor.
        Returns:
        true for OK, false for parser failure.
      • isValid

        public boolean isValid()
        Checks if the state is valid for a restore.
      • getJavaSourceFileProcessors

        public JavaSourceFileProcessor<?>[] getJavaSourceFileProcessors()
        Gets Java source the processors.
        Returns:
        the array of listeners, null for none.
      • dispose

        public boolean dispose()
        Disposes of the Java source and all its classes. No call to Java Manager. is done, this call is initiated from there.
        Overrides:
        dispose in class JavaSource
        Returns:
        true if disposed of, false if already disposed of.
      • disposeContainer

        public void disposeContainer()
        Disposes of the container in order not to process further.
      • onJavaSourceRemoved

        protected boolean onJavaSourceRemoved​(org.eclipse.core.resources.IFile file)
        Called when a Java source has been removed.
        Overrides:
        onJavaSourceRemoved in class JavaSource
        Parameters:
        file - The file handle.
        Returns:
        true if the file belonged to this class, false otherwise.
      • onJavaSourceMoved

        public void onJavaSourceMoved​(org.eclipse.core.resources.IFile newFile,
                                      java.lang.String oldPKG,
                                      java.lang.String newPKG)
        Called when a Java source has been moved or renamed. The getSourceFile() method in JavaSource is already moved or renamed when this method is called.
        Overrides:
        onJavaSourceMoved in class JavaSource
        Parameters:
        newFile - The new file name.
        oldPKG - The old class name of the main class.
        newPKG - The new class name of the main class.
      • onRefactoringChange

        public void onRefactoringChange​(java.lang.String classFQN,
                                        java.lang.String oldFQN,
                                        java.lang.String newFQN)
        Called from Refactoring Rename for classes or methods. The "FQN" is for classes including packages, and enclosed classes are separated by '.' and not '$'. For methods, it's the name followed by ',' and "returnType(param1,..,paramN)" as JavaHelper.getSignature gives.
        Overrides:
        onRefactoringChange in class JavaSource
        Parameters:
        classFQN - The class fully qualified name, null for classes (only for methods).
        oldFQN - The old fully qualified name or "oldName,signature".
        newFQN - The new fully qualified name or "newName,signature".
      • parse

        public void parse​(org.eclipse.jdt.core.compiler.BuildContext context,
                          org.eclipse.jdt.core.dom.CompilationUnit cu)
        Parses the file the first time when no state is present, or after a save operation.
        Parameters:
        context - Context to record problems in.
        cu - The compilation unit.
      • removeAllProblems

        public void removeAllProblems()
        Removes all problems.
      • addProblem

        public void addProblem​(JavaProblem problem)
        Adds a categorized problem when parsing the compilation unit. Do not call this method otherwise.
      • addProblems

        public void addProblems​(JavaProblem... problems)
        Adds categorized problems when parsing the compilation unit. Do not call this method otherwise.
      • reconcile

        public void reconcile​(org.eclipse.jdt.core.compiler.ReconcileContext context)
        Called by the Java compilation participant let the processor handle the reconciled working copy.
        Parameters:
        context - The reconcile context to act on.
      • bufferChanged

        public void bufferChanged​(org.eclipse.jdt.core.BufferChangedEvent event)
        For reconcile buffers, notifies that the given event has occurred.
        Specified by:
        bufferChanged in interface org.eclipse.jdt.core.IBufferChangedListener
        Parameters:
        event - The change event.
      • flagRefactoringRequired

        public void flagRefactoringRequired()
        Method to call from the JavaSource processor to flag it requires refactoring at a later stage.
      • isRefactoringRequired

        public boolean isRefactoringRequired()
        Called to check if refactoring is required.
      • refactor

        public org.eclipse.ltk.core.refactoring.Change refactor()
        Called to perform refactoring.
        Returns:
        A refactor change, or null for none.
      • triggerRecompile

        public void triggerRecompile()
        Triggers recompile.
      • validateClassProcessors

        protected java.lang.String validateClassProcessors​(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:
        validateClassProcessors in class JavaSource
        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.
      • validateMethodProcessors

        protected MethodLookup validateMethodProcessors​(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:
        validateMethodProcessors in class JavaSource
        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.
        Returns:
        The MethodLookup instance, or null if not processed.
      • getTypeFileProcessor

        public TypeFileProcessor getTypeFileProcessor()
        Gets the TypeFileProcessor for the parsed file.
        Returns:
        null if not found.
      • getAvailableMethods

        public 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.
        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.
      • resetDesignerPropFromPositionInString

        public void resetDesignerPropFromPositionInString()
        Resets the DesignerPropFromPositionInString array.
      • addDesignerPropFromPositionInString

        public void addDesignerPropFromPositionInString​(org.eclipse.jdt.core.dom.StringLiteral sl,
                                                        DesignerProp dp)
        Adds a new StringLiteral with a DesignerProp.
        Parameters:
        sl - The StringLiteral.
        dp - The DesignerProp.
      • addDesignerPropFromPositionInString

        public void addDesignerPropFromPositionInString​(int start,
                                                        int length,
                                                        DesignerProp dp)
        Adds a new StringLiteral with a DesignerProp.
        Parameters:
        start - Start position.
        length - The length.
        dp - The DesignerProp.
      • getDesignerPropFromPositionInString

        public DesignerProp getDesignerPropFromPositionInString​(int pos)
        Gets a DesignerProp from a position in the file.
        Parameters:
        pos - The position.
        Returns:
        The DesignerProp matching the position in a StringLiteral, null for none.
      • clearSignatureCache

        public void clearSignatureCache()
        Clears the signature cache.
      • getSimpleSignature

        public java.lang.String getSimpleSignature​(org.eclipse.jdt.core.IMethod method)
        Builds the signature of a method.

        E.g. "void(java.lang.String,com.iizix.prop.PropCnr)" for a method, or "()" or "(com.iizix.prop.Atom)" for a constructor.

        Parameters:
        method - The method binding.
        Returns:
        The signature, or null for failure.
      • getSimpleSignature

        public java.lang.String getSimpleSignature​(org.eclipse.jdt.core.dom.IMethodBinding methodBinding)
        Builds the signature of a method or constructor.

        E.g. "void(java.lang.String,com.iizix.prop.PropCnr)" for a method, or "()" or "(com.iizix.prop.Atom)" for a constructor.

        Parameters:
        methodBinding - The method binding.
        Returns:
        The signature, or null for failure.
      • saveSimpleSignature

        public void saveSimpleSignature​(org.eclipse.jdt.core.IMethod method,
                                        java.lang.String signature)
        Saves a simple method signature.
        Parameters:
        method - The method.
        signature - The signature.
      • saveSimpleSignature

        public void saveSimpleSignature​(org.eclipse.jdt.core.dom.IMethodBinding methodBinding,
                                        java.lang.String signature)
        Saves a simple method signature.
        Parameters:
        methodBinding - The method binding.
        signature - The signature.