mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] suppressable "redundant requires statement" inspection (IDEA-205523)
GitOrigin-RevId: a7591c521a9bd80f7442fa9e9e0f0d3dc2c236f6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f9bc4f650a
commit
4ebf2bcc77
+1
-1
@@ -61,7 +61,7 @@ public class Java9RedundantRequiresStatementInspection extends GlobalJavaBatchIn
|
||||
isDependencyUnused(requiredModule.packagesExportedByModule, moduleImportedPackages, refJavaModule.getName())) {
|
||||
PsiRequiresStatement requiresStatement = ContainerUtil.find(
|
||||
psiJavaModule.getRequires(), statement -> requiredModuleName.equals(statement.getModuleName()));
|
||||
if (requiresStatement != null) {
|
||||
if (requiresStatement != null && !isSuppressedFor(requiresStatement)) {
|
||||
CommonProblemDescriptor descriptor = manager.createProblemDescriptor(
|
||||
requiresStatement,
|
||||
InspectionsBundle.message("inspection.redundant.requires.statement.description", requiredModuleName),
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
</problems>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
</problems>
|
||||
+11
-15
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.java.codeInspection
|
||||
|
||||
import com.intellij.analysis.AnalysisScope
|
||||
@@ -98,6 +84,16 @@ class Java9RedundantRequiresStatementTest : LightJava9ModulesCodeInsightFixtureT
|
||||
mainModule("module MAIN { requires java.base; }")
|
||||
}
|
||||
|
||||
fun testSuppressionByComment() {
|
||||
mainClass()
|
||||
mainModule("module M {\n //noinspection Java9RedundantRequiresStatement\n requires M2;\n}")
|
||||
}
|
||||
|
||||
fun testSuppressionByAnnotation() {
|
||||
mainClass()
|
||||
mainModule("@SuppressWarnings(\"Java9RedundantRequiresStatement\") module M { requires M2; }")
|
||||
}
|
||||
|
||||
private fun mainModule(@Language("JAVA") text: String) {
|
||||
addFile("module-info.java", text, ModuleDescriptor.MAIN)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user