void (@NotNull GrReferenceExpression ref) { final PsiElement resolved = ref.resolve(); if ((resolved instanceof GrParameter || PsiUtil.isLocalVariable(resolved)) && resolved.isPhysical()) { final int offset = resolved.getTextRange().getStartOffset(); //var is declared outside of selected code if (offset < start || end <= offset) { result.add((GrVariable)resolved); } } }