OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 import 'dart:io'; | 5 import 'dart:io'; |
6 import 'dart:convert'; | 6 import 'dart:convert'; |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:path/path.dart' as path; | 9 import 'package:path/path.dart' as path; |
10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
11 import 'package:source_maps/source_maps.dart' hide SourceFile; | 11 import 'package:source_maps/source_maps.dart' hide SourceFile; |
12 import 'package:compiler/src/apiimpl.dart'; | 12 import 'package:compiler/src/apiimpl.dart'; |
13 import 'package:compiler/src/elements/elements.dart' | 13 import 'package:compiler/src/elements/elements.dart' |
14 show LibraryElement, | 14 show LibraryElement, |
15 CompilationUnitElement, | 15 CompilationUnitElement, |
16 ClassElement, | 16 ClassElement, |
17 AstElement; | 17 AstElement; |
18 import 'package:compiler/src/source_file.dart' show SourceFile; | 18 import 'package:compiler/src/io/source_file.dart' show SourceFile; |
19 | 19 |
20 validateSourceMap(Uri targetUri, [Compiler compiler]) { | 20 validateSourceMap(Uri targetUri, [Compiler compiler]) { |
21 Uri mapUri = getMapUri(targetUri); | 21 Uri mapUri = getMapUri(targetUri); |
22 SingleMapping sourceMap = getSourceMap(mapUri); | 22 SingleMapping sourceMap = getSourceMap(mapUri); |
23 checkFileReferences(targetUri, mapUri, sourceMap); | 23 checkFileReferences(targetUri, mapUri, sourceMap); |
24 checkIndexReferences(targetUri, mapUri, sourceMap); | 24 checkIndexReferences(targetUri, mapUri, sourceMap); |
25 checkRedundancy(sourceMap); | 25 checkRedundancy(sourceMap); |
26 if (compiler != null) { | 26 if (compiler != null) { |
27 checkNames(targetUri, mapUri, sourceMap, compiler); | 27 checkNames(targetUri, mapUri, sourceMap, compiler); |
28 } | 28 } |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 return | 167 return |
168 (entry.sourceUrlId == otherEntry.sourceUrlId) && | 168 (entry.sourceUrlId == otherEntry.sourceUrlId) && |
169 (entry.sourceLine == otherEntry.sourceLine) && | 169 (entry.sourceLine == otherEntry.sourceLine) && |
170 (entry.sourceColumn == otherEntry.sourceColumn) && | 170 (entry.sourceColumn == otherEntry.sourceColumn) && |
171 (entry.sourceNameId == otherEntry.sourceNameId); | 171 (entry.sourceNameId == otherEntry.sourceNameId); |
172 } | 172 } |
173 | 173 |
174 Uri getMapUri(Uri targetUri) { | 174 Uri getMapUri(Uri targetUri) { |
175 print('Accessing $targetUri'); | 175 print('Accessing $targetUri'); |
176 File targetFile = new File.fromUri(targetUri); | 176 File targetFile = new File.fromUri(targetUri); |
177 Expect.isTrue(targetFile.existsSync()); | 177 Expect.isTrue(targetFile.existsSync(), "File '$targetUri' doesn't exist."); |
178 List<String> target = targetFile.readAsStringSync().split('\n'); | 178 List<String> target = targetFile.readAsStringSync().split('\n'); |
179 String mapReference = target[target.length - 2]; // #sourceMappingURL=<url> | 179 String mapReference = target[target.length - 2]; // #sourceMappingURL=<url> |
180 Expect.isTrue(mapReference.startsWith('//# sourceMappingURL=')); | 180 Expect.isTrue(mapReference.startsWith('//# sourceMappingURL=')); |
181 String mapName = mapReference.substring(mapReference.indexOf('=') + 1); | 181 String mapName = mapReference.substring(mapReference.indexOf('=') + 1); |
182 return targetUri.resolve(mapName); | 182 return targetUri.resolve(mapName); |
183 } | 183 } |
184 | 184 |
185 SingleMapping getSourceMap(Uri mapUri) { | 185 SingleMapping getSourceMap(Uri mapUri) { |
186 print('Accessing $mapUri'); | 186 print('Accessing $mapUri'); |
187 File mapFile = new File.fromUri(mapUri); | 187 File mapFile = new File.fromUri(mapUri); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 final Position end; | 231 final Position end; |
232 | 232 |
233 Interval(this.begin, this.end); | 233 Interval(this.begin, this.end); |
234 | 234 |
235 bool contains(Position other) { | 235 bool contains(Position other) { |
236 return begin <= other && other <= end; | 236 return begin <= other && other <= end; |
237 } | 237 } |
238 | 238 |
239 String toString() => '$begin-$end'; | 239 String toString() => '$begin-$end'; |
240 } | 240 } |
OLD | NEW |