Search in sources :

Example 26 with LanguageLevelProjectExtension

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

the class LanguageLevelCombo method reset.

public void reset(@NotNull Project project) {
    removeAllItems();
    for (LanguageLevel level : LanguageLevel.values()) {
        addItem(level);
    }
    Sdk sdk = ProjectRootManagerEx.getInstanceEx(project).getProjectSdk();
    sdkUpdated(sdk, project.isDefault());
    LanguageLevelProjectExtension extension = LanguageLevelProjectExtension.getInstance(project);
    if (extension.isDefault()) {
        setSelectedItem(myDefaultItem);
    } else {
        setSelectedItem(extension.getLanguageLevel());
    }
}
Also used : LanguageLevel(com.intellij.pom.java.LanguageLevel) JavaSdk(com.intellij.openapi.projectRoots.JavaSdk) Sdk(com.intellij.openapi.projectRoots.Sdk) LanguageLevelProjectExtension(com.intellij.openapi.roots.LanguageLevelProjectExtension)

Example 27 with LanguageLevelProjectExtension

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

the class GradleProjectImportBuilder 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;
    }
    final LanguageLevel externalLanguageLevel = javaProjectNode.getData().getLanguageLevel();
    final 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)

Example 28 with LanguageLevelProjectExtension

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

the class UnnecessaryReturnInspectionTest method test.

public void test() throws Exception {
    final UnnecessaryReturnInspection inspection = new UnnecessaryReturnInspection();
    inspection.ignoreInThenBranch = true;
    final LanguageLevelProjectExtension levelProjectExtension = LanguageLevelProjectExtension.getInstance(getProject());
    final LanguageLevel level = levelProjectExtension.getLanguageLevel();
    try {
        levelProjectExtension.setLanguageLevel(LanguageLevel.JDK_1_8);
        doTest("com/siyeh/igtest/controlflow/unnecessary_return", new LocalInspectionToolWrapper(inspection), "java 1.8");
    } finally {
        levelProjectExtension.setLanguageLevel(level);
    }
}
Also used : LanguageLevel(com.intellij.pom.java.LanguageLevel) LanguageLevelProjectExtension(com.intellij.openapi.roots.LanguageLevelProjectExtension) LocalInspectionToolWrapper(com.intellij.codeInspection.ex.LocalInspectionToolWrapper)

Example 29 with LanguageLevelProjectExtension

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

the class CompletionStyleTest method testAfterNew15.

public void testAfterNew15() throws Exception {
    final LanguageLevelProjectExtension ll = LanguageLevelProjectExtension.getInstance(getProject());
    final LanguageLevel old = ll.getLanguageLevel();
    ll.setLanguageLevel(LanguageLevel.JDK_1_5);
    try {
        final String path = BASE_PATH;
        configureByFile(path + "/AfterNew15.java");
        performSmartCompletion();
        select('\n', getSelected());
        checkResultByFile(path + "/AfterNew15-out.java");
    } finally {
        ll.setLanguageLevel(old);
    }
}
Also used : LanguageLevel(com.intellij.pom.java.LanguageLevel) LanguageLevelProjectExtension(com.intellij.openapi.roots.LanguageLevelProjectExtension)

Example 30 with LanguageLevelProjectExtension

use of com.intellij.openapi.roots.LanguageLevelProjectExtension in project intellij by bazelbuild.

the class BlazeAndroidSyncPlugin method setProjectSdkAndLanguageLevel.

private static void setProjectSdkAndLanguageLevel(final Project project, final Sdk sdk, final LanguageLevel javaLanguageLevel) {
    UIUtil.invokeAndWaitIfNeeded((Runnable) () -> ApplicationManager.getApplication().runWriteAction(() -> {
        ProjectRootManagerEx rootManager = ProjectRootManagerEx.getInstanceEx(project);
        rootManager.setProjectSdk(sdk);
        LanguageLevelProjectExtension ext = LanguageLevelProjectExtension.getInstance(project);
        ext.setLanguageLevel(javaLanguageLevel);
    }));
}
Also used : ProjectRootManagerEx(com.intellij.openapi.roots.ex.ProjectRootManagerEx) 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