diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java index 1920f1c0c7ee..25157244abb3 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java @@ -16,7 +16,6 @@ import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.ModuleConfigurableEP; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.*; -import com.intellij.openapi.roots.impl.ModuleRootManagerImpl; import com.intellij.openapi.roots.impl.libraries.LibraryEx; import com.intellij.openapi.roots.impl.libraries.LibraryTableBase; import com.intellij.openapi.roots.libraries.Library; @@ -128,7 +127,7 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable { if (myModifiableRootModel == null) { final Module module = getModule(); if (module != null) { - myModifiableRootModel = ((ModuleRootManagerImpl)ModuleRootManager.getInstance(module)).getModifiableModel(new UIRootConfigurationAccessor(myProject)); + myModifiableRootModel = ModuleRootManagerEx.getInstanceEx(module).getModifiableModel(new UIRootConfigurationAccessor(myProject)); } } return myModifiableRootModel; diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/ModuleRootManagerEx.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/ModuleRootManagerEx.java new file mode 100644 index 000000000000..34fec42e6285 --- /dev/null +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/ModuleRootManagerEx.java @@ -0,0 +1,16 @@ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package com.intellij.openapi.roots; + +import com.intellij.openapi.module.Module; +import com.intellij.openapi.roots.impl.RootConfigurationAccessor; +import org.jetbrains.annotations.NotNull; + +public abstract class ModuleRootManagerEx extends ModuleRootManager { + + @NotNull + public abstract ModifiableRootModel getModifiableModel(@NotNull RootConfigurationAccessor accessor); + + public static ModuleRootManagerEx getInstanceEx(@NotNull Module module) { + return (ModuleRootManagerEx) module.getComponent(ModuleRootManager.class); + } +} diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleRootManagerImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleRootManagerImpl.java index d71cce3c51ca..98aa40abce24 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleRootManagerImpl.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleRootManagerImpl.java @@ -32,7 +32,7 @@ import org.jetbrains.jps.model.module.JpsModuleSourceRootType; import java.util.*; -public class ModuleRootManagerImpl extends ModuleRootManager implements Disposable { +public class ModuleRootManagerImpl extends ModuleRootManagerEx implements Disposable { protected static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.impl.ModuleRootManagerImpl"); private final Module myModule; @@ -96,6 +96,7 @@ public class ModuleRootManagerImpl extends ModuleRootManager implements Disposab return getModifiableModel(new RootConfigurationAccessor()); } + @Override @NotNull public ModifiableRootModel getModifiableModel(@NotNull RootConfigurationAccessor accessor) { ApplicationManager.getApplication().assertReadAccessAllowed();