provide accessibility fixes for problems inside annotations (IDEA-148864)

This commit is contained in:
Anna Kozlova
2016-09-15 13:55:49 +03:00
parent ca0109df46
commit e2e3d94711
5 changed files with 52 additions and 3 deletions
@@ -465,7 +465,7 @@ public class AnnotationsHighlightUtil {
final PsiTypeElement operand = expression.getOperand();
final PsiClass classType = PsiUtil.resolveClassInType(operand.getType());
if (classType != null) {
checkAccessibility(expression, classType, HighlightUtil.formatClass(classType));
checkAccessibility(operand.getInnermostComponentReferenceElement(), classType, HighlightUtil.formatClass(classType));
}
}
@@ -478,7 +478,7 @@ public class AnnotationsHighlightUtil {
}
}
private void checkAccessibility(PsiExpression expression, PsiMember resolve, String memberString) {
private void checkAccessibility(PsiJavaCodeReferenceElement expression, PsiMember resolve, String memberString) {
if (resolve.hasModifierProperty(PsiModifier.PRIVATE) &&
PsiTreeUtil.isAncestor(parent, resolve, true)) {
String description = JavaErrorMessages.message("private.symbol",
@@ -486,6 +486,7 @@ public class AnnotationsHighlightUtil {
HighlightUtil.formatClass((PsiClass)parent));
infos[0] =
HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create();
HighlightUtil.registerAccessQuickFixAction(resolve, expression, infos[0], null);
}
}
});
@@ -1,4 +1,4 @@
@SomeAnnotation(<error descr="'Foo.Bar' has private access in 'Foo'">Foo.Bar.class</error>)
@SomeAnnotation(<error descr="'Foo.Bar' has private access in 'Foo'">Foo.Bar</error>.class)
public class Foo{
private static class Bar {
}
@@ -0,0 +1,12 @@
// "Make 'Inner' protected" "true"
@MyAnnotation(Outer.Inner.class)
public class Outer {
protected static class Inner {
}
}
@interface MyAnnotation {
Class<?> value();
}
@@ -0,0 +1,12 @@
// "Make 'Inner' protected" "true"
@MyAnnotation(Outer.I<caret>nner.class)
public class Outer {
private static class Inner {
}
}
@interface MyAnnotation {
Class<?> value();
}
@@ -0,0 +1,24 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.daemon.quickFix;
public class AccessibilityFixesTest extends LightQuickFixParameterizedTestCase {
@Override
protected String getBasePath() {
return "/codeInsight/daemonCodeAnalyzer/quickFix/makePublic";
}
}