List<PsiMethodCallExpression> (PsiField field, ControlFlow flow) { List<PsiMethodCallExpression> results = new ArrayList<>(); PsiManager manager = field.getManager(); List<ControlFlowUtil.ControlFlowEdge> edges = ControlFlowUtil.getEdges(flow, 0); Int2ObjectMap<List<ControlFlowUtil.ControlFlowEdge>> edgesFromStart = new Int2ObjectOpenHashMap<>(); List<Instruction> instructions = flow.getInstructions(); for (ControlFlowUtil.ControlFlowEdge edge : edges) { List<ControlFlowUtil.ControlFlowEdge> existedEdge = edgesFromStart.get(edge.myFrom); if (existedEdge != null) { existedEdge.add(edge); } else { List<ControlFlowUtil.ControlFlowEdge> newEdges = new ArrayList<>(); newEdges.add(edge); edgesFromStart.put(edge.myFrom, newEdges); } } BitSet untilAssignment = new BitSet(); ArrayDeque<Integer> unprocessedInstructions = new ArrayDeque<>(); unprocessedInstructions.add(0); while (!unprocessedInstructions.isEmpty()) { int currentPoint = unprocessedInstructions.poll(); if (instructions.size() <= currentPoint) { return results; } if (untilAssignment.get(currentPoint)) { continue; } Instruction instruction = instructions.get(currentPoint); if (instruction instanceof WriteVariableInstruction writeVariableInstruction && manager.areElementsEquivalent(writeVariableInstruction.variable, field)) { continue; } untilAssignment.set(currentPoint); List<ControlFlowUtil.ControlFlowEdge> nextPoints = edgesFromStart.get(currentPoint); if (nextPoints != null) { unprocessedInstructions.addAll(ContainerUtil.map(nextPoints, t -> t.myTo)); } } for (int index : untilAssignment.stream().toArray()) { if (flow.getElement(index) instanceof PsiMethodCallExpression methodCallExpression) { results.add(methodCallExpression); } } return results; }