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


Java CharFilter.Result方法代码示例

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


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

示例1: getLookupAction

import com.intellij.codeInsight.lookup.CharFilter; //导入方法依赖的package包/类
static CharFilter.Result getLookupAction(final char charTyped, final LookupImpl lookup) {
  final CharFilter.Result filtersDecision = getFiltersDecision(charTyped, lookup);

  final LookupElement currentItem = lookup.getCurrentItem();
  if (currentItem != null && charTyped != ' ') {
    String postfix = lookup.getAdditionalPrefix() + charTyped;
    final PrefixMatcher matcher = lookup.itemMatcher(currentItem);
    for (String lookupString : currentItem.getAllLookupStrings()) {
      if (lookupString.startsWith(matcher.getPrefix() + postfix)) {
        return CharFilter.Result.ADD_TO_PREFIX;
      }
    }
  }

  if (filtersDecision != null) {
    return filtersDecision;
  }
  throw new AssertionError("Typed char not handler by char filter: c=" + charTyped +
                           "; prefix=" + currentItem +
                           "; filters=" + Arrays.toString(getFilters()));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:LookupTypedHandler.java

示例2: getFiltersDecision

import com.intellij.codeInsight.lookup.CharFilter; //导入方法依赖的package包/类
@Nullable
private static CharFilter.Result getFiltersDecision(char charTyped, LookupImpl lookup) {
  lookup.checkValid();
  LookupElement item = lookup.getCurrentItem();
  int prefixLength = item == null ? lookup.getAdditionalPrefix().length(): lookup.itemPattern(item).length();

  for (final CharFilter extension : getFilters()) {
    final CharFilter.Result result = extension.acceptChar(charTyped, prefixLength, lookup);
    if (result != null) {
      return result;
    }
    if (lookup.isLookupDisposed()) {
      throw new AssertionError("Lookup disposed after " + extension);
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:LookupTypedHandler.java

示例3: acceptChar

import com.intellij.codeInsight.lookup.CharFilter; //导入方法依赖的package包/类
@Nullable
@Override
public CharFilter.Result acceptChar(char c, int prefixLength, Lookup lookup) {
  if (c != '.' || !lookup.isCompletion()) {
    return null;
  }
  if (!(lookup.getPsiFile() instanceof XPathFile)) {
    // could be an XML file during XML autocompletion

    final LookupElement item = lookup.getCurrentItem();
    if (item == null || !(item.getObject() instanceof org.intellij.lang.xpath.completion.Lookup)) {
      // current completion item isn't something XPath related, continue with other handlers
      return null;
    }
  }
  // typed '.' should appear literally in editor, it has no meaning for completion
  return Result.HIDE_LOOKUP;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:XPathCharFilter.java

示例4: executeInLookup

import com.intellij.codeInsight.lookup.CharFilter; //导入方法依赖的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

示例5: getFiltersDecision

import com.intellij.codeInsight.lookup.CharFilter; //导入方法依赖的package包/类
@Nullable
private static CharFilter.Result getFiltersDecision(char charTyped, LookupImpl lookup) {
  LookupElement item = lookup.getCurrentItem();
  int prefixLength = item == null ? lookup.getAdditionalPrefix().length(): lookup.itemPattern(item).length();

  for (final CharFilter extension : getFilters()) {
    final CharFilter.Result result = extension.acceptChar(charTyped, prefixLength, lookup);
    if (result != null) {
      return result;
    }
  }
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:LookupTypedHandler.java

示例6: getLookupAction

import com.intellij.codeInsight.lookup.CharFilter; //导入方法依赖的package包/类
static CharFilter.Result getLookupAction(final char charTyped, final LookupImpl lookup) {
  final CharFilter.Result filtersDecision = getFiltersDecision(charTyped, lookup);
  if (filtersDecision != null) {
    return filtersDecision;
  }
  throw new AssertionError("Typed char not handler by char filter: c=" + charTyped +
                           "; prefix=" + lookup.getCurrentItem() +
                           "; filters=" + Arrays.toString(getFilters()));
}
 
开发者ID:consulo,项目名称:consulo,代码行数:10,代码来源:LookupTypedHandler.java

示例7: executeInLookup

import com.intellij.codeInsight.lookup.CharFilter; //导入方法依赖的package包/类
@Override
protected void executeInLookup(LookupImpl lookup, DataContext context, final Caret caret) {
  final Editor editor = lookup.getEditor();
  final int offset = editor.getCaretModel().getOffset();
  final CharSequence seq = editor.getDocument().getCharsSequence();
  if (seq.length() <= offset || !lookup.isCompletion()) {
    myOriginalHandler.execute(editor, caret, 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, caret, context);
    return;
  }

  if (!lookup.performGuardedChange(() -> {
    CaretAction action = new CaretAction() {
      @Override
      public void perform(Caret caret1) {
        caret1.removeSelection();
        int caretOffset = caret1.getOffset();
        if (caretOffset < seq.length()) {
          caret1.moveToOffset(caretOffset + 1);
        }
      }
    };
    if (caret == null) {
      editor.getCaretModel().runForEachCaret(action);
    }
    else {
      action.perform(caret);
    }
  })) {
    return;
  }

  lookup.appendPrefix(c);
  final CompletionProgressIndicator completion = CompletionServiceImpl.getCompletionService().getCurrentCompletion();
  if (completion != null) {
    completion.prefixUpdated();
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:46,代码来源:LookupActionHandler.java

示例8: acceptChar

import com.intellij.codeInsight.lookup.CharFilter; //导入方法依赖的package包/类
@Override
@Nullable
public CharFilter.Result acceptChar(char c) {
  if (!mySeparators.contains(c)) return CharFilter.Result.ADD_TO_PREFIX;
  return CharFilter.Result.HIDE_LOOKUP;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:7,代码来源:ValuesCompletionProvider.java

示例9: acceptChar

import com.intellij.codeInsight.lookup.CharFilter; //导入方法依赖的package包/类
@Nullable
CharFilter.Result acceptChar(char c);
 
开发者ID:consulo,项目名称:consulo,代码行数:3,代码来源:TextCompletionProvider.java


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