Search in sources :

Example 1 with EditorMarkupModel

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);
}
Also used : EditorMarkupModel(com.intellij.openapi.editor.ex.EditorMarkupModel)

Example 2 with EditorMarkupModel

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);
}
Also used : Editor(com.intellij.openapi.editor.Editor) Application(com.intellij.openapi.application.Application) EditorMarkupModel(com.intellij.openapi.editor.ex.EditorMarkupModel) Pair(com.intellij.openapi.util.Pair)

Example 3 with EditorMarkupModel

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));
    }
}
Also used : HintHint(com.intellij.ui.HintHint) TooltipController(com.intellij.codeInsight.hint.TooltipController) RelativePoint(com.intellij.ui.awt.RelativePoint) HintHint(com.intellij.ui.HintHint) RelativePoint(com.intellij.ui.awt.RelativePoint) EditorMarkupModel(com.intellij.openapi.editor.ex.EditorMarkupModel)

Example 4 with EditorMarkupModel

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;
}
Also used : TextEditorHolder(com.intellij.diff.tools.holders.TextEditorHolder) EditorMarkupModel(com.intellij.openapi.editor.ex.EditorMarkupModel) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with EditorMarkupModel

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;
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx) EditorMarkupModel(com.intellij.openapi.editor.ex.EditorMarkupModel)

Aggregations

EditorMarkupModel (com.intellij.openapi.editor.ex.EditorMarkupModel)9 EditorEx (com.intellij.openapi.editor.ex.EditorEx)4 NotNull (org.jetbrains.annotations.NotNull)4 Editor (com.intellij.openapi.editor.Editor)3 HintHint (com.intellij.ui.HintHint)2 SeverityRegistrar (com.intellij.codeInsight.daemon.impl.SeverityRegistrar)1 TrafficLightRenderer (com.intellij.codeInsight.daemon.impl.TrafficLightRenderer)1 TooltipController (com.intellij.codeInsight.hint.TooltipController)1 TextEditorHolder (com.intellij.diff.tools.holders.TextEditorHolder)1 Disposable (com.intellij.openapi.Disposable)1 Application (com.intellij.openapi.application.Application)1 MergeActionGroup (com.intellij.openapi.diff.actions.MergeActionGroup)1 ScrollingModel (com.intellij.openapi.editor.ScrollingModel)1 VisibleAreaListener (com.intellij.openapi.editor.event.VisibleAreaListener)1 MarkupModelEx (com.intellij.openapi.editor.ex.MarkupModelEx)1 EditorImpl (com.intellij.openapi.editor.impl.EditorImpl)1 FileEditor (com.intellij.openapi.fileEditor.FileEditor)1 Pair (com.intellij.openapi.util.Pair)1 LightweightHint (com.intellij.ui.LightweightHint)1 RelativePoint (com.intellij.ui.awt.RelativePoint)1