KotlinInternalInJavaInspection: fix false positive for java test module
#KT-17659 Fixed
This commit is contained in:
@@ -9,7 +9,7 @@ import com.intellij.codeInspection.LocalInspectionTool
|
|||||||
import com.intellij.codeInspection.ProblemsHolder
|
import com.intellij.codeInspection.ProblemsHolder
|
||||||
import com.intellij.psi.*
|
import com.intellij.psi.*
|
||||||
import org.jetbrains.kotlin.asJava.elements.KtLightElement
|
import org.jetbrains.kotlin.asJava.elements.KtLightElement
|
||||||
import org.jetbrains.kotlin.idea.caches.project.getNullableModuleInfo
|
import org.jetbrains.kotlin.idea.util.module
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens.INTERNAL_KEYWORD
|
import org.jetbrains.kotlin.lexer.KtTokens.INTERNAL_KEYWORD
|
||||||
import org.jetbrains.kotlin.psi.KtModifierListOwner
|
import org.jetbrains.kotlin.psi.KtModifierListOwner
|
||||||
|
|
||||||
@@ -39,5 +39,5 @@ class KotlinInternalInJavaInspection : LocalInspectionTool() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun PsiElement.inSameModule(element: PsiElement) = getNullableModuleInfo()?.equals(element.getNullableModuleInfo()) ?: true
|
private fun PsiElement.inSameModule(element: PsiElement) = module?.equals(element.module) ?: true
|
||||||
}
|
}
|
||||||
|
|||||||
idea/testData/multiFileInspections/kotlinInternalInJavaTest/before/testProject/main/kotlin/Shadow.kt
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package pack_one.java_package;
|
||||||
|
|
||||||
|
internal class Foo {
|
||||||
|
fun bar() = "bar"
|
||||||
|
}
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
package pack_one.java_package;
|
||||||
|
|
||||||
|
public class Internal {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Foo foo = new Foo();
|
||||||
|
foo.bar();
|
||||||
|
}
|
||||||
|
}
|
||||||
Vendored
+12
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/main/kotlin" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/test/java" isTestSource="true" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<problems>
|
||||||
|
</problems>
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"inspectionClass": "org.jetbrains.kotlin.idea.inspections.KotlinInternalInJavaInspection",
|
||||||
|
"isMultiModule": "true"
|
||||||
|
}
|
||||||
+5
@@ -43,6 +43,11 @@ public class MultiFileInspectionTestGenerated extends AbstractMultiFileInspectio
|
|||||||
runTest("idea/testData/multiFileInspections/kotlinInternalInJava/kotlinInternalInJava.test");
|
runTest("idea/testData/multiFileInspections/kotlinInternalInJava/kotlinInternalInJava.test");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kotlinInternalInJavaTest/kotlinInternalInJavaTest.test")
|
||||||
|
public void testKotlinInternalInJavaTest_KotlinInternalInJavaTest() throws Exception {
|
||||||
|
runTest("idea/testData/multiFileInspections/kotlinInternalInJavaTest/kotlinInternalInJavaTest.test");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("mainInTwoModules/mainInTwoModules.test")
|
@TestMetadata("mainInTwoModules/mainInTwoModules.test")
|
||||||
public void testMainInTwoModules_MainInTwoModules() throws Exception {
|
public void testMainInTwoModules_MainInTwoModules() throws Exception {
|
||||||
runTest("idea/testData/multiFileInspections/mainInTwoModules/mainInTwoModules.test");
|
runTest("idea/testData/multiFileInspections/mainInTwoModules/mainInTwoModules.test");
|
||||||
|
|||||||
Reference in New Issue
Block a user