diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/java19modules/JavaRequiresAutoModuleInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/java19modules/JavaRequiresAutoModuleInspection.java
new file mode 100644
index 000000000000..672320c8c1ac
--- /dev/null
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/java19modules/JavaRequiresAutoModuleInspection.java
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ */
+package com.intellij.codeInspection.java19modules;
+
+import com.intellij.codeInspection.BaseJavaLocalInspectionTool;
+import com.intellij.codeInspection.InspectionsBundle;
+import com.intellij.codeInspection.ProblemsHolder;
+import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
+import com.intellij.psi.*;
+import com.intellij.psi.impl.light.LightJavaModule;
+import com.intellij.psi.util.PsiUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+
+public class JavaRequiresAutoModuleInspection extends BaseJavaLocalInspectionTool {
+ public boolean TRANSITIVE_ONLY = true;
+
+ @Nullable
+ @Override
+ public JComponent createOptionsPanel() {
+ return new SingleCheckboxOptionsPanel(InspectionsBundle.message("inspection.requires.auto.module.option"), this, "TRANSITIVE_ONLY");
+ }
+
+ @NotNull
+ @Override
+ public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
+ return !PsiUtil.isModuleFile(holder.getFile()) ? PsiElementVisitor.EMPTY_VISITOR : new JavaElementVisitor() {
+ @Override
+ public void visitRequiresStatement(PsiRequiresStatement statement) {
+ super.visitRequiresStatement(statement);
+ PsiJavaModuleReferenceElement refElement = statement.getReferenceElement();
+ if (refElement != null) {
+ PsiPolyVariantReference reference = refElement.getReference();
+ if (reference != null) {
+ PsiElement target = reference.resolve();
+ if (target instanceof LightJavaModule) {
+ if (!TRANSITIVE_ONLY) {
+ holder.registerProblem(refElement, InspectionsBundle.message("inspection.requires.auto.module.message"));
+ }
+ else if (statement.hasModifierProperty(PsiModifier.TRANSITIVE)) {
+ holder.registerProblem(refElement, InspectionsBundle.message("inspection.requires.auto.module.transitive"));
+ }
+ }
+ }
+ }
+ }
+ };
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/java/codeInspection/JavaRequiresAutoModuleInspectionTest.kt b/java/java-tests/testSrc/com/intellij/java/codeInspection/JavaRequiresAutoModuleInspectionTest.kt
new file mode 100644
index 000000000000..e99e1b3d3f64
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/java/codeInspection/JavaRequiresAutoModuleInspectionTest.kt
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+package com.intellij.java.codeInspection
+
+import com.intellij.codeInspection.java19modules.JavaRequiresAutoModuleInspection
+import com.intellij.java.testFramework.fixtures.LightJava9ModulesCodeInsightFixtureTestCase
+
+class JavaRequiresAutoModuleInspectionTest : LightJava9ModulesCodeInsightFixtureTestCase() {
+ private lateinit var inspection: JavaRequiresAutoModuleInspection
+
+ override fun setUp() {
+ super.setUp()
+ inspection = JavaRequiresAutoModuleInspection()
+ myFixture.enableInspections(inspection)
+ }
+
+ fun testTransitive() {
+ highlighting("""module M { requires transitive
-Xlint:requires-automatic and -Xlint:requires-transitive-automatic Javac options.
+
+
\ No newline at end of file
diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml
index e71741a9ed0a..e4d9b21a6d54 100644
--- a/resources/src/META-INF/IdeaPlugin.xml
+++ b/resources/src/META-INF/IdeaPlugin.xml
@@ -948,6 +948,10 @@
enabledByDefault="true" level="WARNING"
key="inspection.module.exports.package.to.itself" bundle="messages.InspectionsBundle"
implementationClass="com.intellij.codeInspection.java19modules.Java9ModuleExportsPackageToItselfInspection"/>
+