Refactor all ctor callsites of PathFragment to instead call a static 'create' method.

This paves the way for changing PathFragment to e.g. an abstract class with multiple subclasses. This way we can split out the windows-specific stuff into one of these concrete classes, making the code more readable and also saving memory (since the shallow heap size of the NonWindowsPathFragment subclass will hopefully be smaller than that of the current PathFragment).

This also lets us pursue gc churn optimizations. We can now do interning in PathFragment#create and can also get rid of unnecessary intermediate PathFragment allocations.

RELNOTES: None

PiperOrigin-RevId: 152145768
diff --git a/src/main/java/com/google/devtools/build/lib/cmdline/PackageIdentifier.java b/src/main/java/com/google/devtools/build/lib/cmdline/PackageIdentifier.java
index 5688a31..3c82f6c 100644
--- a/src/main/java/com/google/devtools/build/lib/cmdline/PackageIdentifier.java
+++ b/src/main/java/com/google/devtools/build/lib/cmdline/PackageIdentifier.java
@@ -49,7 +49,7 @@
       PathFragment.EMPTY_FRAGMENT);
 
   public static PackageIdentifier createInMainRepo(String name) {
-    return createInMainRepo(new PathFragment(name));
+    return createInMainRepo(PathFragment.create(name));
   }
 
   public static PackageIdentifier createInMainRepo(PathFragment name) {
@@ -79,7 +79,7 @@
         ? Preconditions.checkNotNull(
             execPath.getParentDirectory(), "Must pass in files, not root directory")
         : execPath;
-    if (tofind.startsWith(new PathFragment(Label.EXTERNAL_PATH_PREFIX))) {
+    if (tofind.startsWith(PathFragment.create(Label.EXTERNAL_PATH_PREFIX))) {
       // TODO(ulfjack): Remove this when kchodorow@'s exec root rearrangement has been rolled out.
       RepositoryName repository = RepositoryName.create("@" + tofind.getSegment(1));
       return PackageIdentifier.create(repository, tofind.subFragment(2, tofind.segmentCount()));
@@ -137,7 +137,7 @@
       throw new LabelSyntaxException(error);
     }
 
-    return create(repo, new PathFragment(packageName));
+    return create(repo, PathFragment.create(packageName));
   }
 
   public RepositoryName getRepository() {