void () { PsiElementFactory factory = JavaPsiFacade.getElementFactory(getProject()); PsiMethod method = factory.createMethodFromText("void foo(Object o);", null); PsiCodeBlock block = factory.createCodeBlockFromText("{ return o; }", method); assertInstanceOf(block.findReferenceAt(block.getText().indexOf("o")).resolve(), PsiParameter.class); }