Support annotations for 'const'

It was not supported and people use type-level annotations as a
workaround even when the annotations are meant to annotate constants.

  const @Annotation... int foo = 0;

Now we can annotate constants like following.

  @Annotation... const int foo = 0;

Bug: 174436374
Test: aidl_unittests
Change-Id: I5481de6ac48711765fcd7e1726003267360ba9e6
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index 3880f79..4d77f84 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -1542,6 +1542,22 @@
   EXPECT_EQ("", GetCapturedStderr());
 }
 
+TEST_F(AidlTest, ConstantsWithAnnotations) {
+  io_delegate_.SetFileContents("IFoo.aidl",
+                               "interface IFoo {\n"
+                               " @JavaPassthrough(annotation=\"@Foo\")\n"
+                               " const @JavaPassthrough(annotation=\"@Bar\") int FOO = 0;\n"
+                               "}");
+  Options options = Options::From("aidl IFoo.aidl --lang=java -o out");
+  CaptureStderr();
+  EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ("", GetCapturedStderr());
+  string code;
+  EXPECT_TRUE(io_delegate_.GetWrittenContents("out/IFoo.java", &code));
+  EXPECT_THAT(code, HasSubstr("@Foo\n"));
+  EXPECT_THAT(code, HasSubstr("@Bar\n"));
+}
+
 TEST_F(AidlTest, ApiDump) {
   io_delegate_.SetFileContents(
       "foo/bar/IFoo.aidl",