diff options
author | Florian Weikert <fwe@google.com> | 2015-08-28 14:30:06 +0000 |
---|---|---|
committer | John Field <jfield@google.com> | 2015-08-28 15:00:50 +0000 |
commit | 72545d5d5cf1d59254f64b13688175e0f301e324 (patch) | |
tree | 8a806f33ebe98572d337cb7c4afd35a432735d0f /src/main/java/com/google/devtools/build/lib/events | |
parent | 76429bb8fb23a70e28d0a66e3949e5f8a5a2fb42 (diff) |
When a Skylark macro creates a native rule, it also sets the following rule attributes: generator_{function, name, location}
--
MOS_MIGRATED_REVID=101774632
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(); + } } |