use of com.intellij.openapi.vcs.history.VcsFileRevision in project intellij-community by JetBrains.
the class FileAnnotation method createDefaultPreviousFileRevisionProvider.
@Nullable
private static PreviousFileRevisionProvider createDefaultPreviousFileRevisionProvider(@NotNull FileAnnotation annotation) {
List<VcsFileRevision> revisions = annotation.getRevisions();
if (revisions == null)
return null;
Map<VcsRevisionNumber, VcsFileRevision> map = new HashMap<>();
for (int i = 0; i < revisions.size(); i++) {
VcsFileRevision revision = revisions.get(i);
VcsFileRevision previousRevision = i + 1 < revisions.size() ? revisions.get(i + 1) : null;
map.put(revision.getRevisionNumber(), previousRevision);
}
List<VcsFileRevision> lineToRevision = new ArrayList<>(annotation.getLineCount());
for (int i = 0; i < annotation.getLineCount(); i++) {
lineToRevision.add(map.get(annotation.getLineRevisionNumber(i)));
}
VcsFileRevision lastRevision = ContainerUtil.getFirstItem(revisions);
return new PreviousFileRevisionProvider() {
@Nullable
@Override
public VcsFileRevision getPreviousRevision(int lineNumber) {
LOG.assertTrue(lineNumber >= 0 && lineNumber < lineToRevision.size());
return lineToRevision.get(lineNumber);
}
@Nullable
@Override
public VcsFileRevision getLastRevision() {
return lastRevision;
}
};
}
use of com.intellij.openapi.vcs.history.VcsFileRevision in project intellij-community by JetBrains.
the class AnnotateRevisionAction method getFile.
@Nullable
@Override
protected VirtualFile getFile(@NotNull AnActionEvent e) {
VcsFileRevision revision = getFileRevision(e);
if (revision == null)
return null;
final FileType currentFileType = myAnnotation.getFile().getFileType();
FilePath filePath = (revision instanceof VcsFileRevisionEx ? ((VcsFileRevisionEx) revision).getPath() : VcsUtil.getFilePath(myAnnotation.getFile()));
return new VcsVirtualFile(filePath.getPath(), revision, VcsFileSystem.getInstance()) {
@NotNull
@Override
public FileType getFileType() {
FileType type = super.getFileType();
if (!type.isBinary())
return type;
if (!currentFileType.isBinary())
return currentFileType;
return PlainTextFileType.INSTANCE;
}
};
}
use of com.intellij.openapi.vcs.history.VcsFileRevision in project intellij-community by JetBrains.
the class AnnotateRevisionActionBase method actionPerformed.
@Override
public void actionPerformed(@NotNull final AnActionEvent e) {
final VcsFileRevision fileRevision = getFileRevision(e);
final VirtualFile file = getFile(e);
final AbstractVcs vcs = getVcs(e);
annotate(notNull(file), notNull(fileRevision), notNull(vcs), getEditor(e), getAnnotatedLine(e));
}
use of com.intellij.openapi.vcs.history.VcsFileRevision in project intellij-community by JetBrains.
the class AnnotateToggleAction method computeLineNumbers.
@Nullable
private static Map<VcsRevisionNumber, Integer> computeLineNumbers(@NotNull FileAnnotation fileAnnotation) {
final Map<VcsRevisionNumber, Integer> numbers = new HashMap<>();
final List<VcsFileRevision> fileRevisionList = fileAnnotation.getRevisions();
if (fileRevisionList != null) {
int size = fileRevisionList.size();
for (int i = 0; i < size; i++) {
VcsFileRevision revision = fileRevisionList.get(i);
final VcsRevisionNumber number = revision.getRevisionNumber();
numbers.put(number, size - i);
}
}
return numbers.size() < 2 ? null : numbers;
}
use of com.intellij.openapi.vcs.history.VcsFileRevision in project intellij-community by JetBrains.
the class FileAnnotation method createDefaultAuthorsMappingProvider.
@Nullable
private static AuthorsMappingProvider createDefaultAuthorsMappingProvider(@NotNull FileAnnotation annotation) {
List<VcsFileRevision> revisions = annotation.getRevisions();
if (revisions == null)
return null;
Map<VcsRevisionNumber, String> authorsMapping = new HashMap<>();
for (VcsFileRevision revision : revisions) {
String author = revision.getAuthor();
if (author != null)
authorsMapping.put(revision.getRevisionNumber(), author);
}
return () -> authorsMapping;
}
Aggregations