Search in sources :

Example 1 with ContentRevisionVirtualFile

use of com.intellij.openapi.vcs.vfs.ContentRevisionVirtualFile in project intellij-community by JetBrains.

the class AnnotateVcsVirtualFileAction method extractData.

@Nullable
private static AnnotationData extractData(@NotNull Project project, @NotNull VirtualFile file) {
    FilePath filePath = null;
    VcsRevisionNumber revisionNumber = null;
    if (file instanceof VcsVirtualFile) {
        filePath = VcsUtil.getFilePath(file.getPath());
        VcsFileRevision revision = ((VcsVirtualFile) file).getFileRevision();
        revisionNumber = revision != null ? revision.getRevisionNumber() : null;
    } else if (file instanceof ContentRevisionVirtualFile) {
        ContentRevision revision = ((ContentRevisionVirtualFile) file).getContentRevision();
        filePath = revision.getFile();
        revisionNumber = revision.getRevisionNumber();
    }
    if (filePath == null || revisionNumber == null)
        return null;
    AbstractVcs vcs = VcsUtil.getVcsFor(project, filePath);
    return vcs != null ? new AnnotationData(vcs, filePath, revisionNumber) : null;
}
Also used : VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) ContentRevisionVirtualFile(com.intellij.openapi.vcs.vfs.ContentRevisionVirtualFile) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)1 VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)1 VcsRevisionNumber (com.intellij.openapi.vcs.history.VcsRevisionNumber)1 ContentRevisionVirtualFile (com.intellij.openapi.vcs.vfs.ContentRevisionVirtualFile)1 VcsVirtualFile (com.intellij.openapi.vcs.vfs.VcsVirtualFile)1 Nullable (org.jetbrains.annotations.Nullable)1