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


Java MembersGetter类代码示例

本文整理汇总了Java中com.intellij.psi.filters.getters.MembersGetter的典型用法代码示例。如果您正苦于以下问题:Java MembersGetter类的具体用法?Java MembersGetter怎么用?Java MembersGetter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MembersGetter类属于com.intellij.psi.filters.getters包,在下文中一共展示了MembersGetter类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: weigh

import com.intellij.psi.filters.getters.MembersGetter; //导入依赖的package包/类
@NotNull
@Override
public MyResult weigh(@NotNull LookupElement item) {
  final Object object = item.getObject();

  if (object instanceof PsiKeyword) {
    String keyword = ((PsiKeyword)object).getText();
    if (PsiKeyword.RETURN.equals(keyword) && isLastStatement(PsiTreeUtil.getParentOfType(myPosition, PsiStatement.class))) {
      return MyResult.probableKeyword;
    }
    if (PsiKeyword.ELSE.equals(keyword) || PsiKeyword.FINALLY.equals(keyword)) {
      return MyResult.probableKeyword;
    }
  }

  if (myCompletionType == CompletionType.SMART) {
    if (object instanceof PsiLocalVariable || object instanceof PsiParameter || object instanceof PsiThisExpression) {
      return MyResult.localOrParameter;
    }
  }

  if (object instanceof String && item.getUserData(JavaCompletionUtil.SUPER_METHOD_PARAMETERS) == Boolean.TRUE) {
    return MyResult.superMethodParameters;
  }

  if (myCompletionType == CompletionType.SMART) {
    if (item.getUserData(CollectionsUtilityMethodsProvider.COLLECTION_FACTORY) != null) {
      return MyResult.collectionFactory;
    }
    if (Boolean.TRUE.equals(item.getUserData(MembersGetter.EXPECTED_TYPE_INHERITOR_MEMBER))) {
      return MyResult.expectedTypeMember;
    }

    final JavaChainLookupElement chain = item.as(JavaChainLookupElement.CLASS_CONDITION_KEY);
    if (chain != null) {
      Object qualifier = chain.getQualifier().getObject();
      if (qualifier instanceof PsiLocalVariable || qualifier instanceof PsiParameter) {
        return MyResult.localOrParameter;
      }
      if (qualifier instanceof PsiField) {
        return MyResult.qualifiedWithField;
      }
      if (qualifier instanceof PsiMethod && PropertyUtil.isSimplePropertyGetter((PsiMethod)qualifier)) {
        return MyResult.qualifiedWithGetter;
      }
    }

    return MyResult.normal;
  }

  if (myCompletionType == CompletionType.BASIC) {
    StaticallyImportable callElement = item.as(StaticallyImportable.CLASS_CONDITION_KEY);
    if (callElement != null && callElement.canBeImported() && !callElement.willBeImported()) {
      return MyResult.classNameOrGlobalStatic;
    }

    if (object instanceof PsiKeyword && PsiKeyword.CLASS.equals(item.getLookupString())) {
      return MyResult.classLiteral;
    }

    if (object instanceof PsiMethod && PsiUtil.isAnnotationMethod((PsiElement)object)) {
      return MyResult.annoMethod;
    }

    if (object instanceof PsiClass) {
      if (myRequiredSuper.value((PsiClass)object)) {
        return MyResult.suitableClass;
      }
      return MyResult.classNameOrGlobalStatic;
    }

    if (object instanceof PsiField && myNonInitializedFields.contains(object)) {
      return MyResult.nonInitialized;
    }
  }

  return MyResult.normal;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:79,代码来源:PreferByKindWeigher.java


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