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

Unified Diff: pkg/compiler/lib/src/io/source_file.dart

Issue 1420013002: Support multiline location messages and use signature for function spans. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 years, 1 month 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/compiler/lib/src/elements/modelx.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/io/source_file.dart
diff --git a/pkg/compiler/lib/src/io/source_file.dart b/pkg/compiler/lib/src/io/source_file.dart
index d799a9bfaba0048f0420919e5e3ad5d6db3a934a..b07672edcd33ddc21bd5d01196ac334c7ca2b4ab 100644
--- a/pkg/compiler/lib/src/io/source_file.dart
+++ b/pkg/compiler/lib/src/io/source_file.dart
@@ -137,31 +137,48 @@ abstract class SourceFile implements LineColumnProvider {
if (colorize == null) {
colorize = (text) => text;
}
- var line = getLine(start);
- var column = getColumn(line, start);
+ int lineStart = getLine(start);
+ int columnStart = getColumn(lineStart, start);
+ int lineEnd = getLine(end);
+ int columnEnd = getColumn(lineEnd, end);
- var buf = new StringBuffer('${filename}:');
+ StringBuffer buf = new StringBuffer('${filename}:');
if (start != end || start != 0) {
// Line/column info is relevant.
- buf.write('${line + 1}:${column + 1}:');
+ buf.write('${lineStart + 1}:${columnStart + 1}:');
}
buf.write('\n$message\n');
if (start != end && includeSourceLine) {
- String textLine = getLineText(line);
-
- int toColumn = min(column + (end-start), textLine.length);
- buf.write(textLine.substring(0, column));
- buf.write(colorize(textLine.substring(column, toColumn)));
- buf.write(textLine.substring(toColumn));
-
- int i = 0;
- for (; i < column; i++) {
- buf.write(' ');
- }
-
- for (; i < toColumn; i++) {
- buf.write(colorize('^'));
+ if (lineStart == lineEnd) {
+ String textLine = getLineText(lineStart);
+
+ int toColumn = min(columnStart + (end-start), textLine.length);
+ buf.write(textLine.substring(0, columnStart));
+ buf.write(colorize(textLine.substring(columnStart, toColumn)));
+ buf.write(textLine.substring(toColumn));
+
+ int i = 0;
+ for (; i < columnStart; i++) {
+ buf.write(' ');
+ }
+
+ for (; i < toColumn; i++) {
+ buf.write(colorize('^'));
+ }
+ } else {
+ for (int line = lineStart; line <= lineEnd; line++) {
+ String textLine = getLineText(line);
+ if (line == lineStart) {
+ buf.write(textLine.substring(0, columnStart));
+ buf.write(colorize(textLine.substring(columnStart)));
+ } else if (line == lineEnd) {
+ buf.write(colorize(textLine.substring(0, columnEnd)));
+ buf.write(textLine.substring(columnEnd));
+ } else {
+ buf.write(colorize(textLine));
+ }
+ }
}
}
« no previous file with comments | « pkg/compiler/lib/src/elements/modelx.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698