int (@NotNull ControlFlow flow, int startOffset, int endOffset, @NotNull PsiVariable variable) { List<Instruction> instructions = flow.getInstructions(); if (startOffset < 0 || endOffset < 0 || endOffset > instructions.size()) return -1; PsiManager psiManager = variable.getManager(); int readOffset = -1; for (int i = startOffset; i < endOffset; i++) { Instruction instruction = instructions.get(i); if (instruction instanceof ReadVariableInstruction) { if (psiManager.areElementsEquivalent(((ReadVariableInstruction)instruction).variable, variable)) { if (readOffset < 0) { readOffset = i; } else { return -1; } } } else if (instruction instanceof WriteVariableInstruction) { if (psiManager.areElementsEquivalent(((WriteVariableInstruction)instruction).variable, variable)) { return -1; } } } return readOffset; }