void (@NotNull PsiNameIdentifierOwner element) { final ScopeOwner owner = ScopeUtil.getScopeOwner(element); if (owner instanceof PyClass) { return; } final String name = element.getName(); if (name != null) { final PsiElement identifier = element.getNameIdentifier(); final PsiElement problemElement = identifier != null ? identifier : element; if (PyNames.UNDERSCORE.equals(name) || name.startsWith(PyNames.UNDERSCORE) && element instanceof PyParameter) { return; } if (owner != null) { final ScopeOwner nextOwner = ScopeUtil.getScopeOwner(owner); if (nextOwner != null) { final PyResolveProcessor processor = new PyResolveProcessor(name); PyResolveUtil.scopeCrawlUp(processor, nextOwner, null, name, null); for (PsiElement resolved : processor.getElements()) { if (resolved != null) { final PyComprehensionElement comprehension = PsiTreeUtil.getParentOfType(resolved, PyComprehensionElement.class); if (comprehension != null && PyUtil.isOwnScopeComprehension(comprehension)) { return; } final Scope scope = ControlFlowCache.getScope(owner); if (scope.isGlobal(name) || scope.isNonlocal(name)) { return; } if (Arrays.stream(PyInspectionExtension.EP_NAME.getExtensions()) .anyMatch(o -> o.ignoreShadowed(resolved))) { return; } registerProblem(problemElement, PyPsiBundle.message("INSP.shadows.name.from.outer.scope", name), ProblemHighlightType.WEAK_WARNING, null, LocalQuickFix.notNullElements(PythonUiService.getInstance().createPyRenameElementQuickFix(problemElement))); return; } } } } } }