[fidlc] s/TypeParameter/LayoutParameter

This better reflects the correct terminology according to
https://fuchsia.dev/fuchsia-src/reference/fidl/language/lexicon?hl=en#type-terms

Change-Id: If5091a91a9c47ec65e23f06e17f3e5faddb6edeb
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/513480
Commit-Queue: Felix Zhu <fcz@google.com>
Reviewed-by: Alex Zaslavsky <azaslavsky@google.com>
diff --git a/tools/fidl/fidlc/include/fidl/diagnostics.h b/tools/fidl/fidlc/include/fidl/diagnostics.h
index c8a5d5a..bedd7e9 100644
--- a/tools/fidl/fidlc/include/fidl/diagnostics.h
+++ b/tools/fidl/fidlc/include/fidl/diagnostics.h
@@ -44,7 +44,7 @@
     "lists of constraints must be enclosed in brackets");
 constexpr ErrorDef ErrUnnecessaryConstraintBrackets(
     "single constraints must not be enclosed in brackets");
-constexpr ErrorDef ErrEmptyTypeParameterList("no type parameters specified");
+constexpr ErrorDef ErrEmptyLayoutParameterList("no layout parameters specified");
 // end new_syntax
 
 // TODO(fxbug.dev/65978): This is a misnomer in the new syntax: the ordinal comes
diff --git a/tools/fidl/fidlc/include/fidl/parser.h b/tools/fidl/fidlc/include/fidl/parser.h
index 9ec823ed..e2e6dd6 100644
--- a/tools/fidl/fidlc/include/fidl/parser.h
+++ b/tools/fidl/fidlc/include/fidl/parser.h
@@ -339,8 +339,8 @@
   // TODO(fxbug.dev/70247): Consolidate the ParseFoo methods.
   // --- new syntax ---
 
-  std::unique_ptr<raw::TypeParameter> ParseTypeParameter();
-  std::unique_ptr<raw::TypeParameterList> MaybeParseTypeParameterList();
+  std::unique_ptr<raw::LayoutParameter> ParseLayoutParameter();
+  std::unique_ptr<raw::LayoutParameterList> MaybeParseLayoutParameterList();
   std::unique_ptr<raw::TypeConstraints> ParseConstraints();
   std::unique_ptr<raw::LayoutMember> ParseLayoutMember(raw::LayoutMember::Kind);
   std::unique_ptr<raw::Layout> ParseLayout(ASTScope&, const Modifiers&,
diff --git a/tools/fidl/fidlc/include/fidl/raw_ast.h b/tools/fidl/fidlc/include/fidl/raw_ast.h
index 0c56a6e..ce7620b 100644
--- a/tools/fidl/fidlc/include/fidl/raw_ast.h
+++ b/tools/fidl/fidlc/include/fidl/raw_ast.h
@@ -290,13 +290,13 @@
 };
 
 class LayoutReference;
-class TypeParameterList;
+class LayoutParameterList;
 class TypeConstraints;
 
 class TypeConstructorNew final : public SourceElement {
  public:
   TypeConstructorNew(SourceElement const& element, std::unique_ptr<LayoutReference> layout_ref,
-                     std::unique_ptr<TypeParameterList> parameters,
+                     std::unique_ptr<LayoutParameterList> parameters,
                      std::unique_ptr<TypeConstraints> constraints)
       : SourceElement(element),
         layout_ref(std::move(layout_ref)),
@@ -306,7 +306,7 @@
   void Accept(TreeVisitor* visitor) const;
 
   std::unique_ptr<LayoutReference> layout_ref;
-  std::unique_ptr<TypeParameterList> parameters;
+  std::unique_ptr<LayoutParameterList> parameters;
   std::unique_ptr<TypeConstraints> constraints;
 };
 
@@ -901,7 +901,7 @@
   std::unique_ptr<CompoundIdentifier> identifier;
 };
 
-class TypeParameter : public SourceElement {
+class LayoutParameter : public SourceElement {
  public:
   enum Kind {
     kAmbiguous,
@@ -909,55 +909,55 @@
     kType,
   };
 
-  TypeParameter(SourceElement const& element, Kind kind) : SourceElement(element), kind(kind) {}
+  LayoutParameter(SourceElement const& element, Kind kind) : SourceElement(element), kind(kind) {}
 
   void Accept(TreeVisitor* visitor) const;
 
   const Kind kind;
 };
 
-class LiteralTypeParameter final : public TypeParameter {
+class LiteralLayoutParameter final : public LayoutParameter {
  public:
-  explicit LiteralTypeParameter(SourceElement const& element,
-                                std::unique_ptr<LiteralConstant> literal)
-      : TypeParameter(element, Kind::kLiteral), literal(std::move(literal)) {}
+  explicit LiteralLayoutParameter(SourceElement const& element,
+                                  std::unique_ptr<LiteralConstant> literal)
+      : LayoutParameter(element, Kind::kLiteral), literal(std::move(literal)) {}
 
   void Accept(TreeVisitor* visitor) const;
 
   std::unique_ptr<LiteralConstant> literal;
 };
 
-class TypeTypeParameter final : public TypeParameter {
+class TypeLayoutParameter final : public LayoutParameter {
  public:
-  explicit TypeTypeParameter(SourceElement const& element,
-                             std::unique_ptr<TypeConstructorNew> type_ctor)
-      : TypeParameter(element, Kind::kType), type_ctor(std::move(type_ctor)) {}
+  explicit TypeLayoutParameter(SourceElement const& element,
+                               std::unique_ptr<TypeConstructorNew> type_ctor)
+      : LayoutParameter(element, Kind::kType), type_ctor(std::move(type_ctor)) {}
 
   void Accept(TreeVisitor* visitor) const;
 
   std::unique_ptr<TypeConstructorNew> type_ctor;
 };
 
-class AmbiguousTypeParameter final : public TypeParameter {
+class AmbiguousLayoutParameter final : public LayoutParameter {
  public:
-  explicit AmbiguousTypeParameter(SourceElement const& element,
-                                  std::unique_ptr<CompoundIdentifier> identifier)
-      : TypeParameter(element, Kind::kAmbiguous), identifier(std::move(identifier)) {}
+  explicit AmbiguousLayoutParameter(SourceElement const& element,
+                                    std::unique_ptr<CompoundIdentifier> identifier)
+      : LayoutParameter(element, Kind::kAmbiguous), identifier(std::move(identifier)) {}
 
   void Accept(TreeVisitor* visitor) const;
 
   std::unique_ptr<CompoundIdentifier> identifier;
 };
 
-class TypeParameterList final : public SourceElement {
+class LayoutParameterList final : public SourceElement {
  public:
-  TypeParameterList(SourceElement const& element,
-                    std::vector<std::unique_ptr<raw::TypeParameter>> items)
+  LayoutParameterList(SourceElement const& element,
+                      std::vector<std::unique_ptr<raw::LayoutParameter>> items)
       : SourceElement(element), items(std::move(items)) {}
 
   void Accept(TreeVisitor* visitor) const;
 
-  std::vector<std::unique_ptr<raw::TypeParameter>> items;
+  std::vector<std::unique_ptr<raw::LayoutParameter>> items;
 };
 
 class TypeConstraints final : public SourceElement {
diff --git a/tools/fidl/fidlc/lib/flat_ast.cc b/tools/fidl/fidlc/lib/flat_ast.cc
index 9ab0e61..12a3f6e 100644
--- a/tools/fidl/fidlc/lib/flat_ast.cc
+++ b/tools/fidl/fidlc/lib/flat_ast.cc
@@ -2148,7 +2148,7 @@
     // That means the logic here can be very simple (for now): assume the first type parameter is
     // always a maybe_type_ctor, and the second (if it exists) is a maybe_size.
     auto builtin = span.data();
-    std::unique_ptr<raw::TypeParameter> param;
+    std::unique_ptr<raw::LayoutParameter> param;
     if (params->items.size() >= 1) {
       // Because all of the generic types we have today only take at most one nested type, it is
       // okay to pass the name context through like this.  If we ever introduce generic types
@@ -2159,15 +2159,15 @@
       auto name = Name::CreateDerived(this, span, context.full_name());
 
       switch (param->kind) {
-        case raw::TypeParameter::Kind::kType: {
-          auto type_param = static_cast<raw::TypeTypeParameter*>(param.get());
+        case raw::LayoutParameter::Kind::kType: {
+          auto type_param = static_cast<raw::TypeLayoutParameter*>(param.get());
           if (!ConsumeTypeConstructorNew(std::move(type_param->type_ctor), name,
                                          &type_ctor->maybe_arg_type_ctor))
             return false;
           break;
         }
-        case raw::TypeParameter::Kind::kAmbiguous: {
-          auto type_param = static_cast<raw::AmbiguousTypeParameter*>(param.get());
+        case raw::LayoutParameter::Kind::kAmbiguous: {
+          auto type_param = static_cast<raw::AmbiguousLayoutParameter*>(param.get());
           auto inner_name = Name::CreateSourced(this, type_param->identifier->span());
           type_ctor->maybe_arg_type_ctor = std::make_unique<TypeConstructor>(
               inner_name,
@@ -2177,7 +2177,7 @@
               /*maybe_size=*/nullptr, types::Nullability::kNonnullable, fidl::utils::Syntax::kNew);
           break;
         }
-        case raw::TypeParameter::Kind::kLiteral: {
+        case raw::LayoutParameter::Kind::kLiteral: {
           assert(false && "the first type parameter must be a type, not a value");
           break;
         }
@@ -2186,14 +2186,14 @@
     if (builtin == "array" && params->items.size() >= 2) {
       param = std::move(params->items[1]);
       switch (param->kind) {
-        case raw::TypeParameter::Kind::kAmbiguous: {
-          auto type_param = static_cast<raw::AmbiguousTypeParameter*>(param.get());
+        case raw::LayoutParameter::Kind::kAmbiguous: {
+          auto type_param = static_cast<raw::AmbiguousLayoutParameter*>(param.get());
           type_ctor->maybe_size = std::make_unique<Constant>(Constant::Kind::kIdentifier,
                                                              type_param->identifier->span());
           break;
         }
-        case raw::TypeParameter::Kind::kLiteral: {
-          auto type_param = static_cast<raw::LiteralTypeParameter*>(param.get());
+        case raw::LayoutParameter::Kind::kLiteral: {
+          auto type_param = static_cast<raw::LiteralLayoutParameter*>(param.get());
           ConsumeConstant(std::move(type_param->literal), &type_ctor->maybe_size);
           break;
         }
diff --git a/tools/fidl/fidlc/lib/parser.cc b/tools/fidl/fidlc/lib/parser.cc
index 0ab873b..9803bcf 100644
--- a/tools/fidl/fidlc/lib/parser.cc
+++ b/tools/fidl/fidlc/lib/parser.cc
@@ -1691,7 +1691,7 @@
       std::move(comment_tokens_), fidl::utils::Syntax::kOld);
 }
 
-std::unique_ptr<raw::TypeParameter> Parser::ParseTypeParameter() {
+std::unique_ptr<raw::LayoutParameter> Parser::ParseLayoutParameter() {
   ASTScope scope(this);
 
   switch (Peek().combined()) {
@@ -1700,8 +1700,8 @@
     if (!Ok())
       return Fail();
     auto constant = std::make_unique<raw::LiteralConstant>(std::move(literal));
-    return std::make_unique<raw::LiteralTypeParameter>(scope.GetSourceElement(),
-                                                       std::move(constant));
+    return std::make_unique<raw::LiteralLayoutParameter>(scope.GetSourceElement(),
+                                                         std::move(constant));
   }
   default: {
     auto type_ctor = ParseTypeConstructorNew();
@@ -1716,23 +1716,24 @@
     if (type_ctor->layout_ref->kind == raw::LayoutReference::Kind::kNamed &&
         type_ctor->parameters == nullptr && type_ctor->constraints == nullptr) {
       auto named_ref = static_cast<raw::NamedLayoutReference*>(type_ctor->layout_ref.get());
-      return std::make_unique<raw::AmbiguousTypeParameter>(scope.GetSourceElement(),
-                                                           std::move(named_ref->identifier));
+      return std::make_unique<raw::AmbiguousLayoutParameter>(scope.GetSourceElement(),
+                                                             std::move(named_ref->identifier));
     }
-    return std::make_unique<raw::TypeTypeParameter>(scope.GetSourceElement(), std::move(type_ctor));
+    return std::make_unique<raw::TypeLayoutParameter>(scope.GetSourceElement(),
+                                                      std::move(type_ctor));
   }
   }
 }
 
-std::unique_ptr<raw::TypeParameterList> Parser::MaybeParseTypeParameterList() {
+std::unique_ptr<raw::LayoutParameterList> Parser::MaybeParseLayoutParameterList() {
   if (!MaybeConsumeToken(OfKind(Token::Kind::kLeftAngle))) {
     return nullptr;
   }
 
   ASTScope scope(this);
-  std::vector<std::unique_ptr<raw::TypeParameter>> params;
+  std::vector<std::unique_ptr<raw::LayoutParameter>> params;
   for (;;) {
-    params.emplace_back(ParseTypeParameter());
+    params.emplace_back(ParseLayoutParameter());
     if (!Ok())
       return Fail();
     if (!MaybeConsumeToken(OfKind(Token::Kind::kComma)))
@@ -1740,7 +1741,7 @@
   }
 
   ConsumeTokenOrRecover(OfKind(Token::Kind::kRightAngle));
-  return std::make_unique<raw::TypeParameterList>(scope.GetSourceElement(), std::move(params));
+  return std::make_unique<raw::LayoutParameterList>(scope.GetSourceElement(), std::move(params));
 }
 
 std::unique_ptr<raw::TypeConstraints> Parser::ParseConstraints() {
@@ -2021,9 +2022,9 @@
     }
   }
 
-  std::unique_ptr<raw::TypeParameterList> parameters;
+  std::unique_ptr<raw::LayoutParameterList> parameters;
   if (previous_token_.kind() != Token::Kind::kColon) {
-    parameters = MaybeParseTypeParameterList();
+    parameters = MaybeParseLayoutParameterList();
     if (!Ok())
       return Fail();
   }