mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup (better signature, to avoid unneeded assertions)
This commit is contained in:
+11
-9
@@ -655,7 +655,7 @@ public class HighlightMethodUtil {
|
||||
static HighlightInfo checkAmbiguousMethodCallIdentifier(@NotNull PsiReferenceExpression referenceToMethod,
|
||||
@NotNull JavaResolveResult[] resolveResults,
|
||||
@NotNull PsiExpressionList list,
|
||||
final PsiElement element,
|
||||
@Nullable PsiElement element,
|
||||
@NotNull JavaResolveResult resolveResult,
|
||||
@NotNull PsiMethodCallExpression methodCall,
|
||||
@NotNull PsiResolveHelper resolveHelper,
|
||||
@@ -669,7 +669,7 @@ public class HighlightMethodUtil {
|
||||
String description;
|
||||
PsiElement elementToHighlight = ObjectUtils.notNull(referenceToMethod.getReferenceNameElement(), referenceToMethod);
|
||||
if (element != null && !resolveResult.isAccessible()) {
|
||||
description = HighlightUtil.buildProblemWithAccessDescription(referenceToMethod, resolveResult);
|
||||
description = HighlightUtil.buildProblemWithAccessDescription(referenceToMethod, element, resolveResult);
|
||||
}
|
||||
else if (element != null && !resolveResult.isStaticsScopeCorrect()) {
|
||||
if (element instanceof PsiMethod && ((PsiMethod)element).hasModifierProperty(PsiModifier.STATIC)) {
|
||||
@@ -1632,7 +1632,7 @@ public class HighlightMethodUtil {
|
||||
}
|
||||
}
|
||||
if (classReference != null && !resolveHelper.isAccessible(aClass, constructorCall, accessObjectClass)) {
|
||||
String description = HighlightUtil.buildProblemWithAccessDescription(classReference, typeResolveResult);
|
||||
String description = HighlightUtil.buildProblemWithAccessDescription(classReference, aClass, typeResolveResult);
|
||||
PsiElement element = ObjectUtils.notNull(classReference.getReferenceNameElement(), classReference);
|
||||
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description).create();
|
||||
HighlightUtil.registerAccessQuickFixAction(aClass, classReference, info, null);
|
||||
@@ -1656,7 +1656,7 @@ public class HighlightMethodUtil {
|
||||
return;
|
||||
}
|
||||
if (classReference != null && aClass.hasModifierProperty(PsiModifier.PROTECTED) && callingProtectedConstructorFromDerivedClass(constructorCall, aClass)) {
|
||||
holder.add(buildAccessProblem(classReference, typeResolveResult, aClass));
|
||||
holder.add(buildAccessProblem(classReference, aClass, typeResolveResult));
|
||||
} else if (aClass.isInterface() && constructorCall instanceof PsiNewExpression) {
|
||||
final PsiReferenceParameterList typeArgumentList = ((PsiNewExpression)constructorCall).getTypeArgumentList();
|
||||
if (typeArgumentList.getTypeArguments().length > 0) {
|
||||
@@ -1704,7 +1704,7 @@ public class HighlightMethodUtil {
|
||||
else if (classReference != null &&
|
||||
(!result.isAccessible() ||
|
||||
constructor.hasModifierProperty(PsiModifier.PROTECTED) && callingProtectedConstructorFromDerivedClass(constructorCall, aClass))) {
|
||||
holder.add(buildAccessProblem(classReference, result, constructor));
|
||||
holder.add(buildAccessProblem(classReference, constructor, result));
|
||||
}
|
||||
else if (!applicable) {
|
||||
String constructorName = HighlightMessageUtil.getSymbolName(constructor, result.getSubstitutor());
|
||||
@@ -1785,11 +1785,13 @@ public class HighlightMethodUtil {
|
||||
ChangeStringLiteralToCharInMethodCallFix.registerFixes(constructors, constructorCall, info);
|
||||
}
|
||||
|
||||
private static HighlightInfo buildAccessProblem(@NotNull PsiJavaCodeReferenceElement classReference, JavaResolveResult result, PsiMember elementToFix) {
|
||||
String description = HighlightUtil.buildProblemWithAccessDescription(classReference, result);
|
||||
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(classReference).descriptionAndTooltip(description).navigationShift(+1).create();
|
||||
private static HighlightInfo buildAccessProblem(PsiJavaCodeReferenceElement ref,
|
||||
PsiMember resolved,
|
||||
JavaResolveResult result) {
|
||||
String description = HighlightUtil.buildProblemWithAccessDescription(ref, resolved, result);
|
||||
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(ref).descriptionAndTooltip(description).navigationShift(+1).create();
|
||||
if (result.isStaticsScopeCorrect()) {
|
||||
HighlightUtil.registerAccessQuickFixAction(elementToFix, classReference, info, result.getCurrentFileResolveScope());
|
||||
HighlightUtil.registerAccessQuickFixAction(resolved, ref, info, result.getCurrentFileResolveScope());
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
+6
-6
@@ -1717,13 +1717,13 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static String buildProblemWithAccessDescription(@NotNull PsiElement reference, @NotNull JavaResolveResult result) {
|
||||
return buildProblemWithAccessDescription(reference, result, ObjectUtils.notNull(result.getElement())).first;
|
||||
static String buildProblemWithAccessDescription(@NotNull PsiElement ref, @NotNull PsiElement resolved, @NotNull JavaResolveResult result) {
|
||||
return accessProblemTextAndFixes(ref, resolved, result).first;
|
||||
}
|
||||
|
||||
private static Pair<String, List<IntentionAction>> buildProblemWithAccessDescription(PsiElement reference,
|
||||
JavaResolveResult result,
|
||||
PsiElement resolved) {
|
||||
private static Pair<String, List<IntentionAction>> accessProblemTextAndFixes(PsiElement reference,
|
||||
PsiElement resolved,
|
||||
JavaResolveResult result) {
|
||||
assert resolved instanceof PsiModifierListOwner : resolved;
|
||||
PsiModifierListOwner refElement = (PsiModifierListOwner)resolved;
|
||||
String symbolName = HighlightMessageUtil.getSymbolName(refElement, result.getSubstitutor());
|
||||
@@ -2794,7 +2794,7 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
resolved instanceof PsiPackage && ref.getParent() instanceof PsiJavaCodeReferenceElement;
|
||||
if (!skipValidityChecks && !result.isValidResult()) {
|
||||
if (!result.isAccessible()) {
|
||||
Pair<String, List<IntentionAction>> problem = buildProblemWithAccessDescription(ref, result, resolved);
|
||||
Pair<String, List<IntentionAction>> problem = accessProblemTextAndFixes(ref, resolved, result);
|
||||
boolean moduleAccessProblem = problem.second != null;
|
||||
PsiElement range = moduleAccessProblem ? findPackagePrefix(ref) : refName;
|
||||
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(range).descriptionAndTooltip(problem.first).create();
|
||||
|
||||
+3
-3
@@ -1323,7 +1323,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
}
|
||||
final PsiElement method = result.getElement();
|
||||
if (method != null && !result.isAccessible()) {
|
||||
final String accessProblem = HighlightUtil.buildProblemWithAccessDescription(expression, result);
|
||||
String accessProblem = HighlightUtil.buildProblemWithAccessDescription(expression, method, result);
|
||||
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(accessProblem).create();
|
||||
HighlightUtil.registerAccessQuickFixAction((PsiMember)method, expression, info, result.getCurrentFileResolveScope());
|
||||
myHolder.add(info);
|
||||
@@ -1460,10 +1460,10 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
// is not accessible from the class or interface in which the method reference expression appears.
|
||||
private void checkFunctionalInterfaceTypeAccessible(@NotNull PsiFunctionalExpression expression, PsiType functionalInterfaceType) {
|
||||
PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(functionalInterfaceType);
|
||||
final PsiClass psiClass = resolveResult.getElement();
|
||||
PsiClass psiClass = resolveResult.getElement();
|
||||
if (psiClass != null) {
|
||||
if (!PsiUtil.isAccessible(myFile.getProject(), psiClass, expression, null)) {
|
||||
String text = HighlightUtil.buildProblemWithAccessDescription(expression, resolveResult);
|
||||
String text = HighlightUtil.buildProblemWithAccessDescription(expression, psiClass, resolveResult);
|
||||
myHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(text).create());
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user