changeQualifier(refExpr, usage.qualifierClass, usage.member);
}
else {
- final PsiReferenceParameterList parameterList = refExpr.getParameterList();
- if (parameterList != null && parameterList.getTypeArguments().length == 0 && !(refExpr instanceof PsiMethodReferenceExpression)){
- refExpr.setQualifierExpression(null);
- } else {
- final Project project = element.getProject();
- final PsiClass targetClass =
- JavaPsiFacade.getInstance(project).findClass(options.getTargetClassName(), GlobalSearchScope.projectScope(project));
- if (targetClass != null) {
+ final Project project = element.getProject();
+ final PsiClass targetClass =
+ JavaPsiFacade.getInstance(project).findClass(options.getTargetClassName(), GlobalSearchScope.projectScope(project));
+ if (targetClass != null) {
+ final PsiReferenceParameterList parameterList = refExpr.getParameterList();
+ if ((targetClass.isEnum() || PsiTreeUtil.isAncestor(targetClass, element, true)) && parameterList != null && parameterList.getTypeArguments().length == 0 && !(refExpr instanceof PsiMethodReferenceExpression)) {
+ refExpr.setQualifierExpression(null);
+ }
+ else {
changeQualifier(refExpr, targetClass, usage.member);
}
}
import com.intellij.JavaTestUtil;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
-import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
public void testEscalateVisibility1() throws Exception {
doTest("A", "B", true, VisibilityUtil.ESCALATE_VISIBILITY, 0);
}
-
+
+ public void testStringConstantInSwitchLabelExpression() throws Exception {
+ doTest("A", "B", true, VisibilityUtil.ESCALATE_VISIBILITY, 0);
+ }
+
public void testMultipleWithDependencies() throws Exception {
doTest("A", "B", true, VisibilityUtil.ESCALATE_VISIBILITY, 0, 1);
}