public static void removeExcludedRoot(Module module, VirtualFile root) {
   ModuleRootModificationUtil.updateModel(
       module,
       model -> {
         ContentEntry entry = findContentEntryWithAssertion(model, root);
         entry.removeExcludeFolder(root.getUrl());
       });
 }
 public static void removeAllRoots(Module module, Sdk jdk) {
   ModuleRootModificationUtil.updateModel(
       module,
       model -> {
         model.clear();
         model.setSdk(jdk);
       });
 }
 public static void addExcludedRoot(Module module, VirtualFile dir) {
   ModuleRootModificationUtil.updateModel(
       module,
       model ->
           ApplicationManager.getApplication()
               .runReadAction(
                   () -> {
                     findContentEntryWithAssertion(model, dir).addExcludeFolder(dir);
                   }));
 }
 public static <P extends JpsElement> void addSourceRoot(
     Module module, VirtualFile vDir, @NotNull JpsModuleSourceRootType<P> rootType, P properties) {
   ModuleRootModificationUtil.updateModel(
       module,
       model -> {
         ContentEntry entry = findContentEntry(model, vDir);
         if (entry == null) entry = model.addContentEntry(vDir);
         entry.addSourceFolder(vDir, rootType, properties);
       });
 }
 public static Library addProjectLibrary(
     Module module,
     String libName,
     List<VirtualFile> classesRoots,
     List<VirtualFile> sourceRoots) {
   Ref<Library> result = Ref.create();
   ModuleRootModificationUtil.updateModel(
       module,
       model -> result.set(addProjectLibrary(module, model, libName, classesRoots, sourceRoots)));
   return result.get();
 }
  public static ContentEntry addContentRoot(Module module, VirtualFile vDir) {
    ModuleRootModificationUtil.updateModel(module, model -> model.addContentEntry(vDir));

    for (ContentEntry entry : ModuleRootManager.getInstance(module).getContentEntries()) {
      if (Comparing.equal(entry.getFile(), vDir)) {
        Assert.assertFalse(((ContentEntryImpl) entry).isDisposed());
        return entry;
      }
    }

    return null;
  }
 public static void removeSourceRoot(Module module, VirtualFile root) {
   ModuleRootModificationUtil.updateModel(
       module,
       model -> {
         ContentEntry entry = findContentEntryWithAssertion(model, root);
         for (SourceFolder sourceFolder : entry.getSourceFolders()) {
           if (root.equals(sourceFolder.getFile())) {
             entry.removeSourceFolder(sourceFolder);
             break;
           }
         }
       });
 }
 public static void setCompilerOutputPath(Module module, String url, boolean forTests) {
   ModuleRootModificationUtil.updateModel(
       module,
       model -> {
         CompilerModuleExtension extension =
             model.getModuleExtension(CompilerModuleExtension.class);
         extension.inheritCompilerOutputPath(false);
         if (forTests) {
           extension.setCompilerOutputPathForTests(url);
         } else {
           extension.setCompilerOutputPath(url);
         }
       });
 }
 public static void setJavadocUrls(Module module, String... urls) {
   ModuleRootModificationUtil.updateModel(
       module,
       model -> model.getModuleExtension(JavaModuleExternalPaths.class).setJavadocUrls(urls));
 }
 public static void setExcludeCompileOutput(Module module, boolean exclude) {
   ModuleRootModificationUtil.updateModel(
       module,
       model -> model.getModuleExtension(CompilerModuleExtension.class).setExcludeOutput(exclude));
 }
 public static void addLibrary(Module module, String libName, String libPath, String... jarArr) {
   ModuleRootModificationUtil.updateModel(
       module, model -> addLibrary(module, model, libName, libPath, jarArr));
 }
 public static void removeContentEntry(Module module, VirtualFile contentRoot) {
   ModuleRootModificationUtil.updateModel(
       module,
       model -> model.removeContentEntry(findContentEntryWithAssertion(model, contentRoot)));
 }
 public static void addSourceContentToRoots(
     Module module, @NotNull VirtualFile vDir, boolean testSource) {
   ModuleRootModificationUtil.updateModel(
       module, model -> model.addContentEntry(vDir).addSourceFolder(vDir, testSource));
 }