use of com.intellij.pom.java.LanguageLevel in project intellij-community by JetBrains.
the class IntroduceParameterObjectTest method testTypeParametersWithSubstitution.
public void testTypeParametersWithSubstitution() throws Exception {
final LanguageLevelProjectExtension projectExtension = LanguageLevelProjectExtension.getInstance(getProject());
final LanguageLevel oldLevel = projectExtension.getLanguageLevel();
try {
projectExtension.setLanguageLevel(LanguageLevel.HIGHEST);
doTest();
} finally {
projectExtension.setLanguageLevel(oldLevel);
}
}
use of com.intellij.pom.java.LanguageLevel in project intellij-community by JetBrains.
the class MoveMembersTest method testFromNestedToOuterMethodRef.
public void testFromNestedToOuterMethodRef() throws Exception {
final LanguageLevelProjectExtension projectExtension = LanguageLevelProjectExtension.getInstance(getProject());
final LanguageLevel oldLevel = projectExtension.getLanguageLevel();
try {
projectExtension.setLanguageLevel(LanguageLevel.HIGHEST);
doTest("Outer.Inner", "Outer", true, VisibilityUtil.ESCALATE_VISIBILITY, 0);
} finally {
projectExtension.setLanguageLevel(oldLevel);
}
}
use of com.intellij.pom.java.LanguageLevel in project intellij-community by JetBrains.
the class MoveMembersTest method testStaticToInterface.
public void testStaticToInterface() throws Exception {
final LanguageLevelProjectExtension levelProjectExtension = LanguageLevelProjectExtension.getInstance(getProject());
final LanguageLevel level = levelProjectExtension.getLanguageLevel();
try {
levelProjectExtension.setLanguageLevel(LanguageLevel.JDK_1_8);
doTest("A", "B", 0);
} finally {
levelProjectExtension.setLanguageLevel(level);
}
}
use of com.intellij.pom.java.LanguageLevel in project intellij-community by JetBrains.
the class HighlightUtil method checkSwitchSelectorType.
@Nullable
static HighlightInfo checkSwitchSelectorType(@NotNull PsiSwitchStatement statement, @NotNull LanguageLevel level) {
PsiExpression expression = statement.getExpression();
if (expression == null)
return null;
PsiType type = expression.getType();
if (type == null)
return null;
SelectorKind kind = getSwitchSelectorKind(type);
if (kind == SelectorKind.INT)
return null;
LanguageLevel requiredLevel = null;
if (kind == SelectorKind.ENUM)
requiredLevel = LanguageLevel.JDK_1_5;
if (kind == SelectorKind.STRING)
requiredLevel = LanguageLevel.JDK_1_7;
if (kind == null || requiredLevel != null && !level.isAtLeast(requiredLevel)) {
boolean is7 = level.isAtLeast(LanguageLevel.JDK_1_7);
String expected = JavaErrorMessages.message(is7 ? "valid.switch.17.selector.types" : "valid.switch.selector.types");
String message = JavaErrorMessages.message("incompatible.types", expected, JavaHighlightUtil.formatType(type));
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createConvertSwitchToIfIntention(statement));
if (PsiType.LONG.equals(type) || PsiType.FLOAT.equals(type) || PsiType.DOUBLE.equals(type)) {
QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createAddTypeCastFix(PsiType.INT, expression));
QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createWrapLongWithMathToIntExactFix(PsiType.INT, expression));
}
if (requiredLevel != null) {
QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createIncreaseLanguageLevelFix(requiredLevel));
}
return info;
}
PsiClass member = PsiUtil.resolveClassInClassTypeOnly(type);
if (member != null && !PsiUtil.isAccessible(member.getProject(), member, expression, null)) {
String className = PsiFormatUtil.formatClass(member, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_FQ_NAME);
String message = JavaErrorMessages.message("inaccessible.type", className);
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
return null;
}
use of com.intellij.pom.java.LanguageLevel 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;
}
Aggregations