Search in sources :

Example 1 with JavaLanguageLevelPusher

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

the class HighlightUtil method getUnsupportedFeatureMessage.

private static String getUnsupportedFeatureMessage(PsiElement element, Feature feature, LanguageLevel level, PsiFile file) {
    String name = JavaErrorMessages.message(feature.key);
    String message = JavaErrorMessages.message("insufficient.language.level", name, level.getCompilerComplianceDefaultOption());
    Module module = ModuleUtilCore.findModuleForPsiElement(element);
    if (module != null) {
        LanguageLevel moduleLanguageLevel = EffectiveLanguageLevelUtil.getEffectiveLanguageLevel(module);
        if (moduleLanguageLevel.isAtLeast(feature.level)) {
            for (FilePropertyPusher pusher : FilePropertyPusher.EP_NAME.getExtensions()) {
                if (pusher instanceof JavaLanguageLevelPusher) {
                    String newMessage = ((JavaLanguageLevelPusher) pusher).getInconsistencyLanguageLevelMessage(message, element, level, file);
                    if (newMessage != null) {
                        return newMessage;
                    }
                }
            }
        }
    }
    return message;
}
Also used : LanguageLevel(com.intellij.pom.java.LanguageLevel) FilePropertyPusher(com.intellij.openapi.roots.impl.FilePropertyPusher) JavaLanguageLevelPusher(com.intellij.openapi.roots.impl.JavaLanguageLevelPusher) Module(com.intellij.openapi.module.Module)

Aggregations

Module (com.intellij.openapi.module.Module)1 FilePropertyPusher (com.intellij.openapi.roots.impl.FilePropertyPusher)1 JavaLanguageLevelPusher (com.intellij.openapi.roots.impl.JavaLanguageLevelPusher)1 LanguageLevel (com.intellij.pom.java.LanguageLevel)1