diff --git a/platform/projectModel-api/src/com/intellij/openapi/module/ModifiableModuleModel.java b/platform/projectModel-api/src/com/intellij/openapi/module/ModifiableModuleModel.java index 6f3beabe6d9e..2fbbf08b6cc9 100644 --- a/platform/projectModel-api/src/com/intellij/openapi/module/ModifiableModuleModel.java +++ b/platform/projectModel-api/src/com/intellij/openapi/module/ModifiableModuleModel.java @@ -16,7 +16,6 @@ package com.intellij.openapi.module; import com.intellij.openapi.util.InvalidDataException; -import org.jdom.JDOMException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -69,9 +68,7 @@ public interface ModifiableModuleModel { * @return the module instance. * @throws InvalidDataException if the data in the .iml file is semantically incorrect. * @throws IOException if an I/O error occurred when loading the module file. - * @throws JDOMException if the file contains invalid XML data. * @throws ModuleWithNameAlreadyExists if a module with such a name already exists in the project. - * @throws LoadCancelledException if loading the module was cancelled by some of the components. */ @NotNull Module loadModule(@NotNull String filePath) throws IOException, ModuleWithNameAlreadyExists; diff --git a/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java index 8bfd08f450f1..9e9576d42929 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java @@ -39,6 +39,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.StandardFileSystems; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; +import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.HashMap; import com.intellij.util.containers.StringInterner; @@ -50,7 +51,6 @@ import com.intellij.util.messages.MessageBus; import gnu.trove.THashMap; import gnu.trove.TObjectHashingStrategy; import org.jdom.Element; -import org.jdom.JDOMException; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -74,7 +74,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project @NonNls public static final String COMPONENT_NAME = "ProjectModuleManager"; private static final String MODULE_GROUP_SEPARATOR = "/"; private List myModulePaths; - private final List myFailedModulePaths = new ArrayList<>(); + private final List myFailedModulePaths = new SmartList<>(); @NonNls public static final String ELEMENT_MODULES = "modules"; @NonNls public static final String ELEMENT_MODULE = "module"; @NonNls private static final String ATTRIBUTE_FILEURL = "fileurl"; @@ -148,7 +148,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project @Override public void loadState(Element state) { List prevPaths = myModulePaths; - readExternal(state); + myModulePaths = new ArrayList<>(getPathsToModuleFiles(state)); if (prevPaths == null) { return; } @@ -202,7 +202,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project } @NotNull - public static ModulePath[] getPathsToModuleFiles(@NotNull Element element) { + public static List getPathsToModuleFiles(@NotNull Element element) { final List paths = new ArrayList<>(); final Element modules = element.getChild(ELEMENT_MODULES); if (modules != null) { @@ -220,11 +220,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project paths.add(new ModulePath(filepath, group)); } } - return paths.toArray(new ModulePath[paths.size()]); - } - - public void readExternal(@NotNull Element element) { - myModulePaths = new ArrayList<>(Arrays.asList(getPathsToModuleFiles(element))); + return paths; } protected void loadModules(@NotNull ModuleModelImpl moduleModel) { @@ -459,7 +455,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project @Override @NotNull - public Module loadModule(@NotNull String filePath) throws IOException, JDOMException, ModuleWithNameAlreadyExists { + public Module loadModule(@NotNull String filePath) throws IOException, ModuleWithNameAlreadyExists { incModificationCount(); final ModifiableModuleModel modifiableModel = getModifiableModel(); final Module module = modifiableModel.loadModule(filePath); diff --git a/platform/testFramework/src/com/intellij/openapi/application/ex/PathManagerEx.java b/platform/testFramework/src/com/intellij/openapi/application/ex/PathManagerEx.java index 5e9ba1a51841..7df0b95201a0 100644 --- a/platform/testFramework/src/com/intellij/openapi/application/ex/PathManagerEx.java +++ b/platform/testFramework/src/com/intellij/openapi/application/ex/PathManagerEx.java @@ -408,8 +408,7 @@ public class PathManagerEx { try { Element element = JDomSerializationUtil.findComponent(JDOMUtil.load(modulesXml), ModuleManagerImpl.COMPONENT_NAME); assert element != null; - ModuleManagerImpl.ModulePath[] files = ModuleManagerImpl.getPathsToModuleFiles(element); - for (ModuleManagerImpl.ModulePath file : files) { + for (ModuleManagerImpl.ModulePath file : ModuleManagerImpl.getPathsToModuleFiles(element)) { String name = FileUtil.getNameWithoutExtension(PathUtil.getFileName(file.getPath())); ourCommunityModules.add(name); }