void () { List<JpsModuleSourceRoot> toRemove = new ArrayList<>(); for (JpsSourceFolder folder : mySourceFolders) { toRemove.add(folder.getSourceRoot()); Disposer.dispose(folder); } mySourceFolders.clear(); for (JpsModuleSourceRoot root : toRemove) { myModule.removeSourceRoot(root.getUrl(), root.getRootType()); } }