Annotations for defined types in API dumps.
These already existed for enum types (because of @Backing), but we were
missing them for interface/parcelables where @VintfStability is needed.
Bug: 147496715
Test: m android.hardware.vibrator-freeze-api (and API compiles)
Change-Id: I15be062490fe451d1cdb368eaa2d2e92b6fcbd1b
(cherry picked from commit 7e4b9509e969f0216d107a268c5182aa8b9e44bc)
Merged-In: I15be062490fe451d1cdb368eaa2d2e92b6fcbd1b
diff --git a/aidl_language.cpp b/aidl_language.cpp
index c591c45..b5a2983 100644
--- a/aidl_language.cpp
+++ b/aidl_language.cpp
@@ -308,6 +308,12 @@
return HasAnnotation(annotations_, kJavaStableParcelable) && lang == Options::Language::JAVA;
}
+void AidlAnnotatable::DumpAnnotations(CodeWriter* writer) const {
+ if (annotations_.empty()) return;
+
+ writer->Write("%s\n", AidlAnnotatable::ToString().c_str());
+}
+
bool AidlAnnotatable::CheckValidAnnotations() const {
for (const auto& annotation : GetAnnotations()) {
if (!annotation.CheckValid()) {
@@ -740,6 +746,7 @@
}
void AidlParcelable::Dump(CodeWriter* writer) const {
+ DumpAnnotations(writer);
writer->Write("parcelable %s ;\n", GetName().c_str());
}
@@ -753,6 +760,7 @@
if (this->IsHidden()) {
AddHideComment(writer);
}
+ DumpAnnotations(writer);
writer->Write("parcelable %s {\n", GetName().c_str());
writer->Indent();
for (const auto& field : GetFields()) {
@@ -927,7 +935,7 @@
}
void AidlEnumDeclaration::Dump(CodeWriter* writer) const {
- writer->Write("%s\n", AidlAnnotatable::ToString().c_str());
+ DumpAnnotations(writer);
writer->Write("enum %s {\n", GetName().c_str());
writer->Indent();
for (const auto& enumerator : GetEnumerators()) {
@@ -982,6 +990,7 @@
if (this->IsHidden()) {
AddHideComment(writer);
}
+ DumpAnnotations(writer);
writer->Write("interface %s {\n", GetName().c_str());
writer->Indent();
for (const auto& method : GetMethods()) {