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

Unified Diff: pkg/analyzer/lib/src/services/writer.dart

Issue 137533005: Whitespace testing fixes and bit-flip to turn on simple line breaking. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 11 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 | « no previous file | pkg/analyzer/test/services/data/stmt_tests.data » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/services/writer.dart
===================================================================
--- pkg/analyzer/lib/src/services/writer.dart (revision 31766)
+++ pkg/analyzer/lib/src/services/writer.dart (working copy)
@@ -116,7 +116,7 @@
if (work.fits(tok)) {
work.add(tok);
} else {
- if (!isWhitespace(work)) {
+ if (!isAllWhitespace(work)) {
current.add(work);
}
if (current.length > 0) {
@@ -137,10 +137,7 @@
return chunks;
}
- bool isWhitespace(Chunk chunk) {
- var str = chunk.buffer.toString();
- return str.lastIndexOf(new RegExp(r"(\w+)")) == str.length - 1;
- }
+ bool isAllWhitespace(Chunk chunk) => isWhitespace(chunk.buffer.toString());
/// Test whether this token is a good start for a new working chunk
bool goodStart(LineToken tok, Chunk workingChunk) =>
@@ -148,6 +145,9 @@
}
+/// Test if this [string] contains only whitespace characters
+bool isWhitespace(String string) => string.codeUnits.every(
+ (c) => c == 0x09 || c == 0x20 || c == 0x0A || c == 0x0D);
/// Special token indicating a line start
final LINE_START = new SpaceToken(0);
@@ -256,9 +256,9 @@
SourceWriter({this.indentCount: 0, this.lineSeparator: NEW_LINE,
bool useTabs: false, int spacesPerIndent: 2, int maxLineLength: 80}) {
-// linePrinter = new SimpleLineBreaker(maxLineLength, (n) =>
-// getIndentString(n, useTabs: useTabs, spacesPerIndent: spacesPerIndent));
- linePrinter = new SimpleLinePrinter();
+ linePrinter = new SimpleLineBreaker(maxLineLength, (n) =>
+ getIndentString(n, useTabs: useTabs, spacesPerIndent: spacesPerIndent));
+// linePrinter = new SimpleLinePrinter();
currentLine = new Line(indent: indentCount, printer: linePrinter);
}
« no previous file with comments | « no previous file | pkg/analyzer/test/services/data/stmt_tests.data » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698