use of com.intellij.openapi.diff.impl.highlighting.FragmentSide in project intellij-community by JetBrains.
the class MergeList method addActions.
private void addActions(@NotNull final FragmentSide side) {
ChangeList changeList = getChanges(side);
final FragmentSide originalSide = BRANCH_SIDE;
for (int i = 0; i < changeList.getCount(); i++) {
final Change change = changeList.getChange(i);
if (!change.canHasActions(originalSide))
continue;
Icon arrowIcon = side == FragmentSide.SIDE1 ? AllIcons.Diff.ArrowRight : AllIcons.Diff.Arrow;
AnAction applyAction = new DumbAwareAction(DiffBundle.message("merge.dialog.apply.change.action.name"), null, arrowIcon) {
@Override
public void actionPerformed(@Nullable AnActionEvent e) {
apply(change);
}
};
AnAction ignoreAction = new DumbAwareAction(DiffBundle.message("merge.dialog.ignore.change.action.name"), null, AllIcons.Diff.Remove) {
@Override
public void actionPerformed(@Nullable AnActionEvent e) {
change.removeFromList();
}
};
change.getChangeSide(originalSide).getHighlighterHolder().setActions(new AnAction[] { applyAction, ignoreAction });
}
}
use of com.intellij.openapi.diff.impl.highlighting.FragmentSide in project intellij-community by JetBrains.
the class MergeSearchHelper method changeAtOffset.
private Change changeAtOffset(Iterator<Change> iterator, int offset) {
while (iterator.hasNext()) {
Change change = iterator.next();
FragmentSide side = chooseInterestedSide(change);
if (side == null)
continue;
if (change.getChangeSide(side).contains(offset))
return change;
}
return null;
}
use of com.intellij.openapi.diff.impl.highlighting.FragmentSide in project intellij-community by JetBrains.
the class FragmentHighlighterImpl method addModifyActions.
private static void addModifyActions(final LineFragment fragment, DiffMarkup wrapper, DiffMarkup otherWrapper) {
if (fragment.isEqual())
return;
if (fragment.isHasLineChildren())
return;
FragmentSide side = wrapper.getSide();
TextRange range = fragment.getRange(side);
TextRange otherRange = fragment.getRange(side.otherSide());
Document document = wrapper.getDocument();
Document otherDocument = otherWrapper.getDocument();
wrapper.addAction(MergeOperations.mostSensible(document, otherDocument, range, otherRange, side), range.getStartOffset());
otherWrapper.addAction(MergeOperations.mostSensible(otherDocument, document, otherRange, range, side.otherSide()), otherRange.getStartOffset());
}
use of com.intellij.openapi.diff.impl.highlighting.FragmentSide in project intellij-community by JetBrains.
the class Change method apply.
/**
* Apply the change, i.e. change the "Merge result" document and update range markers, highlighting, gutters, etc.
* @param original The source side of the change, which is being applied.
*/
private void apply(@NotNull FragmentSide original) {
FragmentSide targetSide = original.otherSide();
RangeMarker originalRangeMarker = getRangeMarker(original);
RangeMarker rangeMarker = getRangeMarker(targetSide);
TextRange textRange = modifyDocument(getProject(), originalRangeMarker, rangeMarker);
if (textRange != null && isValid()) {
updateTargetRangeMarker(targetSide, textRange);
}
onApplied();
}
use of com.intellij.openapi.diff.impl.highlighting.FragmentSide in project intellij-community by JetBrains.
the class Change method canHasActions.
public boolean canHasActions(FragmentSide fromSide) {
FragmentSide targetSide = fromSide.otherSide();
Document targetDocument = getChangeList().getDocument(targetSide);
if (!targetDocument.isWritable())
return false;
Editor targetEditor = getHighlighterHolder(targetSide).getEditor();
return !targetEditor.isViewer();
}
Aggregations