• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java CompletionServiceImpl类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中com.intellij.codeInsight.completion.impl.CompletionServiceImpl的典型用法代码示例。如果您正苦于以下问题:Java CompletionServiceImpl类的具体用法?Java CompletionServiceImpl怎么用?Java CompletionServiceImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

CompletionServiceImpl类属于com.intellij.codeInsight.completion.impl包,在下文中一共展示了CompletionServiceImpl类的34个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: finishCompletionProcess

点赞 3

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
private void finishCompletionProcess(boolean disposeOffsetMap) {
  cancel();

  ApplicationManager.getApplication().assertIsDispatchThread();
  Disposer.dispose(myQueue);
  LookupManager.getInstance(getProject()).removePropertyChangeListener(myLookupManagerListener);

  CompletionProgressIndicator currentCompletion = CompletionServiceImpl.getCompletionService().getCurrentCompletion();
  LOG.assertTrue(currentCompletion == this, currentCompletion + "!=" + this);

  CompletionServiceImpl
    .assertPhase(CompletionPhase.BgCalculation.class, CompletionPhase.ItemsCalculated.class, CompletionPhase.Synchronous.class,
                 CompletionPhase.CommittingDocuments.class);
  CompletionPhase oldPhase = CompletionServiceImpl.getCompletionPhase();
  if (oldPhase instanceof CompletionPhase.CommittingDocuments) {
    LOG.assertTrue(((CompletionPhase.CommittingDocuments)oldPhase).isRestartingCompletion(), oldPhase);
    ((CompletionPhase.CommittingDocuments)oldPhase).replaced = true;
  }
  CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
  if (disposeOffsetMap) {
    disposeIndicator();
  }
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:24,
代码来源:CompletionProgressIndicator.java

示例2: hideAutopopupIfMeaningless

点赞 3

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
private boolean hideAutopopupIfMeaningless() {
  if (!myLookup.isLookupDisposed() && isAutopopupCompletion() && !myLookup.isSelectionTouched() && !myLookup.isCalculating()) {
    myLookup.refreshUi(true, false);
    final List<LookupElement> items = myLookup.getItems();

    for (LookupElement item : items) {
      if (!myLookup.itemPattern(item).equals(item.getLookupString())) {
        return false;
      }

      if (item.isValid() && item.isWorthShowingInAutoPopup()) {
        return false;
      }
    }

    myLookup.hideLookup(false);
    LOG.assertTrue(CompletionServiceImpl.getCompletionService().getCurrentCompletion() == null);
    CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
    return true;
  }
  return false;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:23,
代码来源:CompletionProgressIndicator.java

示例3: handleEmptyLookup

点赞 3

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
protected void handleEmptyLookup(final boolean awaitSecondInvocation) {
  if (isAutopopupCompletion() && ApplicationManager.getApplication().isUnitTestMode()) {
    return;
  }

  LOG.assertTrue(!isAutopopupCompletion());

  if (ApplicationManager.getApplication().isUnitTestMode() || !myHandler.invokedExplicitly) {
    CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
    return;
  }

  for (final CompletionContributor contributor : CompletionContributor.forParameters(getParameters())) {
    final String text = contributor.handleEmptyLookup(getParameters(), getEditor());
    if (StringUtil.isNotEmpty(text)) {
      LightweightHint hint = showErrorHint(getProject(), getEditor(), text);
      CompletionServiceImpl.setCompletionPhase(
        awaitSecondInvocation ? new CompletionPhase.NoSuggestionsHint(hint, this) : CompletionPhase.NoCompletion);
      return;
    }
  }
  CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:24,
代码来源:CompletionProgressIndicator.java

示例4: arrangeItems

点赞 3

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
@Override
public Pair<List<LookupElement>, Integer> arrangeItems(@NotNull Lookup lookup, boolean onExplicitAction) {
  LinkedHashSet<LookupElement> result = new LinkedHashSet<LookupElement>();
  result.addAll(getPrefixItems(true));
  result.addAll(getPrefixItems(false));

  List<LookupElement> items = getMatchingItems();
  for (LookupElement item : items) {
    if (CompletionServiceImpl.isStartMatch(item, (LookupImpl)lookup)) {
      result.add(item);
    }
  }
  result.addAll(items);
  ArrayList<LookupElement> list = new ArrayList<LookupElement>(result);
  int selected = !lookup.isSelectionTouched() && onExplicitAction ? 0 : list.indexOf(lookup.getCurrentItem());
  return new Pair<List<LookupElement>, Integer>(list, selected >= 0 ? selected : 0);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:18,
代码来源:LookupArranger.java

示例5: hideAutopopupIfMeaningless

点赞 3

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
private boolean hideAutopopupIfMeaningless() {
  if (!myLookup.isLookupDisposed() && isAutopopupCompletion() && !myLookup.isSelectionTouched() && !myLookup.isCalculating()) {
    myLookup.refreshUi(true, false);
    final List<LookupElement> items = myLookup.getItems();

    for (LookupElement item : items) {
      if (!myLookup.itemPattern(item).equals(item.getLookupString())) {
        return false;
      }

      if (item.isValid() && item.isWorthShowingInAutoPopup()) {
        return false;
      }
    }

    myLookup.hideLookup(false);
    LOG.assertTrue(CompletionServiceImpl.getCompletionService().getCurrentCompletion() == null);
    CompletionServiceImpl.setCompletionPhase(new CompletionPhase.EmptyAutoPopup(this));
    return true;
  }
  return false;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:23,
代码来源:CompletionProgressIndicator.java

示例6: handleEmptyLookup

点赞 3

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
protected void handleEmptyLookup(final boolean awaitSecondInvocation) {
  LOG.assertTrue(!isAutopopupCompletion());

  if (ApplicationManager.getApplication().isUnitTestMode() || !myHandler.invokedExplicitly) {
    CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
    return;
  }

  for (final CompletionContributor contributor : CompletionContributor.forParameters(getParameters())) {
    final String text = contributor.handleEmptyLookup(getParameters(), getEditor());
    if (StringUtil.isNotEmpty(text)) {
      LightweightHint hint = showErrorHint(getProject(), getEditor(), text);
      CompletionServiceImpl.setCompletionPhase(
        awaitSecondInvocation ? new CompletionPhase.NoSuggestionsHint(hint, this) : CompletionPhase.NoCompletion);
      return;
    }
  }
  CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:20,
代码来源:CompletionProgressIndicator.java

示例7: arrangeItems

点赞 3

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
@Override
public Pair<List<LookupElement>, Integer> arrangeItems(@NotNull Lookup lookup, boolean onExplicitAction) {
  LinkedHashSet<LookupElement> result = new LinkedHashSet<LookupElement>();
  result.addAll(getPrefixItems(true));
  result.addAll(getPrefixItems(false));

  List<LookupElement> items = getMatchingItems();
  for (LookupElement item : items) {
    if (CompletionServiceImpl.isStartMatch(item, lookup)) {
      result.add(item);
    }
  }
  result.addAll(items);
  ArrayList<LookupElement> list = new ArrayList<LookupElement>(result);
  int selected = !lookup.isSelectionTouched() && onExplicitAction ? 0 : list.indexOf(lookup.getCurrentItem());
  return new Pair<List<LookupElement>, Integer>(list, selected >= 0 ? selected : 0);
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:18,
代码来源:LookupArranger.java

示例8: truncatePrefix

点赞 3

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
static void truncatePrefix(final DataContext dataContext, LookupImpl lookup, final EditorActionHandler handler, final int hideOffset) {
  final Editor editor = lookup.getEditor();
  if (!lookup.performGuardedChange(new Runnable() {
    @Override
    public void run() {
      handler.execute(editor, dataContext);
    }
  })) {
    return;
  }

  final CompletionProgressIndicator process = CompletionServiceImpl.getCompletionService().getCurrentCompletion();
  if (lookup.truncatePrefix(process == null || !process.isAutopopupCompletion())) {
    return;
  }

  if (process != null) {
    if (hideOffset < editor.getCaretModel().getOffset()) {
      process.scheduleRestart();
      return;
    }
    process.prefixUpdated();
  }

  lookup.hide();
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:27,
代码来源:BackspaceHandler.java

示例9: finishCompletionProcess

点赞 3

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
private void finishCompletionProcess(boolean disposeOffsetMap) {
  cancel();

  ApplicationManager.getApplication().assertIsDispatchThread();
  Disposer.dispose(myQueue);
  LookupManager.getInstance(getProject()).removePropertyChangeListener(myLookupManagerListener);

  CompletionProgressIndicator currentCompletion = CompletionServiceImpl.getCompletionService().getCurrentCompletion();
  LOG.assertTrue(currentCompletion == this, currentCompletion + "!=" + this);

  CompletionServiceImpl
          .assertPhase(CompletionPhase.BgCalculation.class, CompletionPhase.ItemsCalculated.class, CompletionPhase.Synchronous.class,
                       CompletionPhase.CommittingDocuments.class);
  CompletionPhase oldPhase = CompletionServiceImpl.getCompletionPhase();
  if (oldPhase instanceof CompletionPhase.CommittingDocuments) {
    LOG.assertTrue(((CompletionPhase.CommittingDocuments)oldPhase).isRestartingCompletion(), oldPhase);
    ((CompletionPhase.CommittingDocuments)oldPhase).replaced = true;
  }
  CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
  if (disposeOffsetMap) {
    disposeIndicator();
  }
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:24,
代码来源:CompletionProgressIndicator.java

示例10: handleEmptyLookup

点赞 3

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
protected void handleEmptyLookup(final boolean awaitSecondInvocation) {
  if (isAutopopupCompletion() && ApplicationManager.getApplication().isUnitTestMode()) {
    return;
  }

  LOG.assertTrue(!isAutopopupCompletion());

  if (ApplicationManager.getApplication().isUnitTestMode() || !myHandler.invokedExplicitly) {
    CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
    return;
  }

  for (final CompletionContributor contributor : CompletionContributor.forParameters(getParameters())) {
    final String text = contributor.handleEmptyLookup(getParameters(), getEditor());
    if (StringUtil.isNotEmpty(text)) {
      LightweightHint hint = showErrorHint(getProject(), getEditor(), text);
      CompletionServiceImpl.setCompletionPhase(
              awaitSecondInvocation ? new CompletionPhase.NoSuggestionsHint(hint, this) : CompletionPhase.NoCompletion);
      return;
    }
  }
  CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:24,
代码来源:CompletionProgressIndicator.java

示例11: getExactMatches

点赞 3

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
private List<LookupElement> getExactMatches(LookupImpl lookup, List<LookupElement> items) {
  String selectedText = lookup.getTopLevelEditor().getSelectionModel().getSelectedText();
  List<LookupElement> exactMatches = new SmartList<>();
  for (int i = 0; i < items.size(); i++) {
    LookupElement item = items.get(i);
    boolean isSuddenLiveTemplate = isSuddenLiveTemplate(item);
    if (isPrefixItem(item, true) && !isSuddenLiveTemplate || item.getLookupString().equals(selectedText)) {
      if (item instanceof LiveTemplateLookupElement) {
        // prefer most recent live template lookup item
        return Collections.singletonList(item);
      }
      exactMatches.add(item);
    }
    else if (i == 0 && isSuddenLiveTemplate && items.size() > 1 && !CompletionServiceImpl.isStartMatch(items.get(1), this)) {
      return Collections.singletonList(item);
    }
  }
  return exactMatches;
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:20,
代码来源:CompletionLookupArranger.java

示例12: checkAutoPopup

点赞 3

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
@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;
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:26,
代码来源:CompletionAutoPopupHandler.java

示例13: arrangeItems

点赞 3

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
@Override
public Pair<List<LookupElement>, Integer> arrangeItems(@Nonnull Lookup lookup, boolean onExplicitAction) {
  LinkedHashSet<LookupElement> result = new LinkedHashSet<>();
  result.addAll(getPrefixItems(true));
  result.addAll(getPrefixItems(false));

  List<LookupElement> items = getMatchingItems();
  for (LookupElement item : items) {
    if (CompletionServiceImpl.isStartMatch(item, this)) {
      result.add(item);
    }
  }
  result.addAll(items);
  ArrayList<LookupElement> list = new ArrayList<>(result);
  int selected = !lookup.isSelectionTouched() && onExplicitAction ? 0 : list.indexOf(lookup.getCurrentItem());
  return new Pair<>(list, selected >= 0 ? selected : 0);
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:18,
代码来源:LookupArranger.java

示例14: checkExpired

点赞 2

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
public boolean checkExpired() {
  if (CompletionServiceImpl.getCompletionPhase() != this) {
    return true;
  }

  if (actionsHappened || focusStamp.isExpired() || DumbService.getInstance(myProject).isDumb() ||
      myEditor.isDisposed() ||
      (myEditor instanceof EditorWindow && !((EditorWindow)myEditor).isValid()) ||
      ApplicationManager.getApplication().isWriteAccessAllowed()) {
    CompletionServiceImpl.setCompletionPhase(NoCompletion);
    return true;
  }

  return false;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:16,
代码来源:CompletionPhase.java

示例15: closeAndFinish

点赞 2

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
public void closeAndFinish(boolean hideLookup) {
  if (!myLookup.isLookupDisposed()) {
    Lookup lookup = LookupManager.getActiveLookup(myEditor);
    LOG.assertTrue(lookup == myLookup, "lookup changed: " + lookup + "; " + this);
  }
  myLookup.removeLookupListener(myLookupListener);
  finishCompletionProcess(true);
  CompletionServiceImpl.assertPhase(CompletionPhase.NoCompletion.getClass());

  if (hideLookup) {
    myLookup.hideLookup(true);
  }
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:14,
代码来源:CompletionProgressIndicator.java

示例16: cleanupForNextTest

点赞 2

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
@TestOnly
public static void cleanupForNextTest() {
  CompletionProgressIndicator currentCompletion = CompletionServiceImpl.getCompletionService().getCurrentCompletion();
  if (currentCompletion != null) {
    currentCompletion.finishCompletionProcess(true);
    CompletionServiceImpl.assertPhase(CompletionPhase.NoCompletion.getClass());
  }
  else {
    CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
  }
  CompletionLookupArranger.cancelLastCompletionStatisticsUpdate();
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:13,
代码来源:CompletionProgressIndicator.java

示例17: toString

点赞 2

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
@Override
public String toString() {
  return "CompletionProgressIndicator[count=" +
         myCount +
         ",phase=" +
         CompletionServiceImpl.getCompletionPhase() +
         "]@" +
         System.identityHashCode(this);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:10,
代码来源:CompletionProgressIndicator.java

示例18: processModifier

点赞 2

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
private void processModifier(KeyEvent e) {
  final int code = e.getKeyCode();
  if (code == KeyEvent.VK_CONTROL || code == KeyEvent.VK_META || code == KeyEvent.VK_ALT || code == KeyEvent.VK_SHIFT) {
    myContentComponent.removeKeyListener(this);
    final CompletionPhase phase = CompletionServiceImpl.getCompletionPhase();
    if (phase instanceof CompletionPhase.BgCalculation) {
      ((CompletionPhase.BgCalculation)phase).modifiersChanged = true;
    }
    else if (phase instanceof CompletionPhase.InsertedSingleItem) {
      CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
    }
  }
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:14,
代码来源:CompletionProgressIndicator.java

示例19: sortByPresentation

点赞 2

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
private static List<LookupElement> sortByPresentation(Iterable<LookupElement> source, LookupImpl lookup) {
  ArrayList<LookupElement> startMatches = ContainerUtil.newArrayList();
  ArrayList<LookupElement> middleMatches = ContainerUtil.newArrayList();
  for (LookupElement element : source) {
    (CompletionServiceImpl.isStartMatch(element, lookup) ? startMatches : middleMatches).add(element);
  }
  ContainerUtil.sort(startMatches, BY_PRESENTATION_COMPARATOR);
  ContainerUtil.sort(middleMatches, BY_PRESENTATION_COMPARATOR);
  startMatches.addAll(middleMatches);
  return startMatches;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:12,
代码来源:CompletionLookupArranger.java

示例20: scheduleAutoPopup

点赞 2

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
public void scheduleAutoPopup(final Editor editor, @Nullable final Condition<PsiFile> condition) {
  if (ApplicationManager.getApplication().isUnitTestMode() && !CompletionAutoPopupHandler.ourTestingAutopopup) {
    return;
  }

  if (!CodeInsightSettings.getInstance().AUTO_POPUP_COMPLETION_LOOKUP) {
    return;
  }
  if (PowerSaveMode.isEnabled()) {
    return;
  }

  if (!CompletionServiceImpl.isPhase(CompletionPhase.CommittingDocuments.class, CompletionPhase.NoCompletion.getClass())) {
    return;
  }

  final CompletionProgressIndicator currentCompletion = CompletionServiceImpl.getCompletionService().getCurrentCompletion();
  if (currentCompletion != null) {
    currentCompletion.closeAndFinish(true);
  }

  final CompletionPhase.CommittingDocuments phase = new CompletionPhase.CommittingDocuments(null, editor);
  CompletionServiceImpl.setCompletionPhase(phase);
  phase.ignoreCurrentDocumentChange();

  CompletionAutoPopupHandler.runLaterWithCommitted(myProject, editor.getDocument(), new Runnable() {
    @Override
    public void run() {
      if (phase.checkExpired()) return;

      PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument());
      if (file != null && condition != null && !condition.value(file)) {
        CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
        return;
      }

      CompletionAutoPopupHandler.invokeCompletion(CompletionType.BASIC, true, myProject, editor, 0, false);
    }
  });
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:41,
代码来源:AutoPopupController.java

示例21: checkAutoPopup

点赞 2

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
@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(new Runnable() {
        @Override
        public void run() {
          EditorModificationUtil.deleteSelectedText(editor);
        }
      });
    }
    return Result.STOP;
  }

  if (Character.isLetter(charTyped) || charTyped == '_') {
    AutoPopupController.getInstance(project).scheduleAutoPopup(editor);
    return Result.STOP;
  }

  return Result.CONTINUE;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:31,
代码来源:CompletionAutoPopupHandler.java

示例22: invokeCompletion

点赞 2

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
public static void invokeCompletion(@NotNull CompletionType completionType,
                                    boolean autopopup,
                                    Project project, Editor editor, int time, boolean restart) {
  if (editor.isDisposed()) {
    CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
    return;
  }

  // retrieve the injected file from scratch since our typing might have destroyed the old one completely
  Editor topLevelEditor = InjectedLanguageUtil.getTopLevelEditor(editor);
  PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(topLevelEditor.getDocument());
  if (file == null) {
    CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
    return;
  }

  PsiFile topLevelFile = InjectedLanguageManager.getInstance(file.getProject()).getTopLevelFile(file);
  if (!PsiDocumentManager.getInstance(project).isCommitted(editor.getDocument())) {
    LOG.error("Non-committed document");
    PsiDocumentManager.getInstance(project).commitAllDocuments();
  }
  Editor newEditor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(topLevelEditor, topLevelFile);
  try {
    new CodeCompletionHandlerBase(completionType, false, autopopup, false).invokeCompletion(project, newEditor, time, false, restart);
  }
  catch (IndexNotReadyException ignored) {
  }
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:29,
代码来源:CompletionAutoPopupHandler.java

示例23: invokeCompletion

点赞 2

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
private void invokeCompletion(final ExpressionContext context) {
  final Project project = context.getProject();
  final Editor editor = context.getEditor();

  final PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(editor, project);
  Runnable runnable = new Runnable() {
    @Override
    public void run() {
      if (project.isDisposed() || editor.isDisposed() || psiFile == null || !psiFile.isValid()) return;

      // it's invokeLater, so another completion could have started
      if (CompletionServiceImpl.getCompletionService().getCurrentCompletion() != null) return;

      CommandProcessor.getInstance().executeCommand(project, new Runnable() {
        @Override
        public void run() {
          // if we're in some completion's insert handler, make sure our new completion isn't treated as the second invocation
          CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
          
          invokeCompletionHandler(project, editor);
          Lookup lookup = LookupManager.getInstance(project).getActiveLookup();

          if (lookup != null) {
            lookup.addLookupListener(new MyLookupListener(context));
          }
          else {
            considerNextTab(editor);
          }
        }
      }, "", null);
    }
  };
  ApplicationManager.getApplication().invokeLater(runnable);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:35,
代码来源:BaseCompleteMacro.java

示例24: truncatePrefix

点赞 2

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
static void truncatePrefix(final DataContext dataContext,
                           LookupImpl lookup,
                           final EditorActionHandler handler,
                           final int hideOffset,
                           final Caret caret) {
  final Editor editor = lookup.getEditor();
  if (!lookup.performGuardedChange(new Runnable() {
    @Override
    public void run() {
      handler.execute(editor, caret, dataContext);
    }
  })) {
    return;
  }

  final CompletionProgressIndicator process = CompletionServiceImpl.getCompletionService().getCurrentCompletion();
  if (lookup.truncatePrefix(process == null || !process.isAutopopupCompletion())) {
    return;
  }

  if (process != null) {
    if (hideOffset < editor.getCaretModel().getOffset()) {
      process.scheduleRestart();
      return;
    }
    process.prefixUpdated();
  }

  lookup.hideLookup(false);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:31,
代码来源:BackspaceHandler.java

示例25: checkExpired

点赞 2

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
public boolean checkExpired() {
  if (CompletionServiceImpl.getCompletionPhase() != this) {
    return true;
  }

  if (actionsHappened || focusStamp.isExpired() || DumbService.getInstance(myProject).isDumb() ||
      myEditor.isDisposed() ||
      ApplicationManager.getApplication().isWriteAccessAllowed()) {
    CompletionServiceImpl.setCompletionPhase(NoCompletion);
    return true;
  }

  return false;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:15,
代码来源:CompletionPhase.java

示例26: CompletionProgressIndicator

点赞 2

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
public CompletionProgressIndicator(final Editor editor,
                                   CompletionParameters parameters,
                                   CodeCompletionHandlerBase handler,
                                   Semaphore freezeSemaphore,
                                   final OffsetMap offsetMap,
                                   boolean hasModifiers) {
  myEditor = editor;
  myParameters = parameters;
  myHandler = handler;
  myFreezeSemaphore = freezeSemaphore;
  myOffsetMap = offsetMap;
  myLookup = (LookupImpl)parameters.getLookup();
  myStartCaret = myEditor.getCaretModel().getOffset();

  myLookup.setArranger(new CompletionLookupArranger(parameters, this));

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

  myLookupManagerListener = new PropertyChangeListener() {
    @Override
    public void propertyChange(PropertyChangeEvent 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", 300, true, myEditor.getContentComponent());
  myQueue.setPassThrough(false);

  ApplicationManager.getApplication().assertIsDispatchThread();
  Disposer.register(this, offsetMap);

  if (hasModifiers && !ApplicationManager.getApplication().isUnitTestMode()) {
    trackModifiers();
  }
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:40,
代码来源:CompletionProgressIndicator.java

示例27: scheduleAdvertising

点赞 2

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
void scheduleAdvertising() {
  if (myLookup.isAvailableToUser()) {
    return;
  }
  final List<CompletionContributor> list = CompletionContributor.forParameters(myParameters);
  for (final CompletionContributor contributor : list) {
    if (myLookup.getAdvertisementText() != null) return;
    if (!myLookup.isCalculating() && !myLookup.isVisible()) return;

    @SuppressWarnings("deprecation") String s = contributor.advertise(myParameters);
    if (myLookup.getAdvertisementText() != null) return;

    if (s != null) {
      myLookup.setAdvertisementText(s);
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          if (isAutopopupCompletion() && !myLookup.isAvailableToUser()) {
            return;
          }
          if (!CompletionServiceImpl.isPhase(CompletionPhase.BgCalculation.class, CompletionPhase.ItemsCalculated.class)) {
            return;
          }
          if (CompletionServiceImpl.getCompletionPhase().indicator != CompletionProgressIndicator.this) {
            return;
          }

          updateLookup();
        }
      }, myQueue.getModalityState());
      return;
    }
  }
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:35,
代码来源:CompletionProgressIndicator.java

示例28: closeAndFinish

点赞 2

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
public void closeAndFinish(boolean hideLookup) {
  if (!myLookup.isLookupDisposed()) {
    Lookup lookup = LookupManager.getActiveLookup(myEditor);
    LOG.assertTrue(lookup == myLookup, "lookup changed: " + lookup + "; " + this);
  }
  myLookup.removeLookupListener(myLookupListener);
  finishCompletionProcess(true);
  CompletionServiceImpl.assertPhase(CompletionPhase.NoCompletion.getClass());

  if (hideLookup) {
    LookupManager.getInstance(getProject()).hideActiveLookup();
  }
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:14,
代码来源:CompletionProgressIndicator.java

示例29: scheduleRestart

点赞 2

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
public void scheduleRestart() {
  ApplicationManager.getApplication().assertIsDispatchThread();
  cancel();

  final CompletionProgressIndicator current = CompletionServiceImpl.getCompletionService().getCurrentCompletion();
  if (this != current) {
    LOG.error(current + "!=" + this);
  }

  hideAutopopupIfMeaningless();

  CompletionPhase oldPhase = CompletionServiceImpl.getCompletionPhase();
  if (oldPhase instanceof CompletionPhase.CommittingDocuments) {
    ((CompletionPhase.CommittingDocuments)oldPhase).replaced = true;
  }

  final CompletionPhase.CommittingDocuments phase = new CompletionPhase.CommittingDocuments(this, myEditor);
  CompletionServiceImpl.setCompletionPhase(phase);
  phase.ignoreCurrentDocumentChange();

  final Project project = getProject();
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      CompletionAutoPopupHandler.runLaterWithCommitted(project, myEditor.getDocument(), new Runnable() {
        @Override
        public void run() {
          if (phase.checkExpired()) return;

          CompletionAutoPopupHandler.invokeCompletion(myParameters.getCompletionType(),
                                                      isAutopopupCompletion(), project, myEditor, myParameters.getInvocationCount(),
                                                      true);
        }
      });
    }
  }, project.getDisposed());
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:38,
代码来源:CompletionProgressIndicator.java

示例30: sortByPresentation

点赞 2

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
private static List<LookupElement> sortByPresentation(Iterable<LookupElement> source, Lookup lookup) {
  ArrayList<LookupElement> startMatches = ContainerUtil.newArrayList();
  ArrayList<LookupElement> middleMatches = ContainerUtil.newArrayList();
  for (LookupElement element : source) {
    (CompletionServiceImpl.isStartMatch(element, lookup) ? startMatches : middleMatches).add(element);
  }
  ContainerUtil.sort(startMatches, BY_PRESENTATION_COMPARATOR);
  ContainerUtil.sort(middleMatches, BY_PRESENTATION_COMPARATOR);
  startMatches.addAll(middleMatches);
  return startMatches;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:12,
代码来源:CompletionLookupArranger.java

示例31: checkAutoPopup

点赞 2

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
@Override
public Result checkAutoPopup(char charTyped, final Project project, final Editor editor, final PsiFile file) {
  CompletionPhase oldPhase = CompletionServiceImpl.getCompletionPhase();
  if (oldPhase instanceof CompletionPhase.EmptyAutoPopup && ((CompletionPhase.EmptyAutoPopup)oldPhase).editor != editor) {
    CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
  }


  if (oldPhase instanceof CompletionPhase.CommittingDocuments && ((CompletionPhase.CommittingDocuments)oldPhase).isRestartingCompletion()) {
    oldPhase.indicator.scheduleRestart();
    return Result.STOP;
  }

  LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(editor);
  if (lookup != null) {
    if (editor.getSelectionModel().hasSelection()) {
      lookup.performGuardedChange(new Runnable() {
        @Override
        public void run() {
          EditorModificationUtil.deleteSelectedText(editor);
        }
      });
    }
    return Result.STOP;
  }

  if (Character.isLetter(charTyped) || charTyped == '_') {
    AutoPopupController.getInstance(project).scheduleAutoPopup(editor);
    return Result.STOP;
  }

  if (CompletionServiceImpl.isPhase(CompletionPhase.EmptyAutoPopup.class, CompletionPhase.CommittingDocuments.class)) {
    CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
  }
  return Result.CONTINUE;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:37,
代码来源:CompletionAutoPopupHandler.java

示例32: invokeCompletion

点赞 2

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
public static void invokeCompletion(CompletionType completionType,
                                    boolean autopopup,
                                    Project project, Editor editor, int time, boolean restart) {
  if (editor.isDisposed()) {
    CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
    return;
  }

  // retrieve the injected file from scratch since our typing might have destroyed the old one completely
  Editor topLevelEditor = InjectedLanguageUtil.getTopLevelEditor(editor);
  PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(topLevelEditor.getDocument());
  if (file == null) {
    CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
    return;
  }

  PsiFile topLevelFile = InjectedLanguageManager.getInstance(file.getProject()).getTopLevelFile(file);
  if (!PsiDocumentManager.getInstance(project).isCommitted(editor.getDocument())) {
    LOG.error("Non-committed document");
    PsiDocumentManager.getInstance(project).commitAllDocuments();
  }
  Editor newEditor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(topLevelEditor, topLevelFile);
  try {
    new CodeCompletionHandlerBase(completionType, false, autopopup, false).invokeCompletion(project, newEditor, time, false, restart);
  }
  catch (IndexNotReadyException ignored) {
  }
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:29,
代码来源:CompletionAutoPopupHandler.java

示例33: executeInLookup

点赞 2

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
@Override
protected void executeInLookup(LookupImpl lookup, DataContext context) {
  final Editor editor = lookup.getEditor();
  final int offset = editor.getCaretModel().getOffset();
  CharSequence seq = editor.getDocument().getCharsSequence();
  if (seq.length() <= offset || !lookup.isCompletion()) {
    myOriginalHandler.execute(editor, context);
    return;
  }

  char c = seq.charAt(offset);
  CharFilter.Result lookupAction = LookupTypedHandler.getLookupAction(c, lookup);

  if (lookupAction != CharFilter.Result.ADD_TO_PREFIX || Character.isWhitespace(c)) {
    myOriginalHandler.execute(editor, context);
    return;
  }

  if (!lookup.performGuardedChange(new Runnable() {
    @Override
    public void run() {
      editor.getSelectionModel().removeSelection();
      editor.getCaretModel().moveToOffset(offset + 1);
    }
  })) {
    return;
  }

  lookup.appendPrefix(c);
  final CompletionProgressIndicator completion = CompletionServiceImpl.getCompletionService().getCurrentCompletion();
  if (completion != null) {
    completion.prefixUpdated();
  }
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:35,
代码来源:LookupActionHandler.java

示例34: checkExpired

点赞 2

import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; //导入依赖的package包/类
public boolean checkExpired() {
  if (CompletionServiceImpl.getCompletionPhase() != this) {
    return true;
  }

  if (myTracker.hasAnythingHappened() || ApplicationManager.getApplication().isWriteAccessAllowed()) {
    CompletionServiceImpl.setCompletionPhase(NoCompletion);
    return true;
  }

  return false;
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:13,
代码来源:CompletionPhase.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)