DEPRECATED_ERROR supported
This commit is contained in:
@@ -241,6 +241,7 @@ public interface Errors {
|
||||
DiagnosticFactory0<JetObjectDeclaration> MANY_COMPANION_OBJECTS = DiagnosticFactory0.create(ERROR, COMPANION_OBJECT);
|
||||
|
||||
DiagnosticFactory2<PsiElement, DeclarationDescriptor, String> DEPRECATION = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<PsiElement, DeclarationDescriptor, String> DEPRECATION_ERROR = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
// Objects
|
||||
|
||||
|
||||
+1
@@ -293,6 +293,7 @@ public class DefaultErrorMessages {
|
||||
MAP.put(MANY_COMPANION_OBJECTS, "Only one companion object is allowed per class");
|
||||
|
||||
MAP.put(DEPRECATION, "''{0}'' is deprecated. {1}", DEPRECATION_RENDERER, STRING);
|
||||
MAP.put(DEPRECATION_ERROR, "Using ''{0}'' is an error. {1}", DEPRECATION_RENDERER, STRING);
|
||||
|
||||
MAP.put(LOCAL_OBJECT_NOT_ALLOWED, "Named object ''{0}'' is a singleton and cannot be local. Try to use anonymous object instead", NAME);
|
||||
MAP.put(LOCAL_INTERFACE_NOT_ALLOWED, "''{0}'' is an interface so it cannot be local. Try to use anonymous object or abstract class instead", NAME);
|
||||
|
||||
+6
@@ -117,6 +117,12 @@ public class DeprecatedSymbolValidator : SymbolUsageValidator {
|
||||
|
||||
private fun createDeprecationDiagnostic(element: PsiElement, descriptor: DeclarationDescriptor, deprecated: AnnotationDescriptor): Diagnostic {
|
||||
val message = deprecated.argumentValue("message") as? String ?: ""
|
||||
val level = deprecated.argumentValue("level") as? ClassDescriptor
|
||||
|
||||
if (level?.name?.asString() == "ERROR") {
|
||||
return Errors.DEPRECATION_ERROR.on(element, descriptor.original, message)
|
||||
}
|
||||
|
||||
return Errors.DEPRECATION.on(element, descriptor.original, message)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
@Deprecated("alas", level = DeprecationLevel.ERROR)
|
||||
fun foo() {}
|
||||
|
||||
@Deprecated("alas", level = DeprecationLevel.ERROR)
|
||||
class C
|
||||
|
||||
fun test(c: <!DEPRECATION_ERROR!>C<!>) {
|
||||
<!DEPRECATION_ERROR!>foo<!>()
|
||||
<!DEPRECATION_ERROR!>C<!>()
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package
|
||||
|
||||
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "alas") public fun foo(): kotlin.Unit
|
||||
public fun test(/*0*/ c: C): kotlin.Unit
|
||||
|
||||
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "alas") public final class C {
|
||||
public constructor C()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
class Table
|
||||
class Tr
|
||||
|
||||
fun table(body: Table.() -> Unit) {}
|
||||
fun Table.tr(body: Tr.() -> Unit) {}
|
||||
@Deprecated("Don't call me", level = DeprecationLevel.ERROR)
|
||||
fun Tr.tr(body: Tr.() -> Unit) {}
|
||||
|
||||
fun builderTest() {
|
||||
table {
|
||||
tr {
|
||||
<!DEPRECATION_ERROR!>tr<!> {}
|
||||
table {
|
||||
tr {
|
||||
<!DEPRECATION_ERROR!>tr<!> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package
|
||||
|
||||
public fun builderTest(): kotlin.Unit
|
||||
public fun table(/*0*/ body: Table.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun Table.tr(/*0*/ body: Tr.() -> kotlin.Unit): kotlin.Unit
|
||||
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Don't call me") public fun Tr.tr(/*0*/ body: Tr.() -> kotlin.Unit): kotlin.Unit
|
||||
|
||||
public final class Table {
|
||||
public constructor Table()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Tr {
|
||||
public constructor Tr()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -4647,6 +4647,18 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("deprecatedError.kt")
|
||||
public void testDeprecatedError() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/deprecated/deprecatedError.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("deprecatedErrorBuilder.kt")
|
||||
public void testDeprecatedErrorBuilder() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/deprecated/deprecatedErrorBuilder.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("functionUsage.kt")
|
||||
public void testFunctionUsage() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/deprecated/functionUsage.kt");
|
||||
|
||||
Reference in New Issue
Block a user