Search in sources :

Example 1 with Lookup

use of com.intellij.codeInsight.lookup.Lookup in project intellij-community by JetBrains.

the class XmlSmartEnterTest method select.

private void select(final char c) {
    if (!LookupEvent.isSpecialCompletionChar(c)) {
        type(c);
        return;
    }
    final LookupManagerImpl manager = (LookupManagerImpl) LookupManager.getInstance(getProject());
    final Lookup lookup = manager.getActiveLookup();
    if (lookup != null) {
        manager.forceSelection(c, lookup.getCurrentItem());
    }
}
Also used : LookupManagerImpl(com.intellij.codeInsight.lookup.impl.LookupManagerImpl) Lookup(com.intellij.codeInsight.lookup.Lookup)

Example 2 with Lookup

use of com.intellij.codeInsight.lookup.Lookup in project intellij-community by JetBrains.

the class BaseCodeInsightAction method update.

@Override
public void update(AnActionEvent event) {
    Presentation presentation = event.getPresentation();
    DataContext dataContext = event.getDataContext();
    Project project = CommonDataKeys.PROJECT.getData(dataContext);
    if (project == null) {
        presentation.setEnabled(false);
        return;
    }
    final Lookup activeLookup = LookupManager.getInstance(project).getActiveLookup();
    if (activeLookup != null) {
        presentation.setEnabled(isValidForLookup());
    } else {
        super.update(event);
    }
}
Also used : Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) Lookup(com.intellij.codeInsight.lookup.Lookup) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 3 with Lookup

use of com.intellij.codeInsight.lookup.Lookup in project intellij-community by JetBrains.

the class ConsoleExecuteAction method update.

@Override
public final void update(@NotNull AnActionEvent e) {
    EditorEx editor = myConsoleView.getConsoleEditor();
    boolean enabled = !editor.isRendererMode() && isEnabled() && (myExecuteActionHandler.isEmptyCommandExecutionAllowed() || !StringUtil.isEmptyOrSpaces(editor.getDocument().getCharsSequence()));
    if (enabled) {
        Lookup lookup = LookupManager.getActiveLookup(editor);
        // we should check getCurrentItem() also - fast typing could produce outdated lookup, such lookup reports isCompletion() true
        enabled = lookup == null || !lookup.isCompletion() || lookup.getCurrentItem() == null || (lookup instanceof LookupImpl && ((LookupImpl) lookup).getFocusDegree() == LookupImpl.FocusDegree.UNFOCUSED);
    }
    e.getPresentation().setEnabled(enabled);
}
Also used : LookupImpl(com.intellij.codeInsight.lookup.impl.LookupImpl) EditorEx(com.intellij.openapi.editor.ex.EditorEx) Lookup(com.intellij.codeInsight.lookup.Lookup)

Example 4 with Lookup

use of com.intellij.codeInsight.lookup.Lookup in project intellij-community by JetBrains.

the class SmartType17CompletionTest method doTest.

private void doTest() {
    configureByFile("/" + getTestName(false) + ".java");
    if (myItems != null && myItems.length == 1) {
        final Lookup lookup = getLookup();
        if (lookup != null) {
            selectItem(lookup.getCurrentItem(), Lookup.NORMAL_SELECT_CHAR);
        }
    }
    checkResultByFile("/" + getTestName(false) + "-out.java");
}
Also used : Lookup(com.intellij.codeInsight.lookup.Lookup)

Example 5 with Lookup

use of com.intellij.codeInsight.lookup.Lookup in project intellij-community by JetBrains.

the class SmartType18CompletionTest method doTest.

private void doTest(boolean insertSelectedItem) {
    configureByFile("/" + getTestName(false) + ".java");
    if (insertSelectedItem) {
        assertNotNull(myItems);
        assertTrue(myItems.length > 0);
        final Lookup lookup = getLookup();
        if (lookup != null) {
            selectItem(lookup.getCurrentItem(), Lookup.NORMAL_SELECT_CHAR);
        }
    }
    checkResultByFile("/" + getTestName(false) + "-out.java");
}
Also used : Lookup(com.intellij.codeInsight.lookup.Lookup)

Aggregations

Lookup (com.intellij.codeInsight.lookup.Lookup)8 LookupElement (com.intellij.codeInsight.lookup.LookupElement)3 Language (com.intellij.lang.Language)2 Project (com.intellij.openapi.project.Project)2 Nullable (org.jetbrains.annotations.Nullable)2 CodeInsightBundle (com.intellij.codeInsight.CodeInsightBundle)1 TargetElementUtil (com.intellij.codeInsight.TargetElementUtil)1 ShowQuickDocInfoAction (com.intellij.codeInsight.documentation.actions.ShowQuickDocInfoAction)1 HintManagerImpl (com.intellij.codeInsight.hint.HintManagerImpl)1 ParameterInfoController (com.intellij.codeInsight.hint.ParameterInfoController)1 LookupEx (com.intellij.codeInsight.lookup.LookupEx)1 LookupManager (com.intellij.codeInsight.lookup.LookupManager)1 LookupImpl (com.intellij.codeInsight.lookup.impl.LookupImpl)1 LookupManagerImpl (com.intellij.codeInsight.lookup.impl.LookupManagerImpl)1 BrowserUtil (com.intellij.ide.BrowserUtil)1 DataManager (com.intellij.ide.DataManager)1 BaseNavigateToSourceAction (com.intellij.ide.actions.BaseNavigateToSourceAction)1 PropertiesComponent (com.intellij.ide.util.PropertiesComponent)1 ChooseByNameBase (com.intellij.ide.util.gotoByName.ChooseByNameBase)1 LanguageDocumentation (com.intellij.lang.LanguageDocumentation)1