aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2021-05-27 01:10:08 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2021-05-27 01:10:08 +0000
commitd3f3d44b10d5121efb93a4274db0ad5d29723c10 (patch)
tree63572c2de561cdf2ffed86ef242f31940c674aa7
parent5253cb0f381e223d635a25eec1437938af2c3ccc (diff)
parent8ed3e829a862cabe577898a0df3b6c8271823b04 (diff)
downloadaidl-d3f3d44b10d5121efb93a4274db0ad5d29723c10.tar.gz
Snap for 7401515 from 8ed3e829a862cabe577898a0df3b6c8271823b04 to sc-d2-release
Change-Id: I4f7e129c0fd47b0812c15cf1451ed28081dcc415
-rw-r--r--aidl_dumpapi.cpp6
-rw-r--r--aidl_unittest.cpp19
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: "