Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Side by Side Diff: pkg/analyzer/benchmark/errors_in_all_libraries.dart

Issue 2060263006: Deprecate FileUriResolver and RelativeFileUriResolver in source_io.dart, replace the usages with Re… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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';
11 11
12 import 'package:analyzer/dart/element/element.dart'; 12 import 'package:analyzer/dart/element/element.dart';
13 import 'package:analyzer/src/generated/engine.dart'; 13 import 'package:analyzer/src/generated/engine.dart';
14 import 'package:analyzer/src/generated/java_io.dart'; 14 import 'package:analyzer/src/generated/java_io.dart';
15 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk; 15 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk;
16 import 'package:analyzer/src/generated/source.dart'; 16 import 'package:analyzer/src/generated/source.dart';
17 import 'package:analyzer/src/generated/source_io.dart'; 17 import 'package:analyzer/src/generated/source_io.dart';
18 import 'package:analyzer/file_system/file_system.dart';
19 import 'package:analyzer/file_system/physical_file_system.dart';
18 import 'package:path/path.dart' as p; 20 import 'package:path/path.dart' as p;
19 21
20 void main(List<String> args) { 22 void main(List<String> args) {
21 JavaSystemIO.setProperty( 23 JavaSystemIO.setProperty(
22 "com.google.dart.sdk", 24 "com.google.dart.sdk",
23 p.normalize( 25 p.normalize(
24 p.join(p.dirname(p.fromUri(Platform.script)), "../../../sdk"))); 26 p.join(p.dirname(p.fromUri(Platform.script)), "../../../sdk")));
25 27
26 // Assumes you have run "pub get" in the analyzer directory itself and uses 28 // Assumes you have run "pub get" in the analyzer directory itself and uses
27 // that "packages" directory as its package root. 29 // that "packages" directory as its package root.
28 var packageRoot = 30 var packageRoot =
29 p.normalize(p.join(p.dirname(p.fromUri(Platform.script)), "packages")); 31 p.normalize(p.join(p.dirname(p.fromUri(Platform.script)), "packages"));
30 32
31 var best = new Duration(days: 1); 33 var best = new Duration(days: 1);
32 while (true) { 34 while (true) {
33 var start = new DateTime.now(); 35 var start = new DateTime.now();
34 AnalysisEngine.instance.clearCaches(); 36 AnalysisEngine.instance.clearCaches();
35 37
36 var context = AnalysisEngine.instance.createAnalysisContext(); 38 var context = AnalysisEngine.instance.createAnalysisContext();
37 context.sourceFactory = new SourceFactory([ 39 context.sourceFactory = new SourceFactory([
38 new DartUriResolver(DirectoryBasedDartSdk.defaultSdk), 40 new DartUriResolver(DirectoryBasedDartSdk.defaultSdk),
39 new FileUriResolver(), 41 new ResourceUriResolver(PhysicalResourceProvider.INSTANCE),
40 new PackageUriResolver([new JavaFile(packageRoot)]) 42 new PackageUriResolver([new JavaFile(packageRoot)])
41 ]); 43 ]);
42 44
43 AnalysisOptionsImpl options = context.analysisOptions; 45 AnalysisOptionsImpl options = context.analysisOptions;
44 options.strongMode = true; 46 options.strongMode = true;
45 options.strongModeHints = true; 47 options.strongModeHints = true;
46 48
47 var mainSource = 49 var mainSource =
48 new FileBasedSource(new JavaFile(p.fromUri(Platform.script))); 50 new FileBasedSource(new JavaFile(p.fromUri(Platform.script)));
49 context.applyChanges(new ChangeSet()..addedSource(mainSource)); 51 context.applyChanges(new ChangeSet()..addedSource(mainSource));
(...skipping 30 matching lines...) Expand all
80 void find(LibraryElement lib) { 82 void find(LibraryElement lib) {
81 if (seen.contains(lib)) return; 83 if (seen.contains(lib)) return;
82 seen.add(lib); 84 seen.add(lib);
83 results.add(lib); 85 results.add(lib);
84 lib.importedLibraries.forEach(find); 86 lib.importedLibraries.forEach(find);
85 lib.exportedLibraries.forEach(find); 87 lib.exportedLibraries.forEach(find);
86 } 88 }
87 find(start); 89 find(start);
88 return results; 90 return results;
89 } 91 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698