Search in sources :

Example 16 with LookupImpl

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

the class TemplateState method runLookup.

private void runLookup(final List<TemplateExpressionLookupElement> lookupItems, @Nullable String advertisingText) {
    if (isDisposed())
        return;
    final LookupManager lookupManager = LookupManager.getInstance(myProject);
    final LookupImpl lookup = (LookupImpl) lookupManager.showLookup(myEditor, lookupItems.toArray(new LookupElement[lookupItems.size()]));
    if (lookup == null)
        return;
    if (CodeInsightSettings.getInstance().AUTO_POPUP_COMPLETION_LOOKUP && myEditor.getUserData(InplaceRefactoring.INPLACE_RENAMER) == null) {
        lookup.setStartCompletionWhenNothingMatches(true);
    }
    if (advertisingText != null) {
        lookup.addAdvertisement(advertisingText, null);
    }
    lookup.refreshUi(true, true);
    ourLookupShown = true;
    lookup.addLookupListener(new LookupAdapter() {

        @Override
        public void lookupCanceled(LookupEvent event) {
            lookup.removeLookupListener(this);
            ourLookupShown = false;
        }

        @Override
        public void itemSelected(LookupEvent event) {
            lookup.removeLookupListener(this);
            if (isFinished())
                return;
            ourLookupShown = false;
            LookupElement item = event.getItem();
            if (item instanceof TemplateExpressionLookupElement) {
                ((TemplateExpressionLookupElement) item).handleTemplateInsert(lookupItems, event.getCompletionChar());
            }
        }
    });
}
Also used : LookupImpl(com.intellij.codeInsight.lookup.impl.LookupImpl)

Example 17 with LookupImpl

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

the class TemplatesCompletionTest method doAutoPopupTest.

private void doAutoPopupTest(@NotNull String textToType, @Nullable Class<? extends PostfixTemplate> expectedClass) {
    configureByFile();
    type(textToType);
    LookupImpl lookup = getLookup();
    if (expectedClass != null) {
        assertNotNull(lookup);
        LookupElement item = lookup.getCurrentItem();
        assertNotNull(item);
        assertInstanceOf(item, PostfixTemplateLookupElement.class);
        assertInstanceOf(((PostfixTemplateLookupElement) item).getPostfixTemplate(), expectedClass);
    } else {
        assertNull(lookup);
    }
}
Also used : LookupImpl(com.intellij.codeInsight.lookup.impl.LookupImpl) LookupElement(com.intellij.codeInsight.lookup.LookupElement)

Example 18 with LookupImpl

use of com.intellij.codeInsight.lookup.impl.LookupImpl in project kotlin by JetBrains.

the class KotlinConfidenceTest method doTest.

protected void doTest() {
    boolean completeByChars = CodeInsightSettings.getInstance().SELECT_AUTOPOPUP_SUGGESTIONS_BY_CHARS;
    CodeInsightSettings.getInstance().SELECT_AUTOPOPUP_SUGGESTIONS_BY_CHARS = true;
    try {
        configureByFile(getBeforeFileName());
        String typeText = getTypeTextFromFile();
        if (typeText != null) {
            type(typeText);
            checkResultByFile(getAfterFileName());
        } else {
            LookupImpl lookup = getLookup();
            assertNull("No completion auto-popup expected", lookup);
        }
    } finally {
        CodeInsightSettings.getInstance().SELECT_AUTOPOPUP_SUGGESTIONS_BY_CHARS = completeByChars;
    }
}
Also used : LookupImpl(com.intellij.codeInsight.lookup.impl.LookupImpl)

Example 19 with LookupImpl

use of com.intellij.codeInsight.lookup.impl.LookupImpl in project intellij-plugins by JetBrains.

the class DartLiveTemplatesTest method expandTemplate.

public void expandTemplate(final Editor editor) {
    final Project project = editor.getProject();
    assertNotNull(project);
    new ListTemplatesAction().actionPerformedImpl(project, editor);
    final LookupImpl lookup = (LookupImpl) LookupManager.getActiveLookup(editor);
    assertNotNull(lookup);
    lookup.finishLookup(Lookup.NORMAL_SELECT_CHAR);
    TemplateState template = TemplateManagerImpl.getTemplateState(editor);
    if (template != null) {
        Disposer.dispose(template);
    }
}
Also used : Project(com.intellij.openapi.project.Project) LookupImpl(com.intellij.codeInsight.lookup.impl.LookupImpl) ListTemplatesAction(com.intellij.codeInsight.template.impl.actions.ListTemplatesAction) TemplateState(com.intellij.codeInsight.template.impl.TemplateState)

Example 20 with LookupImpl

use of com.intellij.codeInsight.lookup.impl.LookupImpl in project intellij-plugins by JetBrains.

the class ActionScriptHighlightingTest method runRenameSpellcheckerFixWithChooseVariant.

private void runRenameSpellcheckerFixWithChooseVariant(String variantName) throws Exception {
    TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
    enableInspectionTool(new SpellCheckingInspection());
    doSimpleHighlightingWithInvokeFixAndCheckResult("Typo: Rename to...");
    final LookupEx lookup = LookupManager.getActiveLookup(myEditor);
    assertNotNull(lookup);
    boolean selected = false;
    for (LookupElement l : lookup.getItems()) {
        if (variantName.equals(l.getLookupString())) {
            selected = true;
            ((LookupImpl) lookup).finishLookup(Lookup.AUTO_INSERT_SELECT_CHAR, l);
        }
    }
    assertTrue(selected);
    LookupManager.getInstance(myProject).hideActiveLookup();
    checkResultByFile(BASE_PATH + getTestName(false) + "_after2.js2");
}
Also used : LookupImpl(com.intellij.codeInsight.lookup.impl.LookupImpl) SpellCheckingInspection(com.intellij.spellchecker.inspections.SpellCheckingInspection) LookupEx(com.intellij.codeInsight.lookup.LookupEx) LookupElement(com.intellij.codeInsight.lookup.LookupElement)

Aggregations

LookupImpl (com.intellij.codeInsight.lookup.impl.LookupImpl)39 ListTemplatesAction (com.intellij.codeInsight.template.impl.actions.ListTemplatesAction)5 Document (com.intellij.openapi.editor.Document)5 Editor (com.intellij.openapi.editor.Editor)5 Project (com.intellij.openapi.project.Project)5 LookupElement (com.intellij.codeInsight.lookup.LookupElement)4 PlainPrefixMatcher (com.intellij.codeInsight.completion.PlainPrefixMatcher)2 LookupEx (com.intellij.codeInsight.lookup.LookupEx)2 TemplateState (com.intellij.codeInsight.template.impl.TemplateState)2 CodeInsightSettings (com.intellij.codeInsight.CodeInsightSettings)1 CamelHumpMatcher (com.intellij.codeInsight.completion.impl.CamelHumpMatcher)1 CompletionSorterImpl (com.intellij.codeInsight.completion.impl.CompletionSorterImpl)1 Lookup (com.intellij.codeInsight.lookup.Lookup)1 LookupManager (com.intellij.codeInsight.lookup.LookupManager)1 LiveTemplateLookupElement (com.intellij.codeInsight.template.impl.LiveTemplateLookupElement)1 CommandAdapter (com.intellij.openapi.command.CommandAdapter)1 CommandEvent (com.intellij.openapi.command.CommandEvent)1 SelectionModel (com.intellij.openapi.editor.SelectionModel)1 DocCommandGroupId (com.intellij.openapi.editor.actionSystem.DocCommandGroupId)1 EditorEx (com.intellij.openapi.editor.ex.EditorEx)1