Search in sources :

Example 26 with EditorImpl

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

the class DaemonRespondToChangesTest method testLightBulbIsHiddenWhenFixRangeIsCollapsed.

public void testLightBulbIsHiddenWhenFixRangeIsCollapsed() {
    configureByText(StdFileTypes.JAVA, "class S { void foo() { boolean var; if (<selection>va<caret>r</selection>) {}} }");
    ((EditorImpl) myEditor).getScrollPane().getViewport().setSize(1000, 1000);
    final Set<LightweightHint> visibleHints = ContainerUtil.newIdentityTroveSet();
    getProject().getMessageBus().connect(getTestRootDisposable()).subscribe(EditorHintListener.TOPIC, new EditorHintListener() {

        @Override
        public void hintShown(final Project project, final LightweightHint hint, final int flags) {
            visibleHints.add(hint);
            hint.addHintListener(new HintListener() {

                @Override
                public void hintHidden(EventObject event) {
                    visibleHints.remove(hint);
                    hint.removeHintListener(this);
                }
            });
        }
    });
    highlightErrors();
    IntentionHintComponent lastHintBeforeDeletion = myDaemonCodeAnalyzer.getLastIntentionHint();
    assertNotNull(lastHintBeforeDeletion);
    delete(myEditor);
    highlightErrors();
    IntentionHintComponent lastHintAfterDeletion = myDaemonCodeAnalyzer.getLastIntentionHint();
    assertSame(lastHintBeforeDeletion, lastHintAfterDeletion);
    assertEmpty(visibleHints);
}
Also used : EditorHintListener(com.intellij.codeInsight.hint.EditorHintListener) HintListener(com.intellij.ui.HintListener) Project(com.intellij.openapi.project.Project) IntentionHintComponent(com.intellij.codeInsight.intention.impl.IntentionHintComponent) EditorHintListener(com.intellij.codeInsight.hint.EditorHintListener) EditorImpl(com.intellij.openapi.editor.impl.EditorImpl) LightweightHint(com.intellij.ui.LightweightHint) LightweightHint(com.intellij.ui.LightweightHint)

Example 27 with EditorImpl

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

the class DaemonRespondToChangesTest method testBulbAppearsAfterType.

public void testBulbAppearsAfterType() throws Throwable {
    String text = "class S { ArrayList<caret>XXX x;}";
    configureByText(StdFileTypes.JAVA, text);
    ((EditorImpl) myEditor).getScrollPane().getViewport().setSize(1000, 1000);
    DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true);
    final Set<LightweightHint> shown = ContainerUtil.newIdentityTroveSet();
    getProject().getMessageBus().connect().subscribe(EditorHintListener.TOPIC, (project, hint, flags) -> {
        shown.add(hint);
        hint.addHintListener(event -> shown.remove(hint));
    });
    DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(getProject());
    highlightErrors();
    IntentionHintComponent hintComponent = codeAnalyzer.getLastIntentionHint();
    assertNotNull(hintComponent);
    assertFalse(hintComponent.isDisposed());
    assertNotNull(hintComponent.getComponentHint());
    assertTrue(shown.contains(hintComponent.getComponentHint()));
    type("x");
    highlightErrors();
    hintComponent = codeAnalyzer.getLastIntentionHint();
    assertNotNull(hintComponent);
    assertFalse(hintComponent.isDisposed());
    assertNotNull(hintComponent.getComponentHint());
    assertTrue(shown.contains(hintComponent.getComponentHint()));
}
Also used : IntentionHintComponent(com.intellij.codeInsight.intention.impl.IntentionHintComponent) EditorImpl(com.intellij.openapi.editor.impl.EditorImpl) LightweightHint(com.intellij.ui.LightweightHint)

Example 28 with EditorImpl

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

the class EditorPaintingPerformanceTest method doTestScrollingPerformance.

private static void doTestScrollingPerformance(String message, int expectedMs) {
    EditorImpl editor = (EditorImpl) myEditor;
    int editorHeight = editor.getPreferredHeight();
    int[] result = { 0 };
    PlatformTestUtil.startPerformanceTest(message, expectedMs, () -> {
        for (int y = 0; y < editorHeight; y += 1000) {
            Rectangle clip = new Rectangle(0, y, EDITOR_WIDTH_PX, 1000);
            NullGraphics2D g = new NullGraphics2D(clip);
            editor.getContentComponent().paintComponent(g);
            result[0] += g.getResult();
        }
    }).cpuBound().assertTiming();
    System.out.println(result[0]);
}
Also used : EditorImpl(com.intellij.openapi.editor.impl.EditorImpl)

Example 29 with EditorImpl

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

the class LanguagePanel method updateHighlighters.

void updateHighlighters() {
    final EditorImpl editor = ((EditorImpl) myPrefix.getEditor());
    if (editor == null)
        return;
    final EditorImpl editor2 = ((EditorImpl) mySuffix.getEditor());
    assert editor2 != null;
    final Language language = InjectedLanguage.findLanguageById(getLanguage());
    if (language == null) {
        editor.setHighlighter(new LexerEditorHighlighter(new PlainSyntaxHighlighter(), editor.getColorsScheme()));
        editor2.setHighlighter(new LexerEditorHighlighter(new PlainSyntaxHighlighter(), editor.getColorsScheme()));
    } else {
        final SyntaxHighlighter s1 = SyntaxHighlighterFactory.getSyntaxHighlighter(language, myProject, null);
        final SyntaxHighlighter s2 = SyntaxHighlighterFactory.getSyntaxHighlighter(language, myProject, null);
        editor.setHighlighter(new LexerEditorHighlighter(s1, editor.getColorsScheme()));
        editor2.setHighlighter(new LexerEditorHighlighter(s2, editor2.getColorsScheme()));
    }
}
Also used : Language(com.intellij.lang.Language) InjectedLanguage(org.intellij.plugins.intelliLang.inject.InjectedLanguage) EditorImpl(com.intellij.openapi.editor.impl.EditorImpl) LexerEditorHighlighter(com.intellij.openapi.editor.ex.util.LexerEditorHighlighter) PlainSyntaxHighlighter(com.intellij.openapi.fileTypes.PlainSyntaxHighlighter) SyntaxHighlighter(com.intellij.openapi.fileTypes.SyntaxHighlighter) PlainSyntaxHighlighter(com.intellij.openapi.fileTypes.PlainSyntaxHighlighter)

Example 30 with EditorImpl

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

the class TextEditorComponent method createEditor.

@NotNull
private Editor createEditor() {
    Editor editor = EditorFactory.getInstance().createEditor(myDocument, myProject);
    ((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true);
    ((EditorEx) editor).getGutterComponentEx().setForceShowRightFreePaintersArea(true);
    ((EditorEx) editor).setFile(myFile);
    ((EditorEx) editor).setContextMenuGroupId(IdeActions.GROUP_EDITOR_POPUP);
    ((EditorImpl) editor).setDropHandler(new FileDropHandler(editor));
    TextEditorProvider.putTextEditor(editor, myTextEditor);
    return editor;
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx) EditorImpl(com.intellij.openapi.editor.impl.EditorImpl) Editor(com.intellij.openapi.editor.Editor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) EditorMarkupModel(com.intellij.openapi.editor.ex.EditorMarkupModel) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

EditorImpl (com.intellij.openapi.editor.impl.EditorImpl)34 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)8 Editor (com.intellij.openapi.editor.Editor)7 LightweightHint (com.intellij.ui.LightweightHint)6 Document (com.intellij.openapi.editor.Document)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 EditorMouseFixture (com.intellij.testFramework.fixtures.EditorMouseFixture)3 NotNull (org.jetbrains.annotations.NotNull)3 IntentionHintComponent (com.intellij.codeInsight.intention.impl.IntentionHintComponent)2 Result (com.intellij.openapi.application.Result)2 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)2 SoftWrap (com.intellij.openapi.editor.SoftWrap)2 EditorEx (com.intellij.openapi.editor.ex.EditorEx)2 FoldingModelEx (com.intellij.openapi.editor.ex.FoldingModelEx)2 SoftWrapModelImpl (com.intellij.openapi.editor.impl.SoftWrapModelImpl)2 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)2 TextEditor (com.intellij.openapi.fileEditor.TextEditor)2 Project (com.intellij.openapi.project.Project)2 HintHint (com.intellij.ui.HintHint)2 EditorHintListener (com.intellij.codeInsight.hint.EditorHintListener)1