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), new ThrowableRunnable() { @Override public void run() { List<RangeHighlighterEx> list = new ArrayList<RangeHighlighterEx>(); CommonProcessors.CollectProcessor<RangeHighlighterEx> coll = new CommonProcessors.CollectProcessor<RangeHighlighterEx>(list); for (int i = 0; i < N - 1; i++) { list.clear(); markupModel.processRangeHighlightersOverlappingWith(2 * i, 2 * i + 1, coll); assertEquals(2, list.size()); // 1 line plus one exact range marker } } }) .assertTiming(); }
public void testRangeHighlighterDisposeVsRemoveAllConflict() throws Exception { Document document = EditorFactory.getInstance().createDocument("[xxxxxxxxxxxxxx]"); MarkupModel markupModel = DocumentMarkupModel.forDocument(document, ourProject, true); RangeMarker m = markupModel.addRangeHighlighter(1, 6, 0, null, HighlighterTargetArea.EXACT_RANGE); assertTrue(m.isValid()); markupModel.removeAllHighlighters(); assertFalse(m.isValid()); assertEmpty(markupModel.getAllHighlighters()); m.dispose(); assertFalse(m.isValid()); }
public void testRangeHighlighterIteratorOrder() throws Exception { Document document = EditorFactory.getInstance().createDocument("1234567890"); final MarkupModelEx markupModel = (MarkupModelEx) DocumentMarkupModel.forDocument(document, ourProject, true); RangeHighlighter exact = markupModel.addRangeHighlighter(3, 6, 0, null, HighlighterTargetArea.EXACT_RANGE); RangeHighlighter line = markupModel.addRangeHighlighter(4, 5, 0, null, HighlighterTargetArea.LINES_IN_RANGE); List<RangeHighlighter> list = new ArrayList<RangeHighlighter>(); markupModel.processRangeHighlightersOverlappingWith( 2, 9, new CommonProcessors.CollectProcessor<RangeHighlighter>(list)); assertEquals(Arrays.asList(line, exact), list); }
public void testRangeHighlightersRecreateBug() throws Exception { Document document = EditorFactory.getInstance().createDocument("[xxxxxxxxxxxxxx]"); MarkupModel markupModel = DocumentMarkupModel.forDocument(document, ourProject, true); for (int i = 0; i < 2; i++) { RangeMarker m = markupModel.addRangeHighlighter(1, 6, 0, null, HighlighterTargetArea.EXACT_RANGE); RangeMarker m2 = markupModel.addRangeHighlighter(2, 7, 0, null, HighlighterTargetArea.EXACT_RANGE); RangeMarker m3 = markupModel.addRangeHighlighter(1, 6, 0, null, HighlighterTargetArea.EXACT_RANGE); markupModel.removeAllHighlighters(); } }