mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
Blocking calls detection inspection created (IDEA-173248)
This commit is contained in:
committed by
Nicolay Mitropolsky
parent
2a877313ca
commit
fea31cf421
@@ -0,0 +1,11 @@
|
||||
package org.jetbrains.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(value = ElementType.METHOD)
|
||||
@Retention(value = RetentionPolicy.CLASS)
|
||||
public @interface Blocking {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.jetbrains.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(value = ElementType.METHOD)
|
||||
@Retention(value = RetentionPolicy.CLASS)
|
||||
public @interface NonBlocking {}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import org.jetbrains.annotations.Blocking;
|
||||
|
||||
public class TestExternalAnnotationsDetection {
|
||||
@Blocking
|
||||
private static void testBlocking() {}
|
||||
|
||||
private static void func() {
|
||||
<warning descr="Inappropriate blocking method call">testBlocking</warning>();
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import org.jetbrains.annotations.Blocking;
|
||||
import org.jetbrains.annotations.NonBlocking;
|
||||
|
||||
public class TestSimpleAnnotationsDetection {
|
||||
@Blocking
|
||||
private static void testBlocking() {}
|
||||
|
||||
@NonBlocking
|
||||
private static void nonBlocking() {
|
||||
<warning descr="Inappropriate blocking method call">testBlocking</warning>();
|
||||
}
|
||||
|
||||
private static void withoutAnnotation() {
|
||||
testBlocking();
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import org.jetbrains.annotations.NonBlocking;
|
||||
|
||||
public class TestThrowsTypeDetection {
|
||||
@NonBlocking
|
||||
private static void nonBlocking() {
|
||||
try {
|
||||
Thread.<warning descr="Inappropriate blocking method call">sleep</warning>(1L);
|
||||
} catch (InterruptedException ignored) {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<item name="TestExternalAnnotationsDetection void func()">
|
||||
<annotation name="org.jetbrains.annotations.NonBlocking"/>
|
||||
</item>
|
||||
Reference in New Issue
Block a user