Search in sources :

Example 1 with TextDiffType

use of com.intellij.diff.util.TextDiffType in project intellij-community by JetBrains.

the class LineStatusMarkerPopup method createEditorComponent.

@Nullable
private EditorFragmentComponent createEditorComponent(@Nullable FileType fileType, @Nullable List<DiffFragment> wordDiff) {
    if (myRange.getType() == Range.INSERTED)
        return null;
    EditorEx uEditor = (EditorEx) EditorFactory.getInstance().createViewer(myTracker.getVcsDocument(), myTracker.getProject());
    uEditor.setColorsScheme(myEditor.getColorsScheme());
    DiffUtil.setEditorCodeStyle(myTracker.getProject(), uEditor, fileType);
    EditorHighlighterFactory highlighterFactory = EditorHighlighterFactory.getInstance();
    uEditor.setHighlighter(highlighterFactory.createEditorHighlighter(myTracker.getProject(), getFileName(myTracker.getDocument())));
    if (wordDiff != null) {
        int vcsStartShift = myTracker.getVcsTextRange(myRange).getStartOffset();
        for (DiffFragment fragment : wordDiff) {
            int vcsStart = vcsStartShift + fragment.getStartOffset1();
            int vcsEnd = vcsStartShift + fragment.getEndOffset1();
            TextDiffType type = getDiffType(fragment);
            DiffDrawUtil.createInlineHighlighter(uEditor, vcsStart, vcsEnd, type);
        }
    }
    EditorFragmentComponent fragmentComponent = EditorFragmentComponent.createEditorFragmentComponent(myEditor.getContentComponent(), uEditor, myRange.getVcsLine1(), myRange.getVcsLine2(), false, false);
    EditorFactory.getInstance().releaseEditor(uEditor);
    return fragmentComponent;
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx) DiffFragment(com.intellij.diff.fragments.DiffFragment) EditorFragmentComponent(com.intellij.codeInsight.hint.EditorFragmentComponent) TextDiffType(com.intellij.diff.util.TextDiffType) EditorHighlighterFactory(com.intellij.openapi.editor.highlighter.EditorHighlighterFactory) HintHint(com.intellij.ui.HintHint) LightweightHint(com.intellij.ui.LightweightHint) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with TextDiffType

use of com.intellij.diff.util.TextDiffType in project intellij-community by JetBrains.

the class LineStatusMarkerPopup method installMasterEditorHighlighters.

private void installMasterEditorHighlighters(@Nullable List<DiffFragment> wordDiff, @NotNull Disposable parentDisposable) {
    if (wordDiff == null)
        return;
    final List<RangeHighlighter> highlighters = new ArrayList<>();
    int currentStartShift = myTracker.getCurrentTextRange(myRange).getStartOffset();
    for (DiffFragment fragment : wordDiff) {
        int currentStart = currentStartShift + fragment.getStartOffset2();
        int currentEnd = currentStartShift + fragment.getEndOffset2();
        TextDiffType type = getDiffType(fragment);
        highlighters.addAll(DiffDrawUtil.createInlineHighlighter(myEditor, currentStart, currentEnd, type));
    }
    Disposer.register(parentDisposable, new Disposable() {

        @Override
        public void dispose() {
            for (RangeHighlighter highlighter : highlighters) {
                highlighter.dispose();
            }
        }
    });
}
Also used : Disposable(com.intellij.openapi.Disposable) RangeHighlighter(com.intellij.openapi.editor.markup.RangeHighlighter) DiffFragment(com.intellij.diff.fragments.DiffFragment) ArrayList(java.util.ArrayList) TextDiffType(com.intellij.diff.util.TextDiffType) HintHint(com.intellij.ui.HintHint) LightweightHint(com.intellij.ui.LightweightHint)

Aggregations

DiffFragment (com.intellij.diff.fragments.DiffFragment)2 TextDiffType (com.intellij.diff.util.TextDiffType)2 HintHint (com.intellij.ui.HintHint)2 LightweightHint (com.intellij.ui.LightweightHint)2 EditorFragmentComponent (com.intellij.codeInsight.hint.EditorFragmentComponent)1 Disposable (com.intellij.openapi.Disposable)1 EditorEx (com.intellij.openapi.editor.ex.EditorEx)1 EditorHighlighterFactory (com.intellij.openapi.editor.highlighter.EditorHighlighterFactory)1 RangeHighlighter (com.intellij.openapi.editor.markup.RangeHighlighter)1 ArrayList (java.util.ArrayList)1 Nullable (org.jetbrains.annotations.Nullable)1