Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
Add static methods to return target kinds for built-in targets
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Googler authored and damienmg committed May 3, 2017
1 parent 6bde6fb commit b448eef
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public PathFragment getExecPath() {

@Override
public String getTargetKind() {
return "source file";
return targetKind();
}

@Override
Expand All @@ -121,4 +121,9 @@ public Rule getAssociatedRule() {
public Location getLocation() {
return location;
}

/** Returns the target kind for all input files. */
public static String targetKind() {
return "source file";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public Rule getGeneratingRule() {

@Override
public String getTargetKind() {
return "generated file";
return targetKind();
}

@Override
Expand All @@ -64,4 +64,9 @@ public Rule getAssociatedRule() {
public Location getLocation() {
return generatingRule.getLocation();
}

/** Returns the target kind for all output files. */
public static String targetKind() {
return "generated file";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -730,4 +730,9 @@ public Collection<? extends Label> getAspectLabelsSuperset(DependencyFilter pred
public RepositoryName getRepository() {
return getLabel().getPackageIdentifier().getRepository();
}

/** Returns the suffix of target kind for all rules. */
public static String targetKindSuffix() {
return " rule";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ public Attribute.Builder<?> copy(String name) {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Package getPackage() {

@Override
public String getTargetKind() {
return "source file";
return targetKind();
}

@Override
Expand Down Expand Up @@ -107,4 +107,9 @@ public boolean equals(Object obj) {
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";
}
}

0 comments on commit b448eef

Please sign in to comment.