private void checkReference(@NotNull final PyReferenceExpression node, @NotNull final PyExpression qualifier) {
      final String name = node.getName();
      final List<LocalQuickFix> quickFixes = new ArrayList<>();
      LocalQuickFix renameElementQuickFix = PythonUiService.getInstance().createPyRenameElementQuickFix(node);
      if (renameElementQuickFix != null) {
        quickFixes.add(renameElementQuickFix);
      }

      if (name != null && name.startsWith("_") && !name.startsWith("__") && !name.endsWith("__")) {
        final PsiReference reference = node.getReference(getResolveContext());
        for (final PyInspectionExtension inspectionExtension : PyInspectionExtension.EP_NAME.getExtensions()) {
          if (inspectionExtension.ignoreProtectedSymbol(node, myTypeEvalContext)) {
            return;
          }
        }
        final PsiElement resolvedExpression = reference.resolve();
        final PyClass resolvedClass = getNotPyiClassOwner(resolvedExpression);

        if (resolvedExpression instanceof PyTargetExpression) {

          final String newName = StringUtil.trimLeading(name, '_');
          if (resolvedClass != null) {

            final String qFixName = resolvedClass.getProperties().containsKey(newName) ?
                                    PyPsiBundle.message("QFIX.use.property") : PyPsiBundle.message("QFIX.add.property");
            quickFixes.add(new PyAddPropertyForFieldQuickFix(qFixName));

            final PyClassType classType = PyUtil.as(myTypeEvalContext.getType(resolvedClass), PyClassType.class);
            if (classType != null) {
              final Set<String> usedNames = classType.getMemberNames(true, myTypeEvalContext);
              if (!usedNames.contains(newName)) {
                quickFixes.add(new PyMakePublicQuickFix());
              }
            }
          }
        }


        if (ignoreTestFunctions) {
          for (PsiElement item = node.getParent(); item != null && !(item instanceof PsiFileSystemItem); item = item.getParent()) {
            if (PythonUnitTestDetectorsKt.isTestElement(item, myTypeEvalContext)) {
              return;
            }
          }
        }

        if (resolvedClass != null) {
          PyClass parentClass = getClassOwner(node);
          while (parentClass != null) {
            if (parentClass.isSubclass(resolvedClass, myTypeEvalContext)) {
              return;
            }
            parentClass = getClassOwner(parentClass);
          }
        }
        final PyType type = myTypeEvalContext.getType(qualifier);
        final @InspectionMessage String message = type instanceof PyModuleType
                                 ? PyPsiBundle.message("INSP.protected.member.access.to.protected.member.of.module", name)
                                 : PyPsiBundle.message("INSP.protected.member.access.to.protected.member.of.class", name);
        registerProblem(node, message, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, null, quickFixes.toArray(LocalQuickFix.EMPTY_ARRAY));
      }
    }
private void checkReference(@NotNull final PyReferenceExpression node, @NotNull final PyExpression qualifier)