Change WalkableGraphFactory#prepareAndGet to take multiple SkyKeys as graph roots

It also changes a few accessors of utility methods in Skyframe library. It
refactors the QueryExpressionMapper to use a general QueryExpressionVisitor.

RELNOTES: None
PiperOrigin-RevId: 165534908
diff --git a/src/main/java/com/google/devtools/build/lib/cmdline/TargetPattern.java b/src/main/java/com/google/devtools/build/lib/cmdline/TargetPattern.java
index 43f77c8..92a6dbb 100644
--- a/src/main/java/com/google/devtools/build/lib/cmdline/TargetPattern.java
+++ b/src/main/java/com/google/devtools/build/lib/cmdline/TargetPattern.java
@@ -293,6 +293,11 @@
     throw new IllegalStateException();
   }
 
+  /** For patterns of type {@link Type#SINGLE_TARGET}, returns the target path. */
+  public String getSingleTargetPath() {
+    throw new IllegalStateException();
+  }
+
   /**
    * For patterns of type {@link Type#SINGLE_TARGET} and {@link Type#TARGETS_IN_PACKAGE}, returns
    * the {@link PackageIdentifier} corresponding to the package that would contain the target(s)
@@ -349,6 +354,11 @@
     }
 
     @Override
+    public String getSingleTargetPath() {
+      return targetName;
+    }
+
+    @Override
     public boolean equals(Object o) {
       if (this == o) {
         return true;