forbid default package classes in static imports (IDEA-26971 )

This commit is contained in:
anna
2011-08-22 17:56:03 +02:00
parent 507e4efb93
commit e23fd301ad
3 changed files with 19 additions and 0 deletions
@@ -2173,6 +2173,13 @@ public class HighlightUtil {
}
if ((resolved instanceof PsiLocalVariable || resolved instanceof PsiParameter) && !(resolved instanceof ImplicitVariable)) {
highlightInfo = HighlightControlFlowUtil.checkVariableMustBeFinal((PsiVariable)resolved, ref);
} else if (resolved instanceof PsiClass) {
if (Comparing.strEqual(((PsiClass)resolved).getQualifiedName(), ((PsiClass)resolved).getName())) {
final PsiElement parent = ref.getParent();
if (parent instanceof PsiImportStaticReferenceElement || parent instanceof PsiImportStaticStatement) {
return HighlightInfo.createHighlightInfo(HighlightInfoType.WRONG_REF, refName, JavaErrorMessages.message("cannot.resolve.symbol", refName.getText()));
}
}
}
return highlightInfo;
}
@@ -0,0 +1,11 @@
import static <error descr="Cannot resolve symbol 'MyConstants'">MyConstants</error>.*;
public class MyClient
{
private int field = MyConstants.CONSTANT;
}
class MyConstants
{
public static final int CONSTANT = 1;
}
@@ -175,6 +175,7 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEADEV13249() throws Exception { doTest(false, false); }
public void testIDEADEV11919() throws Exception { doTest(false, false); }
public void testMethodCannotBeApplied() throws Exception { doTest(false, false); }
public void testDefaultPackageClassInStaticImport() throws Exception { doTest(false, false); }
public void testUnusedParamsOfPublicMethod() throws Exception { doTest(true, false); }