Prohibit using DeprecatedSinceKotlin annotation without arguments
This commit is contained in:
@@ -103,6 +103,7 @@ public interface Errors {
|
|||||||
DiagnosticFactory0<PsiElement> DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<PsiElement> DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory0<PsiElement> DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<PsiElement> DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory0<PsiElement> DEPRECATED_SINCE_KOTLIN_WITH_UNORDERED_VERSIONS = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<PsiElement> DEPRECATED_SINCE_KOTLIN_WITH_UNORDERED_VERSIONS = DiagnosticFactory0.create(ERROR);
|
||||||
|
DiagnosticFactory0<PsiElement> DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS = DiagnosticFactory0.create(ERROR);
|
||||||
|
|
||||||
DiagnosticFactory2<PsiElement, String, String> API_NOT_AVAILABLE = DiagnosticFactory2.create(ERROR);
|
DiagnosticFactory2<PsiElement, String, String> API_NOT_AVAILABLE = DiagnosticFactory2.create(ERROR);
|
||||||
|
|
||||||
|
|||||||
+1
@@ -380,6 +380,7 @@ public class DefaultErrorMessages {
|
|||||||
MAP.put(DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED, "DeprecatedSinceKotlin annotation can be used only together with Deprecated annotation");
|
MAP.put(DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED, "DeprecatedSinceKotlin annotation can be used only together with Deprecated annotation");
|
||||||
MAP.put(DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL, "DeprecatedSinceKotlin annotation can be used only with unspecified deprecation level of Deprecated annotation");
|
MAP.put(DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL, "DeprecatedSinceKotlin annotation can be used only with unspecified deprecation level of Deprecated annotation");
|
||||||
MAP.put(DEPRECATED_SINCE_KOTLIN_WITH_UNORDERED_VERSIONS, "Values of DeprecatedSinceKotlin annotation should be ordered so 'warningSince' <= 'errorSince' <= 'hiddenSince' if specified");
|
MAP.put(DEPRECATED_SINCE_KOTLIN_WITH_UNORDERED_VERSIONS, "Values of DeprecatedSinceKotlin annotation should be ordered so 'warningSince' <= 'errorSince' <= 'hiddenSince' if specified");
|
||||||
|
MAP.put(DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS, "DeprecatedSinceKotlin annotation should have at least one argument");
|
||||||
|
|
||||||
MAP.put(API_NOT_AVAILABLE, "This declaration is only available since Kotlin {0} and cannot be used with the specified API version {1}", STRING, STRING);
|
MAP.put(API_NOT_AVAILABLE, "This declaration is only available since Kotlin {0} and cannot be used with the specified API version {1}", STRING, STRING);
|
||||||
|
|
||||||
|
|||||||
+9
@@ -48,6 +48,15 @@ object DeprecatedSinceKotlinAnnotationChecker : DeclarationChecker {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (deprecatedSinceAnnotation.allValueArguments.isEmpty()) {
|
||||||
|
context.trace.report(
|
||||||
|
Errors.DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS.on(
|
||||||
|
deprecatedSinceAnnotationName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
fun AnnotationDescriptor.getCheckedSinceVersion(name: String) =
|
fun AnnotationDescriptor.getCheckedSinceVersion(name: String) =
|
||||||
getSinceVersion(name).also { checkVersion(it, name, context, deprecatedSinceAnnotationName) }
|
getSinceVersion(name).also { checkVersion(it, name, context, deprecatedSinceAnnotationName) }
|
||||||
|
|
||||||
|
|||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
@Deprecated("")
|
||||||
|
@DeprecatedSinceKotlin
|
||||||
|
fun foo() {}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
foo()
|
||||||
|
}
|
||||||
+1
-3
@@ -1,7 +1,5 @@
|
|||||||
// FIR_IDENTICAL
|
|
||||||
|
|
||||||
@Deprecated("")
|
@Deprecated("")
|
||||||
@DeprecatedSinceKotlin
|
@<!DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS!>DeprecatedSinceKotlin<!>
|
||||||
fun foo() {}
|
fun foo() {}
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
|
|||||||
Reference in New Issue
Block a user