Annotations/@hide consistent across defined types.
@hide was missing for enum.
Probably, we should have something like 'AidlCommentable' to unify
duplicated logic surrounding having comments (and whether they are
hidden).
Bug: 152655547
Test: m
Merged-In: I85c1976e5781f86c99cac610ab4e7b0950d46279
(cherry picked from commit a5d9c5c80348494fff4058c73b2de1665ea9955c)
Change-Id: I85c1976e5781f86c99cac610ab4e7b0950d46279
diff --git a/aidl_language.cpp b/aidl_language.cpp
index d3341b5..5beaea1 100644
--- a/aidl_language.cpp
+++ b/aidl_language.cpp
@@ -683,6 +683,13 @@
return GetPackage() + "." + GetName();
}
+void AidlDefinedType::DumpHeader(CodeWriter* writer) const {
+ if (this->IsHidden()) {
+ AddHideComment(writer);
+ }
+ DumpAnnotations(writer);
+}
+
AidlParcelable::AidlParcelable(const AidlLocation& location, AidlQualifiedName* name,
const std::vector<std::string>& package, const std::string& comments,
const std::string& cpp_header, std::vector<std::string>* type_params)
@@ -746,7 +753,7 @@
}
void AidlParcelable::Dump(CodeWriter* writer) const {
- DumpAnnotations(writer);
+ DumpHeader(writer);
writer->Write("parcelable %s ;\n", GetName().c_str());
}
@@ -757,10 +764,7 @@
variables_(std::move(*variables)) {}
void AidlStructuredParcelable::Dump(CodeWriter* writer) const {
- if (this->IsHidden()) {
- AddHideComment(writer);
- }
- DumpAnnotations(writer);
+ DumpHeader(writer);
writer->Write("parcelable %s {\n", GetName().c_str());
writer->Indent();
for (const auto& field : GetFields()) {
@@ -935,7 +939,7 @@
}
void AidlEnumDeclaration::Dump(CodeWriter* writer) const {
- DumpAnnotations(writer);
+ DumpHeader(writer);
writer->Write("enum %s {\n", GetName().c_str());
writer->Indent();
for (const auto& enumerator : GetEnumerators()) {
@@ -987,10 +991,7 @@
}
void AidlInterface::Dump(CodeWriter* writer) const {
- if (this->IsHidden()) {
- AddHideComment(writer);
- }
- DumpAnnotations(writer);
+ DumpHeader(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 32e45ae..7a40427 100644
--- a/aidl_language.h
+++ b/aidl_language.h
@@ -691,6 +691,7 @@
}
virtual void Dump(CodeWriter* writer) const = 0;
+ void DumpHeader(CodeWriter* writer) const;
private:
std::string name_;