use of com.intellij.openapi.vcs.ex.Range in project intellij-community by JetBrains.
the class ShowChangeMarkerAction method actionPerformed.
@Override
protected void actionPerformed(@NotNull VcsContext context) {
Editor editor = myChangeMarkerContext.getEditor(context);
LineStatusTracker lineStatusTracker = myChangeMarkerContext.getLineStatusTracker(context);
Range range = myChangeMarkerContext.getRange(context);
LineStatusTrackerDrawing.moveToRange(range, editor, lineStatusTracker);
}
use of com.intellij.openapi.vcs.ex.Range in project intellij-community by JetBrains.
the class VcsAwareFormatChangedTextUtil method calculateChangedLinesNumber.
@Override
public int calculateChangedLinesNumber(@NotNull Document document, @NotNull CharSequence contentFromVcs) {
try {
List<Range> changedRanges = getRanges(document, contentFromVcs);
int linesChanges = 0;
for (Range range : changedRanges) {
linesChanges += countLines(range);
}
return linesChanges;
} catch (FilesTooBigForDiffException e) {
LOG.info("File too big, can not calculate changed lines number");
return -1;
}
}
use of com.intellij.openapi.vcs.ex.Range in project intellij-community by JetBrains.
the class VcsAwareFormatChangedTextUtil method getChangedTextRanges.
@NotNull
private static ChangedRangesInfo getChangedTextRanges(@NotNull Document document, @NotNull List<Range> changedRanges) {
final List<TextRange> ranges = ContainerUtil.newArrayList();
final List<TextRange> insertedRanges = ContainerUtil.newArrayList();
for (Range range : changedRanges) {
if (range.getType() != Range.DELETED) {
int changeStartLine = range.getLine1();
int changeEndLine = range.getLine2();
int lineStartOffset = document.getLineStartOffset(changeStartLine);
int lineEndOffset = document.getLineEndOffset(changeEndLine - 1);
TextRange changedTextRange = new TextRange(lineStartOffset, lineEndOffset);
ranges.add(changedTextRange);
if (range.getType() == Range.INSERTED) {
insertedRanges.add(changedTextRange);
}
}
}
return new ChangedRangesInfo(ranges, insertedRanges);
}
use of com.intellij.openapi.vcs.ex.Range in project intellij-community by JetBrains.
the class VcsPreviewPanel method updateView.
@Override
public void updateView() {
EditorColorsScheme colorsScheme = myEditor.getColorsScheme();
StringBuilder sb = new StringBuilder();
sb.append("Deleted line below\n\n" + "Modified line\n\n" + "Added line\n\n" + "Line with modified whitespaces\n\n" + "Added line\n" + "Line with modified whitespaces and deletion after\n");
int additionalLines = Math.max(0, AnnotationsSettings.getInstance().getOrderedColors(colorsScheme).size() - StringUtil.countNewLines(sb));
sb.append(StringUtil.repeat("\n", additionalLines));
myEditor.getDocument().setText(sb);
myEditor.getMarkupModel().removeAllHighlighters();
myEditor.getGutterComponentEx().closeAllAnnotations();
addHighlighter(new Range(1, 1, 0, 1), EditorColors.DELETED_LINES_COLOR);
addHighlighter(createModifiedRange(2, Range.MODIFIED), EditorColors.MODIFIED_LINES_COLOR);
addHighlighter(createModifiedRange(4, Range.INSERTED), EditorColors.ADDED_LINES_COLOR);
addHighlighter(createModifiedRange(6, Range.EQUAL), EditorColors.WHITESPACES_MODIFIED_LINES_COLOR);
addHighlighter(createModifiedRange(8, Range.INSERTED, Range.EQUAL, Range.DELETED), EditorColors.WHITESPACES_MODIFIED_LINES_COLOR);
List<Color> annotationColors = AnnotationsSettings.getInstance().getOrderedColors(colorsScheme);
List<Integer> anchorIndexes = AnnotationsSettings.getInstance().getAnchorIndexes(colorsScheme);
myEditor.getGutterComponentEx().registerTextAnnotation(new MyTextAnnotationGutterProvider(annotationColors, anchorIndexes));
}
use of com.intellij.openapi.vcs.ex.Range in project intellij-community by JetBrains.
the class VcsPreviewPanel method createModifiedRange.
@NotNull
private static Range createModifiedRange(int currentLine, byte... inner) {
List<InnerRange> innerRanges = new ArrayList<>();
int currentInnerLine = currentLine;
for (byte type : inner) {
switch(type) {
case Range.EQUAL:
case Range.INSERTED:
case Range.MODIFIED:
innerRanges.add(new InnerRange(currentInnerLine, currentInnerLine + 1, type));
currentInnerLine++;
break;
case Range.DELETED:
innerRanges.add(new InnerRange(currentInnerLine, currentInnerLine, type));
break;
}
}
return new Range(currentLine, currentInnerLine, 0, 1, innerRanges);
}
Aggregations