Add inspection for usages of Kotlin internal declarations in Java

#KT-11393 Fixed
This commit is contained in:
Vyacheslav Gerasimov
2017-03-16 13:33:07 +03:00
parent bd53922c64
commit a795313c7d
12 changed files with 206 additions and 10 deletions
@@ -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$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="B" />
</component>
</module>
@@ -0,0 +1 @@
internal class SomeInternalClass
@@ -0,0 +1,17 @@
import kotlin.collections.MapsKt;
import kotlin.internal.PlatformImplementations; // Internal in stdlib, error
import java.util.function.Consumer;
public class SomeClass extends PlatformImplementations { // Internal in stdlib, error
public static void doSomething() {
PlatformImplementations a; // Internal in stdlib, error
Integer c;
MapsKt.mapCapacity(3); // Internal in stdlib, error
Consumer<Integer> fun = MapsKt::mapCapacity; // Internal in stdlib, error
SomeInternalClass b = new SomeInternalClass(); // Internal in same module, OK
SomeInternalClassInOtherModule b = new SomeInternalClassInOtherModule(); // Internal in other module, error
}
}
@@ -0,0 +1,11 @@
<?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$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
@@ -0,0 +1 @@
internal class SomeInternalClassInOtherModule
@@ -0,0 +1,72 @@
<problems>
<problem>
<file>test.java</file>
<line>3</line>
<module>A</module>
<package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="test.java" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Usage of Kotlin internal declarations from Java</problem_class>
<description>Usage of Kotlin internal declaration from different module</description>
</problem>
<problem>
<file>test.java</file>
<line>7</line>
<module>A</module>
<package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="test.java" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Usage of Kotlin internal declarations from Java</problem_class>
<description>Usage of Kotlin internal declaration from different module</description>
</problem>
<problem>
<file>test.java</file>
<line>9</line>
<module>A</module>
<package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="test.java" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Usage of Kotlin internal declarations from Java</problem_class>
<description>Usage of Kotlin internal declaration from different module</description>
</problem>
<problem>
<file>test.java</file>
<line>11</line>
<module>A</module>
<package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="test.java" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Usage of Kotlin internal declarations from Java</problem_class>
<description>Usage of Kotlin internal declaration from different module</description>
</problem>
<problem>
<file>test.java</file>
<line>12</line>
<module>A</module>
<package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="test.java" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Usage of Kotlin internal declarations from Java</problem_class>
<description>Usage of Kotlin internal declaration from different module</description>
</problem>
<problem>
<file>test.java</file>
<line>15</line>
<module>A</module>
<package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="test.java" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Usage of Kotlin internal declarations from Java</problem_class>
<description>Usage of Kotlin internal declaration from different module</description>
</problem>
<problem>
<file>test.java</file>
<line>15</line>
<module>A</module>
<package>&lt;default&gt;</package>
<entry_point TYPE="file" FQNAME="test.java" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Usage of Kotlin internal declarations from Java</problem_class>
<description>Usage of Kotlin internal declaration from different module</description>
</problem>
</problems>
@@ -0,0 +1,5 @@
{
"inspectionClass": "org.jetbrains.kotlin.idea.inspections.KotlinInternalInJavaInspection",
"withRuntime": "true",
"isMultiModule": "true"
}