Search in sources :

Example 1 with LanguageLevelModuleExtensionImpl

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

the class IdeaTestUtil method setModuleLanguageLevel.

public static void setModuleLanguageLevel(Module module, final LanguageLevel level) {
    final LanguageLevelModuleExtensionImpl modifiable = (LanguageLevelModuleExtensionImpl) LanguageLevelModuleExtensionImpl.getInstance(module).getModifiableModel(true);
    modifiable.setLanguageLevel(level);
    modifiable.commit();
}
Also used : LanguageLevelModuleExtensionImpl(com.intellij.openapi.roots.LanguageLevelModuleExtensionImpl)

Example 2 with LanguageLevelModuleExtensionImpl

use of com.intellij.openapi.roots.LanguageLevelModuleExtensionImpl 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 3 with LanguageLevelModuleExtensionImpl

use of com.intellij.openapi.roots.LanguageLevelModuleExtensionImpl 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 4 with LanguageLevelModuleExtensionImpl

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

the class JavaLanguageLevelModuleSetupStepTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    initMocks(this);
    mySetupStep = new JavaLanguageLevelModuleSetupStep();
    // Set the module's Java language level to 1.5 to check it changed.
    Module module = getModule();
    ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
    LanguageLevelModuleExtensionImpl moduleExtension = modifiableModel.getModuleExtension(LanguageLevelModuleExtensionImpl.class);
    moduleExtension.setLanguageLevel(JDK_1_5);
    ApplicationManager.getApplication().runWriteAction(modifiableModel::commit);
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) LanguageLevelModuleExtensionImpl(com.intellij.openapi.roots.LanguageLevelModuleExtensionImpl) Module(com.intellij.openapi.module.Module)

Aggregations

LanguageLevelModuleExtensionImpl (com.intellij.openapi.roots.LanguageLevelModuleExtensionImpl)4 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)3 Module (com.intellij.openapi.module.Module)1 LanguageLevel (com.intellij.pom.java.LanguageLevel)1