Java: fix "Missorted modifiers" options and messages

GitOrigin-RevId: ab41b6c1d135c9b788feeec4a273a6f483b9bfa5
This commit is contained in:
Bas Leijdekkers
2024-08-10 14:49:45 +02:00
committed by intellij-monorepo-bot
parent 426cda83e6
commit f40ed914fb
4 changed files with 20 additions and 17 deletions

View File

@@ -1298,16 +1298,16 @@ extends.object.remove.quickfix=Remove redundant 'extends Object'
implicit.call.to.super.ignore.option=Ignore for direct subclasses of 'java.lang.Object' implicit.call.to.super.ignore.option=Ignore for direct subclasses of 'java.lang.Object'
implicit.call.to.super.make.explicit.quickfix=Make call to 'super()' explicit implicit.call.to.super.make.explicit.quickfix=Make call to 'super()' explicit
missorted.modifiers.require.option=Check annotation order missorted.modifiers.require.option=Check annotation order
missorted.modifiers.require.option.description=Use this option to report misplaced annotations: \ missorted.modifiers.require.option.description=Use this option to report annotations in the wrong position: \
(annotations with <code>ElementType.TYPE_USE</code> <em>not</em> directly \ annotations with <code>ElementType.TYPE_USE</code> <em>not</em> directly \
before the type and after the modifier keywords, or \ before the type and after the modifier keywords, or \
other annotations <em>not</em> before the modifier keywords). \ other annotations <em>not</em> before the modifier keywords. \
When this option is disabled, any annotation can be positioned before or after the modifier keywords. \ When this option is disabled, annotations are allowed both before and after the modifier keywords. \
Modifier lists with annotations in between the modifier keywords will always be reported. Annotations in between the modifier keywords will always be reported.
missorted.modifiers.allowed.place=Target TYPE_USE annotations must be placed according to generation options missorted.modifiers.allowed.place=TYPE_USE annotations follow generation options
missorted.modifiers.allowed.place.description=Target TYPE_USE annotations must be placed according to \ missorted.modifiers.allowed.place.description=When this option is enabled, target TYPE_USE annotations are reported when they are not positioned according to the \
<code>Settings->Editor->Code Style->Java->Code Generation->Generate annotations allowed for TYPE_USE directly before a type</code> option, \ <pre>{0}</pre> option in <pre>Settings | Editor | Code Style | Java | Code Generation.</pre>\
otherwise it can be placed in any allowed place When this option is disabled, target TYPE_USE annotations are allowed both directly before the type and before the modifier keywords.
missorted.modifiers.sort.quickfix=Sort modifiers missorted.modifiers.sort.quickfix=Sort modifiers
nested.method.call.ignore.option=Ignore nested method calls in field initializers nested.method.call.ignore.option=Ignore nested method calls in field initializers
ignore.calls.to.static.methods=Ignore calls to static methods ignore.calls.to.static.methods=Ignore calls to static methods

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2003-2020 Dave Griffith, Bas Leijdekkers * Copyright 2003-2024 Dave Griffith, Bas Leijdekkers
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -19,9 +19,11 @@ import com.intellij.codeInsight.AnnotationTargetUtil;
import com.intellij.codeInspection.CleanupLocalInspectionTool; import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.LocalQuickFix; import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.options.OptPane; import com.intellij.codeInspection.options.OptPane;
import com.intellij.java.JavaBundle;
import com.intellij.modcommand.ModPsiUpdater; import com.intellij.modcommand.ModPsiUpdater;
import com.intellij.modcommand.PsiUpdateModCommandQuickFix; import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
import com.intellij.openapi.project.Project; import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.HtmlChunk;
import com.intellij.psi.*; import com.intellij.psi.*;
import com.intellij.refactoring.util.ModifierListUtil; import com.intellij.refactoring.util.ModifierListUtil;
import com.intellij.util.SmartList; import com.intellij.util.SmartList;
@@ -106,10 +108,11 @@ public final class MissortedModifiersInspection extends BaseInspection implement
@Override @Override
public @NotNull OptPane getOptionsPane() { public @NotNull OptPane getOptionsPane() {
return pane( return pane(
checkbox("m_requireAnnotationsFirst", InspectionGadgetsBundle.message("missorted.modifiers.require.option")) checkbox("m_requireAnnotationsFirst", InspectionGadgetsBundle.message("missorted.modifiers.require.option"),
.description(InspectionGadgetsBundle.message("missorted.modifiers.require.option.description")),
checkbox("typeUseWithType", InspectionGadgetsBundle.message("missorted.modifiers.allowed.place")) checkbox("typeUseWithType", InspectionGadgetsBundle.message("missorted.modifiers.allowed.place"))
.description(InspectionGadgetsBundle.message("missorted.modifiers.allowed.place.description")) .description(HtmlChunk.raw(InspectionGadgetsBundle.message("missorted.modifiers.allowed.place.description",
JavaBundle.message("generate.type.use.before.type")))))
.description(HtmlChunk.raw(InspectionGadgetsBundle.message("missorted.modifiers.require.option.description")))
); );
} }

View File

@@ -1,6 +1,6 @@
<html> <html>
<body> <body>
Reports declarations whose modifiers are not in the canonical Reports declaration modifiers that are not in the canonical
preferred order (as stated in the Java Language Specification). preferred order (as stated in the Java Language Specification).
<p><b>Example:</b></p> <p><b>Example:</b></p>
<pre><code> <pre><code>

View File

@@ -1346,8 +1346,8 @@ unwrap.switch.statement=Unwrap 'switch' statement
usage.target.exception=Exception usage.target.exception=Exception
usage.target.package.in.directory={0} (in {1}) usage.target.package.in.directory={0} (in {1})
use.external.annotations=Use &external annotations use.external.annotations=Use &external annotations
generate.type.use.before.type=Generate annotations allowed for TYPE_USE directly &before a type generate.type.use.before.type=Put generated annotations with target TYPE_USE between the modifiers and the type
generate.type.use.before.type.description=Annotations with TYPE_USE as their target will be placed directly before a type. Otherwise, they will be placed before all modifiers. generate.type.use.before.type.description=<html>Annotations with target TYPE_USE will be placed after any modifiers and directly<br>before the type. When disabled, they will be placed before any modifiers.</html>
wrapping.annotation.enums=Enum field annotations wrapping.annotation.enums=Enum field annotations
wrapping.annotation.parameters=Annotation parameters wrapping.annotation.parameters=Annotation parameters
wrapping.record.components=Record components wrapping.record.components=Record components