diff options
author | cparsons <cparsons@google.com> | 2018-02-16 14:21:10 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-02-16 14:23:13 -0800 |
commit | 7ec3f21cad07c4b6726bf1ee89e808298e4959c9 (patch) | |
tree | bde139bf283b75f4dd023ae4896be23faec7c20e /src/main/java/com/google/devtools/build/lib/skylarkinterface | |
parent | 50efbeb1a59a17ef23dd125540492518860971ff (diff) |
Change Skylark's print() on a rule target to print the Skylark-exposed provider keys.
This change only affects printing a rule target directly -- it intentionally does not affect the behavior of str(target), as we want to avoid skylark code being able to parse potentially-private provider keys.
RELNOTES: In skylark, print(target) now shows the provider keys of a target, as debug information.
PiperOrigin-RevId: 186046226
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skylarkinterface')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkPrintable.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkPrintable.java b/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkPrintable.java index 39760c4108..8edfbd58ec 100644 --- a/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkPrintable.java +++ b/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkPrintable.java @@ -21,7 +21,7 @@ package com.google.devtools.build.lib.skylarkinterface; public interface SkylarkPrintable { /** - * Print an official representation of object x. + * Prints an official representation of object x. * * <p>For regular data structures, the value should be parsable back into an equal data structure. * @@ -30,7 +30,7 @@ public interface SkylarkPrintable { void repr(SkylarkPrinter printer); /** - * Print an informal, human-readable representation of the value. + * Prints an informal, human-readable representation of the value. * * <p>By default dispatches to the {@code repr} method. * @@ -39,4 +39,20 @@ public interface SkylarkPrintable { default void str(SkylarkPrinter printer) { repr(printer); } + + /** + * Prints an informal debug representation of the value. + * + * <p>This debug representation is only ever printed to the terminal or to another out-of-band + * channel, and is never accessible to Skylark code. Therefore, it is safe for the debug + * representation to reveal properties of the value that are usually hidden for the sake of + * performance, determinism, or forward-compatibility. + * + * <p>By default dispatches to the {@code str} method. + * + * @param printer a printer to be used for formatting nested values. + */ + default void debugPrint(SkylarkPrinter printer) { + str(printer); + } } |