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


Java PrefixMatcher.prefixMatches方法代码示例

本文整理汇总了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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:LookupTypedHandler.java

示例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);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:19,代码来源:LookupArranger.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:LookupArranger.java

示例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);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:29,代码来源:CompleteReferenceExpression.java

示例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);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:8,代码来源:LookupArranger.java

示例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));
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:52,代码来源:GroovyCompletionUtil.java

示例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));
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:4,代码来源:GroovyCompletionUtil.java

示例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)));
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:6,代码来源:GroovyCompletionUtil.java


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