本文整理汇总了Java中com.intellij.codeInsight.completion.PrefixMatcher.prefixMatches方法的典型用法代码示例。如果您正苦于以下问题:Java PrefixMatcher.prefixMatches方法的具体用法?Java PrefixMatcher.prefixMatches怎么用?Java PrefixMatcher.prefixMatches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.codeInsight.completion.PrefixMatcher
的用法示例。
在下文中一共展示了PrefixMatcher.prefixMatches方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: 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);
}
示例4: addVariantsWithSameQualifier
import com.intellij.codeInsight.completion.PrefixMatcher; //导入方法依赖的package包/类
private static void addVariantsWithSameQualifier(PrefixMatcher matcher, PsiElement element,
GrReferenceExpression patternExpression,
@Nullable GrExpression patternQualifier,
Set<String> result) {
if (element instanceof GrReferenceExpression && element != patternExpression && !PsiUtil.isLValue((GroovyPsiElement)element)) {
final GrReferenceExpression refExpr = (GrReferenceExpression)element;
final String refName = refExpr.getReferenceName();
if (refName != null && !result.contains(refName) && matcher.prefixMatches(refName)) {
final GrExpression hisQualifier = refExpr.getQualifierExpression();
if (hisQualifier != null && patternQualifier != null) {
if (PsiEquivalenceUtil.areElementsEquivalent(hisQualifier, patternQualifier)) {
if (refExpr.resolve() == null) {
result.add(refName);
}
}
}
else if (hisQualifier == null && patternQualifier == null) {
if (refExpr.resolve() == null) {
result.add(refName);
}
}
}
}
for (PsiElement child = element.getFirstChild(); child != null; child = child.getNextSibling()) {
addVariantsWithSameQualifier(matcher, child, patternExpression, patternQualifier, result);
}
}
示例5: prefixMatches
import com.intellij.codeInsight.completion.PrefixMatcher; //导入方法依赖的package包/类
private boolean prefixMatches(LookupElement item) {
PrefixMatcher matcher = itemMatcher(item);
if (!myAdditionalPrefix.isEmpty()) {
matcher = matcher.cloneWithPrefix(matcher.getPrefix() + myAdditionalPrefix);
}
return matcher.prefixMatches(item);
}
示例6: createLookupElements
import com.intellij.codeInsight.completion.PrefixMatcher; //导入方法依赖的package包/类
public static List<? extends LookupElement> createLookupElements(GroovyResolveResult candidate,
boolean afterNew,
PrefixMatcher matcher,
@Nullable PsiElement position) {
final PsiElement element = candidate.getElement();
final PsiElement context = candidate.getCurrentFileResolveContext();
if (context instanceof GrImportStatement && element != null) {
if (element instanceof PsiPackage) {
return Collections.emptyList();
}
final String importedName = ((GrImportStatement)context).getImportedName();
if (importedName != null) {
if (!(matcher.prefixMatches(importedName) ||
element instanceof PsiMethod && getterMatches(matcher, (PsiMethod)element, importedName) ||
element instanceof PsiMethod && setterMatches(matcher, (PsiMethod)element, importedName))
) {
return Collections.emptyList();
}
final GrCodeReferenceElement importReference = ((GrImportStatement)context).getImportReference();
if (importReference != null) {
boolean alias = ((GrImportStatement)context).isAliasedImport();
for (GroovyResolveResult r : importReference.multiResolve(false)) {
final PsiElement resolved = r.getElement();
if (context.getManager().areElementsEquivalent(resolved, element) && (alias || !(element instanceof PsiClass))) {
return generateLookupForImportedElement(candidate, importedName, alias);
}
else {
if (resolved instanceof PsiField && element instanceof PsiMethod && isAccessorFor((PsiMethod)element, (PsiField)resolved)) {
return generateLookupForImportedElement(candidate, getAccessorPrefix((PsiMethod)element) + capitalize(importedName), alias);
}
}
}
}
}
}
String name = element instanceof PsiNamedElement ? ((PsiNamedElement)element).getName() : element.getText();
if (name == null || !matcher.prefixMatches(name)) {
return Collections.emptyList();
}
if (element instanceof PsiClass) {
return JavaClassNameCompletionContributor
.createClassLookupItems((PsiClass)element, afterNew, new GroovyClassNameInsertHandler(), Condition.TRUE);
}
LookupElementBuilder builder = LookupElementBuilder.create(element instanceof PsiPackage ? element : candidate, name);
return Arrays.asList(setupLookupBuilder(element, candidate.getSubstitutor(), builder, position));
}
示例7: setterMatches
import com.intellij.codeInsight.completion.PrefixMatcher; //导入方法依赖的package包/类
private static boolean setterMatches(PrefixMatcher matcher, PsiMethod element, String importedName) {
return isSimplePropertySetter(element) && matcher.prefixMatches(getSetterName(importedName));
}
示例8: getterMatches
import com.intellij.codeInsight.completion.PrefixMatcher; //导入方法依赖的package包/类
private static boolean getterMatches(PrefixMatcher matcher, PsiMethod element, String importedName) {
return isSimplePropertyGetter(element) &&
(matcher.prefixMatches(getGetterNameNonBoolean(importedName)) ||
element.getReturnType() == PsiType.BOOLEAN && matcher.prefixMatches(getGetterNameBoolean(importedName)));
}