Search in sources :

Example 11 with ModuleOrderEntry

use of com.intellij.openapi.roots.ModuleOrderEntry in project intellij-community by JetBrains.

the class PyModuleDependenciesConfigurable method apply.

@Override
public void apply() throws ConfigurationException {
    ApplicationManager.getApplication().runWriteAction(() -> {
        ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel();
        List<ModuleOrderEntry> entries = new ArrayList<>();
        for (OrderEntry entry : model.getOrderEntries()) {
            if (entry instanceof ModuleOrderEntry) {
                entries.add((ModuleOrderEntry) entry);
            }
        }
        for (ModuleOrderEntry entry : entries) {
            model.removeOrderEntry(entry);
        }
        for (Module module : collectDependencies()) {
            model.addModuleOrderEntry(module);
        }
        model.commit();
    });
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) OrderEntry(com.intellij.openapi.roots.OrderEntry) ModuleOrderEntry(com.intellij.openapi.roots.ModuleOrderEntry) ArrayList(java.util.ArrayList) ModuleOrderEntry(com.intellij.openapi.roots.ModuleOrderEntry) Module(com.intellij.openapi.module.Module)

Aggregations

ModuleOrderEntry (com.intellij.openapi.roots.ModuleOrderEntry)11 Module (com.intellij.openapi.module.Module)8 OrderEntry (com.intellij.openapi.roots.OrderEntry)6 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)3 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)3 DependencySetupErrors (com.android.tools.idea.gradle.project.sync.setup.module.common.DependencySetupErrors)2 DependencyScope (com.intellij.openapi.roots.DependencyScope)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 ArrayList (java.util.ArrayList)2 LibraryDependency (com.android.tools.idea.gradle.project.sync.setup.module.dependency.LibraryDependency)1 RefManager (com.intellij.codeInspection.reference.RefManager)1 RefModule (com.intellij.codeInspection.reference.RefModule)1 ModuleData (com.intellij.openapi.externalSystem.model.project.ModuleData)1 ModuleDependencyData (com.intellij.openapi.externalSystem.model.project.ModuleDependencyData)1 OrderAware (com.intellij.openapi.externalSystem.model.project.OrderAware)1 ModuleRootManager (com.intellij.openapi.roots.ModuleRootManager)1 ModuleOrderEntryImpl (com.intellij.openapi.roots.impl.ModuleOrderEntryImpl)1 Pair (com.intellij.openapi.util.Pair)1 NotNull (org.jetbrains.annotations.NotNull)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1