boolean (@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, @NotNull PsiElement place, @NotNull PsiConditionalLoopStatement loop) { if (state.get(PatternResolveState.KEY) == PatternResolveState.WHEN_NONE) return true; PsiExpression condition = loop.getCondition(); if (condition == null) return true; PsiScopeProcessor conditionProcessor = (element, s) -> { assert element instanceof PsiPatternVariable; final NameHint hint = processor.getHint(NameHint.KEY); if (hint != null && !((PsiPatternVariable)element).getName().equals(hint.getName(s))) { return true; } PatternResolveState resolveState = PatternResolveState.stateAtParent((PsiPatternVariable)element, condition); if (resolveState == PatternResolveState.WHEN_TRUE || !PsiTreeUtil .processElements(loop, e -> !(e instanceof PsiBreakStatement) || ((PsiBreakStatement)e).findExitedStatement() != loop)) { return true; } return processor.execute(element, s); }; return condition.processDeclarations(conditionProcessor, PatternResolveState.WHEN_BOTH.putInto(state), null, place); }