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


Java PsiUtil.ACCESS_LEVEL_PUBLIC属性代码示例

本文整理汇总了Java中com.intellij.psi.util.PsiUtil.ACCESS_LEVEL_PUBLIC属性的典型用法代码示例。如果您正苦于以下问题:Java PsiUtil.ACCESS_LEVEL_PUBLIC属性的具体用法?Java PsiUtil.ACCESS_LEVEL_PUBLIC怎么用?Java PsiUtil.ACCESS_LEVEL_PUBLIC使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.intellij.psi.util.PsiUtil的用法示例。


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

示例1: getMemberUseScope

@NotNull
public static SearchScope getMemberUseScope(@NotNull PsiMember member) {
  PsiFile file = member.getContainingFile();
  PsiElement topElement = file == null ? member : file;
  Project project = topElement.getProject();
  final GlobalSearchScope maximalUseScope = ResolveScopeManager.getInstance(project).getUseScope(topElement);
  if (isInServerPage(file)) return maximalUseScope;

  PsiClass aClass = member.getContainingClass();
  if (aClass instanceof PsiAnonymousClass) {
    //member from anonymous class can be called from outside the class
    PsiElement methodCallExpr = PsiUtil.isLanguageLevel8OrHigher(aClass) ? PsiTreeUtil.getTopmostParentOfType(aClass, PsiStatement.class) 
                                                                         : PsiTreeUtil.getParentOfType(aClass, PsiMethodCallExpression.class);
    return new LocalSearchScope(methodCallExpr != null ? methodCallExpr : aClass);
  }

  PsiModifierList modifierList = member.getModifierList();
  int accessLevel = modifierList == null ? PsiUtil.ACCESS_LEVEL_PUBLIC : PsiUtil.getAccessLevel(modifierList);
  if (accessLevel == PsiUtil.ACCESS_LEVEL_PUBLIC || accessLevel == PsiUtil.ACCESS_LEVEL_PROTECTED) {
    return maximalUseScope; // class use scope doesn't matter, since another very visible class can inherit from aClass
  }
  if (accessLevel == PsiUtil.ACCESS_LEVEL_PRIVATE) {
    PsiClass topClass = PsiUtil.getTopLevelClass(member);
    return topClass != null ? new LocalSearchScope(topClass) : file == null ? maximalUseScope : new LocalSearchScope(file);
  }
  if (file instanceof PsiJavaFile) {
    PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(((PsiJavaFile)file).getPackageName());
    if (aPackage != null) {
      SearchScope scope = PackageScope.packageScope(aPackage, false);
      return scope.intersectWith(maximalUseScope);
    }
  }
  return maximalUseScope;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:PsiImplUtil.java

示例2: getAccessLevel

@Override
public int getAccessLevel() {
  final PsiModifierList modifierList = ((PsiModifierListOwner)getElement()).getModifierList();
  if (modifierList == null) {
    return PsiUtil.ACCESS_LEVEL_PUBLIC;
  }
  return PsiUtil.getAccessLevel(modifierList);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:JavaClassTreeElementBase.java

示例3: compare

@Override
public int compare(PsiModifierListOwner element1, PsiModifierListOwner element2) {
  if (element1 == element2) return 0;

  PsiModifierList modifierList1 = element1.getModifierList();
  PsiModifierList modifierList2 = element2.getModifierList();

  int level1 = modifierList1 == null ? PsiUtil.ACCESS_LEVEL_PUBLIC : PsiUtil.getAccessLevel(modifierList1);
  int level2 = modifierList2 == null ? PsiUtil.ACCESS_LEVEL_PUBLIC : PsiUtil.getAccessLevel(modifierList2);
  if (level1 != level2) return level2 - level1;

  int kind1 = getElementTypeLevel(element1);
  int kind2 = getElementTypeLevel(element2);
  if (kind1 != kind2) return kind1 - kind2;

  if (element1 instanceof PsiMethod){
    LOG.assertTrue(element2 instanceof PsiMethod);
    PsiParameter[] params1 = ((PsiMethod)element1).getParameterList().getParameters();
    PsiParameter[] params2 = ((PsiMethod)element2).getParameterList().getParameters();

    if (params1.length != params2.length) return params1.length - params2.length;
  }

  String text1 = myRenderer.getElementText(element1);
  String text2 = myRenderer.getElementText(element2);
  if (!text1.equals(text2)) return text1.compareTo(text2);

  String containerText1 = myRenderer.getContainerText(element1, text1);
  String containerText2 = myRenderer.getContainerText(element2, text2);
  if (containerText1 == null) containerText1 = "";
  if (containerText2 == null) containerText2 = "";
  return containerText1.compareTo(containerText2);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:DefaultSymbolNavigationContributor.java

示例4: getAccessLevel

@Override
public int getAccessLevel() {
  final PsiClass superClass = getSuperClass();
  PsiModifierList modifierList = superClass == null ? null : superClass.getModifierList();
  return modifierList == null ? PsiUtil.ACCESS_LEVEL_PUBLIC : PsiUtil.getAccessLevel(modifierList);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:SuperTypeGroup.java


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