void (final PsiElement element, final String newName, final Map<? extends PsiElement, String> allRenames, final List<? super UsageInfo> result) { if (!(element instanceof PsiLocalVariable) && !(element instanceof PsiParameter)) return; PsiClass toplevel = PsiUtil.getTopLevelClass(element); if (toplevel == null) return; PsiElement scopeElement; if (element instanceof PsiLocalVariable) { scopeElement = CommonJavaRefactoringUtil.getVariableScope((PsiLocalVariable)element); } else { // Parameter scopeElement = ((PsiParameter) element).getDeclarationScope(); } LOG.assertTrue(scopeElement != null); scopeElement.accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitReferenceExpression(@NotNull PsiReferenceExpression expression) { super.visitReferenceExpression(expression); if (!expression.isQualified()) { PsiElement resolved = expression.resolve(); if (resolved instanceof PsiField field) { String fieldNewName = allRenames.containsKey(field) ? allRenames.get(field) : field.getName(); if (newName.equals(fieldNewName)) { result.add(new LocalHidesFieldUsageInfo(expression, element)); } } } } }); }