void () { myFixture.addClass("package foo; public class String {}"); // use foo.String myFixture.configureByText("a.java", "class Foo { Stri<caret> }"); myFixture.completeBasic(); myFixture.getLookup().setCurrentItem(ContainerUtil.find(myFixture.getLookupElements(), it -> it.getLookupString().equals("String") && NormalCompletionTestCase.renderElement(it) .getTailText().contains("foo"))); myFixture.type("\n"); myFixture.checkResult("import foo.String;\n\nclass Foo { String<caret>\n}"); // assert non-imported String is not preselected when completing in another file myFixture.configureByText("b.java", "class Bar { Stri<caret> }"); myFixture.completeBasic(); myFixture.assertPreferredCompletionItems(0, "String", "String"); assertTrue(NormalCompletionTestCase.renderElement(myFixture.getLookupElements()[0]).getTailText().contains("java.lang")); }