void (PsiElement parent, PsiElement lastParent, MultiMap<PsiElement, String> conflicts, @NotNull String varName, final boolean containerIsFile) { if (!containerIsFile && (parent instanceof PsiFile) || parent == null) return; PsiElement child = parent.getFirstChild(); while (child != null && child != lastParent) { // Upper variable declarations if (child instanceof GrVariableDeclaration) { for (GrVariable variable : ((GrVariableDeclaration)child).getVariables()) { if (varName.equals(variable.getName())) { addConflict(varName, variable, conflicts); } } } child = child.getNextSibling(); } if (parent instanceof GrParameterListOwner owner) { //method or closure parameters for (GrParameter parameter : owner.getParameters()) { if (varName.equals(parameter.getName())) { addConflict(varName, parameter, conflicts); } } } else if (parent instanceof GrForStatement statement) { // For statement binding GrForClause clause = statement.getClause(); if (clause != null) { for (GrVariable variable : clause.getDeclaredVariables()) { if (varName.equals(variable.getName())) { addConflict(varName, variable, conflicts); } } } } if (parent instanceof PsiFile) return; validateVariableOccurrencesUp(parent.getParent(), parent, conflicts, varName, false); }