diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/packages/SkylarkClassObject.java | 17 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/packages/SkylarkClassObjectConstructor.java | 7 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/packages/SkylarkClassObject.java b/src/main/java/com/google/devtools/build/lib/packages/SkylarkClassObject.java index 963b30eee6..b65411f00c 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/SkylarkClassObject.java +++ b/src/main/java/com/google/devtools/build/lib/packages/SkylarkClassObject.java @@ -238,6 +238,23 @@ public class SkylarkClassObject implements ClassObject, SkylarkValue, Concatable @Override public void repr(SkylarkPrinter printer) { boolean first = true; + printer.append("struct("); + // Sort by key to ensure deterministic output. + for (String key : Ordering.natural().sortedCopy(values.keySet())) { + if (!first) { + printer.append(", "); + } + first = false; + printer.append(key); + printer.append(" = "); + printer.repr(values.get(key)); + } + printer.append(")"); + } + + @Override + public void reprLegacy(SkylarkPrinter printer) { + boolean first = true; printer.append(constructor.getPrintableName()); printer.append("("); // Sort by key to ensure deterministic output. diff --git a/src/main/java/com/google/devtools/build/lib/packages/SkylarkClassObjectConstructor.java b/src/main/java/com/google/devtools/build/lib/packages/SkylarkClassObjectConstructor.java index 03b4ddb7d9..8bd600852a 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/SkylarkClassObjectConstructor.java +++ b/src/main/java/com/google/devtools/build/lib/packages/SkylarkClassObjectConstructor.java @@ -16,6 +16,7 @@ package com.google.devtools.build.lib.packages; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.events.Location; +import com.google.devtools.build.lib.skylarkinterface.SkylarkPrinter; import com.google.devtools.build.lib.syntax.EvalException; import com.google.devtools.build.lib.syntax.FunctionSignature; import com.google.devtools.build.lib.syntax.SkylarkType; @@ -123,6 +124,11 @@ public class SkylarkClassObjectConstructor extends ClassObjectConstructor return isExported(); } + @Override + public void repr(SkylarkPrinter printer) { + printer.append("<provider>"); + } + /** * A serializable representation of Skylark-defined {@link SkylarkClassObjectConstructor} * that uniquely identifies all {@link SkylarkClassObjectConstructor}s that @@ -169,5 +175,4 @@ public class SkylarkClassObjectConstructor extends ClassObjectConstructor && Objects.equals(this.exportedName, other.exportedName); } } - } |