Make TypeNamespace take AidlNode subclass arguments

Because annotations are attached to AidlType, we need to know the
complete AidlType of arguments and return values in order to decide
which generated type to use.  Make it an invariant that a TypeNamespace
takes only subclasses of AidlNode from aidl.cpp to make this easier to
reason about.

For now, leave most of the existing implementation in place, but push it
down into LanguageTypeNamespace.

Bug: 26729450
Test: unittests still pass

Change-Id: I6684564995c734def96daeccc03dfd5d264469ee
diff --git a/aidl.cpp b/aidl.cpp
index b17092e..6cc25a0 100644
--- a/aidl.cpp
+++ b/aidl.cpp
@@ -194,7 +194,7 @@
   for (const auto& m : c->GetMethods()) {
     bool oneway = m->IsOneway() || c->IsOneway();
 
-    if (!types->MaybeAddContainerType(m->GetType().GetName())) {
+    if (!types->MaybeAddContainerType(m->GetType())) {
       err = 1;  // return type is invalid
     }
 
@@ -216,7 +216,7 @@
 
     int index = 1;
     for (const auto& arg : m->GetArguments()) {
-      if (!types->MaybeAddContainerType(arg->GetType().GetName())) {
+      if (!types->MaybeAddContainerType(arg->GetType())) {
         err = 1;
       }
 
@@ -562,7 +562,7 @@
   // parse the imports of the input file
   ImportResolver import_resolver{io_delegate, import_paths};
   for (auto& import : p.GetImports()) {
-    if (types->HasType(import->GetNeededClass())) {
+    if (types->HasImportType(*import)) {
       // There are places in the Android tree where an import doesn't resolve,
       // but we'll pick the type up through the preprocessed types.
       // This seems like an error, but legacy support demands we support it...
@@ -600,7 +600,7 @@
     err = AidlError::BAD_TYPE;
   }
 
-  interface->SetLanguageType(types->FindTypeByName(interface->GetCanonicalName()));
+  interface->SetLanguageType(types->GetInterfaceType(*interface));
 
   for (const auto& import : p.GetImports()) {
     // If we skipped an unresolved import above (see comment there) we'll have