OLD | NEW |
1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 /// Resolves this library and everything it transitively imports and generates | 6 /// Resolves this library and everything it transitively imports and generates |
7 /// errors in all of those libraries. Does this in an infinite loop, starting | 7 /// errors in all of those libraries. Does this in an infinite loop, starting |
8 /// from scratch each time, to show how VM warm-up affects things and to make | 8 /// from scratch each time, to show how VM warm-up affects things and to make |
9 /// it easier to connect to this with observatory. | 9 /// it easier to connect to this with observatory. |
10 import 'dart:io'; | 10 import 'dart:io'; |
(...skipping 22 matching lines...) Expand all Loading... |
33 var start = new DateTime.now(); | 33 var start = new DateTime.now(); |
34 AnalysisEngine.instance.clearCaches(); | 34 AnalysisEngine.instance.clearCaches(); |
35 | 35 |
36 var context = AnalysisEngine.instance.createAnalysisContext(); | 36 var context = AnalysisEngine.instance.createAnalysisContext(); |
37 context.sourceFactory = new SourceFactory([ | 37 context.sourceFactory = new SourceFactory([ |
38 new DartUriResolver(DirectoryBasedDartSdk.defaultSdk), | 38 new DartUriResolver(DirectoryBasedDartSdk.defaultSdk), |
39 new FileUriResolver(), | 39 new FileUriResolver(), |
40 new PackageUriResolver([new JavaFile(packageRoot)]) | 40 new PackageUriResolver([new JavaFile(packageRoot)]) |
41 ]); | 41 ]); |
42 | 42 |
43 context.analysisOptions.strongMode = true; | 43 AnalysisOptionsImpl options = context.analysisOptions; |
44 context.analysisOptions.strongModeHints = true; | 44 options.strongMode = true; |
| 45 options.strongModeHints = true; |
45 | 46 |
46 var mainSource = | 47 var mainSource = |
47 new FileBasedSource(new JavaFile(p.fromUri(Platform.script))); | 48 new FileBasedSource(new JavaFile(p.fromUri(Platform.script))); |
48 context.applyChanges(new ChangeSet()..addedSource(mainSource)); | 49 context.applyChanges(new ChangeSet()..addedSource(mainSource)); |
49 | 50 |
50 var initialLibrary = | 51 var initialLibrary = |
51 context.resolveCompilationUnit2(mainSource, mainSource); | 52 context.resolveCompilationUnit2(mainSource, mainSource); |
52 | 53 |
53 // Walk all of the transitively referenced libraries and compute errors. | 54 // Walk all of the transitively referenced libraries and compute errors. |
54 var errorCount = 0; | 55 var errorCount = 0; |
(...skipping 24 matching lines...) Expand all Loading... |
79 void find(LibraryElement lib) { | 80 void find(LibraryElement lib) { |
80 if (seen.contains(lib)) return; | 81 if (seen.contains(lib)) return; |
81 seen.add(lib); | 82 seen.add(lib); |
82 results.add(lib); | 83 results.add(lib); |
83 lib.importedLibraries.forEach(find); | 84 lib.importedLibraries.forEach(find); |
84 lib.exportedLibraries.forEach(find); | 85 lib.exportedLibraries.forEach(find); |
85 } | 86 } |
86 find(start); | 87 find(start); |
87 return results; | 88 return results; |
88 } | 89 } |
OLD | NEW |