use of com.intellij.openapi.editor.ex.EditorMarkupModel in project intellij-community by JetBrains.
the class DaemonListeners method repaintErrorStripeRenderer.
static void repaintErrorStripeRenderer(@NotNull Editor editor, @NotNull Project project) {
ApplicationManager.getApplication().assertIsDispatchThread();
if (!project.isInitialized())
return;
final Document document = editor.getDocument();
final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document);
final EditorMarkupModel markup = (EditorMarkupModel) editor.getMarkupModel();
markup.setErrorPanelPopupHandler(new DaemonEditorPopup(psiFile));
markup.setErrorStripTooltipRendererProvider(new DaemonTooltipRendererProvider(project));
markup.setMinMarkHeight(DaemonCodeAnalyzerSettings.getInstance().ERROR_STRIPE_MARK_MIN_HEIGHT);
TrafficLightRenderer.setOrRefreshErrorStripeRenderer(markup, project, document, psiFile);
}
use of com.intellij.openapi.editor.ex.EditorMarkupModel in project intellij-community by JetBrains.
the class PsiChangeHandler method updateChangesForDocument.
private void updateChangesForDocument(@NotNull final Document document) {
ApplicationManager.getApplication().assertIsDispatchThread();
if (myProject.isDisposed())
return;
List<Pair<PsiElement, Boolean>> toUpdate = changedElements.get(document);
if (toUpdate == null) {
// We may still need to rehighlight the file if there were changes inside highlighted ranges.
if (UpdateHighlightersUtil.isWhitespaceOptimizationAllowed(document))
return;
// don't create PSI for files in other projects
PsiElement file = PsiDocumentManager.getInstance(myProject).getCachedPsiFile(document);
if (file == null)
return;
toUpdate = Collections.singletonList(Pair.create(file, true));
}
Application application = ApplicationManager.getApplication();
final Editor editor = FileEditorManager.getInstance(myProject).getSelectedTextEditor();
if (editor != null && !application.isUnitTestMode()) {
application.invokeLater(() -> {
if (!editor.isDisposed()) {
EditorMarkupModel markupModel = (EditorMarkupModel) editor.getMarkupModel();
PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument());
TrafficLightRenderer.setOrRefreshErrorStripeRenderer(markupModel, myProject, editor.getDocument(), file);
}
}, ModalityState.stateForComponent(editor.getComponent()), myProject.getDisposed());
}
for (Pair<PsiElement, Boolean> changedElement : toUpdate) {
PsiElement element = changedElement.getFirst();
Boolean whiteSpaceOptimizationAllowed = changedElement.getSecond();
updateByChange(element, document, whiteSpaceOptimizationAllowed);
}
changedElements.remove(document);
}
use of com.intellij.openapi.editor.ex.EditorMarkupModel in project intellij-community by JetBrains.
the class ConsoleGutterComponent method mouseMoved.
@Override
public void mouseMoved(MouseEvent e) {
int line = EditorUtil.yPositionToLogicalLine(editor, e.getPoint());
if (line == lastGutterToolTipLine) {
return;
}
TooltipController controller = TooltipController.getInstance();
if (lastGutterToolTipLine != -1) {
controller.cancelTooltip(TOOLTIP_GROUP, e, true);
}
String toolTip = gutterContentProvider.getToolTip(line, editor);
setCursor(toolTip == null ? Cursor.getDefaultCursor() : Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
if (toolTip == null) {
lastGutterToolTipLine = -1;
controller.cancelTooltip(TOOLTIP_GROUP, e, false);
} else {
lastGutterToolTipLine = line;
RelativePoint showPoint = new RelativePoint(this, e.getPoint());
controller.showTooltipByMouseMove(editor, showPoint, ((EditorMarkupModel) editor.getMarkupModel()).getErrorStripTooltipRendererProvider().calcTooltipRenderer(toolTip), false, TOOLTIP_GROUP, new HintHint(this, e.getPoint()).setAwtTooltip(true));
}
}
use of com.intellij.openapi.editor.ex.EditorMarkupModel in project intellij-community by JetBrains.
the class ThreesideTextDiffViewer method createEditorHolders.
@NotNull
@Override
protected List<TextEditorHolder> createEditorHolders(@NotNull EditorHolderFactory<TextEditorHolder> factory) {
List<TextEditorHolder> holders = super.createEditorHolders(factory);
boolean[] forceReadOnly = TextDiffViewerUtil.checkForceReadOnly(myContext, myRequest);
for (int i = 0; i < 3; i++) {
if (forceReadOnly[i])
holders.get(i).getEditor().setViewer(true);
}
ThreeSide.LEFT.select(holders).getEditor().setVerticalScrollbarOrientation(EditorEx.VERTICAL_SCROLLBAR_LEFT);
((EditorMarkupModel) ThreeSide.BASE.select(holders).getEditor().getMarkupModel()).setErrorStripeVisible(false);
for (TextEditorHolder holder : holders) {
DiffUtil.disableBlitting(holder.getEditor());
}
return holders;
}
use of com.intellij.openapi.editor.ex.EditorMarkupModel in project intellij-community by JetBrains.
the class DiffUtil method createEditor.
@NotNull
public static EditorEx createEditor(@NotNull Document document, @Nullable Project project, boolean isViewer, boolean enableFolding) {
EditorFactory factory = EditorFactory.getInstance();
EditorEx editor = (EditorEx) (isViewer ? factory.createViewer(document, project) : factory.createEditor(document, project));
editor.putUserData(DiffManagerImpl.EDITOR_IS_DIFF_KEY, Boolean.TRUE);
editor.getSettings().setShowIntentionBulb(false);
((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true);
editor.getGutterComponentEx().setShowDefaultGutterPopup(false);
if (enableFolding) {
setFoldingModelSupport(editor);
} else {
editor.getSettings().setFoldingOutlineShown(false);
editor.getFoldingModel().setFoldingEnabled(false);
}
UIUtil.removeScrollBorder(editor.getComponent());
return editor;
}
Aggregations