mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-17 07:20:53 +07:00
[java-inspections] IDEA-346242 Add 'minimal java version' clause automatically to inspection descriptions, based on the required feature(s)
GitOrigin-RevId: 50a25148d4d36c46e9552b3123d1ef966b40a2c2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a028674bdb
commit
64327f79d6
@@ -622,3 +622,4 @@ intention.family.name.move.members.into.class=Move members into class
|
||||
chooser.popup.title.select.class.to.move.members.to=Select Target Class
|
||||
intention.family.name.move.members.to=Move members to {0}
|
||||
inspection.name.can.be.replaced.with.long.hashcode=Standard 'hashCode()' method can be used
|
||||
inspection.depends.on.the.java.feature=This inspection depends on the Java feature ''{0}'' which is available since Java {1}.
|
||||
|
||||
@@ -1,12 +1,47 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.java.analysis.JavaAnalysisBundle;
|
||||
import com.intellij.openapi.util.text.HtmlChunk;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class AbstractBaseJavaLocalInspectionTool extends LocalInspectionTool {
|
||||
|
||||
/**
|
||||
* @return set of the features required for a given inspection. The inspection will not be launched on the files where
|
||||
* the corresponding features are not available.
|
||||
*/
|
||||
public @NotNull Set<@NotNull JavaFeature> requiredFeatures() {
|
||||
return Set.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailableForFile(@NotNull PsiFile file) {
|
||||
for (JavaFeature feature : requiredFeatures()) {
|
||||
if (!PsiUtil.isAvailable(feature, file)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HtmlChunk getDescriptionAddendum() {
|
||||
Set<JavaFeature> features = requiredFeatures();
|
||||
JavaFeature feature = ContainerUtil.getOnlyItem(features);
|
||||
if (feature != null) {
|
||||
return HtmlChunk.text(JavaAnalysisBundle.message("inspection.depends.on.the.java.feature",
|
||||
feature.getFeatureName(), feature.getMinimumLevel().getShortText()))
|
||||
.wrapWith("p");
|
||||
}
|
||||
return HtmlChunk.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this to report problems at method level.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user