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

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

Issue 12543003: Use limited JavaStringBuilder implementation instead of Dart StringBuffer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweak JavaStringBuilder. Created 7 years, 9 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
Index: pkg/analyzer-experimental/lib/src/generated/java_core.dart
diff --git a/pkg/analyzer-experimental/lib/src/generated/java_core.dart b/pkg/analyzer-experimental/lib/src/generated/java_core.dart
index a450fbd85de638cc6afdb9fe190f37f7403ca222..72bdc99c952196a2ab12d939c9c96fae1b7f711b 100644
--- a/pkg/analyzer-experimental/lib/src/generated/java_core.dart
+++ b/pkg/analyzer-experimental/lib/src/generated/java_core.dart
@@ -217,6 +217,12 @@ class IllegalArgumentException implements Exception {
String toString() => "IllegalStateException: $message";
}
+class StringIndexOutOfBoundsException implements Exception {
+ final int index;
+ const StringIndexOutOfBoundsException(this.index);
+ String toString() => "StringIndexOutOfBoundsException: $index";
+}
+
class IllegalStateException implements Exception {
final String message;
const IllegalStateException([this.message = ""]);
@@ -390,3 +396,31 @@ void javaMapPutAll(Map target, Map source) {
bool javaStringEqualsIgnoreCase(String a, String b) {
return a.toLowerCase() == b.toLowerCase();
}
+
+class JavaStringBuilder {
+ StringBuffer sb = new StringBuffer();
+ String toString() => sb.toString();
+ void append(x) {
+ sb.write(x);
+ }
+ void appendChar(int c) {
+ sb.writeCharCode(c);
+ }
+ int get length => sb.length;
+ void set length(int newLength) {
+ if (newLength < 0) {
+ throw new StringIndexOutOfBoundsException(newLength);
+ }
+ if (sb.length < newLength) {
+ while (sb.length < newLength) {
+ sb.writeCharCode(0);
+ }
+ } else if (sb.length > newLength) {
+ var s = sb.toString().substring(0, newLength);
+ sb = new StringBuffer(s);
+ }
+ }
+ void clear() {
+ sb = new StringBuffer();
+ }
+}
« no previous file with comments | « pkg/analyzer-experimental/lib/src/generated/html_scanner.dart ('k') | pkg/analyzer-experimental/lib/src/generated/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698