Emit "deprecated"

We've supported /** @deprecated note */ but it's passed to only the Java
backend as it is (as comments).

Now the deprecation is emitted properly according to the backend types.

- Java: @Deprecated + /** @deprecated note */
- C++/NDK: __attribute__((deprecated(note))
- Rust: #[deprecated = note]

For now, "note" is only available for the Java backend. Supporting
deprecation notes will be followed.

Bug: 174514415
Test: aidl_unittests / aidl_integration_test
Change-Id: Iefb216585d884b3195719c82748e573bb08922ab
Merged-In: Iefb216585d884b3195719c82748e573bb08922ab
Ignore-AOSP-First: topic with internal-only project
                  (packages/services/Car)
(cherry picked from commit ea571f8f53f30c08bc1b9a4ea02cb473522cbc9b)
diff --git a/aidl_language.h b/aidl_language.h
index 15428c4..2e5d3ce 100644
--- a/aidl_language.h
+++ b/aidl_language.h
@@ -351,8 +351,6 @@
 
   const string& GetUnresolvedName() const { return unresolved_name_; }
 
-  bool IsHidden() const;
-
   const string& GetComments() const { return comments_; }
 
   const std::vector<std::string> GetSplitName() const { return split_name_; }
@@ -430,6 +428,10 @@
     return const_cast<AidlVariableDeclaration*>(
         const_cast<const AidlMember*>(this)->AsVariableDeclaration());
   }
+
+  virtual const std::string& GetComments() const = 0;
+  bool IsHidden() const;
+  bool IsDeprecated() const;
 };
 
 // TODO: This class is used for method arguments and also parcelable fields,
@@ -450,6 +452,7 @@
   AidlVariableDeclaration& operator=(AidlVariableDeclaration&&) = delete;
 
   const AidlVariableDeclaration* AsVariableDeclaration() const override { return this; }
+  const std::string& GetComments() const override { return GetType().GetComments(); }
 
   std::string GetName() const { return name_; }
   std::string GetCapitalizedName() const;
@@ -767,6 +770,7 @@
   }
 
   const AidlConstantDeclaration* AsConstantDeclaration() const override { return this; }
+  const std::string& GetComments() const override { return GetType().GetComments(); }
 
   void TraverseChildren(std::function<void(const AidlNode&)> traverse) const override {
     traverse(GetType());
@@ -796,8 +800,7 @@
   AidlMethod& operator=(AidlMethod&&) = delete;
 
   const AidlMethod* AsMethod() const override { return this; }
-  bool IsHidden() const;
-  const string& GetComments() const { return comments_; }
+  const string& GetComments() const override { return comments_; }
   const AidlTypeSpecifier& GetType() const { return *type_; }
   AidlTypeSpecifier* GetMutableType() { return type_.get(); }
 
@@ -874,6 +877,7 @@
 
   const std::string& GetName() const { return name_; };
   bool IsHidden() const;
+  bool IsDeprecated() const;
   const std::string& GetComments() const { return comments_; }
   void SetComments(const std::string comments) { comments_ = comments; }