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: N/A
Test: m android.hardware.vibrator-freeze-api (and API compiles)
Change-Id: 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()) {
diff --git a/aidl_language.h b/aidl_language.h
index b8ee857..ada8832 100644
--- a/aidl_language.h
+++ b/aidl_language.h
@@ -245,6 +245,8 @@
   bool IsSystemApi() const;
   bool IsStableApiParcelable(Options::Language lang) const;
 
+  void DumpAnnotations(CodeWriter* writer) const;
+
   const AidlAnnotation* UnsupportedAppUsage() const;
   const AidlTypeSpecifier* BackingType(const AidlTypenames& typenames) const;
   std::string ToString() const;