当前位置: 首页>>代码示例>>Java>>正文


Java LookupImpl.getCurrentItem方法代码示例

本文整理汇总了Java中com.intellij.codeInsight.lookup.impl.LookupImpl.getCurrentItem方法的典型用法代码示例。如果您正苦于以下问题:Java LookupImpl.getCurrentItem方法的具体用法?Java LookupImpl.getCurrentItem怎么用?Java LookupImpl.getCurrentItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.codeInsight.lookup.impl.LookupImpl的用法示例。


在下文中一共展示了LookupImpl.getCurrentItem方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入方法依赖的package包/类
@Override
public void execute(Editor editor, DataContext dataContext) {
  TemplateState templateState = TemplateManagerImpl.getTemplateState(editor);
  if (templateState != null && !templateState.isFinished()) {
    SelectionModel selectionModel = editor.getSelectionModel();
    LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(editor);

    // the idea behind lookup checking is that if there is a preselected value in lookup
    // then user might want just to close lookup but not finish a template.
    // E.g. user wants to move to the next template segment by Tab without completion invocation.
    // If there is no selected value in completion that user definitely wants to finish template
    boolean lookupIsEmpty = lookup == null || lookup.getCurrentItem() == null;
    if (!selectionModel.hasSelection() && lookupIsEmpty) {
      CommandProcessor.getInstance().setCurrentCommandName(CodeInsightBundle.message("finish.template.command"));
      templateState.gotoEnd(true);
      return;
    }
  }

  if (myOriginalHandler.isEnabled(editor, dataContext)) {
    myOriginalHandler.execute(editor, dataContext);
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:EscapeHandler.java

示例2: testAutopopupWithEnabledLiveTemplatesInCompletion

import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入方法依赖的package包/类
public void testAutopopupWithEnabledLiveTemplatesInCompletion() {
  LiveTemplateCompletionContributor.setShowTemplatesInTests(false, getTestRootDisposable());

  configureByFile();
  type("instanceof");
  LookupImpl lookup = getLookup();
  assertNotNull(lookup);
  assertEquals(1, lookup.getItems().size());
  LookupElement item = lookup.getCurrentItem();
  assertNotNull(item);
  assertInstanceOf(item, PostfixTemplateLookupElement.class);
  assertInstanceOf(((PostfixTemplateLookupElement)item).getPostfixTemplate(), InstanceofExpressionPostfixTemplate.class);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:TemplatesCompletionTest.java

示例3: doAutoPopupTest

import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入方法依赖的package包/类
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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:TemplatesCompletionTest.java

示例4: dumpLookupElementWeights

import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入方法依赖的package包/类
public static void dumpLookupElementWeights(final LookupImpl lookup) {
  LookupElement selected = lookup.getCurrentItem();
  String sb = "selected: " + selected;
  if (selected != null) {
    sb += "\nprefix: " + lookup.itemPattern(selected);
  }
  sb += "\nweights:\n" + StringUtil.join(getLookupElementWeights(lookup), "\n");
  System.out.println(sb);
  LOG.info(sb);
  try {
    CopyPasteManager.getInstance().setContents(new StringSelection(sb));
  } catch (Exception ignore){}
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:DumpLookupElementWeights.java

示例5: 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));
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:40,代码来源:CompletionLookupArranger.java

示例6: 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));
}
 
开发者ID:consulo,项目名称:consulo,代码行数:32,代码来源:CompletionLookupArranger.java

示例7: dumpLookupElementWeights

import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入方法依赖的package包/类
public static void dumpLookupElementWeights(final LookupImpl lookup) {
  LookupElement selected = lookup.getCurrentItem();
  String sb = "selected: " + selected;
  if (selected != null) {
    sb += "\nprefix: " + lookup.itemPattern(selected);
  }
  sb += "\nweights:\n" + StringUtil.join(getLookupElementWeights(lookup, true), "\n");
  System.out.println(sb);
  LOG.info(sb);
  try {
    CopyPasteManager.getInstance().setContents(new StringSelection(sb));
  } catch (Exception ignore){}
}
 
开发者ID:consulo,项目名称:consulo,代码行数:14,代码来源:DumpLookupElementWeights.java

示例8: 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));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:55,代码来源:CompletionLookupArranger.java


注:本文中的com.intellij.codeInsight.lookup.impl.LookupImpl.getCurrentItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。