| 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 } | 298 } |
| 299 | 299 |
| 300 /// The start, end and closing offsets for a [js.Node]. | 300 /// The start, end and closing offsets for a [js.Node]. |
| 301 class CodePosition { | 301 class CodePosition { |
| 302 final int startPosition; | 302 final int startPosition; |
| 303 final int endPosition; | 303 final int endPosition; |
| 304 final int closingPosition; | 304 final int closingPosition; |
| 305 | 305 |
| 306 CodePosition(this.startPosition, this.endPosition, this.closingPosition); | 306 CodePosition(this.startPosition, this.endPosition, this.closingPosition); |
| 307 | 307 |
| 308 // ignore: MISSING_RETURN |
| 308 int getPosition(CodePositionKind kind) { | 309 int getPosition(CodePositionKind kind) { |
| 309 switch (kind) { | 310 switch (kind) { |
| 310 case CodePositionKind.START: | 311 case CodePositionKind.START: |
| 311 return startPosition; | 312 return startPosition; |
| 312 case CodePositionKind.END: | 313 case CodePositionKind.END: |
| 313 return endPosition; | 314 return endPosition; |
| 314 case CodePositionKind.CLOSING: | 315 case CodePositionKind.CLOSING: |
| 315 return closingPosition; | 316 return closingPosition; |
| 316 } | 317 } |
| 317 } | 318 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 /// For function expressions the inner position is the closing brace or the | 373 /// For function expressions the inner position is the closing brace or the |
| 373 /// arrow: | 374 /// arrow: |
| 374 /// | 375 /// |
| 375 /// foo() => () {} | 376 /// foo() => () {} |
| 376 /// ^ // the inner position of the 'foo' function | 377 /// ^ // the inner position of the 'foo' function |
| 377 /// ^ // the inner position of the closure | 378 /// ^ // the inner position of the closure |
| 378 /// | 379 /// |
| 379 INNER, | 380 INNER, |
| 380 } | 381 } |
| 381 | 382 |
| 383 // ignore: MISSING_RETURN |
| 382 SourceLocation getSourceLocation(SourceInformation sourceInformation, | 384 SourceLocation getSourceLocation(SourceInformation sourceInformation, |
| 383 [SourcePositionKind sourcePositionKind = SourcePositionKind.START]) { | 385 [SourcePositionKind sourcePositionKind = SourcePositionKind.START]) { |
| 384 if (sourceInformation == null) return null; | 386 if (sourceInformation == null) return null; |
| 385 switch (sourcePositionKind) { | 387 switch (sourcePositionKind) { |
| 386 case SourcePositionKind.START: | 388 case SourcePositionKind.START: |
| 387 return sourceInformation.startPosition; | 389 return sourceInformation.startPosition; |
| 388 case SourcePositionKind.INNER: | 390 case SourcePositionKind.INNER: |
| 389 return sourceInformation.closingPosition; | 391 return sourceInformation.closingPosition; |
| 390 } | 392 } |
| 391 } | 393 } |
| (...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 | 1336 |
| 1335 @override | 1337 @override |
| 1336 CodePosition operator [](js.Node node) { | 1338 CodePosition operator [](js.Node node) { |
| 1337 CodePosition codePosition = codePositions[node]; | 1339 CodePosition codePosition = codePositions[node]; |
| 1338 if (codePosition == null) { | 1340 if (codePosition == null) { |
| 1339 coverage.registerNodesWithoutOffset(node); | 1341 coverage.registerNodesWithoutOffset(node); |
| 1340 } | 1342 } |
| 1341 return codePosition; | 1343 return codePosition; |
| 1342 } | 1344 } |
| 1343 } | 1345 } |
| OLD | NEW |