use of org.eclipse.core.filebuffers.LocationKind in project AutoRefactor by JnRouvignac.
the class ApplyRefactoringsJob method applyRefactoring.
private void applyRefactoring(ICompilationUnit compilationUnit, AggregateASTVisitor refactoringToApply, JavaProjectOptions options, IProgressMonitor monitor) throws Exception {
final ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
final IPath path = compilationUnit.getPath();
final LocationKind locationKind = LocationKind.NORMALIZE;
try {
bufferManager.connect(path, locationKind, null);
final ITextFileBuffer textFileBuffer = bufferManager.getTextFileBuffer(path, locationKind);
if (!textFileBuffer.isSynchronized()) {
/*
* Cannot read the source when a file is not synchronized,
* Let's ignore this file to avoid problems when:
* - doing string manipulation with the source text
* - applying automated refactorings to such files
*/
environment.getLogger().error("File \"" + compilationUnit.getPath() + "\" is not synchronized with the file system." + " Automated refactorings will not be applied to it.");
return;
}
final IDocument document = textFileBuffer.getDocument();
applyRefactoring(document, compilationUnit, refactoringToApply, options, monitor);
} finally {
bufferManager.disconnect(path, locationKind, null);
}
}
Aggregations