diff options
author | Jooyung Han <jooyung@google.com> | 2021-05-25 23:00:53 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-05-25 23:00:53 +0000 |
commit | f76788871b025fc394ae0907d66508c0c74e00f7 (patch) | |
tree | 63572c2de561cdf2ffed86ef242f31940c674aa7 | |
parent | fc3ef0412a943b6d608105b866c35bc0895d9e4f (diff) | |
parent | 15a79f217a2abb493d470ea33ed6ad0e5d436147 (diff) | |
download | aidl-f76788871b025fc394ae0907d66508c0c74e00f7.tar.gz |
dumpapi dumps generic type parameters am: 15a79f217a
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/tools/aidl/+/14702399
Change-Id: Iafd5f26c223f71fda9e9ca3f0c2aa0e0b85b089c
-rw-r--r-- | aidl_dumpapi.cpp | 6 | ||||
-rw-r--r-- | aidl_unittest.cpp | 19 |
2 files changed, 24 insertions, 1 deletions
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<T, U> {\n" + "}\n"); + + vector<string> 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<T, U> {\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: " |