Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: pkg/analyzer/lib/src/generated/java_core.dart

Issue 2340583006: Rollback 6bee780067d3c84bfbc387720a26b0eabe7c2357, restore PrintWriter. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/dart/ast/utilities.dart ('k') | pkg/analyzer/test/src/dart/ast/utilities_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/java_core.dart
diff --git a/pkg/analyzer/lib/src/generated/java_core.dart b/pkg/analyzer/lib/src/generated/java_core.dart
index 382fa0de448723c20a580c382d763d08451a4825..ed0d03f2569a361af5609749b4295d022faaef9d 100644
--- a/pkg/analyzer/lib/src/generated/java_core.dart
+++ b/pkg/analyzer/lib/src/generated/java_core.dart
@@ -39,6 +39,45 @@ String formatList(String pattern, List<Object> arguments) {
});
}
+/**
+ * Very limited printf implementation, supports only %s and %d.
+ */
+String _printf(String fmt, List args) {
+ StringBuffer sb = new StringBuffer();
+ bool markFound = false;
+ int argIndex = 0;
+ for (int i = 0; i < fmt.length; i++) {
+ int c = fmt.codeUnitAt(i);
+ if (c == 0x25) {
+ if (markFound) {
+ sb.writeCharCode(c);
+ markFound = false;
+ } else {
+ markFound = true;
+ }
+ continue;
+ }
+ if (markFound) {
+ markFound = false;
+ // %d
+ if (c == 0x64) {
+ sb.write(args[argIndex++]);
+ continue;
+ }
+ // %s
+ if (c == 0x73) {
+ sb.write(args[argIndex++]);
+ continue;
+ }
+ // unknown
+ throw new ArgumentError('[$fmt][$i] = 0x${c.toRadixString(16)}');
+ } else {
+ sb.writeCharCode(c);
+ }
+ }
+ return sb.toString();
+}
+
class Character {
static const int MAX_VALUE = 0xffff;
static const int MAX_CODE_POINT = 0x10ffff;
@@ -97,3 +136,30 @@ abstract class Enum<E extends Enum> implements Comparable<E> {
int compareTo(E other) => ordinal - other.ordinal;
String toString() => name;
}
+
+class PrintStringWriter extends PrintWriter {
+ final StringBuffer _sb = new StringBuffer();
+
+ void print(x) {
+ _sb.write(x);
+ }
+
+ String toString() => _sb.toString();
+}
+
+abstract class PrintWriter {
+ void newLine() {
+ this.print('\n');
+ }
+
+ void print(x);
+
+ void printf(String fmt, List args) {
+ this.print(_printf(fmt, args));
+ }
+
+ void println(String s) {
+ this.print(s);
+ this.newLine();
+ }
+}
« no previous file with comments | « pkg/analyzer/lib/src/dart/ast/utilities.dart ('k') | pkg/analyzer/test/src/dart/ast/utilities_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698