Inspection for highlighting problem API usage
It's planned to use this inspection for show patchset branches problems during development process.
This commit is contained in:
committed by
Nikolay Krasko
parent
a95ec598f2
commit
3ef67e1d9d
@@ -0,0 +1,45 @@
|
||||
package problem.api;
|
||||
|
||||
import lib.LibClass;
|
||||
import lib.LibMethods;
|
||||
import lib.LibSuper;
|
||||
import lib.LibConstructor;
|
||||
|
||||
public class JavaTest {
|
||||
void test() {
|
||||
new LibClass();
|
||||
LibMethods.staticMethod();
|
||||
}
|
||||
|
||||
static void overloads(LibMethods lib) {
|
||||
lib.overload1(12);
|
||||
lib.overload1("Some");
|
||||
|
||||
lib.overload2(12);
|
||||
lib.overload2("Some");
|
||||
|
||||
//noinspection IncompatibleAPI
|
||||
lib.overload2(13);
|
||||
}
|
||||
|
||||
public static class Extends extends LibClass {
|
||||
}
|
||||
|
||||
public class Subclass extends LibSuper {
|
||||
@Override
|
||||
public void test(String str) {
|
||||
}
|
||||
}
|
||||
|
||||
public class SubclassSuppress extends LibSuper {
|
||||
@SuppressWarnings("IncompatibleAPI")
|
||||
@Override
|
||||
public void test(String str) {
|
||||
}
|
||||
}
|
||||
|
||||
public static constructor() {
|
||||
new LibConstructor(null, "some");
|
||||
new LibConstructor(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package problem.api.kotlin.classes
|
||||
|
||||
import lib.LibClass
|
||||
|
||||
fun ktTest() {
|
||||
LibClass()
|
||||
}
|
||||
|
||||
class KtUsage : LibClass()
|
||||
|
||||
fun ktTestSuppress() {
|
||||
@Suppress("IncompatibleAPI")
|
||||
LibClass()
|
||||
}
|
||||
|
||||
@Suppress("IncompatibleAPI")
|
||||
class KtUsageSuppress : LibClass()
|
||||
@@ -0,0 +1,8 @@
|
||||
package problem.api.kotlin.constructors
|
||||
|
||||
import lib.LibConstructor
|
||||
|
||||
fun ktOverloads(lib: LibMethods) {
|
||||
LibConstructor(null, "some")
|
||||
LibConstructor(null)
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<problems>
|
||||
<problem>
|
||||
<file>classes.kt</file>
|
||||
<line>6</line>
|
||||
<description>class example</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>classes.kt</file>
|
||||
<line>9</line>
|
||||
<description>class example</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>overloads.kt</file>
|
||||
<line>6</line>
|
||||
<description>concrete overload example</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>overloads.kt</file>
|
||||
<line>9</line>
|
||||
<description>overload with no params example</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>overloads.kt</file>
|
||||
<line>10</line>
|
||||
<description>overload with no params example</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>static.kt</file>
|
||||
<line>6</line>
|
||||
<description>static method example</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>JavaTest.java</file>
|
||||
<line>10</line>
|
||||
<description>class example</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>JavaTest.java</file>
|
||||
<line>11</line>
|
||||
<description>static method example</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>JavaTest.java</file>
|
||||
<line>15</line>
|
||||
<description>concrete overload example</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>JavaTest.java</file>
|
||||
<line>18</line>
|
||||
<description>overload with no params example</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>JavaTest.java</file>
|
||||
<line>19</line>
|
||||
<description>overload with no params example</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>JavaTest.java</file>
|
||||
<line>25</line>
|
||||
<description>class example</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>JavaTest.java</file>
|
||||
<line>30</line>
|
||||
<description>signature changed example</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>JavaTest.java</file>
|
||||
<line>43</line>
|
||||
<description>constructor example</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>super.kt</file>
|
||||
<line>6</line>
|
||||
<description>signature changed example</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>constructors.kt</file>
|
||||
<line>7</line>
|
||||
<description>constructor example</description>
|
||||
</problem>
|
||||
</problems>
|
||||
@@ -0,0 +1 @@
|
||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.api.IncompatibleAPIInspection
|
||||
@@ -0,0 +1,12 @@
|
||||
<inspection_tool class="IncompatibleAPI" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="problems">
|
||||
<list>
|
||||
<Problem reference="lib.LibClass" reason="class example" />
|
||||
<Problem reference="lib.LibMethods#staticMethod" reason="static method example" />
|
||||
<Problem reference="lib.LibMethods#overload1(int)" reason="concrete overload example" />
|
||||
<Problem reference="lib.LibMethods#overload2" reason="overload with no params example" />
|
||||
<Problem reference="lib.LibSuper#test" reason="signature changed example" />
|
||||
<Problem reference="lib.LibConstructor#LibConstructor(java.lang.Object)" reason="constructor example" />
|
||||
</list>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
@@ -0,0 +1,4 @@
|
||||
package lib;
|
||||
|
||||
public class LibClass {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package lib;
|
||||
|
||||
public class LibConstructor {
|
||||
public LibConstructor(Object object) {
|
||||
}
|
||||
|
||||
public LibConstructor(Object object, String other) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package lib;
|
||||
|
||||
public class LibMethods {
|
||||
public static void staticMethod() {
|
||||
}
|
||||
|
||||
public void overload1(int i) {}
|
||||
public void overload1(String s) {}
|
||||
|
||||
public void overload2(int i) {}
|
||||
public void overload2(String s) {}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package lib;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class LibSuper {
|
||||
public void test(@Nullable String str) {}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package problem.api.kotlin.overloads
|
||||
|
||||
import lib.LibMethods
|
||||
|
||||
fun ktOverloads(lib: LibMethods) {
|
||||
lib.overload1(12)
|
||||
lib.overload1("Some")
|
||||
|
||||
lib.overload2(12)
|
||||
lib.overload2("Some")
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package problem.api.kotlin.statics
|
||||
|
||||
import lib.LibMethods
|
||||
|
||||
fun ktTest() {
|
||||
LibMethods.staticMethod()
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package problem.api.kotlin.s
|
||||
|
||||
import lib.LibSuper
|
||||
|
||||
class Subclass : LibSuper() {
|
||||
override fun test(str: String?) {
|
||||
}
|
||||
}
|
||||
|
||||
class SubclassSuppress : LibSuper() {
|
||||
@Suppress("IncompatibleAPI")
|
||||
override fun test(str: String?) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user