Java Code Examples for com.intellij.codeInsight.lookup.impl.LookupImpl#getEditor()
The following examples show how to use
com.intellij.codeInsight.lookup.impl.LookupImpl#getEditor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListTemplatesHandler.java From consulo with Apache License 2.0 | 5 votes |
private static void showLookup(LookupImpl lookup, @Nullable Map<TemplateImpl, String> template2Argument) { Editor editor = lookup.getEditor(); Project project = editor.getProject(); lookup.addLookupListener(new MyLookupAdapter(project, editor, template2Argument)); lookup.refreshUi(false, true); lookup.showLookup(); }
Example 2
Source File: ListTemplatesHandler.java From consulo with Apache License 2.0 | 5 votes |
private static void showLookup(LookupImpl lookup, @Nonnull PsiFile file) { Editor editor = lookup.getEditor(); Project project = editor.getProject(); lookup.addLookupListener(new MyLookupAdapter(project, editor, file)); lookup.refreshUi(false, true); lookup.showLookup(); }
Example 3
Source File: ChooseItemAction.java From consulo with Apache License 2.0 | 5 votes |
public static boolean hasTemplatePrefix(LookupImpl lookup, char shortcutChar) { lookup.refreshUi(false, false); // to bring the list model up to date CompletionProcess completion = CompletionService.getCompletionService().getCurrentCompletion(); if (completion == null || !completion.isAutopopupCompletion()) { return false; } if (lookup.isSelectionTouched()) { return false; } final PsiFile file = lookup.getPsiFile(); if (file == null) return false; final Editor editor = lookup.getEditor(); final int offset = editor.getCaretModel().getOffset(); PsiDocumentManager.getInstance(file.getProject()).commitDocument(editor.getDocument()); final LiveTemplateLookupElement liveTemplateLookup = ContainerUtil.findInstance(lookup.getItems(), LiveTemplateLookupElement.class); if (liveTemplateLookup == null || !liveTemplateLookup.sudden) { // Lookup doesn't contain sudden live templates. It means that // - there are no live template with given key: // in this case we should find live template with appropriate prefix (custom live templates doesn't participate in this action). // - completion provider worked too long: // in this case we should check custom templates that provides completion lookup. if (LiveTemplateCompletionContributor.customTemplateAvailableAndHasCompletionItem(shortcutChar, editor, file, offset)) { return true; } List<TemplateImpl> templates = TemplateManagerImpl.listApplicableTemplateWithInsertingDummyIdentifier(editor, file, false); TemplateImpl template = LiveTemplateCompletionContributor.findFullMatchedApplicableTemplate(editor, offset, templates); if (template != null && shortcutChar == TemplateSettings.getInstance().getShortcutChar(template)) { return true; } return false; } return liveTemplateLookup.getTemplateShortcut() == shortcutChar; }