Rename AidlType to AidlTypeSpecifier

Bug: 110967839
Test: m -j
Test: system/tools/aidl/runtests.sh
Change-Id: I880007cef0bcf37f1529305d65b482981ee7f759
diff --git a/aidl_language.cpp b/aidl_language.cpp
index 873b572..c58b5ea 100644
--- a/aidl_language.cpp
+++ b/aidl_language.cpp
@@ -39,15 +39,15 @@
     : text_(text),
       comments_(comments) {}
 
-AidlType::AidlType(const std::string& simple_name, unsigned line, const std::string& comments,
-                   bool is_array)
+AidlTypeSpecifier::AidlTypeSpecifier(const std::string& simple_name, unsigned line,
+                                     const std::string& comments, bool is_array)
     : simple_name_(simple_name),
       name_(simple_name),
       line_(line),
       is_array_(is_array),
       comments_(comments) {}
 
-static std::string PrintTypeArgs(vector<unique_ptr<AidlType>>* type_params) {
+static std::string PrintTypeArgs(vector<unique_ptr<AidlTypeSpecifier>>* type_params) {
   if (type_params != nullptr) {
     std::vector<std::string> arg_names;
     for (const auto& ta : *type_params) {
@@ -59,8 +59,9 @@
   }
 }
 
-AidlType::AidlType(const std::string& simple_name, unsigned line, const std::string& comments,
-                   bool is_array, std::vector<std::unique_ptr<AidlType>>* type_params)
+AidlTypeSpecifier::AidlTypeSpecifier(const std::string& simple_name, unsigned line,
+                                     const std::string& comments, bool is_array,
+                                     std::vector<std::unique_ptr<AidlTypeSpecifier>>* type_params)
     : simple_name_(simple_name),
       name_(simple_name + PrintTypeArgs(type_params)),
       line_(line),
@@ -68,7 +69,7 @@
       comments_(comments),
       type_params_(std::move(*type_params)) {}
 
-string AidlType::ToString() const {
+string AidlTypeSpecifier::ToString() const {
   if (is_array_) {
     return GetName() + "[]";
   } else {
@@ -76,20 +77,21 @@
   }
 }
 
-AidlVariableDeclaration::AidlVariableDeclaration(AidlType* type, std::string name, unsigned line)
+AidlVariableDeclaration::AidlVariableDeclaration(AidlTypeSpecifier* type, std::string name,
+                                                 unsigned line)
     : type_(type), name_(name), line_(line) {}
 
 string AidlVariableDeclaration::ToString() const {
   return type_->ToString() + " " + name_;
 }
 
-AidlArgument::AidlArgument(AidlArgument::Direction direction, AidlType* type, std::string name,
-                           unsigned line)
+AidlArgument::AidlArgument(AidlArgument::Direction direction, AidlTypeSpecifier* type,
+                           std::string name, unsigned line)
     : AidlVariableDeclaration(type, name, line),
       direction_(direction),
       direction_specified_(true) {}
 
-AidlArgument::AidlArgument(AidlType* type, std::string name, unsigned line)
+AidlArgument::AidlArgument(AidlTypeSpecifier* type, std::string name, unsigned line)
     : AidlVariableDeclaration(type, name, line),
       direction_(AidlArgument::IN_DIR),
       direction_specified_(false) {}
@@ -157,9 +159,9 @@
   }
 }
 
-AidlMethod::AidlMethod(bool oneway, AidlType* type, std::string name,
-                       std::vector<std::unique_ptr<AidlArgument>>* args,
-                       unsigned line, const std::string& comments, int id)
+AidlMethod::AidlMethod(bool oneway, AidlTypeSpecifier* type, std::string name,
+                       std::vector<std::unique_ptr<AidlArgument>>* args, unsigned line,
+                       const std::string& comments, int id)
     : oneway_(oneway),
       comments_(comments),
       type_(type),
@@ -175,9 +177,9 @@
   }
 }
 
-AidlMethod::AidlMethod(bool oneway, AidlType* type, std::string name,
-                       std::vector<std::unique_ptr<AidlArgument>>* args,
-                       unsigned line, const std::string& comments)
+AidlMethod::AidlMethod(bool oneway, AidlTypeSpecifier* type, std::string name,
+                       std::vector<std::unique_ptr<AidlArgument>>* args, unsigned line,
+                       const std::string& comments)
     : AidlMethod(oneway, type, name, args, line, comments, 0) {
   has_id_ = false;
 }
@@ -187,11 +189,9 @@
   yylex_init(&scanner_);
 }
 
-AidlDefinedType::AidlDefinedType(std::string name, unsigned line,
-                                 const std::string& comments,
+AidlDefinedType::AidlDefinedType(std::string name, unsigned line, const std::string& comments,
                                  const std::vector<std::string>& package)
-    : AidlType(name, line, comments, false /*is_array*/),
-      package_(package) {}
+    : AidlTypeSpecifier(name, line, comments, false /*is_array*/), package_(package) {}
 
 std::string AidlDefinedType::GetPackage() const {
   return Join(package_, '.');
diff --git a/aidl_language.h b/aidl_language.h
index e48a3bc..ff7e452 100644
--- a/aidl_language.h
+++ b/aidl_language.h
@@ -76,13 +76,13 @@
   DISALLOW_COPY_AND_ASSIGN(AidlAnnotatable);
 };
 
-class AidlType : public AidlAnnotatable {
+class AidlTypeSpecifier : public AidlAnnotatable {
  public:
-  AidlType(const std::string& simple_name, unsigned line, const std::string& comments,
-           bool is_array);
-  AidlType(const std::string& simple_name, unsigned line, const std::string& comments,
-           bool is_array, std::vector<std::unique_ptr<AidlType>>* type_params);
-  virtual ~AidlType() = default;
+  AidlTypeSpecifier(const std::string& simple_name, unsigned line, const std::string& comments,
+                    bool is_array);
+  AidlTypeSpecifier(const std::string& simple_name, unsigned line, const std::string& comments,
+                    bool is_array, std::vector<std::unique_ptr<AidlTypeSpecifier>>* type_params);
+  virtual ~AidlTypeSpecifier() = default;
 
   // Name without the generic type parameters (e.g. List)
   const std::string& GetSimpleName() const { return simple_name_; }
@@ -103,7 +103,9 @@
     return reinterpret_cast<const T*>(language_type_);
   }
 
-  const std::vector<std::unique_ptr<AidlType>>& GetTypeParameters() const { return type_params_; }
+  const std::vector<std::unique_ptr<AidlTypeSpecifier>>& GetTypeParameters() const {
+    return type_params_;
+  }
 
  private:
   std::string simple_name_;
@@ -112,25 +114,25 @@
   bool is_array_;
   std::string comments_;
   const android::aidl::ValidatableType* language_type_ = nullptr;
-  const std::vector<std::unique_ptr<AidlType>> type_params_;
+  const std::vector<std::unique_ptr<AidlTypeSpecifier>> type_params_;
 
-  DISALLOW_COPY_AND_ASSIGN(AidlType);
+  DISALLOW_COPY_AND_ASSIGN(AidlTypeSpecifier);
 };
 
 class AidlVariableDeclaration : public AidlNode {
  public:
-  AidlVariableDeclaration(AidlType* type, std::string name, unsigned line);
+  AidlVariableDeclaration(AidlTypeSpecifier* type, std::string name, unsigned line);
   virtual ~AidlVariableDeclaration() = default;
 
   std::string GetName() const { return name_; }
   int GetLine() const { return line_; }
-  const AidlType& GetType() const { return *type_; }
-  AidlType* GetMutableType() { return type_.get(); }
+  const AidlTypeSpecifier& GetType() const { return *type_; }
+  AidlTypeSpecifier* GetMutableType() { return type_.get(); }
 
   std::string ToString() const;
 
  private:
-  std::unique_ptr<AidlType> type_;
+  std::unique_ptr<AidlTypeSpecifier> type_;
   std::string name_;
   unsigned line_;
 
@@ -141,9 +143,9 @@
  public:
   enum Direction { IN_DIR = 1, OUT_DIR = 2, INOUT_DIR = 3 };
 
-  AidlArgument(AidlArgument::Direction direction, AidlType* type,
-               std::string name, unsigned line);
-  AidlArgument(AidlType* type, std::string name, unsigned line);
+  AidlArgument(AidlArgument::Direction direction, AidlTypeSpecifier* type, std::string name,
+               unsigned line);
+  AidlArgument(AidlTypeSpecifier* type, std::string name, unsigned line);
   virtual ~AidlArgument() = default;
 
   Direction GetDirection() const { return direction_; }
@@ -217,19 +219,19 @@
 
 class AidlMethod : public AidlMember {
  public:
-  AidlMethod(bool oneway, AidlType* type, std::string name,
-             std::vector<std::unique_ptr<AidlArgument>>* args,
-             unsigned line, const std::string& comments);
-  AidlMethod(bool oneway, AidlType* type, std::string name,
-             std::vector<std::unique_ptr<AidlArgument>>* args,
-             unsigned line, const std::string& comments, int id);
+  AidlMethod(bool oneway, AidlTypeSpecifier* type, std::string name,
+             std::vector<std::unique_ptr<AidlArgument>>* args, unsigned line,
+             const std::string& comments);
+  AidlMethod(bool oneway, AidlTypeSpecifier* type, std::string name,
+             std::vector<std::unique_ptr<AidlArgument>>* args, unsigned line,
+             const std::string& comments, int id);
   virtual ~AidlMethod() = default;
 
   AidlMethod* AsMethod() override { return this; }
 
   const std::string& GetComments() const { return comments_; }
-  const AidlType& GetType() const { return *type_; }
-  AidlType* GetMutableType() { return type_.get(); }
+  const AidlTypeSpecifier& GetType() const { return *type_; }
+  AidlTypeSpecifier* GetMutableType() { return type_.get(); }
   bool IsOneway() const { return oneway_; }
   const std::string& GetName() const { return name_; }
   unsigned GetLine() const { return line_; }
@@ -253,7 +255,7 @@
  private:
   bool oneway_;
   std::string comments_;
-  std::unique_ptr<AidlType> type_;
+  std::unique_ptr<AidlTypeSpecifier> type_;
   std::string name_;
   unsigned line_;
   const std::vector<std::unique_ptr<AidlArgument>> arguments_;
@@ -308,7 +310,7 @@
   DISALLOW_COPY_AND_ASSIGN(AidlQualifiedName);
 };
 
-class AidlDefinedType : public AidlType {
+class AidlDefinedType : public AidlTypeSpecifier {
  public:
   AidlDefinedType(std::string name, unsigned line,
                   const std::string& comments,
diff --git a/aidl_language_y.yy b/aidl_language_y.yy
index f69b4a3..076aa47 100644
--- a/aidl_language_y.yy
+++ b/aidl_language_y.yy
@@ -27,10 +27,10 @@
     AidlToken* token;
     int integer;
     std::string *str;
-    AidlType::Annotation annotation;
-    AidlType::Annotation annotation_list;
-    AidlType* type;
-    AidlType* unannotated_type;
+    AidlTypeSpecifier::Annotation annotation;
+    AidlTypeSpecifier::Annotation annotation_list;
+    AidlTypeSpecifier* type;
+    AidlTypeSpecifier* unannotated_type;
     AidlArgument* arg;
     AidlArgument::Direction direction;
     std::vector<std::unique_ptr<AidlArgument>>* arg_list;
@@ -44,7 +44,7 @@
     AidlParcelable* parcelable;
     AidlDefinedType* declaration;
     AidlDocument* declaration_list;
-    std::vector<std::unique_ptr<AidlType>>* type_args;
+    std::vector<std::unique_ptr<AidlTypeSpecifier>>* type_args;
 }
 
 %token<token> ANNOTATION "annotation"
@@ -305,16 +305,16 @@
 
 unannotated_type
  : qualified_name {
-    $$ = new AidlType($1->GetDotName(), @1.begin.line, $1->GetComments(), false);
+    $$ = new AidlTypeSpecifier($1->GetDotName(), @1.begin.line, $1->GetComments(), false);
     delete $1;
   }
  | qualified_name '[' ']' {
-    $$ = new AidlType($1->GetDotName(), @1.begin.line, $1->GetComments(),
+    $$ = new AidlTypeSpecifier($1->GetDotName(), @1.begin.line, $1->GetComments(),
                       true);
     delete $1;
   }
  | qualified_name '<' type_args '>' {
-    $$ = new AidlType($1->GetDotName(), @1.begin.line,
+    $$ = new AidlTypeSpecifier($1->GetDotName(), @1.begin.line,
                       $1->GetComments(), false, $3);
     delete $1;
   };
@@ -327,7 +327,7 @@
 
 type_args
  : unannotated_type {
-    $$ = new std::vector<std::unique_ptr<AidlType>>();
+    $$ = new std::vector<std::unique_ptr<AidlTypeSpecifier>>();
     $$->emplace_back($1);
   }
  | type_args ',' unannotated_type {
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index 3a59816..1249470 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -213,7 +213,7 @@
   EXPECT_TRUE(java_types_.HasTypeByCanonicalName("one.IBar"));
   EXPECT_TRUE(java_types_.HasTypeByCanonicalName("another.IBar"));
   // But if we request just "IBar" we should get our imported one.
-  AidlType ambiguous_type("IBar", 0, "", false /* not an array */);
+  AidlTypeSpecifier ambiguous_type("IBar", 0, "", false /* not an array */);
   const java::Type* type = java_types_.Find(ambiguous_type);
   ASSERT_TRUE(type);
   EXPECT_EQ("one.IBar", type->CanonicalName());
diff --git a/type_java_unittest.cpp b/type_java_unittest.cpp
index 78479e6..fd0b77b 100644
--- a/type_java_unittest.cpp
+++ b/type_java_unittest.cpp
@@ -53,9 +53,10 @@
   EXPECT_TRUE(types_.HasTypeByCanonicalName("a.goog.Foo"));
   EXPECT_FALSE(types_.HasTypeByCanonicalName("java.util.List<a.goog.Foo>"));
   // But after we add the list explicitly...
-  std::vector<std::unique_ptr<AidlType>>* type_args = new std::vector<std::unique_ptr<AidlType>>();
-  type_args->emplace_back(new AidlType("Foo", 0, "", false));
-  AidlType container_type("List", 0, "", false /* not array */, type_args);
+  std::vector<std::unique_ptr<AidlTypeSpecifier>>* type_args =
+      new std::vector<std::unique_ptr<AidlTypeSpecifier>>();
+  type_args->emplace_back(new AidlTypeSpecifier("Foo", 0, "", false));
+  AidlTypeSpecifier container_type("List", 0, "", false /* not array */, type_args);
   EXPECT_TRUE(types_.MaybeAddContainerType(container_type));
   // This should work.
   EXPECT_TRUE(types_.HasTypeByCanonicalName("java.util.List<a.goog.Foo>"));
diff --git a/type_namespace.cpp b/type_namespace.cpp
index 06695c6..f578160 100644
--- a/type_namespace.cpp
+++ b/type_namespace.cpp
@@ -97,7 +97,7 @@
   return true;
 }
 
-const ValidatableType* TypeNamespace::GetReturnType(const AidlType& raw_type,
+const ValidatableType* TypeNamespace::GetReturnType(const AidlTypeSpecifier& raw_type,
                                                     const string& filename,
                                                     const AidlDefinedType& context) const {
   string error_msg;
diff --git a/type_namespace.h b/type_namespace.h
index d60657b..68ad1ed 100644
--- a/type_namespace.h
+++ b/type_namespace.h
@@ -102,7 +102,7 @@
                              const std::string& filename) = 0;
   // Add a container type to this namespace.  Returns false only
   // on error. Silently discards requests to add non-container types.
-  virtual bool MaybeAddContainerType(const AidlType& aidl_type) = 0;
+  virtual bool MaybeAddContainerType(const AidlTypeSpecifier& aidl_type) = 0;
 
   // Returns true iff this has a type for |import|.
   virtual bool HasImportType(const AidlImport& import) const = 0;
@@ -112,7 +112,7 @@
 
   // Returns a pointer to a type corresponding to |raw_type| or nullptr
   // if this is an invalid return type.
-  virtual const ValidatableType* GetReturnType(const AidlType& raw_type,
+  virtual const ValidatableType* GetReturnType(const AidlTypeSpecifier& raw_type,
                                                const std::string& filename,
                                                const AidlDefinedType& context) const;
 
@@ -129,7 +129,8 @@
   TypeNamespace() = default;
   virtual ~TypeNamespace() = default;
 
-  virtual const ValidatableType* GetValidatableType(const AidlType& type, std::string* error_msg,
+  virtual const ValidatableType* GetValidatableType(const AidlTypeSpecifier& type,
+                                                    std::string* error_msg,
                                                     const AidlDefinedType& context) const = 0;
 
  private:
@@ -144,7 +145,7 @@
 
   // Get a pointer to an existing type.  Searches first by fully-qualified
   // name, and then class name (dropping package qualifiers).
-  const T* Find(const AidlType& aidl_type) const;
+  const T* Find(const AidlTypeSpecifier& aidl_type) const;
 
   // Find a type by its |name|.  If |name| refers to a container type (e.g.
   // List<String>) you must turn it into a canonical name first (e.g.
@@ -160,7 +161,7 @@
     return FindTypeByCanonicalName(defined_type.GetCanonicalName());
   }
 
-  bool MaybeAddContainerType(const AidlType& aidl_type) override;
+  bool MaybeAddContainerType(const AidlTypeSpecifier& aidl_type) override;
   // We dynamically create container types as we discover them in the parse
   // tree.  Returns false if the contained types cannot be canonicalized.
   virtual bool AddListType(const std::string& contained_type_name) = 0;
@@ -172,15 +173,14 @@
 
  private:
   // Returns true iff the name can be canonicalized to a container type.
-  virtual bool CanonicalizeContainerType(
-      const AidlType& aidl_type,
-      std::vector<std::string>* container_class,
-      std::vector<std::string>* contained_type_names) const;
+  virtual bool CanonicalizeContainerType(const AidlTypeSpecifier& aidl_type,
+                                         std::vector<std::string>* container_class,
+                                         std::vector<std::string>* contained_type_names) const;
 
   // Returns true if this is a container type, rather than a normal type.
   bool IsContainerType(const std::string& type_name) const;
 
-  const ValidatableType* GetValidatableType(const AidlType& type, std::string* error_msg,
+  const ValidatableType* GetValidatableType(const AidlTypeSpecifier& type, std::string* error_msg,
                                             const AidlDefinedType& context) const override;
 
   std::vector<std::unique_ptr<const T>> types_;
@@ -216,8 +216,8 @@
   return true;
 }
 
-template<typename T>
-const T* LanguageTypeNamespace<T>::Find(const AidlType& aidl_type) const {
+template <typename T>
+const T* LanguageTypeNamespace<T>::Find(const AidlTypeSpecifier& aidl_type) const {
   using std::string;
   using std::vector;
   using android::base::Join;
@@ -261,9 +261,8 @@
   return ret;
 }
 
-template<typename T>
-bool LanguageTypeNamespace<T>::MaybeAddContainerType(
-    const AidlType& aidl_type) {
+template <typename T>
+bool LanguageTypeNamespace<T>::MaybeAddContainerType(const AidlTypeSpecifier& aidl_type) {
   using android::base::Join;
 
   const std::string& type_name = aidl_type.GetName();
@@ -311,10 +310,9 @@
   return false;
 }
 
-template<typename T>
+template <typename T>
 bool LanguageTypeNamespace<T>::CanonicalizeContainerType(
-    const AidlType& aidl_type,
-    std::vector<std::string>* container_class,
+    const AidlTypeSpecifier& aidl_type, std::vector<std::string>* container_class,
     std::vector<std::string>* contained_type_names) const {
   std::string container = aidl_type.GetSimpleName();
   std::vector<std::string> args;
@@ -365,7 +363,8 @@
 
 template <typename T>
 const ValidatableType* LanguageTypeNamespace<T>::GetValidatableType(
-    const AidlType& aidl_type, std::string* error_msg, const AidlDefinedType& context) const {
+    const AidlTypeSpecifier& aidl_type, std::string* error_msg,
+    const AidlDefinedType& context) const {
   using android::base::StringPrintf;
 
   const ValidatableType* type = Find(aidl_type);