mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
MoveFieldAssignmentToInitializerInspection: set default level to information; extend text-range to the whole assignment for information level (IDEA-CR-19490)
This commit is contained in:
+9
-7
@@ -21,6 +21,7 @@ import com.intellij.codeInsight.PsiEquivalenceUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
@@ -66,16 +67,17 @@ public class MoveFieldAssignmentToInitializerInspection extends BaseJavaBatchLoc
|
||||
if (!isInitializedWithSameExpression(field, assignment, new ArrayList<>())) return;
|
||||
|
||||
boolean shouldWarn = shouldWarn(ctrOrInitializer, field, assignment);
|
||||
if (shouldWarn) {
|
||||
if (!shouldWarn && !isOnTheFly) return;
|
||||
TextRange range;
|
||||
if (shouldWarn && !InspectionProjectProfileManager.isInformationLevel(getShortName(), assignment)) {
|
||||
PsiExpression lValue = assignment.getLExpression();
|
||||
TextRange range = new TextRange(0, lValue.getTextLength()).shiftRight(lValue.getStartOffsetInParent());
|
||||
holder.registerProblem(assignment, CodeInsightBundle.message("intention.move.field.assignment.to.declaration"),
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, range, new MoveFieldAssignmentToInitializerFix());
|
||||
range = new TextRange(0, lValue.getTextLength()).shiftRight(lValue.getStartOffsetInParent());
|
||||
} else {
|
||||
if(!isOnTheFly) return;
|
||||
holder.registerProblem(assignment, CodeInsightBundle.message("intention.move.field.assignment.to.declaration"),
|
||||
ProblemHighlightType.INFORMATION, new MoveFieldAssignmentToInitializerFix());
|
||||
range = new TextRange(0, assignment.getTextLength());
|
||||
}
|
||||
holder.registerProblem(assignment, CodeInsightBundle.message("intention.move.field.assignment.to.declaration"),
|
||||
shouldWarn ? ProblemHighlightType.GENERIC_ERROR_OR_WARNING : ProblemHighlightType.INFORMATION,
|
||||
range, new MoveFieldAssignmentToInitializerFix());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -920,7 +920,7 @@
|
||||
groupPath="Java" groupBundle="messages.InspectionsBundle" groupKey="group.names.reflective.access.issues"
|
||||
bundle="messages.InspectionsBundle" key="inspection.handle.signature.name"
|
||||
implementationClass="com.intellij.codeInspection.reflectiveAccess.JavaLangInvokeHandleSignatureInspection"/>
|
||||
<localInspection language="JAVA" shortName="MoveFieldAssignmentToInitializer" enabledByDefault="true" level="WARNING"
|
||||
<localInspection language="JAVA" shortName="MoveFieldAssignmentToInitializer" enabledByDefault="true" level="INFORMATION"
|
||||
groupPath="Java" groupBundle="messages.InspectionsBundle" groupKey="group.names.code.style.issues"
|
||||
displayName="Move field assignment to initializer"
|
||||
implementationClass="com.intellij.codeInspection.MoveFieldAssignmentToInitializerInspection"/>
|
||||
|
||||
Reference in New Issue
Block a user