From 15a79f217a2abb493d470ea33ed6ad0e5d436147 Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Sun, 23 May 2021 07:18:58 +0900 Subject: dumpapi dumps generic type parameters dumpapi should dump generic type parameters as well. Bug: 188713899 Test: aidl_unittests Merged-In: I2d880dc095a91ef580caaa218f78775648992d5a Change-Id: I2d880dc095a91ef580caaa218f78775648992d5a (cherry picked from commit 71dfec349957d2db5af76576810b0ee325370e40) --- aidl_dumpapi.cpp | 6 +++++- aidl_unittest.cpp | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/aidl_dumpapi.cpp b/aidl_dumpapi.cpp index 6c7ef78f..c121f9f5 100644 --- a/aidl_dumpapi.cpp +++ b/aidl_dumpapi.cpp @@ -34,7 +34,11 @@ namespace aidl { void DumpVisitor::DumpType(const AidlDefinedType& dt, const string& type) { DumpComments(dt); DumpAnnotations(dt); - out << type << " " << dt.GetName() << " {\n"; + out << type << " " << dt.GetName(); + if (auto generic_type = dt.AsParameterizable(); generic_type && generic_type->IsGeneric()) { + out << "<" << Join(generic_type->GetTypeParameters(), ", ") << ">"; + } + out << " {\n"; out.Indent(); DumpMembers(dt); out.Dedent(); diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp index c3c04dfb..7ea8c171 100644 --- a/aidl_unittest.cpp +++ b/aidl_unittest.cpp @@ -1629,6 +1629,25 @@ TEST_F(AidlTest, ApiDumpWithEnumDefaultValues) { actual); } +TEST_F(AidlTest, ApiDumpWithGenerics) { + io_delegate_.SetFileContents("foo/bar/Foo.aidl", + "package foo.bar;\n" + "parcelable Foo {\n" + "}\n"); + + vector args = {"aidl", "--dumpapi", "-I . ", "-o dump", "foo/bar/Foo.aidl"}; + Options options = Options::From(args); + CaptureStderr(); + EXPECT_TRUE(dump_api(options, io_delegate_)); + EXPECT_EQ("", GetCapturedStderr()); + string actual; + EXPECT_TRUE(io_delegate_.GetWrittenContents("dump/foo/bar/Foo.aidl", &actual)); + EXPECT_EQ(string(kPreamble).append("package foo.bar;\n" + "parcelable Foo {\n" + "}\n"), + actual); +} + TEST_F(AidlTest, CheckNumGenericTypeSecifier) { const string expected_list_stderr = "ERROR: p/IFoo.aidl:1.37-41: List can only have one type parameter, but got: " -- cgit v1.2.3