Package com.iizigo.java
Class JavaManager
java.lang.Object
com.iizigo.project.FileChangesCollection
com.iizigo.java.JavaManager
- All Implemented Interfaces:
IFolderFileChangeListener
,org.eclipse.core.resources.IResourceDeltaVisitor
,org.eclipse.core.resources.IResourceVisitor
Class used to listen to workspace changes file in any Java project.
- Author:
- Christopher Mindus
Field Summary
Fields inherited from class com.iizigo.project.FileChangesCollection
description, monitor, projectManager
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds a resource change listener for Java projects.void
addParser
(IJavaSourceParser<?> parser) Adds a parser.void
clean
(org.eclipse.jdt.core.IJavaProject javaProject) Cleans a project, called by the Java Compilation participant.void
dispose()
Called when disposed of.boolean
doesJavaProjectNeedRebuild
(org.eclipse.core.resources.IProject project) Checks if a Java project needs rebuild or not, i.e.void
Call causing entering of refactoring operation, called from operations that perform "workspace threaded" operation such as moving resources affecting refactoring.void
Exiting a refactor-hold operation (after a call to "enterRefactorHold").void
A JavaSource flags the requirement for a refactoring operation.Gets a new array of all ParsedJavaSource files containing a TypeFileProcessor and are valid.getAvailableMethods
(org.eclipse.jdt.core.IType clazz, String instanceAnnotation, String staticAnnotation) Gets the list of methods that can match the specified annotations.getFullyQualifiedName
(org.eclipse.core.resources.IContainer folder) Gets the fully qualified package name for a folder.getFullyQualifiedName
(org.eclipse.core.runtime.IPath rootPath) From a full path (from the workspace root), get the fully qualified name of the package.static JavaManager
Gets the instance of the singleton.getJavaProject
(org.eclipse.core.resources.IProject project) Gets or creates new Java project for a project.org.eclipse.core.resources.IFolder[]
getJavaSourceFolders
(org.eclipse.core.resources.IProject project) Gets the cached Java source folders for a project.getParsedJavaSource
(org.eclipse.core.resources.IResource resource) Gets a ParsedJavaSource instance from a resource.getParsedJavaSource
(org.eclipse.jdt.core.IType type) Gets a ParsedJavaSource instance from a type.String[]
Gets the parser plug-in IDs.Gets all the JavaClasses available in all projects that are parsed.Gets the pure Java projects, i.e.protected boolean
isFileProcessed
(org.eclipse.core.resources.IFile file) Checks if file is processed.void
loadJavaState
(ModuleModel model, org.eclipse.core.runtime.IProgressMonitor monitor) Called when a Module project is loading, to load the Java parsed files.void
onClose
(org.eclipse.core.resources.IProject project) Called from ProjectManager when a project has been closed.void
onFileAdded
(org.eclipse.core.resources.IFile file) File has been added.void
onFileChanged
(org.eclipse.core.resources.IFile file, int flags) File has been changed (markers, contents, etc).void
onFileMoved
(org.eclipse.core.resources.IFile newFile, org.eclipse.core.resources.IFile oldFile) File has been moved.void
onFileRemoved
(org.eclipse.core.resources.IFile file) File has been removed.void
onFolderAdded
(org.eclipse.core.resources.IFolder folder) Folder has been added.void
onFolderMoved
(org.eclipse.core.resources.IFolder newFolder, org.eclipse.core.resources.IFolder oldFolder) File has been moved.void
onFolderRemoved
(org.eclipse.core.resources.IFolder folder) File has been removed.void
onOpen
(ModuleModel model) Called when a Module project is opened, to register itself in the JavaProject.void
onOpen
(org.eclipse.core.resources.IProject project, org.eclipse.core.runtime.IProgressMonitor monitor) Called when a project is a Java project, assigns the root and Java containers.void
onRefactoringChange
(org.eclipse.core.resources.IFile file, String classFQN, String oldFQN, String newFQN) Called from Refactoring Rename for classes or methods.void
onRefactoringChange
(org.eclipse.core.runtime.IPath oldName, org.eclipse.core.runtime.IPath newName) Called from Refactoring Move or Rename or compilation units.boolean
Removes a resource change listener for Java projects.boolean
visitResource
(org.eclipse.core.resources.IResourceDelta delta) Processes a resource when called from ProjectManager or ModuleModel visiting...Methods inherited from class com.iizigo.project.FileChangesCollection
getFolders, getMultiStatus, isProcessed, onNewFolders, process, setMultiStatus, setNewFolders, setProgressMonitor, visit, visit
Field Details
DEBUG
public static boolean DEBUGDebug output.
Method Details
getInstance
Gets the instance of the singleton.onClose
public void onClose(org.eclipse.core.resources.IProject project) Called from ProjectManager when a project has been closed.dispose
public void dispose()Called when disposed of.doesJavaProjectNeedRebuild
public boolean doesJavaProjectNeedRebuild(org.eclipse.core.resources.IProject project) Checks if a Java project needs rebuild or not, i.e. when first opened.- Returns:
- true if a full build is required, false otherwise.
addParser
Adds a parser. This should be done as soon as possible.getParserPluginIDs
Gets the parser plug-in IDs.addJavaResourceChangeListener
Adds a resource change listener for Java projects. If the listener also implements the interfacecom.iizigo.java.IClasspathChangeListener
, it will receive notifications when the classpath is changed.- Parameters:
listener
- The listener.- Returns:
- true if successful, false for already added.
removeJavaResourceChangeListener
Removes a resource change listener for Java projects.- Parameters:
listener
- The listener.- Returns:
- true if successful, false for already added.
getJavaProject
Gets or creates new Java project for a project.- Returns:
- null if not a Java project or project is not open.
getPureJavaProjects
Gets the pure Java projects, i.e. excluding Module projects.- Returns:
- The array of projects, never null.
getJavaSourceFolders
public org.eclipse.core.resources.IFolder[] getJavaSourceFolders(org.eclipse.core.resources.IProject project) Gets the cached Java source folders for a project.- Parameters:
project
- The project.- Returns:
- null if not a Java project.
visitResource
public boolean visitResource(org.eclipse.core.resources.IResourceDelta delta) Processes a resource when called from ProjectManager or ModuleModel visiting...- Returns:
- true if the resource and children has been processed, false otherwise.
isFileProcessed
protected boolean isFileProcessed(org.eclipse.core.resources.IFile file) Checks if file is processed.- Overrides:
isFileProcessed
in classFileChangesCollection
- Parameters:
file
- The file.- Returns:
- true if file is a Java source file, false otherwise.
onFileAdded
public void onFileAdded(org.eclipse.core.resources.IFile file) throws org.eclipse.core.runtime.CoreException File has been added.- Specified by:
onFileAdded
in interfaceIFolderFileChangeListener
- Overrides:
onFileAdded
in classFileChangesCollection
- Parameters:
file
- The file.- Throws:
org.eclipse.core.runtime.CoreException
- For failures.
onFileChanged
public void onFileChanged(org.eclipse.core.resources.IFile file, int flags) throws org.eclipse.core.runtime.CoreException File has been changed (markers, contents, etc).Subclasses should override to process the event, no need to call the
super
method.- Specified by:
onFileChanged
in interfaceIFolderFileChangeListener
- Overrides:
onFileChanged
in classFileChangesCollection
- Parameters:
file
- The file.flags
- How the file was changed, from IResourceDelta, where the important ones are CONTENT, MARKERS, ENCODING, LOCAL_CHANGE, DERIVED_CHANGED, REPLACED.- Throws:
org.eclipse.core.runtime.CoreException
- For failures.
onFileMoved
public void onFileMoved(org.eclipse.core.resources.IFile newFile, org.eclipse.core.resources.IFile oldFile) throws org.eclipse.core.runtime.CoreException File has been moved.- Specified by:
onFileMoved
in interfaceIFolderFileChangeListener
- Overrides:
onFileMoved
in classFileChangesCollection
- Parameters:
newFile
- The new file.oldFile
- The old file.- Throws:
org.eclipse.core.runtime.CoreException
- For failures.
onFileRemoved
public void onFileRemoved(org.eclipse.core.resources.IFile file) throws org.eclipse.core.runtime.CoreException File has been removed.- Specified by:
onFileRemoved
in interfaceIFolderFileChangeListener
- Overrides:
onFileRemoved
in classFileChangesCollection
- Parameters:
file
- The file.- Throws:
org.eclipse.core.runtime.CoreException
- For failures.
getFullyQualifiedName
Gets the fully qualified package name for a folder.- Parameters:
folder
- The folder name.- Returns:
- The fully qualified package name, null if not inside a Java project source folder.
getFullyQualifiedName
From a full path (from the workspace root), get the fully qualified name of the package.- Parameters:
rootPath
- The root path of a folder.- Returns:
- The fully qualified package name, null if not inside a Java project source folder.
onFolderAdded
public void onFolderAdded(org.eclipse.core.resources.IFolder folder) throws org.eclipse.core.runtime.CoreException Folder has been added.Subclasses should override to process the event, no need to call the
super
method.- Specified by:
onFolderAdded
in interfaceIFolderFileChangeListener
- Overrides:
onFolderAdded
in classFileChangesCollection
- Parameters:
folder
- The folder.- Throws:
org.eclipse.core.runtime.CoreException
- For failures.
onFolderMoved
public void onFolderMoved(org.eclipse.core.resources.IFolder newFolder, org.eclipse.core.resources.IFolder oldFolder) throws org.eclipse.core.runtime.CoreException File has been moved.- Specified by:
onFolderMoved
in interfaceIFolderFileChangeListener
- Overrides:
onFolderMoved
in classFileChangesCollection
- Parameters:
newFolder
- The new folder.oldFolder
- The old folder.- Throws:
org.eclipse.core.runtime.CoreException
- For failures.
onFolderRemoved
public void onFolderRemoved(org.eclipse.core.resources.IFolder folder) throws org.eclipse.core.runtime.CoreException File has been removed.- Specified by:
onFolderRemoved
in interfaceIFolderFileChangeListener
- Overrides:
onFolderRemoved
in classFileChangesCollection
- Parameters:
folder
- The folder.- Throws:
org.eclipse.core.runtime.CoreException
- For failures.
onOpen
Called when a Module project is opened, to register itself in the JavaProject.loadJavaState
Called when a Module project is loading, to load the Java parsed files.onOpen
public void onOpen(org.eclipse.core.resources.IProject project, org.eclipse.core.runtime.IProgressMonitor monitor) Called when a project is a Java project, assigns the root and Java containers.getAllParsedSources
Gets a new array of all ParsedJavaSource files containing a TypeFileProcessor and are valid. The array can be modified without affecting anything.onRefactoringChange
public void onRefactoringChange(org.eclipse.core.runtime.IPath oldName, org.eclipse.core.runtime.IPath newName) Called from Refactoring Move or Rename or compilation units.- Parameters:
oldName
- Full path of old Java file.newName
- Full path of new Java file.
onRefactoringChange
public void onRefactoringChange(org.eclipse.core.resources.IFile file, String classFQN, String oldFQN, 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.- Parameters:
file
- Affected Java source file.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".
clean
public void clean(org.eclipse.jdt.core.IJavaProject javaProject) Cleans a project, called by the Java Compilation participant.- Parameters:
javaProject
- The project to clean.
enterRefactorHold
public void enterRefactorHold()Call causing entering of refactoring operation, called from operations that perform "workspace threaded" operation such as moving resources affecting refactoring.exitRefactorHold
public void exitRefactorHold()Exiting a refactor-hold operation (after a call to "enterRefactorHold").flagRefactoringRequired
A JavaSource flags the requirement for a refactoring operation. The refactoring requirement arises from a change in the references due to: - moved properties, using drag-drop or by dialog box (both int SWT-thread), - renamed and/or moved properties, from drag-drop or dialog box (runs in a "workspace" thread). When this is called, a refactoring operations is triggered in the- Parameters:
js
-
getParsedJavaSource
Gets a ParsedJavaSource instance from a type.- Parameters:
type
- The type.- Returns:
- The ParsedJavaSource instance, or null if not found.
getParsedJavaSource
Gets a ParsedJavaSource instance from a resource.- Parameters:
resource
- The resource, should be an IFile, otherwise it returns null.- Returns:
- The ParsedJavaSource instance, or null if not found.
getPublicOrStaticClasses
Gets all the JavaClasses available in all projects that are parsed. Matching classes are public and public static inner classes.getAvailableMethods
public List<String> getAvailableMethods(org.eclipse.jdt.core.IType clazz, String instanceAnnotation, String staticAnnotation) Gets the list of methods that can match the specified annotations.- Parameters:
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.