Add dependencies for source-generated crates

When using SourceProviders, the dependency tree does not include
directly the source variant, only the built variant. For instance:

  liba --> libbingena_rlib --> libbingena_source

However, libbindgena_rlib did not have a source associated with the
module, and was therefore not added as a dependency. Modify the logic so
that a SourceProvider library will find the right variant and always
have a source defined.

Adds display_name fields to the crate description to ease debugging.

Test: rust-analyzer analysis-stats .
Bug: 174158339
Change-Id: Id65708d57cd176f7e1da353f4a5f7ad65b003090
diff --git a/rust/project_json_test.go b/rust/project_json_test.go
index aff1697..ba66215 100644
--- a/rust/project_json_test.go
+++ b/rust/project_json_test.go
@@ -119,9 +119,9 @@
 func TestProjectJsonBinary(t *testing.T) {
 	bp := `
 	rust_binary {
-		name: "liba",
-		srcs: ["a/src/lib.rs"],
-		crate_name: "a"
+		name: "libz",
+		srcs: ["z/src/lib.rs"],
+		crate_name: "z"
 	}
 	`
 	jsonContent := testProjectJson(t, bp)
@@ -132,7 +132,7 @@
 		if !ok {
 			t.Fatalf("Unexpected type for root_module: %v", crate["root_module"])
 		}
-		if rootModule == "a/src/lib.rs" {
+		if rootModule == "z/src/lib.rs" {
 			return
 		}
 	}
@@ -142,10 +142,10 @@
 func TestProjectJsonBindGen(t *testing.T) {
 	bp := `
 	rust_library {
-		name: "liba",
-		srcs: ["src/lib.rs"],
+		name: "libd",
+		srcs: ["d/src/lib.rs"],
 		rlibs: ["libbindings1"],
-		crate_name: "a"
+		crate_name: "d"
 	}
 	rust_bindgen {
 		name: "libbindings1",
@@ -155,10 +155,10 @@
 		wrapper_src: "src/any.h",
 	}
 	rust_library_host {
-		name: "libb",
-		srcs: ["src/lib.rs"],
+		name: "libe",
+		srcs: ["e/src/lib.rs"],
 		rustlibs: ["libbindings2"],
-		crate_name: "b"
+		crate_name: "e"
 	}
 	rust_bindgen_host {
 		name: "libbindings2",
@@ -190,6 +190,19 @@
 				}
 			}
 		}
+		// Check that liba depends on libbindings1
+		if strings.Contains(rootModule, "d/src/lib.rs") {
+			found := false
+			for _, depName := range validateDependencies(t, crate) {
+				if depName == "bindings1" {
+					found = true
+					break
+				}
+			}
+			if !found {
+				t.Errorf("liba does not depend on libbindings1: %v", crate)
+			}
+		}
 	}
 }