void () { myFixture.addClass("public class Cls { public static class TestImport {}}"); myFixture.addClass("public class Cls2 { public static class TestImport {}}"); myFixture.addClass("package demo;public class TestImport {}"); myFixture.addClass("public class TestImport {}"); myFixture.configureByText("a.java", "import demo.*;import static Cls2.*; class Test {TestIm<caret>}"); myFixture.completeBasic(); LookupElement[] elements = myFixture.getLookupElements(); assertEquals(4, elements.length); List<String> weights = DumpLookupElementWeights.getLookupElementWeights(getLookup(), false); assertEquals("TestImport", elements[0].as(JavaPsiClassReferenceElement.class).getQualifiedName()); assertTrue(weights.get(0).contains("explicitlyImported=CLASS_DECLARED_IN_SAME_PACKAGE_TOP_LEVEL,"));// same package assertEquals("demo.TestImport", elements[1].as(JavaPsiClassReferenceElement.class).getQualifiedName()); assertTrue(weights.get(1).contains("explicitlyImported=CLASS_ON_DEMAND_TOP_LEVEL,"));// on-demand import assertEquals("Cls2.TestImport", elements[2].as(JavaPsiClassReferenceElement.class).getQualifiedName()); assertTrue(weights.get(2).contains("explicitlyImported=CLASS_ON_DEMAND_NESTED,"));// same package, nested class imported assertEquals("Cls.TestImport", elements[3].as(JavaPsiClassReferenceElement.class).getQualifiedName()); assertTrue(weights.get(3) .contains("explicitlyImported=CLASS_DECLARED_IN_SAME_PACKAGE_NESTED,"));// same package but nested class not imported }