PsiLocalVariable (@NotNull String declarationStatementText, @NotNull PsiElement context) { PsiJavaParserFacade facade = JavaPsiFacade.getInstance(context.getProject()).getParserFacade(); PsiDeclarationStatement statement = (PsiDeclarationStatement)facade.createStatementFromText(declarationStatementText, context); return (PsiLocalVariable)statement.getDeclaredElements()[0]; }