[AA] KT-56617 Optimize deprecation calculation for Java class symbols

- Most Java classes aren't deprecated. To avoid building `firSymbol`
  in such cases, this commit adds a simple heuristic which checks the
  class's annotations for the presence of one of the deprecation
  annotations recognized by the Kotlin compiler.
- Note that annotations are compared via simple names, so there is a
  slight margin of error. However, comparing class IDs is more costly in
  my tests, because getting an annotation's class ID is not as cheap as
  getting its simple name.
This commit is contained in:
Marco Pennekamp
2023-03-01 20:52:40 +01:00
committed by Space Team
parent d5933f28ab
commit f9fb718b37
3 changed files with 39 additions and 20 deletions
@@ -178,6 +178,12 @@ private fun FirAnnotation.getDeprecationLevel(): DeprecationLevelValue? {
return DeprecationLevelValue.values().find { it.name == targetName }
}
val deprecationAnnotationSimpleNames: Set<String> = setOf(
StandardClassIds.Annotations.Deprecated.shortClassName.asString(),
StandardClassIds.Annotations.Java.Deprecated.shortClassName.asString(),
StandardClassIds.Annotations.SinceKotlin.shortClassName.asString(),
)
private fun List<FirAnnotation>.extractDeprecationAnnotationInfoPerUseSite(
session: FirSession, fromJava: Boolean
): DeprecationAnnotationInfoPerUseSiteStorage {