com.intellij.codeInsight.lookup.impl.LookupImpl Java Examples

The following examples show how to use com.intellij.codeInsight.lookup.impl.LookupImpl. 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: ShowQuickDocInfoAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  final Project project = e.getData(CommonDataKeys.PROJECT);
  final Editor editor = e.getData(CommonDataKeys.EDITOR);
  final PsiElement element = e.getData(CommonDataKeys.PSI_ELEMENT);

  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, new Runnable() {
      @Override
      public void run() {
        DocumentationManager.getInstance(project).showJavaDocInfo(element, null);
      }
    }, getCommandName(), null);
  }
}
 
Example #2
Source File: CompletionAutoPopupHandler.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public Result checkAutoPopup(char charTyped, @Nonnull final Project project, @Nonnull final Editor editor, @Nonnull 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.isLetterOrDigit(charTyped) || charTyped == '_') {
    AutoPopupController.getInstance(project).scheduleAutoPopup(editor);
    return Result.STOP;
  }

  return Result.CONTINUE;
}
 
Example #3
Source File: EscapeHandler.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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);
  }
}
 
Example #4
Source File: TemplateState.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public synchronized void dispose() {
  if (myLookupListener != null) {
    final LookupImpl lookup = myEditor != null ? (LookupImpl)LookupManager.getActiveLookup(myEditor) : null;
    if (lookup != null) {
      lookup.removeLookupListener(myLookupListener);
    }
    myLookupListener = null;
  }

  myEditorDocumentListener = null;
  myCommandListener = null;
  myCaretListener = null;

  myProcessor = null;

  //Avoid the leak of the editor
  releaseAll();
  myDocument = null;
}
 
Example #5
Source File: CodeCompletionHandlerBase.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private LookupImpl obtainLookup(Editor editor, Project project) {
  CompletionAssertions.checkEditorValid(editor);
  LookupImpl existing = (LookupImpl)LookupManager.getActiveLookup(editor);
  if (existing != null && existing.isCompletion()) {
    existing.markReused();
    if (!autopopup) {
      existing.setFocusDegree(LookupImpl.FocusDegree.FOCUSED);
    }
    return existing;
  }

  LookupImpl lookup = (LookupImpl)LookupManager.getInstance(project).createLookup(editor, LookupElement.EMPTY_ARRAY, "", new LookupArranger.DefaultArranger());
  if (editor.isOneLineMode()) {
    lookup.setCancelOnClickOutside(true);
    lookup.setCancelOnOtherWindowOpen(true);
  }
  lookup.setFocusDegree(autopopup ? LookupImpl.FocusDegree.UNFOCUSED : LookupImpl.FocusDegree.FOCUSED);
  return lookup;
}
 
Example #6
Source File: InplaceRefactoring.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void restoreOldCaretPositionAndSelection(final int offset) {
  //move to old offset
  Runnable runnable = new Runnable() {
    @Override
    public void run() {
      myEditor.getCaretModel().moveToOffset(restoreCaretOffset(offset));
      restoreSelection();
    }
  };

  final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(myEditor);
  if (lookup != null && lookup.getLookupStart() <= (restoreCaretOffset(offset))) {
    lookup.setFocusDegree(LookupImpl.FocusDegree.UNFOCUSED);
    lookup.performGuardedChange(runnable);
  }
  else {
    runnable.run();
  }
}
 
Example #7
Source File: EscapeHandler.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(Editor editor, DataContext dataContext) {
  final SelectionModel selectionModel = editor.getSelectionModel();
  if (selectionModel.hasSelection()) {
    final TemplateState state = TemplateManagerImpl.getTemplateState(editor);
    if (state != null && editor.getUserData(InplaceRefactoring.INPLACE_RENAMER) != null) {
      final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(editor);
      if (lookup != null) {
        selectionModel.removeSelection();
        lookup.hide();
        return;
      }
    }
  }

  myOriginalHandler.execute(editor, dataContext);
}
 
Example #8
Source File: DumpLookupElementWeights.java    From consulo with Apache License 2.0 5 votes vote down vote up
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){}
}
 
Example #9
Source File: ConsoleExecuteAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public final void update(@Nonnull AnActionEvent e) {
  EditorEx editor = myConsoleView.getConsoleEditor();
  boolean enabled = !editor.isRendererMode() && isEnabled() &&
                    (myExecuteActionHandler.isEmptyCommandExecutionAllowed() || !StringUtil.isEmptyOrSpaces(editor.getDocument().getCharsSequence()));
  if (enabled) {
    Lookup lookup = LookupManager.getActiveLookup(editor);
    // we should check getCurrentItem() also - fast typing could produce outdated lookup, such lookup reports isCompletion() true
    enabled = lookup == null || !lookup.isCompletion() || lookup.getCurrentItem() == null ||
              (lookup instanceof LookupImpl && ((LookupImpl)lookup).getFocusDegree() == LookupImpl.FocusDegree.UNFOCUSED);
  }

  e.getPresentation().setEnabled(enabled);
}
 
Example #10
Source File: ChooseItemAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #11
Source File: ChooseItemAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isEnabled(Editor editor, DataContext dataContext) {
  LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(editor);
  if (lookup == null) return false;
  if (!lookup.isAvailableToUser()) return false;
  if (focusedOnly && lookup.getFocusDegree() == LookupImpl.FocusDegree.UNFOCUSED) return false;
  if (finishingChar == Lookup.REPLACE_SELECT_CHAR) {
    return !lookup.getItems().isEmpty();
  }

  return true;
}
 
Example #12
Source File: DesktopPsiAwareTextEditorImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Object getData(@Nonnull final Key<?> dataId) {
  if (PlatformDataKeys.DOMINANT_HINT_AREA_RECTANGLE == dataId) {
    final LookupImpl lookup = (LookupImpl)LookupManager.getInstance(myProject).getActiveLookup();
    if (lookup != null && lookup.isVisible()) {
      return lookup.getBounds();
    }
  }
  if (LangDataKeys.MODULE == dataId) {
    return ModuleUtilCore.findModuleForFile(myFile, myProject);
  }
  return super.getData(dataId);
}
 
Example #13
Source File: ChooseItemAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(@Nonnull final Editor editor, final DataContext dataContext) {
  final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(editor);
  if (lookup == null) {
    throw new AssertionError("The last lookup disposed at: " + LookupImpl.getLastLookupDisposeTrace() + "\n-----------------------\n");
  }

  if ((finishingChar == Lookup.NORMAL_SELECT_CHAR || finishingChar == Lookup.REPLACE_SELECT_CHAR) &&
      hasTemplatePrefix(lookup, finishingChar)) {
    lookup.hideLookup(true);

    ExpandLiveTemplateCustomAction.createExpandTemplateHandler(finishingChar).execute(editor, null, dataContext);

    return;
  }

  if (finishingChar == Lookup.NORMAL_SELECT_CHAR) {
    if (!lookup.isFocused()) {
      FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.EDITING_COMPLETION_CONTROL_ENTER);
    }
  } else if (finishingChar == Lookup.COMPLETE_STATEMENT_SELECT_CHAR) {
    FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.EDITING_COMPLETION_FINISH_BY_SMART_ENTER);
  } else if (finishingChar == Lookup.REPLACE_SELECT_CHAR) {
    FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.EDITING_COMPLETION_REPLACE);
  } else if (finishingChar == '.')  {
    FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.EDITING_COMPLETION_FINISH_BY_CONTROL_DOT);
  }

  lookup.finishLookup(finishingChar);
}
 
Example #14
Source File: DumpLookupElementWeights.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static List<String> getLookupElementWeights(LookupImpl lookup, boolean hideSingleValued) {
  final Map<LookupElement, List<Pair<String, Object>>> weights = lookup.getRelevanceObjects(lookup.getItems(), hideSingleValued);
  return ContainerUtil.map(weights.entrySet(), new Function<Map.Entry<LookupElement, List<Pair<String, Object>>>, String>() {
    @Override
    public String fun(Map.Entry<LookupElement, List<Pair<String, Object>>> entry) {
      return entry.getKey().getLookupString() + "\t" + StringUtil.join(entry.getValue(), new Function<Pair<String, Object>, String>() {
        @Override
        public String fun(Pair<String, Object> pair) {
          return pair.first + "=" + pair.second;
        }
      }, ", ");
    }
  });
}
 
Example #15
Source File: TemplateState.java    From consulo with Apache License 2.0 5 votes vote down vote up
public boolean isToProcessTab() {
  if (isCaretOutsideCurrentSegment()) {
    return false;
  }
  if (ourLookupShown) {
    final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(myEditor);
    if (lookup != null && !lookup.isFocused()) {
      return true;
    }
  }

  return !ourLookupShown;
}
 
Example #16
Source File: ListTemplatesHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
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 #17
Source File: ListTemplatesHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
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 #18
Source File: ListTemplatesHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void showTemplatesLookup(final Project project, final Editor editor, Map<TemplateImpl, String> template2Argument) {
  final LookupImpl lookup = (LookupImpl)LookupManager.getInstance(project).createLookup(editor, LookupElement.EMPTY_ARRAY, "",
                                                                                        new LookupArranger.DefaultArranger());
  for (TemplateImpl template : template2Argument.keySet()) {
    String prefix = computePrefix(template, template2Argument.get(template));
    lookup.addItem(createTemplateElement(template), new PlainPrefixMatcher(prefix));
  }

  showLookup(lookup, template2Argument);
}
 
Example #19
Source File: AbtractTemplateTest.java    From idea-php-typo3-plugin with MIT License 5 votes vote down vote up
protected void testLiveTemplateIsAvailable(String completionChar, String templateContent, Class templateClass) {
    myFixture.configureByText("foo.fluid", templateContent);
    type(completionChar);
    LookupImpl lookup = getLookup();
    assertNotNull(lookup);

    LookupElement item = lookup.getCurrentItem();
    assertNotNull(item);
    assertInstanceOf(item, PostfixTemplateLookupElement.class);
    assertInstanceOf(((PostfixTemplateLookupElement) item).getPostfixTemplate(), templateClass);
}
 
Example #20
Source File: CompletionLookupArrangerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private int getItemToSelect(LookupElementListPresenter lookup, List<? extends 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;
    }

    LookupElement selectedValue = lookup.getCurrentItemOrEmpty();
    if (selectedValue instanceof EmptyLookupItem && ((EmptyLookupItem)selectedValue).isLoading()) {
      int index = lookup.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(PRESENTATION_INVARIANT.get(lastSelection))) {
        return i;
      }
    }
  }

  LookupElement exactMatch = getBestExactMatch(items);
  return Math.max(0, ContainerUtil.indexOfIdentity(items, exactMatch != null ? exactMatch : mostRelevant));
}
 
Example #21
Source File: CompletionLookupArrangerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void prefixTruncated(@Nonnull LookupImpl lookup, int hideOffset) {
  if (hideOffset < lookup.getEditor().getCaretModel().getOffset()) {
    myProcess.scheduleRestart();
    return;
  }
  myProcess.prefixUpdated();
  lookup.hideLookup(false);
}
 
Example #22
Source File: BuildLabelAutoCompletionTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
private List<String> currentLookupStrings() {
  LookupImpl lookup = completionTester.getLookup();
  if (lookup == null) {
    return ImmutableList.of();
  }
  return lookup
      .getItems()
      .stream()
      .map(LookupElement::getLookupString)
      .collect(Collectors.toList());
}
 
Example #23
Source File: BuildFileAutoCompletionTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
private List<String> currentLookupStrings() {
  LookupImpl lookup = completionTester.getLookup();
  if (lookup == null) {
    return ImmutableList.of();
  }
  return lookup
      .getItems()
      .stream()
      .map(LookupElement::getLookupString)
      .collect(Collectors.toList());
}
 
Example #24
Source File: CompletionProgressIndicator.java    From consulo with Apache License 2.0 5 votes vote down vote up
void duringCompletion(CompletionInitializationContext initContext, CompletionParameters parameters) {
  if (isAutopopupCompletion() && shouldPreselectFirstSuggestion(parameters)) {
    myLookup.setFocusDegree(CodeInsightSettings.getInstance().isSelectAutopopupSuggestionsByChars() ? LookupImpl.FocusDegree.FOCUSED : LookupImpl.FocusDegree.SEMI_FOCUSED);
  }
  addDefaultAdvertisements(parameters);

  ProgressManager.checkCanceled();

  Document document = initContext.getEditor().getDocument();
  if (!initContext.getOffsetMap().wasModified(CompletionInitializationContext.IDENTIFIER_END_OFFSET)) {
    try {
      final int selectionEndOffset = initContext.getSelectionEndOffset();
      final PsiReference reference = TargetElementUtil.findReference(myEditor, selectionEndOffset);
      if (reference != null) {
        final int replacementOffset = findReplacementOffset(selectionEndOffset, reference);
        if (replacementOffset > document.getTextLength()) {
          LOG.error("Invalid replacementOffset: " + replacementOffset + " returned by reference " + reference + " of " + reference.getClass() +
                    "; doc=" + document +
                    "; doc actual=" + (document == initContext.getFile().getViewProvider().getDocument()) +
                    "; doc committed=" + PsiDocumentManager.getInstance(getProject()).isCommitted(document));
        }
        else {
          initContext.setReplacementOffset(replacementOffset);
        }
      }
    }
    catch (IndexNotReadyException ignored) {
    }
  }

  for (CompletionContributor contributor : CompletionContributor.forLanguageHonorDumbness(initContext.getPositionLanguage(), initContext.getProject())) {
    ProgressManager.checkCanceled();
    contributor.duringCompletion(initContext);
  }
  if (document instanceof DocumentWindow) {
    myHostOffsets = new OffsetsInFile(initContext.getFile(), initContext.getOffsetMap()).toTopLevelFile();
  }
}
 
Example #25
Source File: CompletionProgressIndicator.java    From consulo with Apache License 2.0 5 votes vote down vote up
CompletionProgressIndicator(Editor editor, @Nonnull Caret caret, int invocationCount,
                            CodeCompletionHandlerBase handler, @Nonnull OffsetMap offsetMap, @Nonnull OffsetsInFile hostOffsets,
                            boolean hasModifiers, @Nonnull LookupImpl lookup) {
  myEditor = editor;
  myCaret = caret;
  myHandler = handler;
  myCompletionType = handler.completionType;
  myInvocationCount = invocationCount;
  myOffsetMap = offsetMap;
  myHostOffsets = hostOffsets;
  myLookup = lookup;
  myStartCaret = myEditor.getCaretModel().getOffset();
  myThreading = ApplicationManager.getApplication().isWriteAccessAllowed() || myHandler.isTestingCompletionQualityMode() ? new SyncCompletion() : new AsyncCompletion();

  myAdvertiserChanges.offer(() -> myLookup.getAdvertiser().clearAdvertisements());

  myArranger = new CompletionLookupArrangerImpl(this);
  myLookup.setArranger(myArranger);

  myLookup.addLookupListener(myLookupListener);
  myLookup.setCalculating(true);

  myLookupManagerListener = evt -> {
    if (evt.getNewValue() != null) {
      LOG.error("An attempt to change the lookup during completion, phase = " + CompletionServiceImpl.getCompletionPhase());
    }
  };
  LookupManager.getInstance(getProject()).addPropertyChangeListener(myLookupManagerListener);

  myQueue = new MergingUpdateQueue("completion lookup progress", ourShowPopupAfterFirstItemGroupingTime, true, myEditor.getContentComponent());
  myQueue.setPassThrough(false);

  ApplicationManager.getApplication().assertIsDispatchThread();

  if (hasModifiers && !ApplicationManager.getApplication().isUnitTestMode()) {
    trackModifiers();
  }
}
 
Example #26
Source File: CodeInsightTestFixtureImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void finishLookup(final char completionChar) {
  CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
    @Override
    public void run() {
      ((LookupImpl)LookupManager.getActiveLookup(getEditor())).finishLookup(completionChar);
    }
  }, null, null);
}
 
Example #27
Source File: CodeInsightTestFixtureImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@javax.annotation.Nullable
public LookupElement[] getLookupElements() {
  LookupImpl lookup = getLookup();
  if (lookup == null) {
    return myEmptyLookup ? LookupElement.EMPTY_ARRAY : null;
  }
  else {
    final List<LookupElement> list = lookup.getItems();
    return list.toArray(new LookupElement[list.size()]);
  }
}
 
Example #28
Source File: FluidCompletionAutoPopupTestCase.java    From idea-php-typo3-plugin with MIT License 4 votes vote down vote up
public LookupImpl getLookup() {
    return (LookupImpl)myFixture.getLookup();
}
 
Example #29
Source File: HaxeLiveTemplatesTest.java    From intellij-haxe with Apache License 2.0 4 votes vote down vote up
public static void expandTemplate(final Editor editor) {
  new ListTemplatesAction().actionPerformedImpl(editor.getProject(), editor);
  ((LookupImpl)LookupManager.getActiveLookup(editor)).finishLookup(Lookup.NORMAL_SELECT_CHAR);

}
 
Example #30
Source File: DumpLookupElementWeights.java    From consulo with Apache License 2.0 4 votes vote down vote up
@RequiredUIAccess
@Override
public void actionPerformed(@Nonnull final AnActionEvent e) {
  final Editor editor = e.getData(CommonDataKeys.EDITOR);
  dumpLookupElementWeights((LookupImpl)LookupManager.getActiveLookup(editor));
}