本文整理汇总了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()));
}
示例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;
}
示例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;
}
示例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();
}
}
示例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;
}
示例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()));
}
示例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();
}
}
示例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;
}
示例9: acceptChar
import com.intellij.codeInsight.lookup.CharFilter; //导入方法依赖的package包/类
@Nullable
CharFilter.Result acceptChar(char c);