void () { @Language("JAVA") @SuppressWarnings("ALL") String fileText = "interface I {void f();}\n" + "class A implements I { public void f(){}}\n" + "class B implements I { public void f(){}}\n" + "class C {\n" + " void foo(java.util.List<I> l) {l.stream().forEach(I::<caret>f);}" + "}"; PsiFile file = myFixture.addFileToProject("Foo.java", fileText); myFixture.configureFromExistingVirtualFile(file.getVirtualFile()); final PsiElement[] impls = getTargets(file); assertEquals(2, impls.length); // target are non-deterministic now Arrays.sort(impls, (o1, o2) -> { String name1 = ((PsiMethod)o1).getContainingClass().getName(); String name2 = ((PsiMethod)o2).getContainingClass().getName(); return StringUtil.compare(name1, name2, false); }); final PsiElement method = impls[0]; assertTrue(method instanceof PsiMethod); final PsiClass aClass = ((PsiMethod)method).getContainingClass(); assertNotNull(aClass); assertEquals("A", aClass.getName()); }