use of com.intellij.openapi.vcs.annotate.VcsAnnotation in project intellij-community by JetBrains.
the class VcsAnnotationCachedProxy method annotate.
/**
* @param currentRevision - just a hint for optimization
*/
private FileAnnotation annotate(VirtualFile file, final VcsRevisionNumber revisionNumber, final boolean currentRevision, final ThrowableComputable<FileAnnotation, VcsException> delegate) throws VcsException {
final AnnotationProvider annotationProvider = myAnnotationProvider;
final FilePath filePath = VcsUtil.getFilePath(file);
final VcsCacheableAnnotationProvider cacheableAnnotationProvider = (VcsCacheableAnnotationProvider) annotationProvider;
VcsAnnotation vcsAnnotation = null;
if (revisionNumber != null) {
Object cachedData = myCache.get(filePath, myVcs.getKeyInstanceMethod(), revisionNumber);
vcsAnnotation = ObjectUtils.tryCast(cachedData, VcsAnnotation.class);
}
if (vcsAnnotation != null) {
final VcsHistoryProvider historyProvider = myVcs.getVcsHistoryProvider();
final VcsAbstractHistorySession history = getHistory(revisionNumber, filePath, historyProvider, vcsAnnotation.getFirstRevision());
if (history == null)
return null;
// question is whether we need "not moved" path here?
final ContentRevision fileContent = myVcs.getDiffProvider().createFileContent(revisionNumber, file);
final FileAnnotation restored = cacheableAnnotationProvider.restore(vcsAnnotation, history, fileContent.getContent(), currentRevision, revisionNumber);
if (restored != null) {
return restored;
}
}
final FileAnnotation fileAnnotation = delegate.compute();
vcsAnnotation = cacheableAnnotationProvider.createCacheable(fileAnnotation);
if (vcsAnnotation == null)
return fileAnnotation;
if (revisionNumber != null) {
myCache.put(filePath, myVcs.getKeyInstanceMethod(), revisionNumber, vcsAnnotation);
}
if (myVcs.getVcsHistoryProvider() instanceof VcsCacheableHistorySessionFactory) {
loadHistoryInBackgroundToCache(revisionNumber, filePath, vcsAnnotation);
}
return fileAnnotation;
}
Aggregations