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

Side by Side Diff: example/format.dart

Issue 1355203002: Handle index expressions in the middle of call chains. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Handle chained indexes. Created 5 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 unified diff | Download patch
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/call_chain_visitor.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart_style.example.format; 5 library dart_style.example.format;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:mirrors'; 8 import 'dart:mirrors';
9 9
10 import 'package:path/path.dart' as p; 10 import 'package:path/path.dart' as p;
(...skipping 26 matching lines...) Expand all
37 try { 37 try {
38 var formatter = new DartFormatter(pageWidth: pageWidth); 38 var formatter = new DartFormatter(pageWidth: pageWidth);
39 39
40 var result; 40 var result;
41 if (isCompilationUnit) { 41 if (isCompilationUnit) {
42 result = formatter.format(source); 42 result = formatter.format(source);
43 } else { 43 } else {
44 result = formatter.formatStatement(source); 44 result = formatter.formatStatement(source);
45 } 45 }
46 46
47 if (debug.useAnsiColors) {
48 result = result.replaceAll(" ", debug.gray(debug.unicodeMidDot));
49 }
50
51 drawRuler("before", pageWidth); 47 drawRuler("before", pageWidth);
52 print(source); 48 print(source);
53 drawRuler("after", pageWidth); 49 drawRuler("after", pageWidth);
54 print(result); 50 print(result);
55 } on FormatterException catch (error) { 51 } on FormatterException catch (error) {
56 print(error.message()); 52 print(error.message());
57 } 53 }
58 } 54 }
59 55
60 void drawRuler(String label, int width) { 56 void drawRuler(String label, int width) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 source = source.replaceAll("‹", ""); 156 source = source.replaceAll("‹", "");
161 157
162 var end = source.indexOf("›"); 158 var end = source.indexOf("›");
163 source = source.replaceAll("›", ""); 159 source = source.replaceAll("›", "");
164 160
165 return new SourceCode(source, 161 return new SourceCode(source,
166 isCompilationUnit: isCompilationUnit, 162 isCompilationUnit: isCompilationUnit,
167 selectionStart: start == -1 ? null : start, 163 selectionStart: start == -1 ? null : start,
168 selectionLength: end == -1 ? null : end - start); 164 selectionLength: end == -1 ? null : end - start);
169 } 165 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/call_chain_visitor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698