use of com.intellij.openapi.roots.LanguageLevelProjectExtension in project intellij-community by JetBrains.
the class TypeCookTest method testConvertToDiamond.
public void testConvertToDiamond() throws Exception {
final LanguageLevelProjectExtension levelProjectExtension = LanguageLevelProjectExtension.getInstance(getProject());
final LanguageLevel oldLevel = levelProjectExtension.getLanguageLevel();
try {
levelProjectExtension.setLanguageLevel(LanguageLevel.JDK_1_8);
start();
} finally {
levelProjectExtension.setLanguageLevel(oldLevel);
}
}
use of com.intellij.openapi.roots.LanguageLevelProjectExtension in project intellij-community by JetBrains.
the class KeywordCompletionTest method testPrivateInJava9Interface.
public void testPrivateInJava9Interface() throws Exception {
LanguageLevelProjectExtension levelProjectExtension = LanguageLevelProjectExtension.getInstance(getProject());
LanguageLevel oldLevel = levelProjectExtension.getLanguageLevel();
try {
levelProjectExtension.setLanguageLevel(LanguageLevel.JDK_1_9);
doTest(false);
} finally {
levelProjectExtension.setLanguageLevel(oldLevel);
}
}
use of com.intellij.openapi.roots.LanguageLevelProjectExtension in project intellij-community by JetBrains.
the class NewProjectUtil method applyJdkToProject.
public static void applyJdkToProject(@NotNull Project project, @NotNull Sdk jdk) {
ProjectRootManagerEx rootManager = ProjectRootManagerEx.getInstanceEx(project);
rootManager.setProjectSdk(jdk);
JavaSdkVersion version = JavaSdk.getInstance().getVersion(jdk);
if (version != null) {
LanguageLevel maxLevel = version.getMaxLanguageLevel();
LanguageLevelProjectExtension extension = LanguageLevelProjectExtension.getInstance(ProjectManager.getInstance().getDefaultProject());
LanguageLevelProjectExtension ext = LanguageLevelProjectExtension.getInstance(project);
if (extension.isDefault() || maxLevel.compareTo(ext.getLanguageLevel()) < 0) {
ext.setLanguageLevel(maxLevel);
}
}
}
use of com.intellij.openapi.roots.LanguageLevelProjectExtension in project intellij-community by JetBrains.
the class JavaProjectDataService method updateSdk.
private static void updateSdk(@NotNull final Project project, @NotNull final JavaSdkVersion version) {
final Sdk sdk = findJdk(version);
if (sdk == null)
return;
ExternalSystemApiUtil.executeProjectChangeAction(new DisposeAwareProjectChange(project) {
@Override
public void execute() {
ProjectRootManager.getInstance(project).setProjectSdk(sdk);
LanguageLevel level = version.getMaxLanguageLevel();
LanguageLevelProjectExtension languageLevelExtension = LanguageLevelProjectExtension.getInstance(project);
if (level.compareTo(languageLevelExtension.getLanguageLevel()) < 0) {
languageLevelExtension.setLanguageLevel(level);
}
}
});
}
use of com.intellij.openapi.roots.LanguageLevelProjectExtension in project intellij-community by JetBrains.
the class JavaProjectDataService method setLanguageLevel.
@SuppressWarnings("MethodMayBeStatic")
public void setLanguageLevel(@NotNull final LanguageLevel languageLevel, @NotNull Project project) {
final LanguageLevelProjectExtension languageLevelExtension = LanguageLevelProjectExtension.getInstance(project);
if (languageLevelExtension.getLanguageLevel().isAtLeast(languageLevel)) {
return;
}
ExternalSystemApiUtil.executeProjectChangeAction(new DisposeAwareProjectChange(project) {
@Override
public void execute() {
languageLevelExtension.setLanguageLevel(languageLevel);
}
});
}
Aggregations