Resolve warnings about 'protected' members in a 'final' classes

GitOrigin-RevId: 5d7c04b6371be1f2cc924a86614919ab6ee5b642
This commit is contained in:
Andrey Cherkasov
2023-12-14 19:35:38 +04:00
committed by intellij-monorepo-bot
parent 70519ef3cd
commit 24adef8e2a
42 changed files with 61 additions and 58 deletions

View File

@@ -26,7 +26,7 @@ import static java.util.Collections.singletonList;
* because JavaDebuggerSettingsPanelProvider has higher priority than XDebuggerSettingsPanelProviderImpl.
*/
public final class JavaDebuggerSettings extends XDebuggerSettings<Element> {
protected JavaDebuggerSettings() {
private JavaDebuggerSettings() {
super("java");
}

View File

@@ -31,7 +31,7 @@ import java.util.Collection;
public final class XBreakpointGroupingByPackageRule<B> extends XBreakpointGroupingRule<B, XBreakpointPackageGroup> {
protected XBreakpointGroupingByPackageRule() {
private XBreakpointGroupingByPackageRule() {
super("XBreakpointGroupingByPackageRule", JavaDebuggerBundle.message("rule.name.group.by.package"));
}

View File

@@ -80,7 +80,7 @@ public final class JavaCollectionBreakpointType extends JavaLineBreakpointTypeBa
}
//@Override
protected String getHelpID() {
private static String getHelpID() {
return HelpID.COLLECTION_WATCHPOINTS;
}

View File

@@ -55,7 +55,7 @@ public final class JavaExceptionBreakpointType extends JavaBreakpointTypeBase<Ja
}
//@Override
protected String getHelpID() {
private static String getHelpID() {
return HelpID.EXCEPTION_BREAKPOINTS;
}

View File

@@ -74,7 +74,7 @@ public final class JavaFieldBreakpointType extends JavaLineBreakpointTypeBase<Ja
}
//@Override
protected String getHelpID() {
private static String getHelpID() {
return HelpID.FIELD_WATCHPOINTS;
}

View File

@@ -48,7 +48,7 @@ public final class JavaWildcardMethodBreakpointType extends JavaBreakpointTypeBa
}
//@Override
protected String getHelpID() {
private static String getHelpID() {
return HelpID.METHOD_BREAKPOINTS;
}

View File

@@ -39,7 +39,7 @@ public final class CompileStepBeforeRun extends BeforeRunTaskProvider<CompileSte
private static final Logger LOG = Logger.getInstance(CompileStepBeforeRun.class);
public static final Key<MakeBeforeRunTask> ID = Key.create("Make");
@NonNls protected static final String MAKE_PROJECT_ON_RUN_KEY = "makeProjectOnRun";
@NonNls private static final String MAKE_PROJECT_ON_RUN_KEY = "makeProjectOnRun";
private final Project myProject;

View File

@@ -16,7 +16,7 @@ import static com.intellij.psi.impl.source.BasicJavaElementType.EXPRESSION_SET;
public final class JavaEnterAfterUnmatchedBraceHandler extends EnterAfterUnmatchedBraceHandler {
protected JavaEnterAfterUnmatchedBraceHandler() {
private JavaEnterAfterUnmatchedBraceHandler() {
}
@Override

View File

@@ -252,8 +252,8 @@ public final class SimplifyStreamApiCallChainsInspection extends AbstractBaseJav
}
@NotNull
protected static TextRange getCallChainRange(@NotNull PsiMethodCallExpression expression,
@NotNull PsiMethodCallExpression qualifierExpression) {
private static TextRange getCallChainRange(@NotNull PsiMethodCallExpression expression,
@NotNull PsiMethodCallExpression qualifierExpression) {
final PsiReferenceExpression qualifierMethodExpression = qualifierExpression.getMethodExpression();
final PsiElement qualifierNameElement = qualifierMethodExpression.getReferenceNameElement();
final int startOffset = (qualifierNameElement != null ? qualifierNameElement : qualifierMethodExpression).getTextOffset();

View File

@@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull;
public final class SillyAssignmentInspection extends AbstractBaseJavaLocalInspectionTool {
protected LocalQuickFix createRemoveAssignmentFix(PsiExpression expression) {
private static LocalQuickFix createRemoveAssignmentFix(PsiExpression expression) {
final PsiElement parent = PsiUtil.skipParenthesizedExprUp(expression.getParent());
if (parent instanceof PsiVariable variable && variable.hasModifierProperty(PsiModifier.FINAL)) {
return null;
@@ -80,7 +80,7 @@ public final class SillyAssignmentInspection extends AbstractBaseJavaLocalInspec
};
}
private void checkSillyAssignment(@NotNull PsiAssignmentExpression assignment, @NotNull ProblemsHolder holder) {
private static void checkSillyAssignment(@NotNull PsiAssignmentExpression assignment, @NotNull ProblemsHolder holder) {
if (assignment.getOperationTokenType() != JavaTokenType.EQ) return;
PsiExpression leftExpression = assignment.getLExpression();
PsiExpression rightExpression = assignment.getRExpression();

View File

@@ -33,7 +33,7 @@ public final class SuspiciousNameCombinationInspection extends AbstractBaseJavaL
@NonNls private static final String ELEMENT_GROUPS = "group";
@NonNls private static final String ATTRIBUTE_NAMES = "names";
@NonNls private static final String ELEMENT_IGNORED_METHODS = "ignored";
protected final List<String> myNameGroups = new ArrayList<>();
private final List<String> myNameGroups = new ArrayList<>();
final MethodMatcher myIgnoredMethods = new MethodMatcher()
// parameter name is 'x' which is completely unrelated to coordinates
.add("java.io.PrintStream", "println")
@@ -74,7 +74,7 @@ public final class SuspiciousNameCombinationInspection extends AbstractBaseJavaL
return true;
}
protected void clearNameGroups() {
private void clearNameGroups() {
myNameGroups.clear();
myWordToGroupMap.clear();
myLongestWord = 0;

View File

@@ -26,7 +26,7 @@ public final class UnusedReturnValue extends GlobalJavaBatchInspectionTool{
public static final AccessModifier DEFAULT_HIGHEST_MODIFIER = AccessModifier.PUBLIC;
public AccessModifier highestModifier = DEFAULT_HIGHEST_MODIFIER;
protected @NotNull AccessModifier getHighestModifier() {
@NotNull AccessModifier getHighestModifier() {
return Objects.requireNonNullElse(highestModifier, DEFAULT_HIGHEST_MODIFIER);
}

View File

@@ -489,7 +489,7 @@ public final class CopyClassesHandler extends CopyHandlerDelegateBase implements
return createdFiles;
}
protected static boolean isSynthetic(PsiClass aClass) {
private static boolean isSynthetic(PsiClass aClass) {
return aClass instanceof SyntheticElement || !aClass.isPhysical();
}

View File

@@ -47,7 +47,9 @@ public final class CreateCastExpressionFromInstanceofAction implements ModComman
return ModCommand.psiUpdate(instanceOfExpression, (expr, updater) -> invoke(context, expr, updater));
}
protected void invoke(@NotNull ActionContext context, @NotNull PsiInstanceOfExpression instanceOfExpression, @NotNull ModPsiUpdater updater) {
private static void invoke(@NotNull ActionContext context,
@NotNull PsiInstanceOfExpression instanceOfExpression,
@NotNull ModPsiUpdater updater) {
PsiElement decl = createAndInsertCast(context.offset(), instanceOfExpression);
if (decl == null) return;
decl = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(decl);

View File

@@ -60,7 +60,7 @@ public final class EncapsulateFieldAction extends BaseRefactoringIntentionAction
}
@Nullable
protected static PsiField getField(@Nullable PsiElement element) {
private static PsiField getField(@Nullable PsiElement element) {
if (!(element instanceof PsiIdentifier)) {
return null;
}

View File

@@ -81,7 +81,7 @@ public abstract class JavaCodeContextType extends TemplateContextType {
}
public static final class ConsumerFunction extends JavaCodeContextType {
protected ConsumerFunction() {
private ConsumerFunction() {
super(JavaBundle.message("live.template.context.consumer.function"));
}

View File

@@ -91,7 +91,7 @@ public final class BooleanMethodIsAlwaysInvertedInspection extends GlobalJavaBat
return null;
}
protected ProblemDescriptor createProblemDescriptor(@NotNull InspectionManager manager, PsiElement identifier, boolean onTheFly) {
ProblemDescriptor createProblemDescriptor(@NotNull InspectionManager manager, PsiElement identifier, boolean onTheFly) {
final InvertBooleanDelegate invertBooleanDelegate = InvertBooleanDelegate.findInvertBooleanDelegate(identifier.getParent());
return manager.createProblemDescriptor(identifier,
JavaBundle.message("boolean.method.is.always.inverted.problem.descriptor"),

View File

@@ -44,10 +44,10 @@ public final class MissingJavadocInspection extends LocalInspectionTool {
public Options METHOD_SETTINGS = new Options("@return@param@throws or @exception");
public Options FIELD_SETTINGS = new Options();
protected static final String PACKAGE_LOCAL = "package";
protected static final String PUBLIC = PsiModifier.PUBLIC;
protected static final String PROTECTED = PsiModifier.PROTECTED;
protected static final String PRIVATE = PsiModifier.PRIVATE;
private static final String PACKAGE_LOCAL = "package";
static final String PUBLIC = PsiModifier.PUBLIC;
private static final String PROTECTED = PsiModifier.PROTECTED;
private static final String PRIVATE = PsiModifier.PRIVATE;
@Override
public @NotNull OptPane getOptionsPane() {

View File

@@ -40,7 +40,7 @@ import org.jetbrains.annotations.NotNull;
*/
public final class SubtractionInCompareToInspection extends BaseInspection {
protected final MethodMatcher methodMatcher;
private final MethodMatcher methodMatcher;
public SubtractionInCompareToInspection() {
methodMatcher = new MethodMatcher()

View File

@@ -78,7 +78,7 @@ public final class TooBroadScopeInspection extends BaseInspection {
return InspectionGadgetsBundle.message("too.broad.scope.problem.descriptor");
}
protected boolean isMovable(PsiExpression expression) {
private boolean isMovable(PsiExpression expression) {
expression = PsiUtil.skipParenthesizedExprDown(expression);
if (expression == null) {
return true;

View File

@@ -41,7 +41,7 @@ import static com.intellij.codeInspection.options.OptPane.*;
public final class InstanceVariableUninitializedUseInspection extends BaseInspection {
protected final List<String> annotationNames = new ArrayList<>();
private final List<String> annotationNames = new ArrayList<>();
/**
* @noinspection PublicField
*/

View File

@@ -26,7 +26,7 @@ import java.util.List;
public final class ParameterizedParametersStaticCollectionInspection extends BaseInspection {
protected static final String PARAMETERS_FQN = "org.junit.runners.Parameterized.Parameters";
private static final String PARAMETERS_FQN = "org.junit.runners.Parameterized.Parameters";
@Override
protected LocalQuickFix buildFix(final Object... infos) {

View File

@@ -40,7 +40,7 @@ import static com.intellij.codeInspection.options.OptPane.stringList;
public final class ClassWithMultipleLoggersInspection extends BaseInspection {
protected final List<String> loggerNames = new ArrayList<>();
private final List<String> loggerNames = new ArrayList<>();
/**
* @noinspection PublicField
*/

View File

@@ -41,7 +41,7 @@ import static com.intellij.codeInspection.options.OptPane.*;
public final class ClassWithoutLoggerInspection extends BaseInspection {
protected final List<String> loggerNames = new ArrayList<>();
private final List<String> loggerNames = new ArrayList<>();
/**
* @noinspection PublicField
*/

View File

@@ -58,8 +58,8 @@ public final class LoggerInitializedWithForeignClassInspection extends BaseInspe
"getLogger," +
// Log4J 2
"getLogger";
protected final List<String> loggerFactoryClassNames = new ArrayList<>();
protected final List<String> loggerFactoryMethodNames = new ArrayList<>();
private final List<String> loggerFactoryClassNames = new ArrayList<>();
private final List<String> loggerFactoryMethodNames = new ArrayList<>();
@SuppressWarnings("PublicField")
public String loggerClassName = DEFAULT_FACTORY_CLASS_NAMES;
@SuppressWarnings("PublicField")

View File

@@ -38,7 +38,7 @@ import static com.intellij.codeInspection.options.OptPane.stringList;
public final class NonStaticFinalLoggerInspection extends BaseInspection {
protected final List<String> loggerClassNames = new ArrayList<>();
private final List<String> loggerClassNames = new ArrayList<>();
@SuppressWarnings("PublicField")
public String loggerClassName = StringUtil.join(JavaLoggingUtils.DEFAULT_LOGGERS, ",");

View File

@@ -49,7 +49,7 @@ public final class PackageNamingConventionInspection extends PackageGlobalInspec
*/
public int m_maxLength = DEFAULT_MAX_LENGTH;
protected Pattern m_regexPattern = Pattern.compile(m_regex);
private Pattern m_regexPattern = Pattern.compile(m_regex);
@Override
public CommonProblemDescriptor @Nullable [] checkPackage(@NotNull RefPackage refPackage,

View File

@@ -24,7 +24,7 @@ import java.util.regex.Matcher;
public final class DynamicRegexReplaceableByCompiledPatternInspection extends BaseInspection {
@NonNls
protected static final Collection<String> regexMethodNames = Set.of(
private static final Collection<String> regexMethodNames = Set.of(
"matches", "replace", "replaceFirst", "replaceAll", "split"
);

View File

@@ -42,10 +42,10 @@ import static com.intellij.codeInspection.options.OptPane.checkbox;
import static com.intellij.codeInspection.options.OptPane.pane;
public final class MethodMayBeStaticInspection extends BaseInspection {
@NonNls protected static final String IGNORE_DEFAULT_METHODS_ATTR_NAME = "m_ignoreDefaultMethods";
@NonNls protected static final String ONLY_PRIVATE_OR_FINAL_ATTR_NAME = "m_onlyPrivateOrFinal";
@NonNls protected static final String IGNORE_EMPTY_METHODS_ATTR_NAME = "m_ignoreEmptyMethods";
@NonNls protected static final String REPLACE_QUALIFIER_ATTR_NAME = "m_replaceQualifier";
@NonNls private static final String IGNORE_DEFAULT_METHODS_ATTR_NAME = "m_ignoreDefaultMethods";
@NonNls private static final String ONLY_PRIVATE_OR_FINAL_ATTR_NAME = "m_onlyPrivateOrFinal";
@NonNls private static final String IGNORE_EMPTY_METHODS_ATTR_NAME = "m_ignoreEmptyMethods";
@NonNls private static final String REPLACE_QUALIFIER_ATTR_NAME = "m_replaceQualifier";
/**
* @noinspection PublicField
*/

View File

@@ -60,7 +60,7 @@ public final class AutoCloseableResourceInspection extends ResourceInspection {
"org.springframework.context.ConfigurableApplicationContext",
"io.micronaut.context.ApplicationContext");
protected final MethodMatcher myMethodMatcher;
final MethodMatcher myMethodMatcher;
final List<String> ignoredTypes = new ArrayList<>(DEFAULT_IGNORED_TYPES);
@SuppressWarnings("PublicField")
public boolean ignoreFromMethodCall = false;

View File

@@ -48,7 +48,7 @@ public final class ExternalizableWithoutPublicNoArgConstructorInspection extends
}
@Nullable
protected static PsiMethod getNoArgConstructor(PsiMethod[] constructors) {
private static PsiMethod getNoArgConstructor(PsiMethod[] constructors) {
for (PsiMethod constructor : constructors) {
final PsiParameterList parameterList = constructor.getParameterList();
if (parameterList.isEmpty()) {

View File

@@ -24,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
*/
public final class SharedThreadLocalRandomInspection extends BaseInspection {
protected final MethodMatcher myMethodMatcher;
private final MethodMatcher myMethodMatcher;
public SharedThreadLocalRandomInspection() {
myMethodMatcher = new MethodMatcher(false, "ignoreArgumentToMethods")

View File

@@ -21,7 +21,7 @@ import java.util.Set;
public final class GuavaPredicateConversionRule extends GuavaLambdaConversionRule {
private static final String GUAVA_PREDICATES_UTILITY = "com.google.common.base.Predicates";
protected GuavaPredicateConversionRule() {
private GuavaPredicateConversionRule() {
super(GuavaLambda.PREDICATE);
}

View File

@@ -21,7 +21,7 @@ import javax.swing.event.AncestorEvent;
import java.awt.*;
public final class PythonSdkEditorAdditionalOptionsProvider extends SdkEditorAdditionalOptionsProvider {
protected PythonSdkEditorAdditionalOptionsProvider() {
private PythonSdkEditorAdditionalOptionsProvider() {
super(PythonSdkType.getInstance());
}

View File

@@ -30,7 +30,7 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
public final class PySignatureCacheManagerImpl extends PySignatureCacheManager {
protected static final Logger LOG = Logger.getInstance(PySignatureCacheManagerImpl.class.getName());
private static final Logger LOG = Logger.getInstance(PySignatureCacheManagerImpl.class.getName());
private final static boolean SHOULD_OVERWRITE_TYPES = false;

View File

@@ -46,7 +46,7 @@ import static com.intellij.codeInspection.options.OptPane.*;
*/
public final class PyPep8NamingInspection extends PyInspection {
protected static final String INSPECTION_SHORT_NAME = "PyPep8NamingInspection";
private static final String INSPECTION_SHORT_NAME = "PyPep8NamingInspection";
private static final Pattern LOWERCASE_REGEX = Pattern.compile("[_\\p{javaLowerCase}][_\\p{javaLowerCase}0-9]*");
private static final Pattern UPPERCASE_REGEX = Pattern.compile("[_\\p{javaUpperCase}][_\\p{javaUpperCase}0-9]*");
private static final Pattern MIXEDCASE_REGEX = Pattern.compile("_?_?[\\p{javaUpperCase}][\\p{javaLowerCase}\\p{javaUpperCase}0-9]*");
@@ -76,10 +76,10 @@ public final class PyPep8NamingInspection extends PyInspection {
);
}
protected void addFunctionQuickFixes(ProblemsHolder holder,
PyClass containingClass,
ASTNode nameNode,
List<LocalQuickFix> quickFixes, TypeEvalContext typeEvalContext) {
private static void addFunctionQuickFixes(ProblemsHolder holder,
PyClass containingClass,
ASTNode nameNode,
List<LocalQuickFix> quickFixes, TypeEvalContext typeEvalContext) {
if (holder != null && holder.isOnTheFly()) {
LocalQuickFix qf = PythonUiService.getInstance().createPyRenameElementQuickFix(nameNode.getPsi());
if (qf != null) {
@@ -92,8 +92,8 @@ public final class PyPep8NamingInspection extends PyInspection {
}
}
protected LocalQuickFix[] createRenameAndIgnoreErrorQuickFixes(@Nullable PsiElement node,
String errorCode) {
private LocalQuickFix[] createRenameAndIgnoreErrorQuickFixes(@Nullable PsiElement node,
String errorCode) {
List<LocalQuickFix> fixes = new ArrayList<>();
if (node != null) {
LocalQuickFix qf = PythonUiService.getInstance().createPyRenameElementQuickFix(node);

View File

@@ -51,7 +51,8 @@ public final class PyShadowingBuiltinsInspection extends PyInspection {
// Persistent settings
public List<String> ignoredNames = new ArrayList<>();
protected @NotNull LocalQuickFix @NotNull [] createQuickFixes(String name, PsiElement problemElement) {
@NotNull
private static LocalQuickFix @NotNull [] createQuickFixes(String name, PsiElement problemElement) {
List<LocalQuickFix> fixes = new ArrayList<>();
LocalQuickFix qf = PythonUiService.getInstance().createPyRenameElementQuickFix(problemElement);
if (qf != null) {

View File

@@ -22,7 +22,7 @@ public final class PyClassInheritorsSearchExecutor implements QueryExecutor<PyCl
/**
* These base classes are to general to look for inheritors list.
*/
protected static final ImmutableSet<String> IGNORED_BASES = ImmutableSet.of("object", "BaseException", "Exception");
private static final ImmutableSet<String> IGNORED_BASES = ImmutableSet.of("object", "BaseException", "Exception");
@Override
public boolean execute(@NotNull final PyClassInheritorsSearch.SearchParameters queryParameters, @NotNull final Processor<? super PyClass> consumer) {

View File

@@ -82,7 +82,7 @@ public final class PyIterableVariableMacro extends Macro {
}
@NotNull
protected List<PsiNamedElement> getIterableElements(@NotNull PsiElement element) {
private static List<PsiNamedElement> getIterableElements(@NotNull PsiElement element) {
final TypeEvalContext typeEvalContext = TypeEvalContext.userInitiated(element.getProject(), element.getContainingFile());
final List<PsiNamedElement> components = new ArrayList<>();
for (PsiNamedElement namedElement : getVisibleNamedElements(element)) {

View File

@@ -142,7 +142,7 @@ public final class PythonCopyPasteProcessor implements CopyPastePreProcessor {
return newText;
}
protected boolean isSupportedFile(PsiFile file) {
private static boolean isSupportedFile(PsiFile file) {
return file instanceof PyFile;
}

View File

@@ -40,7 +40,7 @@ public final class PythonLibraryType extends LibraryType<DummyLibraryProperties>
}
};
protected PythonLibraryType() {
private PythonLibraryType() {
super(LIBRARY_KIND);
}

View File

@@ -59,7 +59,7 @@ public final class PyNameSuggestionProvider implements NameSuggestionProvider {
}
@NotNull
protected String toCamelCase(@NotNull final String name, boolean uppercaseFirstLetter) {
private static String toCamelCase(@NotNull final String name, boolean uppercaseFirstLetter) {
final List<String> strings = StringUtil.split(name, "_");
if (strings.size() > 0) {
final StringBuilder buf = new StringBuilder();