diff options
author | 2015-06-13 03:34:47 +0000 | |
---|---|---|
committer | 2015-06-15 10:51:53 +0000 | |
commit | d61f531427e7448d7900eba03a45674ed5dc000b (patch) | |
tree | 5e34f32565fdad804641eb37877bede73e7bf7ac /src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java | |
parent | 53594cbfbe74a5568503397a29b600e7c9b40a6b (diff) |
Implement Skylark function repr
Move printing code from EvalUtils to Printer.
Rename functions in Printer:
printValue becomes str or print,
prettyPrintValue becomes repr or write,
formatString becomes format,
makeFormattable becomes strFormattable,
prettyPrintValues becomes listString.
write being self-sufficient is made the reference,
and print is the one that is a wrapper around write,
rather than the other way around, avoiding mutual recursion.
--
MOS_MIGRATED_REVID=95897834
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java b/src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java index 5f2c512252..21df356d12 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java @@ -26,7 +26,6 @@ import com.google.devtools.build.lib.events.Location; import com.google.devtools.build.lib.syntax.EvalException.EvalExceptionWithJavaCause; import com.google.devtools.build.lib.util.StringUtilities; -import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -270,12 +269,7 @@ public final class FuncallExpression extends Expression { if (obj != null) { sb.append(obj).append("."); } - sb.append(func); - try { - EvalUtils.printList(args, "(", ", ", ")", null, sb); - } catch (IOException x) { - throw new RuntimeException("Error while printing", x); - } + Printer.printList(sb.append(func), args, "(", ", ", ")", null); return sb.toString(); } @@ -331,7 +325,7 @@ public final class FuncallExpression extends Expression { } else { throw new EvalException(loc, "Method invocation returned None, please contact Skylark developers: " + methodName - + "(" + EvalUtils.prettyPrintValues(", ", ImmutableList.copyOf(args)) + ")"); + + Printer.listString(ImmutableList.copyOf(args), "(", ", ", ")", null)); } } result = SkylarkType.convertToSkylark(result, method); |