Package com.iizigo.java.parser
Class ParsedJavaSource
java.lang.Object
com.iizigo.java.JavaSource
com.iizigo.java.parser.ParsedJavaSource
- All Implemented Interfaces:
- IBufferChangedListener
Class used for Parsed Java Source type.
- Author:
- Christopher Mindus
- Nested Class Summary- Nested classes/interfaces inherited from class com.iizigo.java.JavaSource- JavaSource.Type
- Field Summary- Fields inherited from class com.iizigo.java.JavaSource- NOT_PROCESSED, sourceFile
- Constructor SummaryConstructorsConstructorDescription- ParsedJavaSource- (IFile sourceFile, ModuleModel model, ParsedJavaSourceContainer container, ArrayList<IJavaSourceParser<?>> parsers) Creates a Java source instance for PARSED.
- Method SummaryModifier and TypeMethodDescription- void- addDesignerPropFromPositionInString- (int start, int length, DesignerProp dp) Adds a new StringLiteral with a DesignerProp.- voidAdds a new StringLiteral with a DesignerProp.- void- addProblem- (JavaProblem problem) Adds a categorized problem when parsing the compilation unit.- void- addProblems- (JavaProblem... problems) Adds categorized problems when parsing the compilation unit.- void- bufferChanged- (BufferChangedEvent event) For reconcile buffers, notifies that the given event has occurred.- voidClears the cache.- voidClears the signature cache.- boolean- dispose()Disposes of the Java source and all its classes.- voidDisposes of the container in order not to process further.- voidMethod to call from the JavaSource processor to flag it requires refactoring at a later stage.- void- getAvailableMethods- (ArrayList<String> list, IType clazz, String instanceAnnotation, String staticAnnotation) Gets the list of methods that can match the specified annotations.- getDesignerPropFromPositionInString- (int pos) Gets a DesignerProp from a position in the file.Gets Java source the processors.- getSimpleSignature- (IMethodBinding methodBinding) Builds the signature of a method or constructor.- getSimpleSignature- (IMethod method) Builds the signature of a method.Gets the TypeFileProcessor for the parsed file.- booleanCalled to check if refactoring is required.- boolean- isValid()Checks if the state is valid for a restore.- void- onJavaSourceMoved- (IFile newFile, String oldPKG, String newPKG) Called when a Java source has been moved or renamed.- protected boolean- onJavaSourceRemoved- (IFile file) Called when a Java source has been removed.- void- onRefactoringChange- (String classFQN, String oldFQN, String newFQN) Called from Refactoring Rename for classes or methods.- void- parse- (BuildContext context, CompilationUnit cu) Parses the file the first time when no state is present, or after a save operation.- void- reconcile- (ReconcileContext context) Called by the Java compilation participant let the processor handle the reconciled working copy.- refactor()Called to perform refactoring.- voidRemoves all problems.- voidResets the DesignerPropFromPositionInString array.- boolean- restoreState- (ICompilationUnit icu, IProgressMonitor monitor) Restores the states of the processors.- void- saveSimpleSignature- (IMethodBinding methodBinding, String signature) Saves a simple method signature.- void- saveSimpleSignature- (IMethod method, String signature) Saves a simple method signature.- voidTriggers recompile.- protected String- validateClassProcessors- (IType type, String implementsInterface, String requiredAnnotation, String annotationParam, String annotationValue) Validates the class for the interface and annotation.- protected MethodLookup- validateMethodProcessors- (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.JavaSource- getClass, getFileName, getJavaClassCount, getJavaProject, getProject, getPublicOrStaticClasses, getSourceFile, getType, isDisposed, resolveClassReferences, triggerSWTChangeEvent, validateClass, validateMethod
- Constructor Details- ParsedJavaSourcepublic ParsedJavaSource- (IFile sourceFile, ModuleModel model, ParsedJavaSourceContainer container, 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 Details- restoreStateRestores the states of the processors.- Parameters:
- icu- The compilation unit.
- monitor- Progress monitor.
- Returns:
- true for OK, false for parser failure.
 
- isValidpublic boolean isValid()Checks if the state is valid for a restore.
- getJavaSourceFileProcessorsGets Java source the processors.- Returns:
- the array of listeners, null for none.
 
- disposepublic 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:
- disposein class- JavaSource
- Returns:
- true if disposed of, false if already disposed of.
 
- disposeContainerpublic void disposeContainer()Disposes of the container in order not to process further.
- onJavaSourceRemovedCalled when a Java source has been removed.- Overrides:
- onJavaSourceRemovedin class- JavaSource
- Parameters:
- file- The file handle.
- Returns:
- true if the file belonged to this class, false otherwise.
 
- onJavaSourceMovedCalled 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:
- onJavaSourceMovedin 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.
 
- onRefactoringChangeCalled 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:
- onRefactoringChangein 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".
 
- parseParses 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.
 
- removeAllProblemspublic void removeAllProblems()Removes all problems.
- addProblemAdds a categorized problem when parsing the compilation unit. Do not call this method otherwise.
- addProblemsAdds categorized problems when parsing the compilation unit. Do not call this method otherwise.
- reconcileCalled by the Java compilation participant let the processor handle the reconciled working copy.- Parameters:
- context- The reconcile context to act on.
 
- bufferChangedFor reconcile buffers, notifies that the given event has occurred.- Specified by:
- bufferChangedin interface- IBufferChangedListener
- Parameters:
- event- The change event.
 
- flagRefactoringRequiredpublic void flagRefactoringRequired()Method to call from the JavaSource processor to flag it requires refactoring at a later stage.
- isRefactoringRequiredpublic boolean isRefactoringRequired()Called to check if refactoring is required.
- refactorCalled to perform refactoring.- Returns:
- A refactor change, or null for none.
 
- triggerRecompilepublic void triggerRecompile()Triggers recompile.
- validateClassProcessorsprotected String validateClassProcessors- (IType type, String implementsInterface, String requiredAnnotation, String annotationParam, String annotationValue) Validates the class for the interface and annotation.- Overrides:
- validateClassProcessorsin 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.
 
- validateMethodProcessorsprotected MethodLookup validateMethodProcessors- (IType type, String method, boolean isStatic, String requiredAnnotation, String annotationParam, String annotationValue, boolean allowAll) Validates the method for the annotation.- Overrides:
- validateMethodProcessorsin 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.
 
- getTypeFileProcessorGets the TypeFileProcessor for the parsed file.- Returns:
- null if not found.
 
- getAvailableMethodspublic void getAvailableMethods- (ArrayList<String> list, IType clazz, String instanceAnnotation, 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.
 
- resetDesignerPropFromPositionInStringpublic void resetDesignerPropFromPositionInString()Resets the DesignerPropFromPositionInString array.
- addDesignerPropFromPositionInStringAdds a new StringLiteral with a DesignerProp.- Parameters:
- sl- The StringLiteral.
- dp- The DesignerProp.
 
- addDesignerPropFromPositionInStringAdds a new StringLiteral with a DesignerProp.- Parameters:
- start- Start position.
- length- The length.
- dp- The DesignerProp.
 
- getDesignerPropFromPositionInStringGets a DesignerProp from a position in the file.- Parameters:
- pos- The position.
- Returns:
- The DesignerProp matching the position in a StringLiteral, null for none.
 
- clearCachepublic void clearCache()Clears the cache.- Overrides:
- clearCachein class- JavaSource
 
- clearSignatureCachepublic void clearSignatureCache()Clears the signature cache.
- getSimpleSignatureBuilds 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.
 
- getSimpleSignatureBuilds 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.
 
- saveSimpleSignatureSaves a simple method signature.- Parameters:
- method- The method.
- signature- The signature.
 
- saveSimpleSignatureSaves a simple method signature.- Parameters:
- methodBinding- The method binding.
- signature- The signature.