BaseConvertToFStringProcessor (@NotNull Editor editor, @NotNull PsiFile file) { final PsiElement anchor = file.findElementAt(editor.getCaretModel().getOffset()); if (anchor == null) return null; final PyBinaryExpression binaryExpr = PsiTreeUtil.getParentOfType(anchor, PyBinaryExpression.class); if (binaryExpr != null && binaryExpr.getOperator() == PyTokenTypes.PERC) { final PyStringLiteralExpression pyString = as(binaryExpr.getLeftExpression(), PyStringLiteralExpression.class); if (pyString != null) { return new OldStyleConvertToFStringProcessor(pyString); } } final PyCallExpression callExpr = PsiTreeUtil.getParentOfType(anchor, PyCallExpression.class); if (callExpr != null) { final PyReferenceExpression callee = as(callExpr.getCallee(), PyReferenceExpression.class); if (callee != null && PyNames.FORMAT.equals(callee.getName())) { final PyStringLiteralExpression pyString = as(callee.getQualifier(), PyStringLiteralExpression.class); if (pyString != null) { return new NewStyleConvertToFStringProcessor(pyString); } } } return null; }