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

Unified Diff: test/generated_sdk/lib/convert/line_splitter.dart

Issue 1162723007: remove generated_sdk from checked in code (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 7 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 | « test/generated_sdk/lib/convert/latin1.dart ('k') | test/generated_sdk/lib/convert/string_conversion.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/generated_sdk/lib/convert/line_splitter.dart
diff --git a/test/generated_sdk/lib/convert/line_splitter.dart b/test/generated_sdk/lib/convert/line_splitter.dart
deleted file mode 100644
index 53337f00fffc0bf049c08659a3978df5e1e82773..0000000000000000000000000000000000000000
--- a/test/generated_sdk/lib/convert/line_splitter.dart
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-part of dart.convert;
-
-/**
- * This class splits [String] values into individual lines.
- */
-class LineSplitter extends Converter<String, List<String>> {
-
- const LineSplitter();
-
- List<String> convert(String data) {
- var lines = new List<String>();
-
- _LineSplitterSink._addSlice(data, 0, data.length, true, lines.add);
-
- return lines;
- }
-
- StringConversionSink startChunkedConversion(Sink<dynamic> sink) {
- if (sink is! StringConversionSink) {
- sink = new StringConversionSink.from(sink);
- }
- return new _LineSplitterSink(sink);
- }
-}
-
-// TODO(floitsch): deal with utf8.
-class _LineSplitterSink extends StringConversionSinkBase {
- static const int _LF = 10;
- static const int _CR = 13;
-
- final StringConversionSink _sink;
-
- String _carry;
-
- _LineSplitterSink(this._sink);
-
- void addSlice(String chunk, int start, int end, bool isLast) {
- if (_carry != null) {
- chunk = _carry + chunk.substring(start, end);
- start = 0;
- end = chunk.length;
- _carry = null;
- }
- _carry = _addSlice(chunk, start, end, isLast, _sink.add);
- if (isLast) _sink.close();
- }
-
- void close() {
- addSlice('', 0, 0, true);
- }
-
- static String _addSlice(String chunk, int start, int end, bool isLast,
- void adder(String val)) {
-
- int pos = start;
- while (pos < end) {
- int skip = 0;
- int char = chunk.codeUnitAt(pos);
- if (char == _LF) {
- skip = 1;
- } else if (char == _CR) {
- skip = 1;
- if (pos + 1 < end) {
- if (chunk.codeUnitAt(pos + 1) == _LF) {
- skip = 2;
- }
- } else if (!isLast) {
- return chunk.substring(start, end);
- }
- }
- if (skip > 0) {
- adder(chunk.substring(start, pos));
- start = pos = pos + skip;
- } else {
- pos++;
- }
- }
- if (pos != start) {
- var carry = chunk.substring(start, pos);
- if (isLast) {
- // Add remaining
- adder(carry);
- } else {
- return carry;
- }
- }
- return null;
- }
-}
« no previous file with comments | « test/generated_sdk/lib/convert/latin1.dart ('k') | test/generated_sdk/lib/convert/string_conversion.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698