mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
allow inspections to report INFORMATION level problems when normal problems are configured, e.g. for special cases where highlighting is not needed but intention could be handy
This commit is contained in:
+10
-2
@@ -96,12 +96,20 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection
|
||||
final PsiElement lambdaContext = parent != null ? parent.getParent() : null;
|
||||
if (lambdaContext != null &&
|
||||
(LambdaUtil.isValidLambdaContext(lambdaContext) || !(lambdaContext instanceof PsiExpressionStatement)) &&
|
||||
canBeConvertedToLambda(aClass, false, reportNotAnnotatedInterfaces, Collections.emptySet())) {
|
||||
canBeConvertedToLambda(aClass, false, isOnTheFly || reportNotAnnotatedInterfaces, Collections.emptySet())) {
|
||||
final PsiElement lBrace = aClass.getLBrace();
|
||||
LOG.assertTrue(lBrace != null);
|
||||
final TextRange rangeInElement = new TextRange(0, aClass.getStartOffsetInParent() + lBrace.getStartOffsetInParent());
|
||||
ProblemHighlightType problemHighlightType = ProblemHighlightType.LIKE_UNUSED_SYMBOL;
|
||||
if (isOnTheFly && !reportNotAnnotatedInterfaces) {
|
||||
final PsiClass baseClass = aClass.getBaseClassType().resolve();
|
||||
LOG.assertTrue(baseClass != null);
|
||||
if (!AnnotationUtil.isAnnotated(baseClass, CommonClassNames.JAVA_LANG_FUNCTIONAL_INTERFACE, false, false)) {
|
||||
problemHighlightType = ProblemHighlightType.INFORMATION;
|
||||
}
|
||||
}
|
||||
holder.registerProblem(parent, "Anonymous #ref #loc can be replaced with lambda",
|
||||
ProblemHighlightType.LIKE_UNUSED_SYMBOL, rangeInElement, new ReplaceWithLambdaFix());
|
||||
problemHighlightType, rangeInElement, new ReplaceWithLambdaFix());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+6
-3
@@ -29,11 +29,14 @@ public class HighlightInfoFilterImpl implements HighlightInfoFilter {
|
||||
|
||||
@Override
|
||||
public boolean accept(@NotNull HighlightInfo info, PsiFile file) {
|
||||
if (Holder.ourTestMode) return true; // Tests need to verify highlighting is applied no matter what attributes are defined for this kind of highlighting
|
||||
if (Holder.ourTestMode) {
|
||||
return true; // Tests need to verify highlighting is applied no matter what attributes are defined for this kind of highlighting
|
||||
}
|
||||
|
||||
TextAttributes attributes = info.getTextAttributes(file, null);
|
||||
// optimization
|
||||
return attributes == TextAttributes.ERASE_MARKER || attributes != null &&
|
||||
!(attributes.isEmpty() && info.getSeverity() == HighlightSeverity.INFORMATION && info.getGutterIconRenderer() == null);
|
||||
return attributes == TextAttributes.ERASE_MARKER ||
|
||||
attributes != null &&
|
||||
!(attributes.isEmpty() && info.getSeverity() == HighlightSeverity.INFORMATION && info.getGutterIconRenderer() == null && info.getToolTip() == null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user