本文整理汇总了Java中com.intellij.psi.util.PsiUtil.getAccessLevel方法的典型用法代码示例。如果您正苦于以下问题:Java PsiUtil.getAccessLevel方法的具体用法?Java PsiUtil.getAccessLevel怎么用?Java PsiUtil.getAccessLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.util.PsiUtil
的用法示例。
在下文中一共展示了PsiUtil.getAccessLevel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMemberUseScope
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@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;
}
示例2: getAccessLevel
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Override
public int getAccessLevel() {
final PsiModifierList modifierList = ((PsiModifierListOwner)getElement()).getModifierList();
if (modifierList == null) {
return PsiUtil.ACCESS_LEVEL_PUBLIC;
}
return PsiUtil.getAccessLevel(modifierList);
}
示例3: compare
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@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);
}
示例4: preferLeftForImplement
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private static boolean preferLeftForImplement(PsiMethod left, PsiMethod right) {
if (PsiUtil.getAccessLevel(left.getModifierList()) > PsiUtil.getAccessLevel(right.getModifierList())) return true;
PsiClass lClass = left.getContainingClass();
PsiClass rClass = right.getContainingClass();
if (lClass != null && !lClass.isInterface()) return true;
if (rClass != null && !rClass.isInterface()) return false;
// implement annotated method
PsiAnnotation[] leftAnnotations = left.getModifierList().getAnnotations();
PsiAnnotation[] rightAnnotations = right.getModifierList().getAnnotations();
return leftAnnotations.length > rightAnnotations.length;
}
示例5: getAccessLevel
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@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);
}