org.eclipse.core.internal.resources
Class AliasManager

java.lang.Object
  extended by org.eclipse.core.internal.resources.AliasManager
All Implemented Interfaces:
java.util.EventListener, ILifecycleListener, IManager, IResourceChangeListener

public class AliasManager
extends java.lang.Object
implements IManager, ILifecycleListener, IResourceChangeListener

An alias is a resource that occupies the same file system location as another resource in the workspace. When a resource is modified in a way that affects the file on disk, all aliases need to be updated. This class is used to maintain data structures for quickly computing the set of aliases for a given resource, and for efficiently updating all aliases when a resource changes on disk. The approach for computing aliases is optimized for alias-free workspaces and alias-free projects. That is, if the workspace contains no aliases, then updating should be very quick. If a resource is changed in a project that contains no aliases, it should also be very fast. The data structures maintained by the alias manager can be seen as a cache, that is, they store no information that cannot be recomputed from other available information. On shutdown, the alias manager discards all state; on startup, the alias manager eagerly rebuilds its state. The reasoning is that it's better to incur this cost on startup than on the first attempt to modify a resource. After startup, the state is updated incrementally on the following occasions: - when projects are deleted, opened, closed, or moved - when linked resources are created, deleted, or moved.


Nested Class Summary
 class AliasManager.AddToCollectionDoit
           
 
Field Summary
 org.eclipse.core.runtime.IPath suffix
          The suffix object is also used only during the computeAliases method.
 
Constructor Summary
AliasManager(Workspace workspace)
           
 
Method Summary
 IResource[] computeAliases(IResource resource, org.eclipse.core.filesystem.IFileStore location)
          Returns all aliases of the given resource, or null if there are none.
 void handleEvent(LifecycleEvent event)
           
 void resourceChanged(IResourceChangeEvent event)
          Notifies this listener that some resource changes are happening, or have already happened.
 void shutdown(org.eclipse.core.runtime.IProgressMonitor monitor)
           
 void startup(org.eclipse.core.runtime.IProgressMonitor monitor)
           
 void updateAliases(IResource resource, org.eclipse.core.filesystem.IFileStore location, int depth, org.eclipse.core.runtime.IProgressMonitor monitor)
          The file underlying the given resource has changed on disk.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

suffix

public org.eclipse.core.runtime.IPath suffix
The suffix object is also used only during the computeAliases method. In this case it is a field because it is referenced from an inner class and we want to avoid creating a pointer array. It is public to eliminate the need for synthetic accessor methods.

Constructor Detail

AliasManager

public AliasManager(Workspace workspace)
Method Detail

computeAliases

public IResource[] computeAliases(IResource resource,
                                  org.eclipse.core.filesystem.IFileStore location)
Returns all aliases of the given resource, or null if there are none.


handleEvent

public void handleEvent(LifecycleEvent event)
Specified by:
handleEvent in interface ILifecycleListener

resourceChanged

public void resourceChanged(IResourceChangeEvent event)
Description copied from interface: IResourceChangeListener
Notifies this listener that some resource changes are happening, or have already happened.

The supplied event gives details. This event object (and the resource delta within it) is valid only for the duration of the invocation of this method.

Note: This method is called by the platform; it is not intended to be called directly by clients.

Note that during resource change event notification, further changes to resources may be disallowed.

Specified by:
resourceChanged in interface IResourceChangeListener
Parameters:
event - the resource change event
See Also:
IResourceDelta

shutdown

public void shutdown(org.eclipse.core.runtime.IProgressMonitor monitor)
Specified by:
shutdown in interface IManager

startup

public void startup(org.eclipse.core.runtime.IProgressMonitor monitor)
Specified by:
startup in interface IManager

updateAliases

public void updateAliases(IResource resource,
                          org.eclipse.core.filesystem.IFileStore location,
                          int depth,
                          org.eclipse.core.runtime.IProgressMonitor monitor)
                   throws org.eclipse.core.runtime.CoreException
The file underlying the given resource has changed on disk. Compute all aliases for this resource and update them. This method will not attempt to incur any units of work on the given progress monitor, but it may update the subtask to reflect what aliases are being updated.

Parameters:
resource - the resource to compute aliases for
location - the file system location of the resource (passed as a parameter because in the project deletion case the resource is no longer accessible at time of update).
depth - whether to search for aliases on all children of the given resource. Only depth ZERO and INFINITE are used.
Throws:
org.eclipse.core.runtime.CoreException