Split type resolution from constref resolution

Resolving both types and constrefs causes deeply nested recursive calls
with redundant checks on the same node.

Now type resolution is performed first and then constref's are resolved.

Due to the change of type resolution (it now imports every referenced
type as well), .d files are changed to list referenced types.

Bug: 201905322
Test: aidl_unittest
Change-Id: I0c415adc947c05c9b9fdf824e4c828cf9f73d227
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index f296ce7..4aaf7ae 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -4512,13 +4512,12 @@
 }
 
 TEST_P(AidlTest, UnknownConstReference) {
-  io_delegate_.SetFileContents("Foo.aidl", " parcelable Foo { UnknownType field = UNKNOWN_REF; }");
+  io_delegate_.SetFileContents("Foo.aidl", " parcelable Foo { int field = UNKNOWN_REF; }");
   auto options =
       Options::From("aidl --lang " + to_string(GetLanguage()) + " -o out -h out Foo.aidl");
   const string err =
-      "ERROR: Foo.aidl:1.18-30: Failed to resolve 'UnknownType'\n"
-      "ERROR: Foo.aidl:1.38-50: Can't find UNKNOWN_REF in Foo\n"
-      "ERROR: Foo.aidl:1.38-50: Unknown reference 'UNKNOWN_REF'\n";
+      "ERROR: Foo.aidl:1.30-42: Can't find UNKNOWN_REF in Foo\n"
+      "ERROR: Foo.aidl:1.30-42: Unknown reference 'UNKNOWN_REF'\n";
   CaptureStderr();
   EXPECT_FALSE(compile_aidl(options, io_delegate_));
   EXPECT_EQ(err, GetCapturedStderr());