use of org.eclipse.core.filebuffers.ITextFileBufferManager in project eclipse.jdt.ls by eclipse.
the class SerialVersionHashOperation method computeId.
private String computeId(final ASTNode declarationNode, final IProgressMonitor monitor) throws InterruptedException {
Assert.isNotNull(monitor);
long serialVersionID = SERIAL_VALUE;
try {
monitor.beginTask(CorrectionMessages.SerialVersionHashOperation_computing_id, 200);
final IJavaProject project = fCompilationUnit.getJavaProject();
final IPath path = fCompilationUnit.getResource().getFullPath();
ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
try {
bufferManager.connect(path, LocationKind.IFILE, new SubProgressMonitor(monitor, 10));
if (monitor.isCanceled()) {
throw new InterruptedException();
}
if (monitor.isCanceled()) {
throw new InterruptedException();
}
} finally {
bufferManager.disconnect(path, LocationKind.IFILE, new SubProgressMonitor(monitor, 10));
}
project.getProject().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new SubProgressMonitor(monitor, 60));
if (monitor.isCanceled()) {
throw new InterruptedException();
}
ITypeBinding typeBinding = getTypeBinding(declarationNode);
if (typeBinding != null) {
Long id = calculateSerialVersionId(typeBinding, new SubProgressMonitor(monitor, 100));
if (id != null) {
serialVersionID = id.longValue();
}
}
} catch (CoreException exception) {
JavaLanguageServerPlugin.logException(exception.getMessage(), exception);
} catch (IOException exception) {
JavaLanguageServerPlugin.logException(exception.getMessage(), exception);
} finally {
monitor.done();
}
return serialVersionID + LONG_SUFFIX;
}
use of org.eclipse.core.filebuffers.ITextFileBufferManager in project eclipse.jdt.ls by eclipse.
the class DocumentAdapter method close.
@Override
public void close() {
synchronized (lock) {
if (fIsClosed) {
return;
}
fIsClosed = true;
fDocument.removeDocumentListener(this);
if (fTextFileBuffer != null) {
try {
ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
manager.disconnect(fFile.getFullPath(), LocationKind.NORMALIZE, null);
} catch (CoreException x) {
// ignore
}
fTextFileBuffer = null;
}
fireBufferChanged(new BufferChangedEvent(this, 0, 0, null));
fBufferListeners.clear();
fDocument = null;
}
}
use of org.eclipse.core.filebuffers.ITextFileBufferManager in project eclipse.jdt.ls by eclipse.
the class DocumentAdapter method setContents.
@Override
public void setContents(String contents) {
synchronized (lock) {
if (fDocument == null) {
if (fTextFileBuffer != null) {
fDocument = fTextFileBuffer.getDocument();
} else {
ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
fDocument = manager.createEmptyDocument(fFile.getFullPath(), LocationKind.IFILE);
}
fDocument.addDocumentListener(this);
((ISynchronizable) fDocument).setLockObject(lock);
}
}
if (!contents.equals(fDocument.get())) {
fDocument.set(contents);
}
}
use of org.eclipse.core.filebuffers.ITextFileBufferManager in project jbosstools-hibernate by jbosstools.
the class NewHibernateMappingPreviewPage method performDisconnect.
protected void performDisconnect() {
final ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
for (IPath filePathTo_Show : paths2Disconnect) {
try {
bufferManager.disconnect(filePathTo_Show, LocationKind.IFILE, null);
} catch (CoreException e) {
// $NON-NLS-1$
HibernateConsolePlugin.getDefault().logErrorMessage("CoreException: ", e);
}
}
paths2Disconnect.clear();
}
use of org.eclipse.core.filebuffers.ITextFileBufferManager in project egit by eclipse.
the class IndexDiffCache method dispose.
/**
* Used by {@link Activator}
*/
public void dispose() {
if (bufferListener != null) {
ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
if (bufferManager != null) {
bufferManager.removeFileBufferListener(bufferListener);
bufferListener = null;
}
}
for (IndexDiffCacheEntry entry : entries.values()) {
entry.dispose();
}
Job.getJobManager().cancel(JobFamilies.INDEX_DIFF_CACHE_UPDATE);
try {
Job.getJobManager().join(JobFamilies.INDEX_DIFF_CACHE_UPDATE, null);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
Aggregations