| OLD | NEW |
| 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_map_builder'); | 5 #library('source_map_builder'); |
| 6 | 6 |
| 7 #import('dart:json'); | 7 #import('dart:json'); |
| 8 | 8 |
| 9 #import('scanner/scannerlib.dart'); | 9 #import('scanner/scannerlib.dart'); |
| 10 #import('source_file.dart'); | 10 #import('source_file.dart'); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 148 |
| 149 SourceMapEntry(this.sourceLocation, this.targetOffset); | 149 SourceMapEntry(this.sourceLocation, this.targetOffset); |
| 150 } | 150 } |
| 151 | 151 |
| 152 class SourceFileLocation { | 152 class SourceFileLocation { |
| 153 SourceFile sourceFile; | 153 SourceFile sourceFile; |
| 154 Token token; | 154 Token token; |
| 155 int line; | 155 int line; |
| 156 | 156 |
| 157 SourceFileLocation(this.sourceFile, this.token) { | 157 SourceFileLocation(this.sourceFile, this.token) { |
| 158 assert(token.charOffset < sourceFile.text.length); | 158 assert(isValid()); |
| 159 } | 159 } |
| 160 | 160 |
| 161 String getSourceUrl() => sourceFile.filename; | 161 String getSourceUrl() => sourceFile.filename; |
| 162 | 162 |
| 163 int getLine() { | 163 int getLine() { |
| 164 if (line == null) line = sourceFile.getLine(token.charOffset); | 164 if (line == null) line = sourceFile.getLine(token.charOffset); |
| 165 return line; | 165 return line; |
| 166 } | 166 } |
| 167 | 167 |
| 168 int getColumn() => sourceFile.getColumn(getLine(), token.charOffset); | 168 int getColumn() => sourceFile.getColumn(getLine(), token.charOffset); |
| 169 | 169 |
| 170 String getSourceName() { | 170 String getSourceName() { |
| 171 if (token.isIdentifier()) return token.slowToString(); | 171 if (token.isIdentifier()) return token.slowToString(); |
| 172 return null; | 172 return null; |
| 173 } | 173 } |
| 174 |
| 175 bool isValid() => token.charOffset < sourceFile.text.length; |
| 174 } | 176 } |
| OLD | NEW |