PsiElement ( @NotNull final PyClass aClass, @NotNull final String attributeName, @NotNull final String value) { if (aClass.findClassAttribute(attributeName, false, null) != null) { return null; //Do not add any if exist already } final PyElementGenerator generator = PyElementGenerator.getInstance(aClass.getProject()); final String text = String.format("%s = %s", attributeName, value); final LanguageLevel level = LanguageLevel.forElement(aClass); final PyAssignmentStatement assignmentStatement = generator.createFromText(level, PyAssignmentStatement.class, text); //TODO: Add metaclass to the top. Add others between last attributeName and first method return addElementToStatementList(assignmentStatement, aClass.getStatementList(), true); }