本文整理汇总了Java中com.intellij.codeInsight.completion.PrefixMatcher类的典型用法代码示例。如果您正苦于以下问题:Java PrefixMatcher类的具体用法?Java PrefixMatcher怎么用?Java PrefixMatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PrefixMatcher类属于com.intellij.codeInsight.completion包,在下文中一共展示了PrefixMatcher类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: calculateLookupItems
import com.intellij.codeInsight.completion.PrefixMatcher; //导入依赖的package包/类
@Override
public LookupElement[] calculateLookupItems(@NotNull Expression[] params, ExpressionContext context) {
if (params.length == 0) return LookupElement.EMPTY_ARRAY;
Result paramResult = params[0].calculateQuickResult(context);
if (paramResult instanceof PsiTypeResult) {
final PsiType type = ((PsiTypeResult)paramResult).getType();
final PsiFile file = PsiDocumentManager.getInstance(context.getProject()).getPsiFile(context.getEditor().getDocument());
final PsiElement element = file.findElementAt(context.getStartOffset());
final Set<LookupElement> set = new LinkedHashSet<LookupElement>();
JavaTemplateUtil.addTypeLookupItem(set, type);
CodeInsightUtil.processSubTypes(type, element, false, PrefixMatcher.ALWAYS_TRUE, new Consumer<PsiType>() {
@Override
public void consume(PsiType psiType) {
JavaTemplateUtil.addTypeLookupItem(set, psiType);
}
});
return set.toArray(new LookupElement[set.size()]);
}
return LookupElement.EMPTY_ARRAY;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:SubtypesMacro.java
示例2: MembersGetter
import com.intellij.codeInsight.completion.PrefixMatcher; //导入依赖的package包/类
protected MembersGetter(StaticMemberProcessor processor, @NotNull final PsiElement place) {
myPlace = place;
processor.processMembersOfRegisteredClasses(PrefixMatcher.ALWAYS_TRUE, new PairConsumer<PsiMember, PsiClass>() {
@Override
public void consume(PsiMember member, PsiClass psiClass) {
myImportedStatically.add(member);
}
});
PsiClass current = PsiTreeUtil.getContextOfType(place, PsiClass.class);
while (current != null) {
current = CompletionUtil.getOriginalOrSelf(current);
myPlaceClasses.add(current);
current = PsiTreeUtil.getContextOfType(current, PsiClass.class);
}
PsiMethod eachMethod = PsiTreeUtil.getContextOfType(place, PsiMethod.class);
while (eachMethod != null) {
eachMethod = CompletionUtil.getOriginalOrSelf(eachMethod);
myPlaceMethods.add(eachMethod);
eachMethod = PsiTreeUtil.getContextOfType(eachMethod, PsiMethod.class);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:MembersGetter.java
示例3: completeTillTypedCharOccurrence
import com.intellij.codeInsight.completion.PrefixMatcher; //导入依赖的package包/类
private static boolean completeTillTypedCharOccurrence(char charTyped, LookupImpl lookup, LookupElement item) {
PrefixMatcher matcher = lookup.itemMatcher(item);
final String oldPrefix = matcher.getPrefix() + lookup.getAdditionalPrefix();
PrefixMatcher expanded = matcher.cloneWithPrefix(oldPrefix + charTyped);
if (expanded.prefixMatches(item)) {
for (String s : item.getAllLookupStrings()) {
if (matcher.prefixMatches(s)) {
int i = -1;
while (true) {
i = s.indexOf(charTyped, i + 1);
if (i < 0) break;
final String newPrefix = s.substring(0, i + 1);
if (expanded.prefixMatches(newPrefix)) {
lookup.replacePrefix(oldPrefix, newPrefix);
return true;
}
}
}
}
}
return false;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:LookupTypedHandler.java
示例4: getLookupAction
import com.intellij.codeInsight.completion.PrefixMatcher; //导入依赖的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
示例5: CompleteReferenceProcessor
import com.intellij.codeInsight.completion.PrefixMatcher; //导入依赖的package包/类
protected CompleteReferenceProcessor(GrReferenceExpression place, Consumer<LookupElement> consumer, @NotNull PrefixMatcher matcher, CompletionParameters parameters) {
super(null, EnumSet.allOf(ResolveKind.class), place, PsiType.EMPTY_ARRAY);
myConsumer = consumer;
myMatcher = matcher;
myParameters = parameters;
myPreferredFieldNames = addAllRestrictedProperties(place);
mySkipPackages = shouldSkipPackages(place);
myEventListener = JavaPsiFacade.getInstance(place.getProject()).findClass("java.util.EventListener", place.getResolveScope());
myPropertyNames.addAll(myPreferredFieldNames);
myFieldPointerOperator = place.hasAt();
myMethodPointerOperator = place.getDotTokenType() == GroovyTokenTypes.mMEMBER_POINTER;
myIsMap = isMap(place);
final PsiType thisType = GrReferenceResolveUtil.getQualifierType(place);
mySubstitutorComputer = new SubstitutorComputer(thisType, PsiType.EMPTY_ARRAY, PsiType.EMPTY_ARRAY, true, place, place.getParent());
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:CompleteReferenceExpression.java
示例6: prefixReplaced
import com.intellij.codeInsight.completion.PrefixMatcher; //导入依赖的package包/类
public final void prefixReplaced(Lookup lookup, String newPrefix) {
//noinspection unchecked
Map<LookupElement, PrefixMatcher> newMatchers = new LinkedHashMap(EqualityPolicy.IDENTITY);
for (LookupElement item : myItems) {
if (item.isValid()) {
PrefixMatcher matcher = itemMatcher(item).cloneWithPrefix(newPrefix);
if (matcher.prefixMatches(item)) {
newMatchers.put(item, matcher);
}
}
}
myMatchers.clear();
myMatchers.putAll(newMatchers);
myItems.clear();
myItems.addAll(newMatchers.keySet());
prefixChanged(lookup);
}
开发者ID:consulo,项目名称:consulo,代码行数:19,代码来源:LookupArranger.java
示例7: MembersGetter
import com.intellij.codeInsight.completion.PrefixMatcher; //导入依赖的package包/类
protected MembersGetter(StaticMemberProcessor processor, @NotNull final PsiElement place)
{
myPlace = place;
processor.processMembersOfRegisteredClasses(PrefixMatcher.ALWAYS_TRUE, (member, psiClass) -> myImportedStatically.add(member));
PsiClass current = PsiTreeUtil.getContextOfType(place, PsiClass.class);
while(current != null)
{
current = CompletionUtil.getOriginalOrSelf(current);
myPlaceClasses.add(current);
current = PsiTreeUtil.getContextOfType(current, PsiClass.class);
}
PsiMethod eachMethod = PsiTreeUtil.getContextOfType(place, PsiMethod.class);
while(eachMethod != null)
{
eachMethod = CompletionUtil.getOriginalOrSelf(eachMethod);
myPlaceMethods.add(eachMethod);
eachMethod = PsiTreeUtil.getContextOfType(eachMethod, PsiMethod.class);
}
}
开发者ID:consulo,项目名称:consulo-java,代码行数:23,代码来源:MembersGetter.java
示例8: getAllVirtualTypeElementNames
import com.intellij.codeInsight.completion.PrefixMatcher; //导入依赖的package包/类
public Collection<String> getAllVirtualTypeElementNames(PrefixMatcher prefixMatcher, final GlobalSearchScope scope) {
Collection<String> keys =
FileBasedIndex.getInstance().getAllKeys(VirtualTypeIndex.KEY, project);
keys.removeIf(k -> !prefixMatcher.prefixMatches(k));
return keys;
}
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:8,代码来源:DiIndex.java
示例9: processMembers
import com.intellij.codeInsight.completion.PrefixMatcher; //导入依赖的package包/类
public void processMembers(final Consumer<LookupElement> results, @Nullable final PsiClass where,
final boolean acceptMethods, final boolean searchInheritors) {
if (where == null || isPrimitiveClass(where)) return;
final boolean searchFactoryMethods = searchInheritors &&
!CommonClassNames.JAVA_LANG_OBJECT.equals(where.getQualifiedName()) &&
!isPrimitiveClass(where);
final Project project = myPlace.getProject();
final GlobalSearchScope scope = myPlace.getResolveScope();
final PsiClassType baseType = JavaPsiFacade.getElementFactory(project).createType(where);
Consumer<PsiType> consumer = new Consumer<PsiType>() {
@Override
public void consume(PsiType psiType) {
PsiClass psiClass = PsiUtil.resolveClassInType(psiType);
if (psiClass == null) {
return;
}
psiClass = CompletionUtil.getOriginalOrSelf(psiClass);
if (mayProcessMembers(psiClass)) {
final FilterScopeProcessor<PsiElement> declProcessor = new FilterScopeProcessor<PsiElement>(TrueFilter.INSTANCE);
psiClass.processDeclarations(declProcessor, ResolveState.initial(), null, myPlace);
doProcessMembers(acceptMethods, results, psiType == baseType, declProcessor.getResults());
String name = psiClass.getName();
if (name != null && searchFactoryMethods) {
Collection<PsiMember> factoryMethods = JavaStaticMemberTypeIndex.getInstance().getStaticMembers(name, project, scope);
doProcessMembers(acceptMethods, results, false, factoryMethods);
}
}
}
};
consumer.consume(baseType);
if (searchInheritors && !CommonClassNames.JAVA_LANG_OBJECT.equals(where.getQualifiedName())) {
CodeInsightUtil.processSubTypes(baseType, myPlace, true, PrefixMatcher.ALWAYS_TRUE, consumer);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:MembersGetter.java
示例10: addCompletions
import com.intellij.codeInsight.completion.PrefixMatcher; //导入依赖的package包/类
public static void addCompletions(@NotNull final JavaSmartCompletionParameters parameters,
@NotNull Consumer<LookupElement> result, final PrefixMatcher matcher) {
PsiType expectedType = parameters.getDefaultType();
if (!InheritanceUtil.isInheritor(expectedType, CommonClassNames.JAVA_LANG_CLASS)) {
expectedType = parameters.getExpectedType();
if (!InheritanceUtil.isInheritor(expectedType, CommonClassNames.JAVA_LANG_CLASS)) {
return;
}
}
PsiType classParameter = PsiUtil.substituteTypeParameter(expectedType, CommonClassNames.JAVA_LANG_CLASS, 0, false);
boolean addInheritors = false;
PsiElement position = parameters.getPosition();
if (classParameter instanceof PsiWildcardType) {
final PsiWildcardType wildcardType = (PsiWildcardType)classParameter;
classParameter = wildcardType.isSuper() ? wildcardType.getSuperBound() : wildcardType.getExtendsBound();
addInheritors = wildcardType.isExtends() && classParameter instanceof PsiClassType;
} else if (!matcher.getPrefix().isEmpty()) {
addInheritors = true;
classParameter = PsiType.getJavaLangObject(position.getManager(), position.getResolveScope());
}
if (classParameter != null) {
PsiFile file = position.getContainingFile();
addClassLiteralLookupElement(classParameter, result, file);
if (addInheritors) {
addInheritorClassLiterals(file, classParameter, result, matcher);
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:ClassLiteralGetter.java
示例11: addInheritorClassLiterals
import com.intellij.codeInsight.completion.PrefixMatcher; //导入依赖的package包/类
private static void addInheritorClassLiterals(final PsiFile context,
final PsiType classParameter,
final Consumer<LookupElement> result, PrefixMatcher matcher) {
final String canonicalText = classParameter.getCanonicalText();
if (CommonClassNames.JAVA_LANG_OBJECT.equals(canonicalText) && StringUtil.isEmpty(matcher.getPrefix())) {
return;
}
CodeInsightUtil.processSubTypes(classParameter, context, true, matcher, new Consumer<PsiType>() {
@Override
public void consume(PsiType type) {
addClassLiteralLookupElement(type, result, context);
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ClassLiteralGetter.java
示例12: getBestMatchingDegree
import com.intellij.codeInsight.completion.PrefixMatcher; //导入依赖的package包/类
public static int getBestMatchingDegree(LookupElement element, PrefixMatcher matcher) {
int max = Integer.MIN_VALUE;
for (String lookupString : element.getAllLookupStrings()) {
max = Math.max(max, matcher.matchingDegree(lookupString));
}
return -max;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:RealPrefixMatchingWeigher.java
示例13: prefixMatches
import com.intellij.codeInsight.completion.PrefixMatcher; //导入依赖的package包/类
private boolean prefixMatches(LookupImpl lookup, LookupElement item) {
PrefixMatcher matcher = lookup.itemMatcherNullable(item);
if (matcher == null) {
return false;
}
if (!myAdditionalPrefix.isEmpty()) {
matcher = matcher.cloneWithPrefix(matcher.getPrefix() + myAdditionalPrefix);
}
return matcher.prefixMatches(item);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:LookupArranger.java
示例14: CompleteReferencesWithSameQualifier
import com.intellij.codeInsight.completion.PrefixMatcher; //导入依赖的package包/类
private CompleteReferencesWithSameQualifier(@NotNull GrReferenceExpression refExpr,
@NotNull PrefixMatcher matcher,
@Nullable GrExpression qualifier) {
myRefExpr = refExpr;
myMatcher = matcher;
myQualifier = qualifier;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:CompleteReferencesWithSameQualifier.java
示例15: CompleteReferenceExpression
import com.intellij.codeInsight.completion.PrefixMatcher; //导入依赖的package包/类
private CompleteReferenceExpression(@NotNull PrefixMatcher matcher,
@NotNull Consumer<LookupElement> consumer,
@NotNull GrReferenceExpressionImpl refExpr,
@NotNull CompletionParameters parameters) {
myMatcher = matcher;
myConsumer = consumer;
myParameters = parameters;
myRefExpr = refExpr;
myProcessor = new CompleteReferenceProcessor();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:CompleteReferenceExpression.java
示例16: CompleteCodeReferenceElement
import com.intellij.codeInsight.completion.PrefixMatcher; //导入依赖的package包/类
private CompleteCodeReferenceElement(@NotNull GrCodeReferenceElementImpl ref,
@NotNull Consumer<LookupElement> consumer,
@NotNull PrefixMatcher matcher) {
myRef = ref;
myConsumer = consumer;
myMatcher = matcher;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:CompleteCodeReferenceElement.java
示例17: getLookupElements
import com.intellij.codeInsight.completion.PrefixMatcher; //导入依赖的package包/类
@NotNull
@Override
public Collection<LookupElement> getLookupElements(@NotNull PhpToolboxCompletionContributorParameter parameter) {
return PhpIndex.getInstance(parameter.getProject())
.getAllFunctionNames(PrefixMatcher.ALWAYS_TRUE).stream().map(
s -> LookupElementBuilder.create(s).withIcon(PhpIcons.FUNCTION)
)
.collect(Collectors.toCollection(HashSet::new));
}
开发者ID:Haehnchen,项目名称:idea-php-toolbox,代码行数:10,代码来源:FunctionProvider.java
示例18: processMembers
import com.intellij.codeInsight.completion.PrefixMatcher; //导入依赖的package包/类
public void processMembers(final Consumer<LookupElement> results, @Nullable final PsiClass where,
final boolean acceptMethods, final boolean searchInheritors) {
if (where == null || CommonClassNames.JAVA_LANG_STRING.equals(where.getQualifiedName())) return;
final boolean searchFactoryMethods = searchInheritors &&
!CommonClassNames.JAVA_LANG_OBJECT.equals(where.getQualifiedName()) &&
!CommonClassNames.JAVA_LANG_STRING.equals(where.getQualifiedName());
final Project project = myPlace.getProject();
final GlobalSearchScope scope = myPlace.getResolveScope();
final PsiClassType baseType = JavaPsiFacade.getElementFactory(project).createType(where);
Consumer<PsiType> consumer = new Consumer<PsiType>() {
@Override
public void consume(PsiType psiType) {
PsiClass psiClass = PsiUtil.resolveClassInType(psiType);
if (psiClass == null) {
return;
}
psiClass = CompletionUtil.getOriginalOrSelf(psiClass);
if (mayProcessMembers(psiClass)) {
final FilterScopeProcessor<PsiElement> declProcessor = new FilterScopeProcessor<PsiElement>(TrueFilter.INSTANCE);
psiClass.processDeclarations(declProcessor, ResolveState.initial(), null, myPlace);
doProcessMembers(acceptMethods, results, psiType != baseType, declProcessor.getResults());
String name = psiClass.getName();
if (name != null && searchFactoryMethods) {
Collection<PsiMember> factoryMethods = JavaStaticMemberTypeIndex.getInstance().getStaticMembers(name, project, scope);
doProcessMembers(acceptMethods, results, psiType != baseType, factoryMethods);
}
}
}
};
consumer.consume(baseType);
if (searchInheritors && !CommonClassNames.JAVA_LANG_OBJECT.equals(where.getQualifiedName())) {
CodeInsightUtil.processSubTypes(baseType, myPlace, true, PrefixMatcher.ALWAYS_TRUE, consumer);
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:39,代码来源:MembersGetter.java
示例19: addCompletions
import com.intellij.codeInsight.completion.PrefixMatcher; //导入依赖的package包/类
public static void addCompletions(@NotNull final JavaSmartCompletionParameters parameters,
@NotNull Consumer<LookupElement> result, final PrefixMatcher matcher) {
PsiType expectedType = parameters.getExpectedType();
if (!InheritanceUtil.isInheritor(expectedType, CommonClassNames.JAVA_LANG_CLASS)) {
return;
}
PsiType classParameter = PsiUtil.substituteTypeParameter(expectedType, CommonClassNames.JAVA_LANG_CLASS, 0, false);
boolean addInheritors = false;
PsiElement position = parameters.getPosition();
if (classParameter instanceof PsiWildcardType) {
final PsiWildcardType wildcardType = (PsiWildcardType)classParameter;
classParameter = wildcardType.isSuper() ? wildcardType.getSuperBound() : wildcardType.getExtendsBound();
addInheritors = wildcardType.isExtends() && classParameter instanceof PsiClassType;
} else if (!matcher.getPrefix().isEmpty()) {
addInheritors = true;
classParameter = PsiType.getJavaLangObject(position.getManager(), position.getResolveScope());
}
if (classParameter != null) {
PsiFile file = position.getContainingFile();
addClassLiteralLookupElement(classParameter, result, file);
if (addInheritors) {
addInheritorClassLiterals(file, classParameter, result, matcher);
}
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:28,代码来源:ClassLiteralGetter.java
示例20: addItem
import com.intellij.codeInsight.completion.PrefixMatcher; //导入依赖的package包/类
public void addItem(LookupElement item, PrefixMatcher matcher) {
myMatchers.put(item, matcher);
LookupElementPresentation presentation = updateLookupWidth(item);
synchronized (myList) {
myArranger.addElement(this, item, presentation);
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:8,代码来源:LookupImpl.java
注:本文中的com.intellij.codeInsight.completion.PrefixMatcher类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论