use of com.intellij.codeInsight.lookup.impl.LookupImpl in project intellij-community by JetBrains.
the class ShowQuickDocInfoAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
DataContext dataContext = e.getDataContext();
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
final PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
if (project != null && editor != null) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(CODEASSISTS_QUICKJAVADOC_FEATURE);
final LookupImpl lookup = (LookupImpl) LookupManager.getInstance(project).getActiveLookup();
if (lookup != null) {
//dumpLookupElementWeights(lookup);
FeatureUsageTracker.getInstance().triggerFeatureUsed(CODEASSISTS_QUICKJAVADOC_LOOKUP_FEATURE);
}
actionPerformedImpl(project, editor);
} else if (project != null && element != null) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(CODEASSISTS_QUICKJAVADOC_CTRLN_FEATURE);
CommandProcessor.getInstance().executeCommand(project, () -> DocumentationManager.getInstance(project).showJavaDocInfo(element, null), getCommandName(), null);
}
}
use of com.intellij.codeInsight.lookup.impl.LookupImpl in project intellij-community by JetBrains.
the class CompletionAutoPopupHandler method checkAutoPopup.
@Override
public Result checkAutoPopup(char charTyped, final Project project, final Editor editor, final PsiFile file) {
LookupImpl lookup = (LookupImpl) LookupManager.getActiveLookup(editor);
if (LOG.isDebugEnabled()) {
LOG.debug("checkAutoPopup: character=" + charTyped + ";");
LOG.debug("phase=" + CompletionServiceImpl.getCompletionPhase());
LOG.debug("lookup=" + lookup);
LOG.debug("currentCompletion=" + CompletionServiceImpl.getCompletionService().getCurrentCompletion());
}
if (lookup != null) {
if (editor.getSelectionModel().hasSelection()) {
lookup.performGuardedChange(() -> EditorModificationUtil.deleteSelectedText(editor));
}
return Result.STOP;
}
if (Character.isLetter(charTyped) || charTyped == '_') {
AutoPopupController.getInstance(project).scheduleAutoPopup(editor);
return Result.STOP;
}
return Result.CONTINUE;
}
use of com.intellij.codeInsight.lookup.impl.LookupImpl in project intellij-community by JetBrains.
the class CompletionTestBase method doTest.
protected void doTest(String directory) {
CamelHumpMatcher.forceStartMatching(myFixture.getTestRootDisposable());
final List<String> stringList = TestUtils.readInput(getTestDataPath() + "/" + getTestName(true) + ".test");
if (directory.length() != 0)
directory += "/";
final String fileName = directory + getTestName(true) + "." + getExtension();
myFixture.addFileToProject(fileName, stringList.get(0));
myFixture.configureByFile(fileName);
boolean old = CodeInsightSettings.getInstance().AUTOCOMPLETE_COMMON_PREFIX;
CodeInsightSettings.getInstance().AUTOCOMPLETE_COMMON_PREFIX = false;
CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = false;
String result = "";
try {
myFixture.completeBasic();
final LookupImpl lookup = (LookupImpl) LookupManager.getActiveLookup(myFixture.getEditor());
if (lookup != null) {
List<LookupElement> items = lookup.getItems();
if (!addReferenceVariants()) {
items = ContainerUtil.findAll(items, lookupElement -> {
final Object o = lookupElement.getObject();
return !(o instanceof PsiMember) && !(o instanceof GrVariable) && !(o instanceof GroovyResolveResult) && !(o instanceof PsiPackage);
});
}
Collections.sort(items, (o1, o2) -> o1.getLookupString().compareTo(o2.getLookupString()));
result = "";
for (LookupElement item : items) {
result = result + "\n" + item.getLookupString();
}
result = result.trim();
LookupManager.getInstance(myFixture.getProject()).hideActiveLookup();
}
} finally {
CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = true;
CodeInsightSettings.getInstance().AUTOCOMPLETE_COMMON_PREFIX = old;
}
assertEquals(StringUtil.trimEnd(stringList.get(1), "\n"), result);
}
use of com.intellij.codeInsight.lookup.impl.LookupImpl in project intellij-community by JetBrains.
the class CompletionTestCase method selectItem.
protected void selectItem(LookupElement item, char ch) {
final LookupImpl lookup = (LookupImpl) LookupManager.getInstance(myProject).getActiveLookup();
assert lookup != null;
lookup.setCurrentItem(item);
lookup.finishLookup(ch);
}
use of com.intellij.codeInsight.lookup.impl.LookupImpl in project intellij-community by JetBrains.
the class LightCompletionTestCase method complete.
protected void complete(final int time) {
new CodeCompletionHandlerBase(myType).invokeCompletion(getProject(), getEditor(), time);
LookupImpl lookup = (LookupImpl) LookupManager.getActiveLookup(myEditor);
myItems = lookup == null ? null : lookup.getItems().toArray(LookupElement.EMPTY_ARRAY);
myPrefix = lookup == null ? null : lookup.itemPattern(lookup.getItems().get(0));
}
Aggregations