Skip to content

Commit

Permalink
Java: enable preview features by default when setting the language le…
Browse files Browse the repository at this point in the history
…vel to X - Experimental features (IDEA-325463)

GitOrigin-RevId: 2237198742b7561e99de39bad6291304ad1b183e
  • Loading branch information
BasLeijdekkers authored and intellij-monorepo-bot committed Jul 19, 2023
1 parent 76efbe8 commit 89a73e9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.pom.java;

import com.intellij.ide.IdeBundle;
Expand Down Expand Up @@ -89,6 +89,7 @@ private static void applyUnnacceptedLevels(@NotNull Project project,
}
if (!previewLevels.isEmpty() && !PropertiesComponent.getInstance(project).getBoolean(IGNORE_USED_PREVIEW_FEATURES, false)) {
LanguageLevel languageLevel = previewLevels.first();
if (languageLevel == LanguageLevel.JDK_X) return;
int previewFeature = languageLevel.toJavaVersion().feature;
PREVIEW_NOTIFICATION_GROUP.createNotification(
JavaBundle.message("java.preview.features.notification.title"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public enum LanguageLevel {
LanguageLevel(Supplier<@Nls String> presentableTextSupplier, int major) {
myPresentableText = presentableTextSupplier;
myVersion = JavaVersion.compose(major);
myPreview = name().endsWith("_PREVIEW");
myPreview = name().endsWith("_PREVIEW") || name().endsWith("_X");
}

public boolean isPreview() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.java.openapi.projectRoots;

import com.intellij.openapi.projectRoots.JavaSdkVersion;
Expand All @@ -21,7 +21,8 @@ public void sdkVersionFromLanguageLevel() {
@Test
public void maxLanguageLevelSanity() {
for (JavaSdkVersion version : JavaSdkVersion.values()) {
assertFalse("Fails for " + version.toString(), version.getMaxLanguageLevel().isPreview());
LanguageLevel languageLevel = version.getMaxLanguageLevel();
assertFalse("Fails for " + version, languageLevel.isPreview() && languageLevel != LanguageLevel.JDK_X);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ public JavaVersion toJavaVersion() {
}

public boolean isPreview() {
return name().endsWith("_PREVIEW");
return name().endsWith("_PREVIEW") || name().endsWith("_X");
}
}

0 comments on commit 89a73e9

Please sign in to comment.