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

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

Issue 139263011: dartfmt line wrapping bypass option support. (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 | « pkg/analyzer/lib/src/services/formatter_impl.dart ('k') | 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 32022)
+++ pkg/analyzer/lib/src/services/writer.dart (working copy)
@@ -5,10 +5,7 @@
library source_writer;
-/// DEBUG flag indicating whether to use the experimental line-breaker
-const _USE_LINE_BREAKER = false;
-
class Line {
final tokens = <LineToken>[];
@@ -122,10 +119,9 @@
if (work.fits(tok)) {
work.add(tok);
} else {
- if (!isAllWhitespace(work)) {
+ if (!isAllWhitespace(work) || isLineStart(current)) {
current.add(work);
- }
- if (current.length > 0) {
+ } else if (current.length > 0) {
chunks.add(current);
current = new Chunk(maxLength: maxLength);
}
@@ -176,6 +172,8 @@
bool isAllWhitespace(Chunk chunk) => isWhitespace(chunk.buffer.toString());
+ bool isLineStart(chunk) => chunk.length == 0 && chunk.start == LINE_START;
+
/// Test whether this token is a good start for a new working chunk
bool goodStart(LineToken tok, Chunk workingChunk) =>
tok is SpaceToken && tok.breakWeight >= workingChunk.start.breakWeight;
@@ -293,7 +291,7 @@
SourceWriter({this.indentCount: 0, this.lineSeparator: NEW_LINE,
bool useTabs: false, int spacesPerIndent: 2, int maxLineLength: 80}) {
- if (_USE_LINE_BREAKER) {
+ if (maxLineLength > 0) {
linePrinter = new SimpleLineBreaker(maxLineLength, (n) =>
getIndentString(n, useTabs: useTabs, spacesPerIndent: spacesPerIndent));
} else {
« no previous file with comments | « pkg/analyzer/lib/src/services/formatter_impl.dart ('k') | pkg/analyzer/test/services/data/stmt_tests.data » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698