Search in sources :

Example 41 with ModifiableRootModel

use of com.intellij.openapi.roots.ModifiableRootModel in project android by JetBrains.

the class JavaLanguageLevelModuleSetupStep method doSetUpModule.

@Override
protected void doSetUpModule(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider, @NotNull JavaModuleModel javaModuleModel, @Nullable SyncAction.ModuleModels gradleModels, @Nullable ProgressIndicator indicator) {
    LanguageLevel languageLevel = javaModuleModel.getJavaLanguageLevel();
    if (languageLevel == null) {
        // Java language is still not correct. Most likely this module does not have dependents.
        // Get minimum language level from all Android modules.
        languageLevel = getMinimumLanguageLevelForAndroidModules(ideModelsProvider);
    }
    if (languageLevel == null) {
        // The minimum safe Java language level.
        languageLevel = JDK_1_6;
    }
    ModifiableRootModel rootModel = ideModelsProvider.getModifiableRootModel(module);
    LanguageLevelModuleExtensionImpl moduleExtension = rootModel.getModuleExtension(LanguageLevelModuleExtensionImpl.class);
    moduleExtension.setLanguageLevel(languageLevel);
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) LanguageLevelModuleExtensionImpl(com.intellij.openapi.roots.LanguageLevelModuleExtensionImpl) LanguageLevel(com.intellij.pom.java.LanguageLevel)

Example 42 with ModifiableRootModel

use of com.intellij.openapi.roots.ModifiableRootModel in project android by JetBrains.

the class ContentRootModuleSetupStep method gradleModelNotFound.

@Override
protected void gradleModelNotFound(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider) {
    ModifiableRootModel moduleModel = ideModelsProvider.getModifiableRootModel(module);
    removeExistingContentEntries(moduleModel);
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel)

Example 43 with ModifiableRootModel

use of com.intellij.openapi.roots.ModifiableRootModel in project android by JetBrains.

the class DependenciesModuleSetupStepTest method createContentRoot.

private static void createContentRoot(@NotNull Module module) {
    VirtualFile moduleFolder = getModuleFolder(module);
    ModifiableRootModel modifiableRootModel = ModuleRootManager.getInstance(module).getModifiableModel();
    modifiableRootModel.addContentEntry(moduleFolder);
    ApplicationManager.getApplication().runWriteAction(modifiableRootModel::commit);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel)

Example 44 with ModifiableRootModel

use of com.intellij.openapi.roots.ModifiableRootModel in project android by JetBrains.

the class JavaLanguageLevelModuleSetupStepTest method verifyLanguageLevel.

private static void verifyLanguageLevel(@NotNull Module module, @NotNull LanguageLevel expected) {
    ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
    LanguageLevelModuleExtensionImpl moduleExtension = modifiableModel.getModuleExtension(LanguageLevelModuleExtensionImpl.class);
    try {
        assertEquals(expected, moduleExtension.getLanguageLevel());
    } finally {
        modifiableModel.dispose();
    }
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) LanguageLevelModuleExtensionImpl(com.intellij.openapi.roots.LanguageLevelModuleExtensionImpl)

Example 45 with ModifiableRootModel

use of com.intellij.openapi.roots.ModifiableRootModel in project android by JetBrains.

the class ProjectResourceRepositoryTest method addModuleDependency.

private static void addModuleDependency(Module from, Module to) {
    final ModifiableRootModel model = ModuleRootManager.getInstance(from).getModifiableModel();
    model.addModuleOrderEntry(to);
    ApplicationManager.getApplication().runWriteAction(model::commit);
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel)

Aggregations

ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)102 Module (com.intellij.openapi.module.Module)44 VirtualFile (com.intellij.openapi.vfs.VirtualFile)29 ContentEntry (com.intellij.openapi.roots.ContentEntry)27 File (java.io.File)18 Library (com.intellij.openapi.roots.libraries.Library)15 ModuleRootManager (com.intellij.openapi.roots.ModuleRootManager)14 ModuleManager (com.intellij.openapi.module.ModuleManager)8 Sdk (com.intellij.openapi.projectRoots.Sdk)8 IOException (java.io.IOException)8 NotNull (org.jetbrains.annotations.NotNull)8 OrderEntry (com.intellij.openapi.roots.OrderEntry)7 Project (com.intellij.openapi.project.Project)6 LibraryTable (com.intellij.openapi.roots.libraries.LibraryTable)6 Nullable (org.jetbrains.annotations.Nullable)6 ModifiableModuleModel (com.intellij.openapi.module.ModifiableModuleModel)5 ConfigurationException (com.intellij.openapi.options.ConfigurationException)5 THashMap (gnu.trove.THashMap)5 FlexProjectConfigurationEditor (com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor)4 AccessToken (com.intellij.openapi.application.AccessToken)4