use of com.intellij.openapi.editor.ex.RangeHighlighterEx in project intellij-community by JetBrains.
the class Bookmark method createHighlighter.
public RangeHighlighter createHighlighter(@NotNull MarkupModelEx markup) {
final RangeHighlighterEx highlighter;
int line = getLine();
if (line >= 0) {
highlighter = markup.addPersistentLineHighlighter(line, HighlighterLayer.ERROR + 1, null);
if (highlighter != null) {
highlighter.setGutterIconRenderer(new MyGutterIconRenderer(this));
TextAttributes textAttributes = ObjectUtils.notNull(EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.BOOKMARKS_ATTRIBUTES), new TextAttributes());
Color stripeColor = ObjectUtils.notNull(textAttributes.getErrorStripeColor(), new JBColor(0x000000, 0xdbdbdb));
highlighter.setErrorStripeMarkColor(stripeColor);
highlighter.setErrorStripeTooltip(getBookmarkTooltip());
TextAttributes attributes = highlighter.getTextAttributes();
if (attributes == null) {
attributes = new TextAttributes();
}
attributes.setBackgroundColor(textAttributes.getBackgroundColor());
attributes.setForegroundColor(textAttributes.getForegroundColor());
highlighter.setTextAttributes(attributes);
}
} else {
highlighter = null;
}
myHighlighterRef = highlighter == null ? null : new WeakReference<>(highlighter);
return highlighter;
}
use of com.intellij.openapi.editor.ex.RangeHighlighterEx in project intellij-community by JetBrains.
the class Bookmark method release.
public void release() {
int line = getLine();
if (line < 0) {
return;
}
final Document document = getDocument();
if (document == null)
return;
MarkupModelEx markup = (MarkupModelEx) DocumentMarkupModel.forDocument(document, myProject, true);
final Document markupDocument = markup.getDocument();
if (markupDocument.getLineCount() <= line)
return;
RangeHighlighterEx highlighter = findMyHighlighter();
if (highlighter != null) {
myHighlighterRef = null;
highlighter.dispose();
}
}
use of com.intellij.openapi.editor.ex.RangeHighlighterEx 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.RangeHighlighterEx in project intellij-community by JetBrains.
the class HighlightingSessionImpl method queueDisposeHighlighterFor.
void queueDisposeHighlighterFor(@NotNull HighlightInfo info) {
RangeHighlighterEx highlighter = info.getHighlighter();
if (highlighter == null)
return;
// that highlighter may have been reused for another info
myEDTQueue.offer(() -> {
Object actualInfo = highlighter.getErrorStripeTooltip();
if (actualInfo == info && info.getHighlighter() == highlighter)
highlighter.dispose();
});
}
use of com.intellij.openapi.editor.ex.RangeHighlighterEx in project intellij-community by JetBrains.
the class DaemonRespondToChangesTest method testErrorDisappearsRightAfterTypingInsideVisibleAreaWhileDaemonContinuesToChugAlong.
public void testErrorDisappearsRightAfterTypingInsideVisibleAreaWhileDaemonContinuesToChugAlong() throws Throwable {
String text = "class X{\nint xxx;\n{\nint i = <selection>null</selection><caret>;\n" + StringUtil.repeat("{ this.hashCode(); }\n\n\n", 10000) + "}}";
configureByText(StdFileTypes.JAVA, text);
((EditorImpl) myEditor).getScrollPane().getViewport().setSize(100, 100);
DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true);
myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
((EditorImpl) myEditor).getScrollPane().getViewport().setViewPosition(new Point(0, 0));
((EditorImpl) myEditor).getScrollPane().getViewport().setExtentSize(new Dimension(100, 100000));
ProperTextRange visibleRange = VisibleHighlightingPassFactory.calculateVisibleRange(getEditor());
assertTrue(visibleRange.getLength() > 0);
final Document document = myEditor.getDocument();
assertTrue(visibleRange.getLength() < document.getTextLength());
List<HighlightInfo> err1 = highlightErrors();
HighlightInfo info = assertOneElement(err1);
final String errorDescription = "Incompatible types. Found: 'null', required: 'int'";
assertEquals(errorDescription, info.getDescription());
MarkupModelEx model = (MarkupModelEx) DocumentMarkupModel.forDocument(document, myProject, false);
final boolean[] errorRemoved = { false };
model.addMarkupModelListener(getTestRootDisposable(), new MarkupModelListener.Adapter() {
@Override
public void beforeRemoved(@NotNull RangeHighlighterEx highlighter) {
Object tt = highlighter.getErrorStripeTooltip();
if (!(tt instanceof HighlightInfo))
return;
String description = ((HighlightInfo) tt).getDescription();
if (errorDescription.equals(description)) {
errorRemoved[0] = true;
List<TextEditorHighlightingPass> passes = myDaemonCodeAnalyzer.getPassesToShowProgressFor(document);
GeneralHighlightingPass ghp = null;
for (TextEditorHighlightingPass pass : passes) {
if (pass instanceof GeneralHighlightingPass && pass.getId() == Pass.UPDATE_ALL) {
assert ghp == null : ghp;
ghp = (GeneralHighlightingPass) pass;
}
}
assertNotNull(ghp);
boolean finished = ghp.isFinished();
assertFalse(finished);
}
}
});
type("1");
List<HighlightInfo> errors = highlightErrors();
assertEmpty(errors);
assertTrue(errorRemoved[0]);
}
Aggregations