Index: sdk/lib/_internal/compiler/implementation/source_map_builder.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/source_map_builder.dart b/sdk/lib/_internal/compiler/implementation/source_map_builder.dart |
index 1665d222fd334181ac89e6b452c306b472c8a015..a4d2e4baac1fa28aeaf1f29b3be1d86507056364 100644 |
--- a/sdk/lib/_internal/compiler/implementation/source_map_builder.dart |
+++ b/sdk/lib/_internal/compiler/implementation/source_map_builder.dart |
@@ -173,28 +173,50 @@ class SourceMapEntry { |
SourceMapEntry(this.sourceLocation, this.targetOffset); |
} |
-class SourceFileLocation { |
+abstract class SourceFileLocation { |
SourceFile sourceFile; |
- Token token; |
- int line; |
- SourceFileLocation(this.sourceFile, this.token) { |
+ SourceFileLocation(this.sourceFile) { |
assert(isValid()); |
} |
+ int line; |
+ |
+ int get offset; |
+ |
String getSourceUrl() => sourceFile.filename; |
int getLine() { |
- if (line == null) line = sourceFile.getLine(token.charOffset); |
+ if (line == null) line = sourceFile.getLine(offset); |
return line; |
} |
- int getColumn() => sourceFile.getColumn(getLine(), token.charOffset); |
+ int getColumn() => sourceFile.getColumn(getLine(), offset); |
+ |
+ String getSourceName(); |
+ |
+ bool isValid() => offset < sourceFile.length; |
+} |
+ |
+class TokenSourceFileLocation extends SourceFileLocation { |
+ final Token token; |
+ |
+ TokenSourceFileLocation(SourceFile sourceFile, this.token) |
+ : super(sourceFile); |
+ |
+ int get offset => token.charOffset; |
String getSourceName() { |
if (token.isIdentifier()) return token.value; |
return null; |
} |
+} |
+ |
+class OffsetSourceFileLocation extends SourceFileLocation { |
+ final int offset; |
+ final String sourceName; |
+ OffsetSourceFileLocation(SourceFile sourceFile, this.offset, |
+ [this.sourceName]) : super(sourceFile); |
- bool isValid() => token.charOffset < sourceFile.length; |
+ String getSourceName() => sourceName; |
} |