mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
pass explanations from language level pushers for more places (IDEA-163152)
This commit is contained in:
+8
-4
@@ -360,9 +360,10 @@ public class HighlightMethodUtil {
|
||||
TextRange fixRange = getFixRange(methodCall);
|
||||
highlightInfo = HighlightUtil.checkUnhandledExceptions(methodCall, fixRange);
|
||||
if (highlightInfo == null) {
|
||||
final String invalidCallMessage =
|
||||
String invalidCallMessage =
|
||||
LambdaUtil.getInvalidQualifier4StaticInterfaceMethodMessage((PsiMethod)resolved, methodCall.getMethodExpression(), resolveResult.getCurrentFileResolveScope(), languageLevel);
|
||||
if (invalidCallMessage != null) {
|
||||
invalidCallMessage = HighlightUtil.extendUnsupportedLanguageLevelDescription(invalidCallMessage, methodCall, languageLevel, methodCall.getContainingFile(), LanguageLevel.JDK_1_8);
|
||||
highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).descriptionAndTooltip(invalidCallMessage).range(fixRange).create();
|
||||
if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_8)) {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createIncreaseLanguageLevelFix(LanguageLevel.JDK_1_8));
|
||||
@@ -589,9 +590,12 @@ public class HighlightMethodUtil {
|
||||
? LambdaUtil.getInvalidQualifier4StaticInterfaceMethodMessage((PsiMethod)element, referenceToMethod,
|
||||
resolveResult.getCurrentFileResolveScope(), languageLevel)
|
||||
: null;
|
||||
description = staticInterfaceMethodMessage != null
|
||||
? staticInterfaceMethodMessage
|
||||
: HighlightUtil.buildProblemWithStaticDescription(element);
|
||||
if (staticInterfaceMethodMessage != null) {
|
||||
description = HighlightUtil.extendUnsupportedLanguageLevelDescription(staticInterfaceMethodMessage, methodCall, languageLevel, referenceToMethod.getContainingFile(), LanguageLevel.JDK_1_8);
|
||||
}
|
||||
else {
|
||||
description = HighlightUtil.buildProblemWithStaticDescription(element);
|
||||
}
|
||||
elementToHighlight = referenceToMethod.getReferenceNameElement();
|
||||
}
|
||||
else {
|
||||
|
||||
+25
-16
@@ -358,9 +358,10 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String description = extendUnsupportedLanguageLevelDescription("Intersection types in cast are not supported at this language level", expression, languageLevel, expression.getContainingFile(), LanguageLevel.JDK_1_8);
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
|
||||
.range(expression)
|
||||
.descriptionAndTooltip("Intersection types in cast are not supported at this language level").create();
|
||||
.descriptionAndTooltip(description).create();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -3000,21 +3001,7 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
if (file.getManager().isInProject(file) && !level.isAtLeast(feature.level)) {
|
||||
String message = JavaErrorMessages.message("insufficient.language.level", JavaErrorMessages.message(feature.key));
|
||||
|
||||
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) {
|
||||
message = newMessage;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
message = extendUnsupportedLanguageLevelDescription(message, element, level, file, feature.level);
|
||||
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(message).create();
|
||||
QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createIncreaseLanguageLevelFix(feature.level));
|
||||
QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createShowModulePropertiesFix(element));
|
||||
@@ -3023,4 +3010,26 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static String extendUnsupportedLanguageLevelDescription(@NotNull String message,
|
||||
@NotNull PsiElement element,
|
||||
@NotNull LanguageLevel fileLanguageLevel,
|
||||
@NotNull PsiFile file,
|
||||
@NotNull LanguageLevel featureLevel) {
|
||||
Module module = ModuleUtilCore.findModuleForPsiElement(element);
|
||||
if (module != null) {
|
||||
LanguageLevel moduleLanguageLevel = EffectiveLanguageLevelUtil.getEffectiveLanguageLevel(module);
|
||||
if (moduleLanguageLevel.isAtLeast(featureLevel)) {
|
||||
for (FilePropertyPusher pusher : FilePropertyPusher.EP_NAME.getExtensions()) {
|
||||
if (pusher instanceof JavaLanguageLevelPusher) {
|
||||
String newMessage = ((JavaLanguageLevelPusher)pusher).getInconsistencyLanguageLevelMessage(message, element, fileLanguageLevel, file);
|
||||
if (newMessage != null) {
|
||||
return newMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user