Search in sources :

Example 6 with Inlay

use of com.intellij.openapi.editor.Inlay in project intellij-community by JetBrains.

the class InlineElementData method addHighlToView.

@Override
public void addHighlToView(Editor view, EditorColorsScheme scheme, Map<TextAttributesKey, String> displayText) {
    int offset = getStartOffset();
    ParameterHintsPresentationManager.getInstance().addHint(view, offset, myText, false, false);
    List<Inlay> inlays = view.getInlayModel().getInlineElementsInRange(offset, offset);
    for (Inlay inlay : inlays) {
        EditorCustomElementRenderer renderer = inlay.getRenderer();
        if (!(renderer instanceof RendererWrapper)) {
            Disposer.dispose(inlay);
            RendererWrapper wrapper = new RendererWrapper(renderer);
            wrapper.drawBorder = myAddBorder;
            view.getInlayModel().addInlineElement(offset, wrapper);
        }
    }
}
Also used : EditorCustomElementRenderer(com.intellij.openapi.editor.EditorCustomElementRenderer) Inlay(com.intellij.openapi.editor.Inlay)

Example 7 with Inlay

use of com.intellij.openapi.editor.Inlay in project intellij-community by JetBrains.

the class EditorInlayTest method testDocumentEditingWithSoftWraps.

public void testDocumentEditingWithSoftWraps() throws Exception {
    initText("long line");
    configureSoftWraps(7);
    Inlay inlay = addInlay(1);
    assertNotNull(myEditor.getSoftWrapModel().getSoftWrap(5));
    new WriteCommandAction.Simple<Void>(ourProject) {

        @Override
        protected void run() throws Throwable {
            myEditor.getDocument().setText(" ");
        }
    }.execute();
    assertFalse(inlay.isValid());
}
Also used : WriteCommandAction(com.intellij.openapi.command.WriteCommandAction) Inlay(com.intellij.openapi.editor.Inlay)

Example 8 with Inlay

use of com.intellij.openapi.editor.Inlay in project intellij-community by JetBrains.

the class XDebuggerInlayUtil method createInlay.

public static void createInlay(@NotNull Project project, @NotNull VirtualFile file, int offset, String inlayText) {
    UIUtil.invokeLaterIfNeeded(() -> {
        FileEditor editor = FileEditorManager.getInstance(project).getSelectedEditor(file);
        if (editor instanceof TextEditor) {
            Editor e = ((TextEditor) editor).getEditor();
            CharSequence text = e.getDocument().getImmutableCharSequence();
            int insertOffset = offset;
            while (insertOffset < text.length() && Character.isJavaIdentifierPart(text.charAt(insertOffset))) insertOffset++;
            List<Inlay> existing = e.getInlayModel().getInlineElementsInRange(insertOffset, insertOffset);
            for (Inlay inlay : existing) {
                if (inlay.getRenderer() instanceof MyRenderer) {
                    Disposer.dispose(inlay);
                }
            }
            e.getInlayModel().addInlineElement(insertOffset, new MyRenderer(inlayText));
        }
    });
}
Also used : FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) Inlay(com.intellij.openapi.editor.Inlay) Editor(com.intellij.openapi.editor.Editor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor)

Example 9 with Inlay

use of com.intellij.openapi.editor.Inlay in project intellij-community by JetBrains.

the class InlayModelImpl method getElementAt.

@Nullable
@Override
public Inlay getElementAt(@NotNull Point point) {
    if (myInlayTree.size() == 0)
        return null;
    int offset = myEditor.logicalPositionToOffset(myEditor.xyToLogicalPosition(point));
    List<Inlay> inlays = getInlineElementsInRange(offset, offset);
    if (inlays.isEmpty())
        return null;
    VisualPosition startVisualPosition = myEditor.offsetToVisualPosition(offset);
    int x = myEditor.visualPositionToXY(startVisualPosition).x;
    for (Inlay inlay : inlays) {
        int endX = x + inlay.getWidthInPixels();
        if (point.x >= x && point.x < endX)
            return inlay;
        x = endX;
    }
    return null;
}
Also used : Inlay(com.intellij.openapi.editor.Inlay) VisualPosition(com.intellij.openapi.editor.VisualPosition) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Inlay (com.intellij.openapi.editor.Inlay)9 Editor (com.intellij.openapi.editor.Editor)3 ParameterInfoController (com.intellij.codeInsight.hint.ParameterInfoController)2 FileEditor (com.intellij.openapi.fileEditor.FileEditor)2 TextEditor (com.intellij.openapi.fileEditor.TextEditor)2 Project (com.intellij.openapi.project.Project)2 ShowParameterInfoContext (com.intellij.codeInsight.hint.ShowParameterInfoContext)1 MethodParameterInfoHandler (com.intellij.codeInsight.hint.api.impls.MethodParameterInfoHandler)1 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)1 CaretModel (com.intellij.openapi.editor.CaretModel)1 EditorCustomElementRenderer (com.intellij.openapi.editor.EditorCustomElementRenderer)1 VisualPosition (com.intellij.openapi.editor.VisualPosition)1 ArrayList (java.util.ArrayList)1 Nullable (org.jetbrains.annotations.Nullable)1