PyStringLiteralExpression (String str) { final PsiFile dummyFile = createDummyFile(LanguageLevel.getDefault(), "a=(" + str + ")"); final PyAssignmentStatement expressionStatement = (PyAssignmentStatement)dummyFile.getFirstChild(); final PyExpression assignedValue = expressionStatement.getAssignedValue(); if (assignedValue != null) { return (PyStringLiteralExpression)((PyParenthesizedExpression)assignedValue).getContainedExpression(); } return createStringLiteralFromString(str); }