Java Code Examples for com.intellij.codeInsight.lookup.Lookup#REPLACE_SELECT_CHAR

The following examples show how to use com.intellij.codeInsight.lookup.Lookup#REPLACE_SELECT_CHAR . 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: 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 2
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 3
Source File: InsertionContext.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static boolean shouldAddCompletionChar(char completionChar) {
  return completionChar != Lookup.AUTO_INSERT_SELECT_CHAR && completionChar != Lookup.REPLACE_SELECT_CHAR && completionChar != Lookup.NORMAL_SELECT_CHAR;
}
 
Example 4
Source File: ChooseItemAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
public Replacing() {
  super(new Handler(false, Lookup.REPLACE_SELECT_CHAR));
}