Add static methods to return target kinds for built-in targets

Add static methods to return target kinds of InputFile and OutFile, as well as
suffix of target kind of Rule.

RELNOTES: None
PiperOrigin-RevId: 154866926
diff --git a/src/main/java/com/google/devtools/build/lib/packages/InputFile.java b/src/main/java/com/google/devtools/build/lib/packages/InputFile.java
index 6f2fe22..c04a346 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/InputFile.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/InputFile.java
@@ -109,7 +109,7 @@
 
   @Override
   public String getTargetKind() {
-    return "source file";
+    return targetKind();
   }
 
   @Override
@@ -121,4 +121,9 @@
   public Location getLocation() {
     return location;
   }
+
+  /** Returns the target kind for all input files. */
+  public static String targetKind() {
+    return "source file";
+  }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/packages/OutputFile.java b/src/main/java/com/google/devtools/build/lib/packages/OutputFile.java
index eed4c63..101cb1b 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/OutputFile.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/OutputFile.java
@@ -52,7 +52,7 @@
 
   @Override
   public String getTargetKind() {
-    return "generated file";
+    return targetKind();
   }
 
   @Override
@@ -64,4 +64,9 @@
   public Location getLocation() {
     return generatingRule.getLocation();
   }
+
+  /** Returns the target kind for all output files. */
+  public static String targetKind() {
+    return "generated file";
+  }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/packages/Rule.java b/src/main/java/com/google/devtools/build/lib/packages/Rule.java
index 0a9bd9c..da411c1 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/Rule.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/Rule.java
@@ -730,4 +730,9 @@
   public RepositoryName getRepository() {
     return getLabel().getPackageIdentifier().getRepository();
   }
+
+  /** Returns the suffix of target kind for all rules. */
+  public static String targetKindSuffix() {
+    return " rule";
+  }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
index d8c06f5..9293b09 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
@@ -1168,7 +1168,7 @@
       Attribute... attributes) {
     this.name = name;
     this.isSkylark = isSkylark;
-    this.targetKind = name + " rule";
+    this.targetKind = name + Rule.targetKindSuffix();
     this.skylarkExecutable = skylarkExecutable;
     this.skylarkTestable = skylarkTestable;
     this.documented = documented;
diff --git a/src/main/java/com/google/devtools/build/lib/query2/FakeSubincludeTarget.java b/src/main/java/com/google/devtools/build/lib/query2/FakeSubincludeTarget.java
index 224ada6..2a221d1 100644
--- a/src/main/java/com/google/devtools/build/lib/query2/FakeSubincludeTarget.java
+++ b/src/main/java/com/google/devtools/build/lib/query2/FakeSubincludeTarget.java
@@ -56,7 +56,7 @@
 
   @Override
   public String getTargetKind() {
-    return "source file";
+    return targetKind();
   }
 
   @Override
@@ -107,4 +107,9 @@
     FakeSubincludeTarget other = (FakeSubincludeTarget) obj;
     return label.equals(other.label) && pkg.equals(other.pkg);
   }
+
+  /** Returns the target kind for all fake sub-include targets. */
+  public static String targetKind() {
+    return "source file";
+  }
 }