diff options
author | Florian Weikert <fwe@google.com> | 2015-09-02 14:04:33 +0000 |
---|---|---|
committer | Florian Weikert <fwe@google.com> | 2015-09-02 14:33:19 +0000 |
commit | 6a663390e5247c8619991ca763a9496839d61f8b (patch) | |
tree | a1ddb3c8c161efc7f9882ca71b0bd96cfcf53957 /src/main/java/com/google/devtools/build/lib/events | |
parent | e899fc3054d25cf5d8fd06d585dd05737944e7cd (diff) |
When a Skylark macro creates a native rule, it also sets the following rule attributes: generator_{function, name, location}
--
MOS_MIGRATED_REVID=102139196
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/events')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/events/Location.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/events/Location.java b/src/main/java/com/google/devtools/build/lib/events/Location.java index 608d307c68..74b04a913a 100644 --- a/src/main/java/com/google/devtools/build/lib/events/Location.java +++ b/src/main/java/com/google/devtools/build/lib/events/Location.java @@ -291,4 +291,30 @@ public abstract class Location implements Serializable { return null; } }; + + /** + * Returns the location in the format "filename:line". + * + * <p>If such a location is not defined, this method returns an empty string. + */ + public static String printPathAndLine(Location location) { + return (location == null) ? "" : location.printPathAndLine(); + } + + /** + * Returns this location in the format "filename:line". + */ + public String printPathAndLine() { + StringBuilder builder = new StringBuilder(); + PathFragment path = getPath(); + if (path != null) { + builder.append(path.getPathString()); + } + + LineAndColumn position = getStartLineAndColumn(); + if (position != null) { + builder.append(":").append(position.getLine()); + } + return builder.toString(); + } } |