Search in sources :

Example 1 with PyReprExpression

use of com.jetbrains.python.psi.PyReprExpression in project intellij-community by JetBrains.

the class ReplaceBackquoteExpressionQuickFix method applyFix.

@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
    PsiElement problemElement = descriptor.getPsiElement();
    if (problemElement instanceof PyReprExpression) {
        if (((PyReprExpression) problemElement).getExpression() != null) {
            PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project);
            problemElement.replace(elementGenerator.createExpressionFromText("repr(" + ((PyReprExpression) problemElement).getExpression().getText() + ")"));
        }
    }
}
Also used : PyReprExpression(com.jetbrains.python.psi.PyReprExpression) PyElementGenerator(com.jetbrains.python.psi.PyElementGenerator) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 PyElementGenerator (com.jetbrains.python.psi.PyElementGenerator)1 PyReprExpression (com.jetbrains.python.psi.PyReprExpression)1