mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
IDEA-98936 (classes in default (unnamed) package cannot be referenced from other packages)
This commit is contained in:
@@ -395,8 +395,18 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
|
||||
// TODO: support type parameters in FQ names
|
||||
String text = getTextSkipWhiteSpaceAndComments();
|
||||
if (StringUtil.isEmptyOrSpaces(text)) return JavaResolveResult.EMPTY_ARRAY;
|
||||
|
||||
PsiClass aClass = JavaPsiFacade.getInstance(getProject()).findClass(text, getResolveScope());
|
||||
if (aClass == null) return JavaResolveResult.EMPTY_ARRAY;
|
||||
|
||||
if (!isQualified() && text.equals(aClass.getQualifiedName())) {
|
||||
PsiFile file = getContainingFile();
|
||||
if (file instanceof PsiJavaFile && !((PsiJavaFile)file).getPackageName().isEmpty()) {
|
||||
// classes in default (unnamed) package cannot be referenced from other packages
|
||||
return JavaResolveResult.EMPTY_ARRAY;
|
||||
}
|
||||
}
|
||||
|
||||
return new JavaResolveResult[]{new CandidateInfo(aClass, updateSubstitutor(PsiSubstitutor.EMPTY, aClass), this, false)};
|
||||
}
|
||||
case CLASS_IN_QUALIFIED_NEW_KIND: {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
public class Test {
|
||||
public Test(int i) {
|
||||
new x();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
class x { }
|
||||
@@ -157,7 +157,7 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase {
|
||||
doTest(BASE_PATH + "/alreadyImportedClass/pack/AlreadyImportedClass.java", BASE_PATH + "/alreadyImportedClass", false, false);
|
||||
}
|
||||
|
||||
public void testImportDefaultPackage() throws Exception {
|
||||
public void testImportDefaultPackage1() throws Exception {
|
||||
doTest(BASE_PATH + "/importDefaultPackage/x/Usage.java", BASE_PATH + "/importDefaultPackage", false, false);
|
||||
}
|
||||
|
||||
@@ -165,6 +165,10 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase {
|
||||
doTest(BASE_PATH + "/importDefaultPackage/x/ImportOnDemandUsage.java", BASE_PATH + "/importDefaultPackage", false, false);
|
||||
}
|
||||
|
||||
public void testImportDefaultPackage3() throws Exception {
|
||||
doTest(BASE_PATH + "/importDefaultPackage/Test.java", BASE_PATH + "/importDefaultPackage", false, false);
|
||||
}
|
||||
|
||||
public void testImportDefaultPackageInvalid() throws Exception {
|
||||
doTest(BASE_PATH + "/importDefaultPackage/x/InvalidUse.java", BASE_PATH + "/importDefaultPackage", false, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user