From ec31fa83fc4be1543e9e8ecfa5e226c023a71b5a Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 27 Jan 2017 15:17:36 +0100 Subject: [PATCH] notnull --- .../intellij/testFramework/ModuleTestCase.java | 16 +++++++++------- .../intellij/openapi/module/ModuleManager.java | 5 ++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/java/testFramework/src/com/intellij/testFramework/ModuleTestCase.java b/java/testFramework/src/com/intellij/testFramework/ModuleTestCase.java index bc00a96b8a3f..cf23fce616db 100644 --- a/java/testFramework/src/com/intellij/testFramework/ModuleTestCase.java +++ b/java/testFramework/src/com/intellij/testFramework/ModuleTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,7 +81,7 @@ public abstract class ModuleTestCase extends IdeaTestCase { } } - protected Module createModule(final File moduleFile) { + protected Module createModule(@NotNull File moduleFile) { return createModule(moduleFile, StdModuleTypes.JAVA); } @@ -99,14 +99,16 @@ public abstract class ModuleTestCase extends IdeaTestCase { return module; } - protected Module loadModule(@NotNull String modulePath) { - final String normalizedPath = FileUtil.toSystemIndependentName(modulePath); - LocalFileSystem.getInstance().refreshAndFindFileByPath(normalizedPath); + protected Module loadModule(@NotNull VirtualFile file) { + return loadModule(file.getPath()); + } + protected Module loadModule(@NotNull String modulePath) { final ModuleManager moduleManager = ModuleManager.getInstance(myProject); Module module; try { - module = ApplicationManager.getApplication().runWriteAction((ThrowableComputable)() -> moduleManager.loadModule(normalizedPath)); + module = ApplicationManager.getApplication().runWriteAction((ThrowableComputable)() -> moduleManager.loadModule( + FileUtil.toSystemIndependentName(modulePath))); } catch (Exception e) { LOG.error(e); @@ -130,7 +132,7 @@ public abstract class ModuleTestCase extends IdeaTestCase { @Override public boolean visitFile(@NotNull VirtualFile file) { if (!file.isDirectory() && file.getName().endsWith(ModuleFileType.DOT_DEFAULT_EXTENSION)) { - ModuleImpl module = (ModuleImpl)loadModule(file.getPath()); + ModuleImpl module = (ModuleImpl)loadModule(file); if (moduleConsumer != null) { moduleConsumer.consume(module); } diff --git a/platform/projectModel-api/src/com/intellij/openapi/module/ModuleManager.java b/platform/projectModel-api/src/com/intellij/openapi/module/ModuleManager.java index 7ef52032a98a..0e25a83c0d61 100644 --- a/platform/projectModel-api/src/com/intellij/openapi/module/ModuleManager.java +++ b/platform/projectModel-api/src/com/intellij/openapi/module/ModuleManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,8 +64,7 @@ public abstract class ModuleManager extends SimpleModificationTracker { * @throws ModuleWithNameAlreadyExists if a module with such a name already exists in the project. */ @NotNull - public abstract Module loadModule(@NotNull String filePath) - throws InvalidDataException, IOException, JDOMException, ModuleWithNameAlreadyExists; + public abstract Module loadModule(@NotNull String filePath) throws IOException, JDOMException, ModuleWithNameAlreadyExists; /** * Disposes of the specified module and removes it from the project.