use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.
the class CallHierarchyNodeDescriptor method navigate.
public void navigate(boolean requestFocus) {
if (!myNavigateToReference) {
PsiElement element = getPsiElement();
if (element instanceof Navigatable && ((Navigatable) element).canNavigate()) {
((Navigatable) element).navigate(requestFocus);
}
return;
}
final PsiReference firstReference = myReferences.get(0);
final PsiElement element = firstReference.getElement();
if (element == null)
return;
final PsiElement callElement = element.getParent();
if (callElement instanceof Navigatable && ((Navigatable) callElement).canNavigate()) {
((Navigatable) callElement).navigate(requestFocus);
} else {
final PsiFile psiFile = callElement.getContainingFile();
if (psiFile == null || psiFile.getVirtualFile() == null)
return;
FileEditorManager.getInstance(myProject).openFile(psiFile.getVirtualFile(), requestFocus);
}
Editor editor = PsiUtilBase.findEditor(callElement);
if (editor != null) {
HighlightManager highlightManager = HighlightManager.getInstance(myProject);
EditorColorsManager colorManager = EditorColorsManager.getInstance();
TextAttributes attributes = colorManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
ArrayList<RangeHighlighter> highlighters = new ArrayList<>();
for (PsiReference psiReference : myReferences) {
final PsiElement eachElement = psiReference.getElement();
if (eachElement != null) {
final PsiElement eachMethodCall = eachElement.getParent();
if (eachMethodCall != null) {
final TextRange textRange = eachMethodCall.getTextRange();
highlightManager.addRangeHighlight(editor, textRange.getStartOffset(), textRange.getEndOffset(), attributes, false, highlighters);
}
}
}
}
}
use of com.intellij.openapi.editor.markup.RangeHighlighter 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.markup.RangeHighlighter in project intellij-community by JetBrains.
the class EditorImplTest method testChangingHighlightersInBulkModeListener.
public void testChangingHighlightersInBulkModeListener() throws Exception {
DocumentBulkUpdateListener.Adapter listener = new DocumentBulkUpdateListener.Adapter() {
@Override
public void updateFinished(@NotNull Document doc) {
if (doc == myEditor.getDocument()) {
myEditor.getMarkupModel().addRangeHighlighter(7, 8, 0, null, HighlighterTargetArea.EXACT_RANGE);
}
}
};
getProject().getMessageBus().connect(getTestRootDisposable()).subscribe(DocumentBulkUpdateListener.TOPIC, listener);
initText("abcdef");
DocumentEx document = (DocumentEx) myEditor.getDocument();
runWriteCommand(() -> {
DocumentUtil.executeInBulk(document, true, () -> {
document.insertString(3, "\n\n");
});
});
RangeHighlighter[] highlighters = myEditor.getMarkupModel().getAllHighlighters();
assertEquals(1, highlighters.length);
assertEquals(7, highlighters[0].getStartOffset());
assertEquals(8, highlighters[0].getEndOffset());
}
use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.
the class EditorImplTest method testChangingHighlightersAfterClearingFoldingsDuringFoldingBatchUpdate.
public void testChangingHighlightersAfterClearingFoldingsDuringFoldingBatchUpdate() throws Exception {
initText("abc\n\ndef");
addCollapsedFoldRegion(2, 6, "...");
runFoldingOperation(() -> {
((FoldingModelEx) myEditor.getFoldingModel()).clearFoldRegions();
myEditor.getMarkupModel().addRangeHighlighter(7, 8, 0, new TextAttributes(null, null, null, null, Font.BOLD), HighlighterTargetArea.EXACT_RANGE);
});
RangeHighlighter[] highlighters = myEditor.getMarkupModel().getAllHighlighters();
assertEquals(1, highlighters.length);
assertEquals(7, highlighters[0].getStartOffset());
assertEquals(8, highlighters[0].getEndOffset());
}
use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.
the class VcsPreviewPanel method addHighlighter.
private void addHighlighter(@NotNull Range range, @NotNull ColorKey colorKey) {
TextRange textRange = DiffUtil.getLinesRange(myEditor.getDocument(), range.getLine1(), range.getLine2());
RangeHighlighter highlighter = LineStatusMarkerRenderer.createRangeHighlighter(range, textRange, myEditor.getMarkupModel());
highlighter.setLineMarkerRenderer(new LineStatusMarkerRenderer(range) {
@Override
public boolean canDoAction(MouseEvent e) {
return isInsideMarkerArea(e);
}
@Override
public void doAction(Editor editor, MouseEvent e) {
myDispatcher.getMulticaster().selectionInPreviewChanged(colorKey.getExternalName());
}
});
}
Aggregations