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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/source_file.dart

Issue 12294028: Fix warnings spotted by dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 source_file; 5 library source_file;
6 6
7 import 'dart:math'; 7 import 'dart:math';
8 8
9 import 'colors.dart' as colors; 9 import 'colors.dart' as colors;
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 * in the file. 69 * in the file.
70 */ 70 */
71 String getLocationMessage(String message, int start, int end, 71 String getLocationMessage(String message, int start, int end,
72 bool includeText, String color(String x)) { 72 bool includeText, String color(String x)) {
73 var line = getLine(start); 73 var line = getLine(start);
74 var column = getColumn(line, start); 74 var column = getColumn(line, start);
75 75
76 var buf = new StringBuffer( 76 var buf = new StringBuffer(
77 '${filename}:${line + 1}:${column + 1}: $message'); 77 '${filename}:${line + 1}:${column + 1}: $message');
78 if (includeText) { 78 if (includeText) {
79 buf.add('\n'); 79 buf.write('\n');
80 var textLine; 80 var textLine;
81 // +1 for 0-indexing, +1 again to avoid the last line of the file 81 // +1 for 0-indexing, +1 again to avoid the last line of the file
82 if ((line + 2) < _lineStarts.length) { 82 if ((line + 2) < _lineStarts.length) {
83 textLine = text.substring(_lineStarts[line], _lineStarts[line+1]); 83 textLine = text.substring(_lineStarts[line], _lineStarts[line+1]);
84 } else { 84 } else {
85 textLine = '${text.substring(_lineStarts[line])}\n'; 85 textLine = '${text.substring(_lineStarts[line])}\n';
86 } 86 }
87 87
88 int toColumn = min(column + (end-start), textLine.length); 88 int toColumn = min(column + (end-start), textLine.length);
89 buf.add(textLine.substring(0, column)); 89 buf.write(textLine.substring(0, column));
90 buf.add(color(textLine.substring(column, toColumn))); 90 buf.write(color(textLine.substring(column, toColumn)));
91 buf.add(textLine.substring(toColumn)); 91 buf.write(textLine.substring(toColumn));
92 92
93 int i = 0; 93 int i = 0;
94 for (; i < column; i++) { 94 for (; i < column; i++) {
95 buf.add(' '); 95 buf.write(' ');
96 } 96 }
97 97
98 for (; i < toColumn; i++) { 98 for (; i < toColumn; i++) {
99 buf.add(color('^')); 99 buf.write(color('^'));
100 } 100 }
101 } 101 }
102 102
103 return buf.toString(); 103 return buf.toString();
104 } 104 }
105 } 105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698