String (@NotNull final PsiElement element) { if (element instanceof PyFile) { return FileUtilRt.getNameWithoutExtension(((PyFile)element).getName()); } if (element instanceof PsiDirectory) { return ((PsiDirectory)element).getName(); } // Magic literals are always represented by their string values if ((element instanceof PyStringLiteralExpression) && PyMagicLiteralTools.couldBeMagicLiteral(element)) { return ((StringLiteralExpression)element).getStringValue(); } if (element instanceof PyElement) { final String name = ((PyElement)element).getName(); if (name != null) { return name; } } return element.getNode() != null ? element.getNode().getText() : element.getText(); }