Search in sources :

Example 16 with LanguageLevelProjectExtension

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

the class CreateSwitchTest method doTestString.

private void doTestString() {
    final LanguageLevelProjectExtension languageLevelProjectExtension = LanguageLevelProjectExtension.getInstance(getProject());
    final LanguageLevel oldLanguageLevel = languageLevelProjectExtension.getLanguageLevel();
    languageLevelProjectExtension.setLanguageLevel(LanguageLevel.JDK_1_7);
    try {
        doTest();
    } finally {
        languageLevelProjectExtension.setLanguageLevel(oldLanguageLevel);
    }
}
Also used : LanguageLevel(com.intellij.pom.java.LanguageLevel) LanguageLevelProjectExtension(com.intellij.openapi.roots.LanguageLevelProjectExtension)

Example 17 with LanguageLevelProjectExtension

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

the class LambdaPostfixTemplateTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    LanguageLevelProjectExtension levelProjectExtension = LanguageLevelProjectExtension.getInstance(myFixture.getProject());
    myDefaultLanguageLevel = levelProjectExtension.getLanguageLevel();
    levelProjectExtension.setLanguageLevel(LanguageLevel.JDK_1_8);
}
Also used : LanguageLevelProjectExtension(com.intellij.openapi.roots.LanguageLevelProjectExtension)

Example 18 with LanguageLevelProjectExtension

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

the class NewProjectTest method testLanguageLevelForApi21.

@Test
public void testLanguageLevelForApi21() {
    newProject("Test Application").withBriefNames().withMinSdk("21").create();
    AndroidModuleModel appAndroidModel = guiTest.ideFrame().getAndroidProjectForModule("app");
    assertThat(appAndroidModel.getAndroidProject().getDefaultConfig().getProductFlavor().getMinSdkVersion().getApiString()).named("minSdkVersion API").isEqualTo("21");
    assertThat(appAndroidModel.getJavaLanguageLevel()).named("Gradle Java language level").isSameAs(LanguageLevel.JDK_1_7);
    LanguageLevelProjectExtension projectExt = LanguageLevelProjectExtension.getInstance(guiTest.ideFrame().getProject());
    assertThat(projectExt.getLanguageLevel()).named("Project Java language level").isSameAs(LanguageLevel.JDK_1_7);
    for (Module module : ModuleManager.getInstance(guiTest.ideFrame().getProject()).getModules()) {
        LanguageLevelModuleExtension moduleExt = LanguageLevelModuleExtensionImpl.getInstance(module);
        assertThat(moduleExt.getLanguageLevel()).named("Gradle Java language level in module " + module.getName()).isSameAs(LanguageLevel.JDK_1_7);
    }
}
Also used : AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) LanguageLevelProjectExtension(com.intellij.openapi.roots.LanguageLevelProjectExtension) Module(com.intellij.openapi.module.Module) LanguageLevelModuleExtension(com.intellij.openapi.roots.LanguageLevelModuleExtension) Test(org.junit.Test)

Example 19 with LanguageLevelProjectExtension

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

the class PostProjectBuildTasksExecutor method syncJavaLangLevel.

private void syncJavaLangLevel() {
    Boolean updateJavaLangLevel = myProject.getUserData(UPDATE_JAVA_LANG_LEVEL_AFTER_BUILD);
    if (updateJavaLangLevel == null || !updateJavaLangLevel.booleanValue()) {
        return;
    }
    myProject.putUserData(UPDATE_JAVA_LANG_LEVEL_AFTER_BUILD, null);
    executeProjectChangeAction(true, new DisposeAwareProjectChange(myProject) {

        @Override
        public void execute() {
            if (myProject.isOpen()) {
                //noinspection TestOnlyProblems
                LanguageLevel langLevel = getMaxJavaLangLevel();
                if (langLevel != null) {
                    LanguageLevelProjectExtension ext = LanguageLevelProjectExtension.getInstance(myProject);
                    if (langLevel != ext.getLanguageLevel()) {
                        ext.setLanguageLevel(langLevel);
                    }
                }
            }
        }
    });
}
Also used : DisposeAwareProjectChange(com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange) LanguageLevel(com.intellij.pom.java.LanguageLevel) LanguageLevelProjectExtension(com.intellij.openapi.roots.LanguageLevelProjectExtension)

Example 20 with LanguageLevelProjectExtension

use of com.intellij.openapi.roots.LanguageLevelProjectExtension in project liferay-ide by liferay.

the class LiferayGradleProjectImportBuilder method beforeCommit.

@Override
protected void beforeCommit(@NotNull DataNode<ProjectData> dataNode, @NotNull Project project) {
    DataNode<JavaProjectData> javaProjectNode = ExternalSystemApiUtil.find(dataNode, JavaProjectData.KEY);
    if (javaProjectNode == null) {
        return;
    }
    JavaProjectData javaProjectData = javaProjectNode.getData();
    LanguageLevel externalLanguageLevel = javaProjectData.getLanguageLevel();
    LanguageLevelProjectExtension languageLevelExtension = LanguageLevelProjectExtension.getInstance(project);
    if (externalLanguageLevel != languageLevelExtension.getLanguageLevel()) {
        languageLevelExtension.setLanguageLevel(externalLanguageLevel);
    }
}
Also used : LanguageLevel(com.intellij.pom.java.LanguageLevel) JavaProjectData(com.intellij.externalSystem.JavaProjectData) LanguageLevelProjectExtension(com.intellij.openapi.roots.LanguageLevelProjectExtension)

Aggregations

LanguageLevelProjectExtension (com.intellij.openapi.roots.LanguageLevelProjectExtension)31 LanguageLevel (com.intellij.pom.java.LanguageLevel)23 LocalInspectionToolWrapper (com.intellij.codeInspection.ex.LocalInspectionToolWrapper)3 DisposeAwareProjectChange (com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange)3 ProjectRootManagerEx (com.intellij.openapi.roots.ex.ProjectRootManagerEx)3 JavaProjectData (com.intellij.externalSystem.JavaProjectData)2 Module (com.intellij.openapi.module.Module)2 JavaSdk (com.intellij.openapi.projectRoots.JavaSdk)2 Sdk (com.intellij.openapi.projectRoots.Sdk)2 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 ProjectEx (com.intellij.openapi.project.ex.ProjectEx)1 JavaSdkVersion (com.intellij.openapi.projectRoots.JavaSdkVersion)1 CompilerProjectExtension (com.intellij.openapi.roots.CompilerProjectExtension)1 LanguageLevelModuleExtension (com.intellij.openapi.roots.LanguageLevelModuleExtension)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 JavaModuleFixtureBuilder (com.intellij.testFramework.builders.JavaModuleFixtureBuilder)1 IdeaProjectTestFixture (com.intellij.testFramework.fixtures.IdeaProjectTestFixture)1 File (java.io.File)1 IOException (java.io.IOException)1