diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skylarkinterface')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkPrintableValue.java | 26 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkValue.java | 34 |
2 files changed, 34 insertions, 26 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkPrintableValue.java b/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkPrintableValue.java deleted file mode 100644 index 69426ea6c8..0000000000 --- a/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkPrintableValue.java +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -package com.google.devtools.build.lib.skylarkinterface; - -/** - * A Skylark value that is represented by {@code str()} differently than by {@code repr()}. - */ -public interface SkylarkPrintableValue extends SkylarkValue { - /** - * Print an informal, human-readable representation of the value. - * - * @param printer a printer to be used for formatting nested values. - */ - void str(SkylarkPrinter printer); -} diff --git a/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkValue.java b/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkValue.java index a7c8c2779b..bf6a5c5586 100644 --- a/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkValue.java +++ b/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkValue.java @@ -37,4 +37,38 @@ public interface SkylarkValue { * @param printer a printer to be used for formatting nested values. */ void repr(SkylarkPrinter printer); + + /** + * Print a legacy representation of object x. + * + * <p>By default dispatches to the {@code repr} method. Should be called instead of {@code repr} + * if --incompatible_descriptive_string_representations=false is used. + * + * @param printer an instance of a printer to be used for formatting nested values + */ + default void reprLegacy(SkylarkPrinter printer) { + repr(printer); + } + + /** + * Print an informal, human-readable representation of the value. + * + * <p>By default dispatches to the {@code repr} method. + * + * @param printer a printer to be used for formatting nested values. + */ + default void str(SkylarkPrinter printer) { + repr(printer); + } + + /** + * Print a legacy informal, human-readable representation of the value. + * + * <p>By default dispatches to the {@code reprLegacy} method. + * + * @param printer a printer to be used for formatting nested values. + */ + default void strLegacy(SkylarkPrinter printer) { + reprLegacy(printer); + } } |