void () { final List<Pair<TypeMigrationUsageInfo, PsiType>> roots = new ArrayList<>(myMigrationRoots); myMigrationRoots = new LinkedList<>(); final PsiReference[][] cachedUsages = new PsiReference[roots.size()][]; int j = 0; for (Pair<TypeMigrationUsageInfo, PsiType> p : roots) { cachedUsages[j++] = markRootUsages(p.getFirst().getElement(), p.getSecond()); } j = 0; for (Pair<TypeMigrationUsageInfo, PsiType> root : roots) { setRootAndMigrate(root.getFirst(), root.getSecond(), cachedUsages[j++]); } }