| We are developing an Eclipse plugin for PlasticSCM. 
PlasticSCM is a new SCM system, like CVS, Subversion, ClearCase, etc ... More 
info in http://www.codicesoftware.com
 We 
have the following problems managing IFileModificationValidator when doing a 
refactor with org.eclipse.ltk.internal.core.refactoring plug-in. I will try to 
explain the problem in a short manner.
 
 Our checked-in files, are in 
a readOnly status. When we checkout a file to modify it, readOnly property is 
removed.When we do a refactor, our IFileModificationValidator is called and it 
checkouts all needed files. But there is a problem with readOnly properties. 
Look at this code, extracted from
 org.eclipse.ltk.internal.core.refactoring.TextFileChange 
class.
 
 01 public RefactoringStatus isValid(IProgressMonitor pm) 
throws CoreException {
 02     pm.beginTask("", 1); 
//$NON-NLS-1$
 03     ITextFileBuffer buffer = 
FileBuffers.getTextFileBufferManager().getTextFileBuffer(fFile.getFullPath());
 04     
fDirty= buffer != null && 
buffer.isDirty();
 05     RefactoringStatus result= 
fValidationState.isValid(needsSaving());
 06     if 
(needsSaving()) 
{
 07           
result.merge(Changes.validateModifiesFiles(new IFile[] 
{fFile}));
 08     } else 
{
 09           // we are 
reading the file. So it should be at least in 
sync
 10           
result.merge(Changes.checkInSync(new IFile[] 
{fFile}));
 11     }
 12     
pm.worked(1);
 13     return result;
 14 
}
 
 When this code is invoked for a checked-in file (before a call to 
our IFileModificationValidator), at line 05, the 
fValidationState.isValid(needsSaving()) call returns a fatal error because the 
involved resource is readOnly. Then, at line 07, this code call our 
IFileModification validator, where the resource is chekced out, and set to
 nonReadOnly. But is too late, because the fatal error produced on line 05, 
make that all process be aborted.
 
 The problem would be solved, if 
lines 05 and 07 are called in reverse order. If first call to 
Changes.validateModifiesFiles(new IFile[] {fFile}), this code will call our 
IFileModificationValidator code, so the readOnly property will be removed, and 
then the fValidationState.isValid(needsSaving()) will not 
fail.
 
 Somebody can help me with this problem?
 
 Thanks 
for all, and king regards
   |