void (final String parameterName, final PsiMethod constructor) { @NonNls String fieldName = convertToFieldName(parameterName); final PsiManager manager = PsiManager.getInstance(myProject); PsiElementFactory factory = JavaPsiFacade.getElementFactory(manager.getProject()); final PsiCodeBlock body = constructor.getBody(); if (body != null) { try { final PsiReferenceExpression refExpr = (PsiReferenceExpression)factory.createExpressionFromText(fieldName, body); if (refExpr.resolve() != null) fieldName = "this." + fieldName; PsiStatement statement = factory.createStatementFromText(fieldName + "=" + parameterName + ";", null); statement = (PsiStatement)CodeStyleManager.getInstance(manager.getProject()).reformat(statement); body.add(statement); } catch (IncorrectOperationException e) { LOG.error(e); } } }