LanguageLevel (@NotNull PsiFile file, @NotNull HighlightingFeature feature) { LanguageLevel standardLevel = feature.getStandardLevel(); if (feature.level.isPreview()) { JavaSdkVersion sdkVersion = JavaSdkVersionUtil.getJavaSdkVersion(file); if (sdkVersion != null) { if (standardLevel != null && sdkVersion.isAtLeast(JavaSdkVersion.fromLanguageLevel(standardLevel))) { return standardLevel; } LanguageLevel previewLevel = sdkVersion.getMaxLanguageLevel().getPreviewLevel(); if (previewLevel != null && previewLevel.isAtLeast(feature.level)) { return previewLevel; } } } return feature.level; }