aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/cmdline
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/cmdline')
-rw-r--r--src/main/java/com/google/devtools/build/lib/cmdline/Label.java32
1 files changed, 5 insertions, 27 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/cmdline/Label.java b/src/main/java/com/google/devtools/build/lib/cmdline/Label.java
index b689f6daa7..9c229018b0 100644
--- a/src/main/java/com/google/devtools/build/lib/cmdline/Label.java
+++ b/src/main/java/com/google/devtools/build/lib/cmdline/Label.java
@@ -24,13 +24,13 @@ import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;
import com.google.devtools.build.lib.skylarkinterface.SkylarkPrintableValue;
+import com.google.devtools.build.lib.skylarkinterface.SkylarkPrinter;
import com.google.devtools.build.lib.util.Preconditions;
import com.google.devtools.build.lib.util.StringCanonicalizer;
import com.google.devtools.build.lib.util.StringUtilities;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.skyframe.SkyFunctionName;
import com.google.devtools.build.skyframe.SkyKey;
-import java.io.IOException;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.Serializable;
@@ -562,34 +562,12 @@ public final class Label implements Comparable<Label>, Serializable, SkylarkPrin
}
@Override
- public void write(Appendable buffer, char quotationMark) {
- // We don't use the Skylark Printer class here to avoid creating a circular dependency.
- //
- // TODO(bazel-team): make the representation readable Label(//foo),
- // and isolate the legacy functions that want the unreadable variant.
- try {
- // There is no need to escape the contents of the Label since characters that might otherwise
- // require escaping are disallowed.
- buffer.append(quotationMark);
- buffer.append(toString());
- buffer.append(quotationMark);
- } catch (IOException e) {
- // This function will only be used with in-memory Appendables, hence we should never get here.
- throw new AssertionError(e);
- }
+ public void repr(SkylarkPrinter printer) {
+ printer.repr(getCanonicalForm());
}
@Override
- public void print(Appendable buffer, char quotationMark) {
- // We don't use the Skylark Printer class here to avoid creating a circular dependency.
- //
- // TODO(bazel-team): make the representation readable Label(//foo),
- // and isolate the legacy functions that want the unreadable variant.
- try {
- buffer.append(toString());
- } catch (IOException e) {
- // This function will only be used with in-memory Appendables, hence we should never get here.
- throw new AssertionError(e);
- }
+ public void str(SkylarkPrinter printer) {
+ printer.append(getCanonicalForm());
}
}