本文整理汇总了Java中com.intellij.codeInsight.lookup.impl.LookupImpl.isSelectionTouched方法的典型用法代码示例。如果您正苦于以下问题:Java LookupImpl.isSelectionTouched方法的具体用法?Java LookupImpl.isSelectionTouched怎么用?Java LookupImpl.isSelectionTouched使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.codeInsight.lookup.impl.LookupImpl
的用法示例。
在下文中一共展示了LookupImpl.isSelectionTouched方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasTemplatePrefix
import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入方法依赖的package包/类
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();
PsiDocumentManager.getInstance(file.getProject()).commitDocument(editor.getDocument());
return ((TemplateManagerImpl)TemplateManager.getInstance(file.getProject())).prepareTemplate(editor, shortcutChar, null) != null;
}
示例2: hasTemplatePrefix
import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入方法依赖的package包/类
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;
}
示例3: getItemToSelect
import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入方法依赖的package包/类
private static int getItemToSelect(LookupImpl lookup, List<LookupElement> items, boolean onExplicitAction, @Nullable LookupElement mostRelevant) {
if (items.isEmpty() || lookup.getFocusDegree() == LookupImpl.FocusDegree.UNFOCUSED) {
return 0;
}
if (lookup.isSelectionTouched() || !onExplicitAction) {
final LookupElement lastSelection = lookup.getCurrentItem();
int old = ContainerUtil.indexOfIdentity(items, lastSelection);
if (old >= 0) {
return old;
}
Object selectedValue = lookup.getList().getSelectedValue();
if (selectedValue instanceof EmptyLookupItem && ((EmptyLookupItem)selectedValue).isLoading()) {
int index = lookup.getList().getSelectedIndex();
if (index >= 0 && index < items.size()) {
return index;
}
}
for (int i = 0; i < items.size(); i++) {
String invariant = PRESENTATION_INVARIANT.get(items.get(i));
if (invariant != null && invariant.equals(PRESENTATION_INVARIANT.get(lastSelection))) {
return i;
}
}
}
String selectedText = lookup.getEditor().getSelectionModel().getSelectedText();
for (int i = 0; i < items.size(); i++) {
LookupElement item = items.get(i);
if (isAlphaSorted() && isPrefixItem(lookup, item, true) && !isLiveTemplate(item) ||
item.getLookupString().equals(selectedText)) {
return i;
}
}
return Math.max(0, ContainerUtil.indexOfIdentity(items, mostRelevant));
}
示例4: getItemToSelect
import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入方法依赖的package包/类
private int getItemToSelect(LookupImpl lookup, List<LookupElement> items, boolean onExplicitAction, @Nullable LookupElement mostRelevant) {
if (items.isEmpty() || lookup.getFocusDegree() == LookupImpl.FocusDegree.UNFOCUSED) {
return 0;
}
if (lookup.isSelectionTouched() || !onExplicitAction) {
final LookupElement lastSelection = lookup.getCurrentItem();
int old = ContainerUtil.indexOfIdentity(items, lastSelection);
if (old >= 0) {
return old;
}
Object selectedValue = lookup.getList().getSelectedValue();
if (selectedValue instanceof EmptyLookupItem && ((EmptyLookupItem)selectedValue).isLoading()) {
int index = lookup.getList().getSelectedIndex();
if (index >= 0 && index < items.size()) {
return index;
}
}
for (int i = 0; i < items.size(); i++) {
PresentationInvariant invariant = PRESENTATION_INVARIANT.get(items.get(i));
if (invariant != null && invariant.equals(GLOBAL_PRESENTATION_INVARIANT.get(lastSelection))) {
return i;
}
}
}
LookupElement exactMatch = getBestExactMatch(lookup, items);
return Math.max(0, ContainerUtil.indexOfIdentity(items, exactMatch != null ? exactMatch : mostRelevant));
}
示例5: hasTemplatePrefix
import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入方法依赖的package包/类
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;
}
示例6: getItemToSelect
import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入方法依赖的package包/类
private static int getItemToSelect(LookupImpl lookup, List<LookupElement> items, boolean onExplicitAction, @Nullable LookupElement mostRelevant) {
if (items.isEmpty() || lookup.getFocusDegree() == LookupImpl.FocusDegree.UNFOCUSED) {
return 0;
}
if (lookup.isSelectionTouched() || !onExplicitAction) {
final LookupElement lastSelection = lookup.getCurrentItem();
int old = ContainerUtil.indexOfIdentity(items, lastSelection);
if (old >= 0) {
return old;
}
Object selectedValue = lookup.getList().getSelectedValue();
if (selectedValue instanceof EmptyLookupItem && ((EmptyLookupItem)selectedValue).isLoading()) {
int index = lookup.getList().getSelectedIndex();
if (index >= 0 && index < items.size()) {
return index;
}
}
for (int i = 0; i < items.size(); i++) {
String invariant = PRESENTATION_INVARIANT.get(items.get(i));
if (invariant != null && invariant.equals(PRESENTATION_INVARIANT.get(lastSelection))) {
return i;
}
}
}
String selectedText = lookup.getEditor().getSelectionModel().getSelectedText();
int exactMatchIndex = -1;
for (int i = 0; i < items.size(); i++) {
LookupElement item = items.get(i);
boolean isSuddenLiveTemplate = isSuddenLiveTemplate(item);
if (isPrefixItem(lookup, item, true) && !isSuddenLiveTemplate || item.getLookupString().equals(selectedText)) {
if (item instanceof LiveTemplateLookupElement) {
// prefer most recent live template lookup item
exactMatchIndex = i;
break;
}
if (exactMatchIndex == -1) {
// prefer most recent item
exactMatchIndex = i;
}
}
else if (i == 0 && isSuddenLiveTemplate && items.size() > 1 && !CompletionServiceImpl.isStartMatch(items.get(1), lookup)) {
return 0;
}
}
if (exactMatchIndex >= 0) {
return exactMatchIndex;
}
return Math.max(0, ContainerUtil.indexOfIdentity(items, mostRelevant));
}