Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-team-dev] ResourceRuleFactory.modifyRule()

Hello,

Hope someone can shed some light here. In 3.2 the method in subj returns
workspace root when supplied resource is a project while in previous
releases it just returned the project itself. The javadoc for this method is
somewhat misleading:

	/**
	 * Default implementation of
<code>IResourceRuleFactory#modifyRule</code>.
	 * This default implementation returns the resource being modified,
or the
	 * parent resource if modifying a project description file.
	 * Note that this must encompass any rule required by the
<code>validateSave</code> hook.
	 * <p>
	 * Subclasses may override this method. The rule provided by an
overriding 
	 * method must at least contain the rule from this default
implementation.
	 * 
	 * @see
org.eclipse.core.runtime.jobs.ISchedulingRule#contains(org.eclipse.core.runt
ime.jobs.ISchedulingRule)
	 * @see
org.eclipse.core.resources.IResourceRuleFactory#modifyRule(IResource)
	 * @see IFileModificationValidator#validateSave(IFile)
	 * @see IProjectDescription#DESCRIPTION_FILE_NAME
	 */
	public ISchedulingRule modifyRule(IResource resource) {
		//modifying the project description requires the root
		if (resource.getType() == IResource.PROJECT)
			return workspace.getRoot();
		IPath path = resource.getFullPath();
		//modifying the project description may cause linked
resources to be created or deleted
		if (path.segmentCount() == 2 &&
path.segment(1).equals(IProjectDescription.DESCRIPTION_FILE_NAME))
			return parent(resource);
		return resource;
	}

First it is incorrect in that it does not reflect the case when the supplied
resource is a project. Second it suggests that all derived rule factories
must be pessimistic in case of projects and essentially project level
operations should lock the whole workspace according to the current
implementation, is this intended?

My real question is if it is safe to use project as a rule just like it was
in pre 3.2 releases.

Thanks and regards,
Vladimir.



Back to the top