use of com.intellij.openapi.editor.ex.MarkupModelEx in project intellij-community by JetBrains.
the class ApplyPatchChange method createStatusHighlighter.
private void createStatusHighlighter() {
int line1 = myPatchDeletionRange.start;
int line2 = myPatchInsertionRange.end;
Color color = getStatusColor();
if (isResolved()) {
color = ColorUtil.mix(color, myViewer.getPatchEditor().getGutterComponentEx().getBackground(), 0.6f);
}
String tooltip = getStatusText();
EditorEx patchEditor = myViewer.getPatchEditor();
Document document = patchEditor.getDocument();
MarkupModelEx markupModel = patchEditor.getMarkupModel();
TextRange textRange = DiffUtil.getLinesRange(document, line1, line2);
RangeHighlighter highlighter = markupModel.addRangeHighlighter(textRange.getStartOffset(), textRange.getEndOffset(), HighlighterLayer.LAST, null, HighlighterTargetArea.LINES_IN_RANGE);
PairConsumer<Editor, MouseEvent> clickHandler = getResultRange() != null ? (e, event) -> myViewer.scrollToChange(this, Side.RIGHT, false) : null;
highlighter.setLineMarkerRenderer(LineStatusMarkerRenderer.createRenderer(line1, line2, color, tooltip, clickHandler));
myHighlighters.add(highlighter);
}
use of com.intellij.openapi.editor.ex.MarkupModelEx in project intellij-community by JetBrains.
the class RangeMarkerTest method testRangeHighlighterLinesInRangeForLongLinePerformance.
public void testRangeHighlighterLinesInRangeForLongLinePerformance() throws Exception {
final int N = 50000;
Document document = EditorFactory.getInstance().createDocument(StringUtil.repeatSymbol('x', 2 * N));
final MarkupModelEx markupModel = (MarkupModelEx) DocumentMarkupModel.forDocument(document, ourProject, true);
for (int i = 0; i < N - 1; i++) {
markupModel.addRangeHighlighter(2 * i, 2 * i + 1, 0, null, HighlighterTargetArea.EXACT_RANGE);
}
markupModel.addRangeHighlighter(N / 2, N / 2 + 1, 0, null, HighlighterTargetArea.LINES_IN_RANGE);
PlatformTestUtil.startPerformanceTest("slow highlighters lookup", (int) (N * Math.log(N) / 1000), () -> {
List<RangeHighlighterEx> list = new ArrayList<>();
CommonProcessors.CollectProcessor<RangeHighlighterEx> coll = new CommonProcessors.CollectProcessor<>(list);
for (int i = 0; i < N - 1; i++) {
list.clear();
markupModel.processRangeHighlightersOverlappingWith(2 * i, 2 * i + 1, coll);
// 1 line plus one exact range marker
assertEquals(2, list.size());
}
}).useLegacyScaling().assertTiming();
}
use of com.intellij.openapi.editor.ex.MarkupModelEx in project intellij-community by JetBrains.
the class UpdateHighlightersUtil method addHighlighterToEditorIncrementally.
static void addHighlighterToEditorIncrementally(@NotNull Project project, @NotNull Document document, @NotNull PsiFile file, int startOffset, int endOffset, @NotNull final HighlightInfo info, // if null global scheme will be used
@Nullable final EditorColorsScheme colorsScheme, final int group, @NotNull Map<TextRange, RangeMarker> ranges2markersCache) {
ApplicationManager.getApplication().assertIsDispatchThread();
if (isFileLevelOrGutterAnnotation(info))
return;
if (info.getStartOffset() < startOffset || info.getEndOffset() > endOffset)
return;
MarkupModel markup = DocumentMarkupModel.forDocument(document, project, true);
final SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(project);
final boolean myInfoIsError = isSevere(info, severityRegistrar);
Processor<HighlightInfo> otherHighlightInTheWayProcessor = oldInfo -> {
if (!myInfoIsError && isCovered(info, severityRegistrar, oldInfo)) {
return false;
}
return oldInfo.getGroup() != group || !oldInfo.equalsByActualOffset(info);
};
boolean allIsClear = DaemonCodeAnalyzerEx.processHighlights(document, project, null, info.getActualStartOffset(), info.getActualEndOffset(), otherHighlightInTheWayProcessor);
if (allIsClear) {
createOrReuseHighlighterFor(info, colorsScheme, document, group, file, (MarkupModelEx) markup, null, ranges2markersCache, severityRegistrar);
clearWhiteSpaceOptimizationFlag(document);
assertMarkupConsistent(markup, project);
}
}
use of com.intellij.openapi.editor.ex.MarkupModelEx in project intellij-community by JetBrains.
the class DaemonCodeAnalyzerEx method processHighlights.
public static boolean processHighlights(@NotNull Document document, @NotNull Project project, @Nullable("null means all") final HighlightSeverity minSeverity, final int startOffset, final int endOffset, @NotNull final Processor<HighlightInfo> processor) {
LOG.assertTrue(ApplicationManager.getApplication().isReadAccessAllowed());
final SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(project);
MarkupModelEx model = (MarkupModelEx) DocumentMarkupModel.forDocument(document, project, true);
return model.processRangeHighlightersOverlappingWith(startOffset, endOffset, marker -> {
Object tt = marker.getErrorStripeTooltip();
if (!(tt instanceof HighlightInfo))
return true;
HighlightInfo info = (HighlightInfo) tt;
return minSeverity != null && severityRegistrar.compare(info.getSeverity(), minSeverity) < 0 || info.getHighlighter() == null || processor.process(info);
});
}
use of com.intellij.openapi.editor.ex.MarkupModelEx in project intellij-community by JetBrains.
the class DaemonCodeAnalyzerEx method processHighlightsOverlappingOutside.
static boolean processHighlightsOverlappingOutside(@NotNull Document document, @NotNull Project project, @Nullable("null means all") final HighlightSeverity minSeverity, final int startOffset, final int endOffset, @NotNull final Processor<HighlightInfo> processor) {
LOG.assertTrue(ApplicationManager.getApplication().isReadAccessAllowed());
final SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(project);
MarkupModelEx model = (MarkupModelEx) DocumentMarkupModel.forDocument(document, project, true);
return model.processRangeHighlightersOutside(startOffset, endOffset, marker -> {
Object tt = marker.getErrorStripeTooltip();
if (!(tt instanceof HighlightInfo))
return true;
HighlightInfo info = (HighlightInfo) tt;
return minSeverity != null && severityRegistrar.compare(info.getSeverity(), minSeverity) < 0 || info.getHighlighter() == null || processor.process(info);
});
}
Aggregations