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

Side by Side Diff: pkg/front_end/lib/dependency_grapher.dart

Issue 2618633006: Create a wrapper class to handle CompilerOptions in a uniform way. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/base/processed_options.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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:async'; 5 import 'dart:async';
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/error/listener.dart'; 8 import 'package:analyzer/error/listener.dart';
9 import 'package:analyzer/src/dart/scanner/reader.dart'; 9 import 'package:analyzer/src/dart/scanner/reader.dart';
10 import 'package:analyzer/src/generated/parser.dart'; 10 import 'package:analyzer/src/generated/parser.dart';
11 import 'package:front_end/file_system.dart'; 11 import 'package:front_end/file_system.dart';
12 import 'package:front_end/src/async_dependency_walker.dart'; 12 import 'package:front_end/src/async_dependency_walker.dart';
13 import 'package:front_end/src/base/processed_options.dart';
13 import 'package:front_end/src/base/uri_resolver.dart'; 14 import 'package:front_end/src/base/uri_resolver.dart';
14 import 'package:front_end/src/scanner/scanner.dart'; 15 import 'package:front_end/src/scanner/scanner.dart';
15 import 'package:package_config/packages_file.dart' as package_config;
16 16
17 import 'compiler_options.dart'; 17 import 'compiler_options.dart';
18 18
19 /// Generates a representation of the dependency graph of a program. 19 /// Generates a representation of the dependency graph of a program.
20 /// 20 ///
21 /// Given the Uri of one or more files, this function follows `import`, 21 /// Given the Uri of one or more files, this function follows `import`,
22 /// `export`, and `part` declarations to discover a graph of all files involved 22 /// `export`, and `part` declarations to discover a graph of all files involved
23 /// in the program. 23 /// in the program.
24 Future<Graph> graphForProgram( 24 Future<Graph> graphForProgram(
25 List<Uri> sources, CompilerOptions options) async { 25 List<Uri> sources, CompilerOptions options) async {
26 Map<String, Uri> packages; 26 var processedOptions = new ProcessedOptions(options);
27 if (options.packagesFilePath == null) { 27 var uriResolver = await processedOptions.getUriResolver();
28 throw new UnimplementedError(); // TODO(paulberry): search for .packages 28 var walker = new _Walker(processedOptions.fileSystem, uriResolver, processedOp tions.compileSdk);
29 } else if (options.packagesFilePath.isEmpty) {
30 packages = {};
31 } else {
32 var contents = await options.fileSystem
33 .entityForPath(options.packagesFilePath)
34 .readAsBytes();
35 var baseLocation =
36 options.fileSystem.context.toUri(options.packagesFilePath);
37 packages = package_config.parse(contents, baseLocation);
38 }
39 var sdkLibraries = <String, Uri>{}; // TODO(paulberry): support SDK libraries
40 var uriResolver =
41 new UriResolver(packages, sdkLibraries, options.fileSystem.context);
42 var walker = new _Walker(options.fileSystem, uriResolver, options.compileSdk);
43 var startingPoint = new _StartingPoint(walker, sources); 29 var startingPoint = new _StartingPoint(walker, sources);
44 await walker.walk(startingPoint); 30 await walker.walk(startingPoint);
45 return walker.graph; 31 return walker.graph;
46 } 32 }
47 33
48 /// A representation of the dependency graph of a program. 34 /// A representation of the dependency graph of a program.
49 /// 35 ///
50 /// Not intended to be extended, implemented, or mixed in by clients. 36 /// Not intended to be extended, implemented, or mixed in by clients.
51 class Graph { 37 class Graph {
52 /// A list of all library cycles in the program, in topologically sorted order 38 /// A list of all library cycles in the program, in topologically sorted order
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 handleDependency(referencedUri); 172 handleDependency(referencedUri);
187 } 173 }
188 } 174 }
189 } 175 }
190 if (!coreUriFound) { 176 if (!coreUriFound) {
191 handleDependency(dartCoreUri); 177 handleDependency(dartCoreUri);
192 } 178 }
193 return dependencies; 179 return dependencies;
194 } 180 }
195 } 181 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/base/processed_options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698