use of com.intellij.openapi.vcs.annotate.AnnotationProvider 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;
}
use of com.intellij.openapi.vcs.annotate.AnnotationProvider in project intellij-community by JetBrains.
the class AnnotateDiffViewerAction method doCreateAnnotationsLoader.
@Nullable
private static FileAnnotationLoader doCreateAnnotationsLoader(@NotNull Project project, @Nullable AbstractVcs vcs, @Nullable final VirtualFile file) {
if (vcs == null || file == null)
return null;
final AnnotationProvider annotationProvider = vcs.getAnnotationProvider();
if (annotationProvider == null)
return null;
FileStatus fileStatus = FileStatusManager.getInstance(project).getStatus(file);
if (fileStatus == FileStatus.UNKNOWN || fileStatus == FileStatus.ADDED || fileStatus == FileStatus.IGNORED) {
return null;
}
return new FileAnnotationLoader(vcs) {
@Override
public FileAnnotation compute() throws VcsException {
return annotationProvider.annotate(file);
}
};
}
Aggregations