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

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

Issue 2551023005: Prepare for decoupling analyzer ASTs from element model. (Closed)
Patch Set: Created 4 years 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/ast/resolution_accessors.dart';
12 import 'package:analyzer/dart/element/element.dart'; 13 import 'package:analyzer/dart/element/element.dart';
13 import 'package:analyzer/file_system/file_system.dart'; 14 import 'package:analyzer/file_system/file_system.dart';
14 import 'package:analyzer/file_system/physical_file_system.dart'; 15 import 'package:analyzer/file_system/physical_file_system.dart';
15 import 'package:analyzer/source/package_map_resolver.dart'; 16 import 'package:analyzer/source/package_map_resolver.dart';
16 import 'package:analyzer/src/context/builder.dart'; 17 import 'package:analyzer/src/context/builder.dart';
17 import 'package:analyzer/src/dart/sdk/sdk.dart'; 18 import 'package:analyzer/src/dart/sdk/sdk.dart';
18 import 'package:analyzer/src/generated/engine.dart'; 19 import 'package:analyzer/src/generated/engine.dart';
19 import 'package:analyzer/src/generated/source.dart'; 20 import 'package:analyzer/src/generated/source.dart';
20 import 'package:analyzer/src/generated/source_io.dart'; 21 import 'package:analyzer/src/generated/source_io.dart';
21 import 'package:analyzer/src/source/source_resource.dart'; 22 import 'package:analyzer/src/source/source_resource.dart';
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 55
55 var mainSource = 56 var mainSource =
56 new FileSource(resourceProvider.getFile(p.fromUri(Platform.script))); 57 new FileSource(resourceProvider.getFile(p.fromUri(Platform.script)));
57 context.applyChanges(new ChangeSet()..addedSource(mainSource)); 58 context.applyChanges(new ChangeSet()..addedSource(mainSource));
58 59
59 var initialLibrary = 60 var initialLibrary =
60 context.resolveCompilationUnit2(mainSource, mainSource); 61 context.resolveCompilationUnit2(mainSource, mainSource);
61 62
62 // Walk all of the transitively referenced libraries and compute errors. 63 // Walk all of the transitively referenced libraries and compute errors.
63 var errorCount = 0; 64 var errorCount = 0;
64 var allLibraries = _reachableLibraries(initialLibrary.element.library); 65 var allLibraries =
66 _reachableLibraries(elementForCompilationUnit(initialLibrary).library);
65 for (var lib in allLibraries) { 67 for (var lib in allLibraries) {
66 for (var unit in lib.units) { 68 for (var unit in lib.units) {
67 var source = unit.source; 69 var source = unit.source;
68 70
69 // Skip core libraries. 71 // Skip core libraries.
70 if (source.uri.scheme == 'dart') continue; 72 if (source.uri.scheme == 'dart') continue;
71 73
72 var librarySource = context.getLibrariesContaining(source).single; 74 var librarySource = context.getLibrariesContaining(source).single;
73 context.resolveCompilationUnit2(source, librarySource); 75 context.resolveCompilationUnit2(source, librarySource);
74 errorCount += context.computeErrors(source).length; 76 errorCount += context.computeErrors(source).length;
(...skipping 14 matching lines...) Expand all
89 if (seen.contains(lib)) return; 91 if (seen.contains(lib)) return;
90 seen.add(lib); 92 seen.add(lib);
91 results.add(lib); 93 results.add(lib);
92 lib.importedLibraries.forEach(find); 94 lib.importedLibraries.forEach(find);
93 lib.exportedLibraries.forEach(find); 95 lib.exportedLibraries.forEach(find);
94 } 96 }
95 97
96 find(start); 98 find(start);
97 return results; 99 return results;
98 } 100 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698