| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// Source information system mapping that attempts a semantic mapping between | 5 /// Source information system mapping that attempts a semantic mapping between |
| 6 /// offsets of JavaScript code points to offsets of Dart code points. | 6 /// offsets of JavaScript code points to offsets of Dart code points. |
| 7 | 7 |
| 8 library dart2js.source_information.position; | 8 library dart2js.source_information.position; |
| 9 | 9 |
| 10 import '../common.dart'; | 10 import '../common.dart'; |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 // location points to the 'name' of accessed property, `b` in the | 215 // location points to the 'name' of accessed property, `b` in the |
| 216 // example. The latter is needed when both `a` and `b` are compiled into | 216 // example. The latter is needed when both `a` and `b` are compiled into |
| 217 // JavaScript invocations. | 217 // JavaScript invocations. |
| 218 return new PositionSourceInformation( | 218 return new PositionSourceInformation( |
| 219 new OffsetSourceLocation( | 219 new OffsetSourceLocation( |
| 220 sourceFile, left.getBeginToken().charOffset, name), | 220 sourceFile, left.getBeginToken().charOffset, name), |
| 221 new OffsetSourceLocation( | 221 new OffsetSourceLocation( |
| 222 sourceFile, right.getBeginToken().charOffset, name)); | 222 sourceFile, right.getBeginToken().charOffset, name)); |
| 223 } | 223 } |
| 224 | 224 |
| 225 // TODO(johnniwinther): Clean up the use of this and [buildBinary], |
| 226 // [buildIndex], etc. |
| 225 @override | 227 @override |
| 226 SourceInformation buildCall(Node receiver, Node call) { | 228 SourceInformation buildCall(Node receiver, Node call) { |
| 227 return new PositionSourceInformation( | 229 return new PositionSourceInformation( |
| 228 new OffsetSourceLocation( | 230 new OffsetSourceLocation( |
| 229 sourceFile, receiver.getBeginToken().charOffset, name), | 231 sourceFile, receiver.getBeginToken().charOffset, name), |
| 230 new OffsetSourceLocation( | 232 new OffsetSourceLocation( |
| 231 sourceFile, call.getBeginToken().charOffset, name)); | 233 sourceFile, call.getBeginToken().charOffset, name)); |
| 232 } | 234 } |
| 233 | 235 |
| 234 @override | 236 @override |
| (...skipping 24 matching lines...) Expand all Loading... |
| 259 } | 261 } |
| 260 // TODO(johnniwinther): Are there other cases? | 262 // TODO(johnniwinther): Are there other cases? |
| 261 } | 263 } |
| 262 return null; | 264 return null; |
| 263 } | 265 } |
| 264 | 266 |
| 265 @override | 267 @override |
| 266 SourceInformationBuilder forContext(AstElement element) { | 268 SourceInformationBuilder forContext(AstElement element) { |
| 267 return new PositionSourceInformationBuilder(element); | 269 return new PositionSourceInformationBuilder(element); |
| 268 } | 270 } |
| 271 |
| 272 @override |
| 273 SourceInformation buildForeignCode(Node node) => buildBegin(node); |
| 274 |
| 275 @override |
| 276 SourceInformation buildStringInterpolation(Node node) => buildBegin(node); |
| 277 |
| 278 @override |
| 279 SourceInformation buildForInIterator(Node node) => buildBegin(node); |
| 280 |
| 281 @override |
| 282 SourceInformation buildForInMoveNext(Node node) => buildBegin(node); |
| 283 |
| 284 @override |
| 285 SourceInformation buildForInCurrent(Node node) => buildBegin(node); |
| 286 |
| 287 @override |
| 288 SourceInformation buildForInSet(Node node) => buildBegin(node); |
| 289 |
| 290 @override |
| 291 SourceInformation buildIndex(Node node) => buildBegin(node); |
| 292 |
| 293 @override |
| 294 SourceInformation buildIndexSet(Node node) => buildBegin(node); |
| 295 |
| 296 @override |
| 297 SourceInformation buildBinary(Node node) => buildBegin(node); |
| 298 |
| 299 @override |
| 300 SourceInformation buildCatch(Node node) => buildBegin(node); |
| 301 |
| 302 @override |
| 303 SourceInformation buildIs(Node node) => buildBegin(node); |
| 304 |
| 305 @override |
| 306 SourceInformation buildAs(Node node) => buildBegin(node); |
| 269 } | 307 } |
| 270 | 308 |
| 271 /// The start, end and closing offsets for a [js.Node]. | 309 /// The start, end and closing offsets for a [js.Node]. |
| 272 class CodePosition { | 310 class CodePosition { |
| 273 final int startPosition; | 311 final int startPosition; |
| 274 final int endPosition; | 312 final int endPosition; |
| 275 final int closingPosition; | 313 final int closingPosition; |
| 276 | 314 |
| 277 CodePosition(this.startPosition, this.endPosition, this.closingPosition); | 315 CodePosition(this.startPosition, this.endPosition, this.closingPosition); |
| 278 | 316 |
| (...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1284 | 1322 |
| 1285 @override | 1323 @override |
| 1286 CodePosition operator [](js.Node node) { | 1324 CodePosition operator [](js.Node node) { |
| 1287 CodePosition codePosition = codePositions[node]; | 1325 CodePosition codePosition = codePositions[node]; |
| 1288 if (codePosition == null) { | 1326 if (codePosition == null) { |
| 1289 coverage.registerNodesWithoutOffset(node); | 1327 coverage.registerNodesWithoutOffset(node); |
| 1290 } | 1328 } |
| 1291 return codePosition; | 1329 return codePosition; |
| 1292 } | 1330 } |
| 1293 } | 1331 } |
| OLD | NEW |