diff options
author | 2024-07-02 15:03:00 +0100 | |
---|---|---|
committer | 2024-07-02 15:19:01 +0100 | |
commit | ecb807b69b92f200ceefc8ab56eed303f8f86385 (patch) | |
tree | b30645ef8e22901e65d0471d3e24738bd353c6e2 /api/coverage/tools | |
parent | 58d9eab52455a344dc44a49d7f24452c0aa864a5 (diff) |
Simplify handling of nested classes
The `isInnerClass()` is being deprecated as it does not check if the
class is an "inner" class, i.e. a non-static "nested" class it only
checks to see if it is a "nested" class. The latter is what the code
wants but rather than try and synchronize code changes in this with
the Metalava update this change removes use of `isInnerClass()`
altogether and uses `containingClass()` instead of `parent()`. The
former will return non-null only for nested classes. The loop still
has the same behavior.
Bug: 325470146
Test: # Tested by making sure the following are unchanged by this.
# flag-api-mapping-PublicApi
# flag-api-mapping-SystemApi
# flag-api-mapping-ModuleLibApi
# flag-api-mapping-SystemServerApi
Change-Id: Ia3bfa101c9f81aacd4d769f09572d34849a6f9a6
Diffstat (limited to 'api/coverage/tools')
-rw-r--r-- | api/coverage/tools/ExtractFlaggedApis.kt | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/api/coverage/tools/ExtractFlaggedApis.kt b/api/coverage/tools/ExtractFlaggedApis.kt index 5efda98a1518..bf67187f4bad 100644 --- a/api/coverage/tools/ExtractFlaggedApis.kt +++ b/api/coverage/tools/ExtractFlaggedApis.kt @@ -75,10 +75,10 @@ fun addFlaggedApi(builder: FlagApiMap.Builder, api: JavaMethod.Builder, flag: St fun getClassFlag(classItem: ClassItem): String? { var classFlag = getFlagAnnotation(classItem) var cur = classItem - // If a class is not an inner class, use its @FlaggedApi annotation value. + // If a class is not a nested class, use its @FlaggedApi annotation value. // Otherwise, use the flag value of the closest outer class that is annotated by @FlaggedApi. - while (cur.isInnerClass() && classFlag == null) { - cur = cur.parent() as ClassItem + while (classFlag == null) { + cur = cur.containingClass() ?: break classFlag = getFlagAnnotation(cur) } return classFlag |