PyStatement (String self_name) { if (PyNames.CANONICAL_SELF.equals(self_name)) { return (PyStatement)myDeclaration; } final String text = myDeclaration.getText(); final Project project = myDeclaration.getProject(); return PyElementGenerator.getInstance(project).createFromText(LanguageLevel.getDefault(), PyStatement.class, text.replaceFirst(PyNames.CANONICAL_SELF + "\\.", self_name + ".")); }