| 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 // TODO(jmesserly): this file needs to be refactored, it's a port from | 5 // TODO(jmesserly): this file needs to be refactored, it's a port from |
| 6 // package:dev_compiler's tests | 6 // package:dev_compiler's tests |
| 7 library analyzer.test.src.task.strong.strong_test_helper; | 7 library analyzer.test.src.task.strong.strong_test_helper; |
| 8 | 8 |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 var endLoc = _locationForOffset(lineInfo, source.uri, end ?? start); | 37 var endLoc = _locationForOffset(lineInfo, source.uri, end ?? start); |
| 38 | 38 |
| 39 var lineStart = startLoc.offset - startLoc.column; | 39 var lineStart = startLoc.offset - startLoc.column; |
| 40 // Find the end of the line. This is not exposed directly on LineInfo, but | 40 // Find the end of the line. This is not exposed directly on LineInfo, but |
| 41 // we can find it pretty easily. | 41 // we can find it pretty easily. |
| 42 // TODO(jmesserly): for now we do the simple linear scan. Ideally we can get | 42 // TODO(jmesserly): for now we do the simple linear scan. Ideally we can get |
| 43 // some help from the LineInfo API. | 43 // some help from the LineInfo API. |
| 44 int lineEnd = endLoc.offset; | 44 int lineEnd = endLoc.offset; |
| 45 int lineNum = lineInfo.getLocation(lineEnd).lineNumber; | 45 int lineNum = lineInfo.getLocation(lineEnd).lineNumber; |
| 46 while (lineEnd < content.length && | 46 while (lineEnd < content.length && |
| 47 lineInfo.getLocation(++lineEnd).lineNumber == lineNum); | 47 lineInfo.getLocation(++lineEnd).lineNumber == lineNum) {} |
| 48 | 48 |
| 49 if (end == null) { | 49 if (end == null) { |
| 50 end = lineEnd; | 50 end = lineEnd; |
| 51 endLoc = _locationForOffset(lineInfo, source.uri, lineEnd); | 51 endLoc = _locationForOffset(lineInfo, source.uri, lineEnd); |
| 52 } | 52 } |
| 53 | 53 |
| 54 var text = content.substring(start, end); | 54 var text = content.substring(start, end); |
| 55 var lineText = content.substring(lineStart, lineEnd); | 55 var lineText = content.substring(lineStart, lineEnd); |
| 56 return new SourceSpanWithContext(startLoc, endLoc, text, lineText); | 56 return new SourceSpanWithContext(startLoc, endLoc, text, lineText); |
| 57 } | 57 } |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 @override | 474 @override |
| 475 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 475 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
| 476 if (uri.scheme == 'package') { | 476 if (uri.scheme == 'package') { |
| 477 return (provider.getResource( | 477 return (provider.getResource( |
| 478 provider.convertPath('/packages/' + uri.path)) as File) | 478 provider.convertPath('/packages/' + uri.path)) as File) |
| 479 .createSource(uri); | 479 .createSource(uri); |
| 480 } | 480 } |
| 481 return super.resolveAbsolute(uri, actualUri); | 481 return super.resolveAbsolute(uri, actualUri); |
| 482 } | 482 } |
| 483 } | 483 } |
| OLD | NEW |