void (String field, Consumer<PsiElement> checker) { PsiReference iRef = configure(); JavaCodeFragment codeFragment = JavaCodeFragmentFactory.getInstance(getProject()).createExpressionCodeFragment( field, iRef.getElement(), null, true); codeFragment.setVisibilityChecker(JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE); PsiElement[] fileContent = codeFragment.getChildren(); assertEquals(1, fileContent.length); assertTrue(fileContent[0] instanceof PsiExpression); PsiExpression expr = (PsiExpression)fileContent[0]; JavaResolveResult[] results = ((PsiReferenceExpressionImpl)expr).multiResolve(false); assertSize(1, results); checker.accept(results[0].getElement()); }