void (@NotNull final PsiElement finalElement, @NotNull final PyReferenceExpression element, @NotNull final PsiFile usageFile, boolean addImport) { final PyExpression qualifier = element.getQualifier(); if (qualifier == null) return; if (qualifier.getText().equals(PyNames.CANONICAL_SELF)) { PyUtil.removeQualifier(element); return; } if (qualifier instanceof PyCallExpression) { // remove qualifier A().m() if (addImport) AddImportHelper.addImport((PsiNamedElement)finalElement, usageFile, element); PyUtil.removeQualifier(element); removeFormerImport(usageFile, addImport); } else { final PsiReference reference = qualifier.getReference(); if (reference == null) return; final PsiElement resolved = reference.resolve(); if (resolved instanceof PyTargetExpression) { // qualifier came from assignment a = A(); a.m() updateAssignment(element, resolved); } else if (resolved instanceof PyClass) { //call with first instance argument A.m(A()) PyUtil.removeQualifier(element); updateArgumentList(element); } } }