private void refreshSources(CompileContext compileContext) {
          if (project.isDisposed()) {
            return;
          }
          final Set<String> candidates = CollectionFactory.createFilePathSet();
          synchronized (myRootsToRefresh) {
            candidates.addAll(myRootsToRefresh);
            myRootsToRefresh.clear();
          }

          if (candidates.isEmpty() && !compileContext.isAnnotationProcessorsEnabled()) {
            return;
          }

          BackgroundTaskUtil.submitTask(ProjectDisposableService.getInstance(project), () -> {
            if (project.isDisposed()) {
              return;
            }

            if (compileContext.isAnnotationProcessorsEnabled()) {
              // annotation processors may have re-generated code
              final CompilerConfiguration config = CompilerConfiguration.getInstance(project);
              try {
                for (Module module : ReadAction.nonBlocking(() -> compileContext.getCompileScope().getAffectedModules()).executeSynchronously()) {
                  if (project.isDisposed()) {
                    return;
                  }
                  if (module.isDisposed()) {
                    continue;
                  }
                  if (config.getAnnotationProcessingConfiguration(module).isEnabled()) {
                    final String productionPath = CompilerPaths.getAnnotationProcessorsGenerationPath(module, false);
                    if (productionPath != null) {
                      candidates.add(productionPath);
                    }
                    final String testsPath = CompilerPaths.getAnnotationProcessorsGenerationPath(module, true);
                    if (testsPath != null) {
                      candidates.add(testsPath);
                    }
                  }
                }
              }
              catch (ProcessCanceledException ignored) {
              }
              catch (Throwable e) {
                LOG.info(e);
              }
            }

            if (candidates.isEmpty()) {
              return;
            }

            CompilerUtil.refreshOutputRoots(candidates);

            LocalFileSystem lfs = LocalFileSystem.getInstance();
            try {
              Collection<VirtualFile> toRefresh = ReadAction.nonBlocking(() -> {
                if (project.isDisposed()) {
                  return Collections.<VirtualFile>emptySet();
                }
                ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
                return candidates.stream().map(lfs::findFileByPath).filter(root -> root != null && fileIndex.isInSourceContent(root)).collect(Collectors.toSet());

              }).executeSynchronously();

              if (!toRefresh.isEmpty()) {
                lfs.refreshFiles(toRefresh, true, true, null);
              }
            }
            catch (ProcessCanceledException ignored) {
            }
            catch (Throwable e) {
              LOG.info(e);
            }
          });
        }
private void refreshSources(CompileContext compileContext)