use of com.intellij.codeInsight.completion.CodeCompletionHandlerBase in project intellij-community by JetBrains.
the class CodeInsightTestFixtureImpl method complete.
@Override
public LookupElement[] complete(@NotNull final CompletionType type, final int invocationCount) {
assertInitialized();
myEmptyLookup = false;
return UIUtil.invokeAndWaitIfNeeded(new Computable<LookupElement[]>() {
@Override
public LookupElement[] compute() {
CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
@Override
public void run() {
final CodeCompletionHandlerBase handler = new CodeCompletionHandlerBase(type) {
@Override
@SuppressWarnings("deprecation")
protected void completionFinished(CompletionProgressIndicator indicator, boolean hasModifiers) {
myEmptyLookup = indicator.getLookup().getItems().isEmpty();
super.completionFinished(indicator, hasModifiers);
}
};
Editor editor = getCompletionEditor();
assertNotNull(editor);
handler.invokeCompletion(getProject(), editor, invocationCount);
// to compare with file text
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
}
}, null, null, getEditor().getDocument());
return getLookupElements();
}
});
}
use of com.intellij.codeInsight.completion.CodeCompletionHandlerBase in project Perl5-IDEA by Camelcade.
the class PerlAnnotationInsertHandler method handleInsert.
@Override
public void handleInsert(final InsertionContext context, LookupElement item) {
final Editor editor = context.getEditor();
if ("returns".equals(item.getLookupString())) {
EditorModificationUtil.insertStringAtCaret(editor, " ");
context.setLaterRunnable(() -> new CodeCompletionHandlerBase(CompletionType.BASIC).invokeCompletion(context.getProject(), editor, 1));
}
}
use of com.intellij.codeInsight.completion.CodeCompletionHandlerBase in project smali by JesusFreke.
the class SmaliCodeFragmentFactoryTest method assertCompletionContains.
private void assertCompletionContains(String completionText, PsiElement context, String[] expectedItems, String[] disallowedItems) {
SmaliCodeFragmentFactory codeFragmentFactory = new SmaliCodeFragmentFactory();
JavaCodeFragment fragment = codeFragmentFactory.createCodeFragment(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, completionText), context, getProject());
Editor editor = createEditor(fragment.getVirtualFile());
editor.getCaretModel().moveToOffset(completionText.length());
new CodeCompletionHandlerBase(CompletionType.BASIC).invokeCompletion(getProject(), editor);
List<LookupElement> elements = LookupManager.getInstance(getProject()).getActiveLookup().getItems();
HashSet expectedSet = Sets.newHashSet(expectedItems);
HashSet disallowedSet = Sets.newHashSet(disallowedItems);
for (LookupElement element : elements) {
expectedSet.remove(element.toString());
Assert.assertFalse(disallowedSet.contains(element.toString()));
}
Assert.assertTrue(expectedSet.size() == 0);
}
use of com.intellij.codeInsight.completion.CodeCompletionHandlerBase in project intellij-plugins by JetBrains.
the class FlexCssCompletionTest method testClassReferenceCompletion.
@JSTestOptions({ JSTestOption.WithJsSupportLoader, JSTestOption.WithFlexFacet })
public void testClassReferenceCompletion() throws Exception {
configureByFiles(null, FlexCompletionTest.BASE_PATH + getTestName(false) + ".css");
new CodeCompletionHandlerBase(CompletionType.BASIC).invokeCompletion(myProject, myEditor);
checkResultByFile(FlexCompletionTest.BASE_PATH + getTestName(false) + "_after.css");
}
use of com.intellij.codeInsight.completion.CodeCompletionHandlerBase in project intellij-community by JetBrains.
the class XmlHighlightingTest method testCorrectGeneratedDtdUpdate.
public void testCorrectGeneratedDtdUpdate() throws Exception {
configureByFile(BASE_PATH + getTestName(false) + ".xml");
Collection<HighlightInfo> infos = filterInfos(doHighlighting());
assertEquals(2, infos.size());
WriteCommandAction.runWriteCommandAction(null, () -> EditorModificationUtil.deleteSelectedText(myEditor));
infos = filterInfos(doHighlighting());
assertEquals(11, infos.size());
WriteCommandAction.runWriteCommandAction(null, () -> EditorModificationUtil.insertStringAtCaret(myEditor, "<"));
new CodeCompletionHandlerBase(CompletionType.BASIC).invokeCompletion(myProject, myEditor);
infos = filterInfos(doHighlighting());
assertEquals(2, infos.size());
LookupManager.getInstance(myProject).hideActiveLookup();
}
Aggregations