Add "required_parameters" to Annotation params
Some annotations must have a set of parameters. To model this
requirements, the schema for annotations has "required_parameters" now.
For example, @Backing for enum types should have "type" parameter even
though the annotation itself is optional.
AidlAnnotation::CheckValid() checks if there's no missing required
parameters.
Bug: none
Test: aidl_unittests
Change-Id: I50d82a1576f62bfdc2f220b66b7475cf74198e53
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index 413be99..a3de25f 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -3056,6 +3056,13 @@
EXPECT_EQ(AidlError::BAD_TYPE, error);
}
+TEST_P(AidlTest, BackingAnnotationRequireTypeParameter) {
+ const string expected_stderr = "ERROR: Enum.aidl:1.1-9: Missing 'type' on @Backing.\n";
+ CaptureStderr();
+ EXPECT_EQ(nullptr, Parse("Enum.aidl", "@Backing enum Enum { FOO }", typenames_, GetLanguage()));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
TEST_F(AidlTest, SupportJavaOnlyImmutableAnnotation) {
io_delegate_.SetFileContents("Foo.aidl",
"@JavaOnlyImmutable parcelable Foo { int a; Bar b; List<Bar> c; "