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 AstElement, | 14 show AstElement, |
15 ClassElement, | 15 ClassElement, |
16 CompilationUnitElement, | 16 CompilationUnitElement, |
17 Element, | 17 Element, |
18 FunctionElement, | 18 FunctionElement, |
19 LibraryElement, | 19 LibraryElement, |
20 MemberElement; | 20 MemberElement; |
21 import 'package:compiler/src/io/source_file.dart' show SourceFile; | 21 import 'package:compiler/src/io/source_file.dart' show SourceFile; |
22 import 'package:compiler/src/io/source_information.dart' | 22 import 'package:compiler/src/io/source_information.dart' |
23 show computeElementNameForSourceMaps; | 23 show computeElementNameForSourceMaps; |
24 | 24 |
25 validateSourceMap(Uri targetUri, | 25 validateSourceMap(Uri targetUri, |
26 {Uri mainUri, | 26 {Uri mainUri, |
27 Position mainPosition, | 27 Position mainPosition, |
28 Compiler compiler}) { | 28 CompilerImpl compiler}) { |
29 Uri mapUri = getMapUri(targetUri); | 29 Uri mapUri = getMapUri(targetUri); |
30 List<String> targetLines = new File.fromUri(targetUri).readAsLinesSync(); | 30 List<String> targetLines = new File.fromUri(targetUri).readAsLinesSync(); |
31 SingleMapping sourceMap = getSourceMap(mapUri); | 31 SingleMapping sourceMap = getSourceMap(mapUri); |
32 checkFileReferences(targetUri, mapUri, sourceMap); | 32 checkFileReferences(targetUri, mapUri, sourceMap); |
33 checkIndexReferences(targetLines, mapUri, sourceMap); | 33 checkIndexReferences(targetLines, mapUri, sourceMap); |
34 checkRedundancy(sourceMap); | 34 checkRedundancy(sourceMap); |
35 if (compiler != null) { | 35 if (compiler != null) { |
36 checkNames(targetUri, mapUri, sourceMap, compiler); | 36 checkNames(targetUri, mapUri, sourceMap, compiler); |
37 } | 37 } |
38 if (mainUri != null && mainPosition != null) { | 38 if (mainUri != null && mainPosition != null) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 Expect.isFalse(sameSourcePoint(previous, next), | 93 Expect.isFalse(sameSourcePoint(previous, next), |
94 '$previous and $next are consecutive entries on line $line in the ' | 94 '$previous and $next are consecutive entries on line $line in the ' |
95 'source map but point to same source locations'); | 95 'source map but point to same source locations'); |
96 } | 96 } |
97 previous = next; | 97 previous = next; |
98 } | 98 } |
99 }); | 99 }); |
100 } | 100 } |
101 | 101 |
102 checkNames(Uri targetUri, Uri mapUri, | 102 checkNames(Uri targetUri, Uri mapUri, |
103 SingleMapping sourceMap, Compiler compiler) { | 103 SingleMapping sourceMap, CompilerImpl compiler) { |
104 Map<Uri, CompilationUnitElement> compilationUnitMap = {}; | 104 Map<Uri, CompilationUnitElement> compilationUnitMap = {}; |
105 | 105 |
106 void mapCompilationUnits(LibraryElement library) { | 106 void mapCompilationUnits(LibraryElement library) { |
107 library.compilationUnits.forEach((CompilationUnitElement compilationUnit) { | 107 library.compilationUnits.forEach((CompilationUnitElement compilationUnit) { |
108 compilationUnitMap[compilationUnit.script.readableUri] = compilationUnit; | 108 compilationUnitMap[compilationUnit.script.readableUri] = compilationUnit; |
109 }); | 109 }); |
110 } | 110 } |
111 | 111 |
112 compiler.libraryLoader.libraries.forEach((LibraryElement library) { | 112 compiler.libraryLoader.libraries.forEach((LibraryElement library) { |
113 mapCompilationUnits(library); | 113 mapCompilationUnits(library); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 final Position end; | 321 final Position end; |
322 | 322 |
323 Interval(this.begin, this.end); | 323 Interval(this.begin, this.end); |
324 | 324 |
325 bool contains(Position other) { | 325 bool contains(Position other) { |
326 return begin <= other && other <= end; | 326 return begin <= other && other <= end; |
327 } | 327 } |
328 | 328 |
329 String toString() => '$begin-$end'; | 329 String toString() => '$begin-$end'; |
330 } | 330 } |
OLD | NEW |