boolean (@Nullable PsiElement place, @NotNull String name, boolean allowShadowing) { if (place == null) { return false; } PsiResolveHelper helper = JavaPsiFacade.getInstance(place.getProject()).getResolveHelper(); PsiVariable existingVariable = helper.resolveAccessibleReferencedVariable(name, place); if (existingVariable == null) return false; return !allowShadowing || !(existingVariable instanceof PsiField) || PsiTreeUtil.getNonStrictParentOfType(place, PsiMethod.class) == null; }