Search in sources :

Example 1 with EditorHintListener

use of com.intellij.codeInsight.hint.EditorHintListener in project intellij-community by JetBrains.

the class SelectUnselectOccurrenceActionsTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    EditorHintListener listener = new EditorHintListener() {

        @Override
        public void hintShown(Project project, LightweightHint hint, int flags) {
            hintCount++;
        }
    };
    ApplicationManager.getApplication().getMessageBus().connect(myFixture.getTestRootDisposable()).subscribe(EditorHintListener.TOPIC, listener);
}
Also used : Project(com.intellij.openapi.project.Project) EditorHintListener(com.intellij.codeInsight.hint.EditorHintListener) LightweightHint(com.intellij.ui.LightweightHint)

Example 2 with EditorHintListener

use of com.intellij.codeInsight.hint.EditorHintListener in project intellij-community by JetBrains.

the class FindInEditorTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    myFindModel = new FindModel();
    myOutputStream = new ByteArrayOutputStream();
    LivePreview.ourTestOutput = new PrintStream(myOutputStream);
    EditorHintListener listener = (project, hint, flags) -> LivePreview.processNotFound();
    ApplicationManager.getApplication().getMessageBus().connect(getTestRootDisposable()).subscribe(EditorHintListener.TOPIC, listener);
}
Also used : PrintStream(java.io.PrintStream) UIUtil(com.intellij.util.ui.UIUtil) ByteArrayOutputStream(java.io.ByteArrayOutputStream) EditorImpl(com.intellij.openapi.editor.impl.EditorImpl) SearchResults(com.intellij.find.impl.livePreview.SearchResults) LivePreviewController(com.intellij.find.impl.livePreview.LivePreviewController) LivePreview(com.intellij.find.impl.livePreview.LivePreview) ApplicationManager(com.intellij.openapi.application.ApplicationManager) EditorHintListener(com.intellij.codeInsight.hint.EditorHintListener) IdeActions(com.intellij.openapi.actionSystem.IdeActions) LightCodeInsightTestCase(com.intellij.testFramework.LightCodeInsightTestCase) EditorMouseFixture(com.intellij.testFramework.fixtures.EditorMouseFixture) PrintStream(java.io.PrintStream) EditorHintListener(com.intellij.codeInsight.hint.EditorHintListener) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 3 with EditorHintListener

use of com.intellij.codeInsight.hint.EditorHintListener in project intellij-community by JetBrains.

the class CompletionProgressIndicator method showErrorHint.

private static LightweightHint showErrorHint(Project project, Editor editor, String text) {
    final LightweightHint[] result = { null };
    final EditorHintListener listener = (project1, hint, flags) -> result[0] = hint;
    final MessageBusConnection connection = project.getMessageBus().connect();
    connection.subscribe(EditorHintListener.TOPIC, listener);
    assert text != null;
    HintManager.getInstance().showErrorHint(editor, StringUtil.escapeXml(text), HintManager.UNDER);
    connection.disconnect();
    return result[0];
}
Also used : LookupImpl(com.intellij.codeInsight.lookup.impl.LookupImpl) MessageType(com.intellij.openapi.ui.MessageType) Document(com.intellij.openapi.editor.Document) IdeActions(com.intellij.openapi.actionSystem.IdeActions) AutoPopupController(com.intellij.codeInsight.AutoPopupController) PerformanceWatcher(com.intellij.diagnostic.PerformanceWatcher) Semaphore(com.intellij.util.concurrency.Semaphore) Disposer(com.intellij.openapi.util.Disposer) FeatureUsageTracker(com.intellij.featureStatistics.FeatureUsageTracker) EditorHintListener(com.intellij.codeInsight.hint.EditorHintListener) WriteCommandAction(com.intellij.openapi.command.WriteCommandAction) Logger(com.intellij.openapi.diagnostic.Logger) ReferenceRange(com.intellij.psi.ReferenceRange) Extensions(com.intellij.openapi.extensions.Extensions) ProgressManager(com.intellij.openapi.progress.ProgressManager) DumbService(com.intellij.openapi.project.DumbService) DocumentWindow(com.intellij.injected.editor.DocumentWindow) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) CodeInsightSettings(com.intellij.codeInsight.CodeInsightSettings) PsiReference(com.intellij.psi.PsiReference) Set(java.util.Set) com.intellij.codeInsight.lookup(com.intellij.codeInsight.lookup) TextRange(com.intellij.openapi.util.TextRange) KeyEvent(java.awt.event.KeyEvent) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) PropertyChangeListener(java.beans.PropertyChangeListener) ApplicationManager(com.intellij.openapi.application.ApplicationManager) Registry(com.intellij.openapi.util.registry.Registry) Queue(java.util.Queue) NotNull(org.jetbrains.annotations.NotNull) LightweightHint(com.intellij.ui.LightweightHint) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) ProgressIndicatorBase(com.intellij.openapi.progress.util.ProgressIndicatorBase) ContainerUtil(com.intellij.util.containers.ContainerUtil) KeyAdapter(java.awt.event.KeyAdapter) Caret(com.intellij.openapi.editor.Caret) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) CompletionSorterImpl(com.intellij.codeInsight.completion.impl.CompletionSorterImpl) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) MessageBusConnection(com.intellij.util.messages.MessageBusConnection) ProgressWrapper(com.intellij.openapi.progress.util.ProgressWrapper) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) JobScheduler(com.intellij.concurrency.JobScheduler) PsiDocumentManager(com.intellij.psi.PsiDocumentManager) CompletionAutoPopupHandler(com.intellij.codeInsight.editorActions.CompletionAutoPopupHandler) StringUtil(com.intellij.openapi.util.text.StringUtil) CompletionServiceImpl(com.intellij.codeInsight.completion.impl.CompletionServiceImpl) Editor(com.intellij.openapi.editor.Editor) GuiUtils(com.intellij.ui.GuiUtils) EditorWindow(com.intellij.injected.editor.EditorWindow) Disposable(com.intellij.openapi.Disposable) ElementPattern(com.intellij.patterns.ElementPattern) MergingUpdateQueue(com.intellij.util.ui.update.MergingUpdateQueue) TestOnly(org.jetbrains.annotations.TestOnly) java.awt(java.awt) TimeUnit(java.util.concurrent.TimeUnit) CommandProcessor(com.intellij.openapi.command.CommandProcessor) Update(com.intellij.util.ui.update.Update) Result(com.intellij.openapi.application.Result) Pair(com.intellij.openapi.util.Pair) TargetElementUtil(com.intellij.codeInsight.TargetElementUtil) ObjectUtils(com.intellij.util.ObjectUtils) HintManager(com.intellij.codeInsight.hint.HintManager) javax.swing(javax.swing) MessageBusConnection(com.intellij.util.messages.MessageBusConnection) EditorHintListener(com.intellij.codeInsight.hint.EditorHintListener) LightweightHint(com.intellij.ui.LightweightHint)

Example 4 with EditorHintListener

use of com.intellij.codeInsight.hint.EditorHintListener 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)

Aggregations

EditorHintListener (com.intellij.codeInsight.hint.EditorHintListener)4 Project (com.intellij.openapi.project.Project)3 LightweightHint (com.intellij.ui.LightweightHint)3 IdeActions (com.intellij.openapi.actionSystem.IdeActions)2 ApplicationManager (com.intellij.openapi.application.ApplicationManager)2 EditorImpl (com.intellij.openapi.editor.impl.EditorImpl)2 AutoPopupController (com.intellij.codeInsight.AutoPopupController)1 CodeInsightSettings (com.intellij.codeInsight.CodeInsightSettings)1 TargetElementUtil (com.intellij.codeInsight.TargetElementUtil)1 CompletionServiceImpl (com.intellij.codeInsight.completion.impl.CompletionServiceImpl)1 CompletionSorterImpl (com.intellij.codeInsight.completion.impl.CompletionSorterImpl)1 CompletionAutoPopupHandler (com.intellij.codeInsight.editorActions.CompletionAutoPopupHandler)1 HintManager (com.intellij.codeInsight.hint.HintManager)1 IntentionHintComponent (com.intellij.codeInsight.intention.impl.IntentionHintComponent)1 com.intellij.codeInsight.lookup (com.intellij.codeInsight.lookup)1 LookupImpl (com.intellij.codeInsight.lookup.impl.LookupImpl)1 JobScheduler (com.intellij.concurrency.JobScheduler)1 PerformanceWatcher (com.intellij.diagnostic.PerformanceWatcher)1 FeatureUsageTracker (com.intellij.featureStatistics.FeatureUsageTracker)1 LivePreview (com.intellij.find.impl.livePreview.LivePreview)1