Chromium Code Reviews| Index: pkg/compiler/lib/src/io/source_information.dart |
| diff --git a/pkg/compiler/lib/src/io/source_information.dart b/pkg/compiler/lib/src/io/source_information.dart |
| index c238268db6ffb80ed9d94f8dd7bab46f06ffa7c6..fb038ee2210218f966e6f9cac1d18e37ac4782d1 100644 |
| --- a/pkg/compiler/lib/src/io/source_information.dart |
| +++ b/pkg/compiler/lib/src/io/source_information.dart |
| @@ -95,14 +95,55 @@ class StartEndSourceInformation implements SourceInformation { |
| String toString() { |
| StringBuffer sb = new StringBuffer(); |
| sb.write('${startPosition.sourceUri}:'); |
| - sb.write('[${startPosition.line},${startPosition.column}]'); |
| + sb.write('[${startPosition.line + 1},${startPosition.column + 1}]'); |
|
floitsch
2015/02/24 19:58:12
Is this just to make it easier to reason? That is,
Johnni Winther
2015/03/02 11:48:14
Done.
|
| if (endPosition != null) { |
| - sb.write('-[${endPosition.line},${endPosition.column}]'); |
| + sb.write('-[${endPosition.line + 1},${endPosition.column + 1}]'); |
| } |
| return sb.toString(); |
| } |
| } |
| +/// [SourceInformation] that consists of an offset position into the source |
| +/// code. |
| +class PositionSourceInformation implements SourceInformation { |
| + final SourceLocation sourcePosition; |
| + |
| + PositionSourceInformation(this.sourcePosition); |
| + |
| + @override |
| + void beginMapping(CodeOutput output) { |
| + output.setSourceLocation(sourcePosition); |
| + } |
| + |
| + @override |
| + void endMapping(CodeOutput output) { |
| + // Do nothing. |
| + } |
| + |
| + SourceSpan get sourceSpan { |
| + Uri uri = sourcePosition.sourceUri; |
| + int offset = sourcePosition.offset; |
| + return new SourceSpan(uri, offset, offset); |
| + } |
| + |
| + int get hashCode { |
| + return sourcePosition.hashCode * 17 & 0x7FFFFFFF; |
| + } |
| + |
| + bool operator ==(other) { |
| + if (identical(this, other)) return true; |
| + if (other is! PositionSourceInformation) return false; |
| + return sourcePosition == other.sourcePosition; |
| + } |
| + |
| + String toString() { |
| + StringBuffer sb = new StringBuffer(); |
| + sb.write('${sourcePosition.sourceUri}:'); |
| + sb.write('[${sourcePosition.line + 1},${sourcePosition.column + 1}]'); |
| + return sb.toString(); |
| + } |
| +} |
| + |
| /// A location in a source file. |
| abstract class SourceLocation { |
| final SourceFile _sourceFile; |
| @@ -147,7 +188,7 @@ abstract class SourceLocation { |
| sourceName == other.sourceName; |
| } |
| - String toString() => '${sourceUri}:[${line},${column}]'; |
| + String toString() => '${sourceUri}:[${line + 1},${column + 1}]'; |
| } |
| class TokenSourceLocation extends SourceLocation { |