Search in sources :

Example 6 with LookupEx

use of com.intellij.codeInsight.lookup.LookupEx 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)

Example 7 with LookupEx

use of com.intellij.codeInsight.lookup.LookupEx in project android by JetBrains.

the class AndroidLayoutDomTest method testDimenUnitsCompletion1.

public void testDimenUnitsCompletion1() throws Exception {
    VirtualFile file = copyFileToProject(getTestName(true) + ".xml");
    myFixture.configureFromExistingVirtualFile(file);
    myFixture.complete(CompletionType.BASIC);
    UsefulTestCase.assertSameElements(myFixture.getLookupElementStrings(), "3dp", "3px", "3sp", "3pt", "3mm", "3in");
    PsiElement originalElement = myFixture.getFile().findElementAt(myFixture.getEditor().getCaretModel().getOffset());
    LookupEx lookup = myFixture.getLookup();
    LookupElement dpElement = null;
    LookupElement pxElement = null;
    for (LookupElement element : lookup.getItems()) {
        if (element.getLookupString().endsWith("dp")) {
            dpElement = element;
        } else if (element.getLookupString().endsWith("px")) {
            pxElement = element;
        }
    }
    DocumentationProvider provider;
    PsiElement docTargetElement;
    lookup.setCurrentItem(dpElement);
    docTargetElement = DocumentationManager.getInstance(getProject()).findTargetElement(myFixture.getEditor(), myFixture.getFile(), originalElement);
    provider = DocumentationManager.getProviderFromElement(docTargetElement);
    assertEquals("<html><body><b>Density-independent Pixels</b> - an abstract unit that is based on the physical " + "density of the screen.</body></html>", provider.generateDoc(docTargetElement, originalElement));
    lookup.setCurrentItem(pxElement);
    docTargetElement = DocumentationManager.getInstance(getProject()).findTargetElement(myFixture.getEditor(), myFixture.getFile(), originalElement);
    provider = DocumentationManager.getProviderFromElement(docTargetElement);
    assertEquals("<html><body><b>Pixels</b> - corresponds to actual pixels on the screen. Not recommended.</body></html>", provider.generateDoc(docTargetElement, originalElement));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LookupEx(com.intellij.codeInsight.lookup.LookupEx) LookupElement(com.intellij.codeInsight.lookup.LookupElement) DocumentationProvider(com.intellij.lang.documentation.DocumentationProvider)

Example 8 with LookupEx

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

the class DartServerCompletionTest method selectLookup.

private void selectLookup(@NotNull final String lookupToSelect, final char completionChar) {
    final LookupEx activeLookup = LookupManager.getActiveLookup(getEditor());
    assertNotNull(activeLookup);
    final LookupElement lookup = ContainerUtil.find(activeLookup.getItems(), element -> lookupToSelect.equals(element.getLookupString()));
    assertNotNull(lookupToSelect + " is not in the completion list", lookup);
    activeLookup.setCurrentItem(lookup);
    myFixture.finishLookup(completionChar);
}
Also used : LookupEx(com.intellij.codeInsight.lookup.LookupEx) LookupElement(com.intellij.codeInsight.lookup.LookupElement)

Aggregations

LookupEx (com.intellij.codeInsight.lookup.LookupEx)8 LookupElement (com.intellij.codeInsight.lookup.LookupElement)4 LookupImpl (com.intellij.codeInsight.lookup.impl.LookupImpl)2 Editor (com.intellij.openapi.editor.Editor)2 Project (com.intellij.openapi.project.Project)2 DaemonCodeAnalyzerImpl (com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl)1 ShowIntentionsPass (com.intellij.codeInsight.daemon.impl.ShowIntentionsPass)1 LookupAdapter (com.intellij.codeInsight.lookup.LookupAdapter)1 LookupEvent (com.intellij.codeInsight.lookup.LookupEvent)1 TemplateState (com.intellij.codeInsight.template.impl.TemplateState)1 EditorWindow (com.intellij.injected.editor.EditorWindow)1 DocumentationProvider (com.intellij.lang.documentation.DocumentationProvider)1 Document (com.intellij.openapi.editor.Document)1 DocCommandGroupId (com.intellij.openapi.editor.actionSystem.DocCommandGroupId)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 RefactoringActionHandler (com.intellij.refactoring.RefactoringActionHandler)1 InplaceRefactoring (com.intellij.refactoring.rename.inplace.InplaceRefactoring)1 SpellCheckingInspection (com.intellij.spellchecker.inspections.SpellCheckingInspection)1 PopupUpdateProcessor (com.intellij.ui.popup.PopupUpdateProcessor)1