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());
}
}
});
}
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);
}
}
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;
}
}
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);
}
}
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");
}
Aggregations