[Analysis API] add diagnostic tests on deprecated declarations

^KT-60996
This commit is contained in:
Dmitrii Gridin
2024-03-05 17:30:16 +01:00
committed by Space Team
parent 9cc2c22116
commit 805b7bc8f4
8 changed files with 189 additions and 0 deletions
@@ -76,6 +76,12 @@ public class Fe10IdeNormalAnalysisSourceModuleCollectDiagnosticsTestGenerated ex
runTest("analysis/analysis-api/testData/components/diagnosticsProvider/diagnostics/delegationToLibraryInterface.kt");
}
@Test
@TestMetadata("deprecationFromLibrary.kt")
public void testDeprecationFromLibrary() {
runTest("analysis/analysis-api/testData/components/diagnosticsProvider/diagnostics/deprecationFromLibrary.kt");
}
@Test
@TestMetadata("duplicatedCallableWithImplicitType.kt")
public void testDuplicatedCallableWithImplicitType() {
@@ -76,6 +76,12 @@ public class FirIdeNormalAnalysisSourceModuleCollectDiagnosticsTestGenerated ext
runTest("analysis/analysis-api/testData/components/diagnosticsProvider/diagnostics/delegationToLibraryInterface.kt");
}
@Test
@TestMetadata("deprecationFromLibrary.kt")
public void testDeprecationFromLibrary() {
runTest("analysis/analysis-api/testData/components/diagnosticsProvider/diagnostics/deprecationFromLibrary.kt");
}
@Test
@TestMetadata("duplicatedCallableWithImplicitType.kt")
public void testDuplicatedCallableWithImplicitType() {
@@ -76,6 +76,12 @@ public class FirIdeNormalAnalysisSourceModuleDanglingFileCollectDiagnosticsTestG
runTest("analysis/analysis-api/testData/components/diagnosticsProvider/diagnostics/delegationToLibraryInterface.kt");
}
@Test
@TestMetadata("deprecationFromLibrary.kt")
public void testDeprecationFromLibrary() {
runTest("analysis/analysis-api/testData/components/diagnosticsProvider/diagnostics/deprecationFromLibrary.kt");
}
@Test
@TestMetadata("duplicatedCallableWithImplicitType.kt")
public void testDuplicatedCallableWithImplicitType() {
@@ -76,6 +76,12 @@ public class FirStandaloneNormalAnalysisSourceModuleCollectDiagnosticsTestGenera
runTest("analysis/analysis-api/testData/components/diagnosticsProvider/diagnostics/delegationToLibraryInterface.kt");
}
@Test
@TestMetadata("deprecationFromLibrary.kt")
public void testDeprecationFromLibrary() {
runTest("analysis/analysis-api/testData/components/diagnosticsProvider/diagnostics/deprecationFromLibrary.kt");
}
@Test
@TestMetadata("duplicatedCallableWithImplicitType.kt")
public void testDuplicatedCallableWithImplicitType() {
@@ -76,6 +76,12 @@ public class FirStandaloneNormalAnalysisSourceModuleDanglingFileCollectDiagnosti
runTest("analysis/analysis-api/testData/components/diagnosticsProvider/diagnostics/delegationToLibraryInterface.kt");
}
@Test
@TestMetadata("deprecationFromLibrary.kt")
public void testDeprecationFromLibrary() {
runTest("analysis/analysis-api/testData/components/diagnosticsProvider/diagnostics/deprecationFromLibrary.kt");
}
@Test
@TestMetadata("duplicatedCallableWithImplicitType.kt")
public void testDuplicatedCallableWithImplicitType() {
@@ -0,0 +1,88 @@
// IGNORE_FE10
// MODULE: lib
// MODULE_KIND: LibraryBinary
// FILE: lib.kt
package one
@Deprecated("Deprecated class")
class MyDeprecatedClass {
@property:Deprecated("Deprecated property")
@get:Deprecated("Deprecated getter")
@set:Deprecated("Deprecated setter")
var deprecatedProperty: Int = 0
get() = field
set(value) {
field = value
}
@Deprecated("Deprecated function")
fun deprecatedFunction() {
}
@get:Deprecated("Deprecated getter")
@set:Deprecated("Deprecated setter")
var deprecatedAccessors: Int = 1
get() = field
set(value) {
field = value
}
}
typealias MyTypeAliasWithDeprecatedClass = MyDeprecatedClass
@Deprecated("Deprecated typealias")
typealias MyDeprecatedTypeAlias = Int
@property:Deprecated("Deprecated property")
@get:Deprecated("Deprecated getter")
@set:Deprecated("Deprecated setter")
var deprecatedProperty: Int = 2
get() = field
set(value) {
field = value
}
@get:Deprecated("Deprecated getter")
@set:Deprecated("Deprecated setter")
var deprecatedAccessors: Int = 3
get() = field
set(value) {
field = value
}
@Deprecated("Deprecated function")
fun deprecatedFunction() {
}
class MyClassWithDeprecatedConstructor @Deprecated("Deprecated constructor") constructor()
// MODULE: main(lib)
// FILE: usage.kt
package one
fun usage(
deprecatedClass: MyDeprecatedClass,
deprecatedTypealias: MyDeprecatedTypeAlias,
typealiasWithDeprecatedClass: MyTypeAliasWithDeprecatedClass,
) {
deprecatedClass.deprecatedProperty.toString()
deprecatedClass.deprecatedProperty = 1
deprecatedClass.deprecatedAccessors.toString()
deprecatedClass.deprecatedAccessors = 2
deprecatedClass.deprecatedFunction()
deprecatedProperty.toString()
deprecatedProperty = 3
deprecatedAccessors.toString()
deprecatedAccessors = 4
deprecatedFunction()
MyClassWithDeprecatedConstructor()
}
@@ -0,0 +1,43 @@
Diagnostics from elements:
for PSI element of type KtNameReferenceExpression at (71,21-39)
DEPRECATION text ranges: [(302,320)]
PSI: KtNameReferenceExpression at (71,21-39)
for PSI element of type KtNameReferenceExpression at (72,21-39)
DEPRECATION text ranges: [(352,370)]
PSI: KtNameReferenceExpression at (72,21-39)
for PSI element of type KtNameReferenceExpression at (74,21-40)
DEPRECATION text ranges: [(396,415)]
PSI: KtNameReferenceExpression at (74,21-40)
for PSI element of type KtNameReferenceExpression at (75,21-40)
DEPRECATION text ranges: [(447,466)]
PSI: KtNameReferenceExpression at (75,21-40)
for PSI element of type KtNameReferenceExpression at (77,21-39)
DEPRECATION text ranges: [(492,510)]
PSI: KtNameReferenceExpression at (77,21-39)
for PSI element of type KtNameReferenceExpression at (79,5-23)
DEPRECATION text ranges: [(518,536)]
PSI: KtNameReferenceExpression at (79,5-23)
for PSI element of type KtNameReferenceExpression at (80,5-23)
DEPRECATION text ranges: [(552,570)]
PSI: KtNameReferenceExpression at (80,5-23)
for PSI element of type KtNameReferenceExpression at (82,5-24)
DEPRECATION text ranges: [(580,599)]
PSI: KtNameReferenceExpression at (82,5-24)
for PSI element of type KtNameReferenceExpression at (83,5-24)
DEPRECATION text ranges: [(615,634)]
PSI: KtNameReferenceExpression at (83,5-24)
for PSI element of type KtNameReferenceExpression at (85,5-23)
DEPRECATION text ranges: [(644,662)]
PSI: KtNameReferenceExpression at (85,5-23)
for PSI element of type KtNameReferenceExpression at (87,5-37)
DEPRECATION text ranges: [(670,702)]
PSI: KtNameReferenceExpression at (87,5-37)
for PSI element of type KtTypeReference at (67,22-39)
DEPRECATION text ranges: [(145,162)]
PSI: KtTypeReference at (67,22-39)
for PSI element of type KtTypeReference at (68,26-47)
DEPRECATION text ranges: [(189,210)]
PSI: KtTypeReference at (68,26-47)
for PSI element of type KtTypeReference at (69,35-65)
TYPEALIAS_EXPANSION_DEPRECATION text ranges: [(246,276)]
PSI: KtTypeReference at (69,35-65)
@@ -0,0 +1,28 @@
Diagnostics from elements:
for PSI element of type KtNameReferenceExpression at (71,21-39)
DEPRECATION text ranges: [(302,320)]
PSI: KtNameReferenceExpression at (71,21-39)
for PSI element of type KtNameReferenceExpression at (72,21-39)
DEPRECATION text ranges: [(352,370)]
PSI: KtNameReferenceExpression at (72,21-39)
for PSI element of type KtNameReferenceExpression at (77,21-39)
DEPRECATION text ranges: [(492,510)]
PSI: KtNameReferenceExpression at (77,21-39)
for PSI element of type KtNameReferenceExpression at (79,5-23)
DEPRECATION text ranges: [(518,536)]
PSI: KtNameReferenceExpression at (79,5-23)
for PSI element of type KtNameReferenceExpression at (80,5-23)
DEPRECATION text ranges: [(552,570)]
PSI: KtNameReferenceExpression at (80,5-23)
for PSI element of type KtNameReferenceExpression at (85,5-23)
DEPRECATION text ranges: [(644,662)]
PSI: KtNameReferenceExpression at (85,5-23)
for PSI element of type KtNameReferenceExpression at (87,5-37)
DEPRECATION text ranges: [(670,702)]
PSI: KtNameReferenceExpression at (87,5-37)
for PSI element of type KtTypeReference at (67,22-39)
DEPRECATION text ranges: [(145,162)]
PSI: KtTypeReference at (67,22-39)
for PSI element of type KtTypeReference at (69,35-65)
TYPEALIAS_EXPANSION_DEPRECATION text ranges: [(246,276)]
PSI: KtTypeReference at (69,35-65)