private FileAnnotation annotate()

in src/org/jetbrains/tfsIntegration/core/TFSAnnotationProvider.java [71:128]


  private FileAnnotation annotate(final VirtualFile file, final int changeset) throws VcsException {
    final Ref<VcsException> exception = new Ref<>();
    final Ref<FileAnnotation> result = new Ref<>();

    Runnable runnable = () -> {
      try {
        final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
        TFSProgressUtil.setIndeterminate(progressIndicator, true);
        final FilePath localPath = TfsFileUtil.getFilePath(file);

        final Collection<WorkspaceInfo> workspaces = Workstation.getInstance().findWorkspaces(localPath, false, myVcs.getProject());
        TFSProgressUtil.checkCanceled(progressIndicator);
        if (workspaces.isEmpty()) {
          exception.set(new VcsException(MessageFormat.format("Mappings not found for file ''{0}''", localPath.getPresentableUrl())));
          return;
        }

        final WorkspaceInfo workspace = workspaces.iterator().next();
        final Map<FilePath, ExtendedItem> path2item =
          workspace.getExtendedItems(Collections.singletonList(localPath), myVcs.getProject(), TFSBundle.message("loading.item"));
        if (path2item.isEmpty()) {
          exception.set(new VcsException(MessageFormat.format("''{0}'' is unversioned", localPath.getPresentableUrl())));
          return;
        }
        TFSProgressUtil.checkCanceled(progressIndicator);

        final VersionSpecBase versionSpec = changeset == CURRENT_CHANGESET
                                            ? new WorkspaceVersionSpec(workspace.getName(), workspace.getOwnerName())
                                            : new ChangesetVersionSpec(changeset);
        final List<TFSFileRevision> revisionList =
          TFSHistoryProvider.getRevisions(myVcs.getProject(), path2item.get(localPath).getSitem(), false, workspace, versionSpec);
        TFSProgressUtil.checkCanceled(progressIndicator);
        if (revisionList.isEmpty()) {
          return;
        }

        result.set(annotate(workspace, localPath, revisionList));
      }
      catch (TfsException e) {
        exception.set(new VcsException(e));
      }
      catch (VcsException e) {
        exception.set(e);
      }
    };

    if (ApplicationManager.getApplication().isDispatchThread()) {
      ProgressManager.getInstance().runProcessWithProgressSynchronously(runnable, "Computing Annotations", true, myVcs.getProject());
    }
    else {
      runnable.run();
    }

    if (!exception.isNull()) {
      throw exception.get();
    }
    return result.get();
  }