void () { PsiFile file = PsiFileFactory.getInstance(getProject()).createFileFromText("a.java", JavaFileType.INSTANCE, """ class Parent { void foo( ); } class Child extends Parent { } class User { void caller() { new Child().foo(); } }""", 0, true); PsiReference ref = file.findReferenceAt(file.getText().indexOf("foo()")); assertNotNull(ref); assertTrue(ref.getElement().getResolveScope().contains(file.getViewProvider().getVirtualFile())); assertInstanceOf(ref.resolve(), PsiMethod.class); }