OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /** | 5 /** |
6 * This file contains code to output a description of tasks and their | 6 * This file contains code to output a description of tasks and their |
7 * dependencies in ".dot" format. Prior to running, the user should run "pub | 7 * dependencies in ".dot" format. Prior to running, the user should run "pub |
8 * get" in the analyzer directory to ensure that a "packages" folder exists. | 8 * get" in the analyzer directory to ensure that a "packages" folder exists. |
9 * | 9 * |
10 * TODO(paulberry): | 10 * TODO(paulberry): |
11 * - Add general.dart and html.dart for completeness. | 11 * - Add general.dart and html.dart for completeness. |
12 * - Use Graphviz's "record" feature to produce more compact output | 12 * - Use Graphviz's "record" feature to produce more compact output |
13 * (http://www.graphviz.org/content/node-shapes#record) | 13 * (http://www.graphviz.org/content/node-shapes#record) |
14 * - Produce a warning if a result descriptor is found which isn't the output | 14 * - Produce a warning if a result descriptor is found which isn't the output |
15 * of exactly one task. | 15 * of exactly one task. |
16 * - Convert this tool to use package_config to find the package map. | 16 * - Convert this tool to use package_config to find the package map. |
17 */ | 17 */ |
18 library analyzer.tool.task_dependency_graph.generate; | 18 library analyzer.tool.task_dependency_graph.generate; |
19 | 19 |
20 import 'dart:io' hide File; | 20 import 'dart:io' hide File; |
21 import 'dart:io' as io; | 21 import 'dart:io' as io; |
22 | 22 |
23 import 'package:analyzer/analyzer.dart'; | 23 import 'package:analyzer/analyzer.dart'; |
24 import 'package:analyzer/dart/element/element.dart'; | 24 import 'package:analyzer/dart/element/element.dart'; |
25 import 'package:analyzer/dart/element/type.dart'; | 25 import 'package:analyzer/dart/element/type.dart'; |
26 import 'package:analyzer/file_system/file_system.dart'; | 26 import 'package:analyzer/file_system/file_system.dart'; |
27 import 'package:analyzer/file_system/physical_file_system.dart'; | 27 import 'package:analyzer/file_system/physical_file_system.dart'; |
| 28 import 'package:analyzer/source/package_map_resolver.dart'; |
28 import 'package:analyzer/src/codegen/tools.dart'; | 29 import 'package:analyzer/src/codegen/tools.dart'; |
| 30 import 'package:analyzer/src/context/builder.dart'; |
29 import 'package:analyzer/src/dart/sdk/sdk.dart'; | 31 import 'package:analyzer/src/dart/sdk/sdk.dart'; |
30 import 'package:analyzer/src/generated/constant.dart'; | 32 import 'package:analyzer/src/generated/constant.dart'; |
31 import 'package:analyzer/src/generated/engine.dart'; | 33 import 'package:analyzer/src/generated/engine.dart'; |
32 import 'package:analyzer/src/generated/java_io.dart'; | |
33 import 'package:analyzer/src/generated/sdk.dart'; | 34 import 'package:analyzer/src/generated/sdk.dart'; |
34 import 'package:analyzer/src/generated/source.dart'; | 35 import 'package:analyzer/src/generated/source.dart'; |
35 import 'package:analyzer/src/generated/source_io.dart'; | 36 import 'package:analyzer/src/generated/source_io.dart'; |
36 import 'package:path/path.dart' as path; | 37 import 'package:path/path.dart' as path; |
37 import 'package:path/path.dart'; | 38 import 'package:path/path.dart'; |
38 | 39 |
39 /** | 40 /** |
40 * Generate the target .dot file. | 41 * Generate the target .dot file. |
41 */ | 42 */ |
42 main() { | 43 main() { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 resourceProvider = PhysicalResourceProvider.INSTANCE; | 153 resourceProvider = PhysicalResourceProvider.INSTANCE; |
153 DartSdk sdk = new FolderBasedDartSdk(resourceProvider, | 154 DartSdk sdk = new FolderBasedDartSdk(resourceProvider, |
154 FolderBasedDartSdk.defaultSdkDirectory(resourceProvider)); | 155 FolderBasedDartSdk.defaultSdkDirectory(resourceProvider)); |
155 context = AnalysisEngine.instance.createAnalysisContext(); | 156 context = AnalysisEngine.instance.createAnalysisContext(); |
156 String packageRootPath; | 157 String packageRootPath; |
157 if (Platform.packageRoot != null) { | 158 if (Platform.packageRoot != null) { |
158 packageRootPath = Uri.parse(Platform.packageRoot).toFilePath(); | 159 packageRootPath = Uri.parse(Platform.packageRoot).toFilePath(); |
159 } else { | 160 } else { |
160 packageRootPath = path.join(rootDir, 'packages'); | 161 packageRootPath = path.join(rootDir, 'packages'); |
161 } | 162 } |
162 JavaFile packagesDir = new JavaFile(packageRootPath); | 163 ContextBuilder builder = new ContextBuilder(resourceProvider, null, null); |
163 List<UriResolver> uriResolvers = [ | 164 List<UriResolver> uriResolvers = [ |
164 new DartUriResolver(sdk), | 165 new DartUriResolver(sdk), |
165 new PackageUriResolver(<JavaFile>[packagesDir]), | 166 new PackageMapUriResolver( |
| 167 resourceProvider, |
| 168 builder |
| 169 .convertPackagesToMap(builder.createPackageMap(packageRootPath))), |
166 new ResourceUriResolver(PhysicalResourceProvider.INSTANCE) | 170 new ResourceUriResolver(PhysicalResourceProvider.INSTANCE) |
167 ]; | 171 ]; |
168 context.sourceFactory = new SourceFactory(uriResolvers); | 172 context.sourceFactory = new SourceFactory(uriResolvers); |
169 Source dartDartSource = | 173 Source dartDartSource = |
170 setupSource(path.join('lib', 'src', 'task', 'dart.dart')); | 174 setupSource(path.join('lib', 'src', 'task', 'dart.dart')); |
171 Source taskSource = setupSource(path.join('lib', 'plugin', 'task.dart')); | 175 Source taskSource = setupSource(path.join('lib', 'plugin', 'task.dart')); |
172 Source modelSource = setupSource(path.join('lib', 'task', 'model.dart')); | 176 Source modelSource = setupSource(path.join('lib', 'task', 'model.dart')); |
173 Source enginePluginSource = | 177 Source enginePluginSource = |
174 setupSource(path.join('lib', 'src', 'plugin', 'engine_plugin.dart')); | 178 setupSource(path.join('lib', 'src', 'plugin', 'engine_plugin.dart')); |
175 CompilationUnitElement modelElement = getUnit(modelSource).element; | 179 CompilationUnitElement modelElement = getUnit(modelSource).element; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 @override | 354 @override |
351 visitIdentifier(Identifier node) { | 355 visitIdentifier(Identifier node) { |
352 Element element = node.staticElement; | 356 Element element = node.staticElement; |
353 if (element is PropertyAccessorElement && | 357 if (element is PropertyAccessorElement && |
354 element.isGetter && | 358 element.isGetter && |
355 element.returnType.isSubtypeOf(type)) { | 359 element.returnType.isSubtypeOf(type)) { |
356 callback(element); | 360 callback(element); |
357 } | 361 } |
358 } | 362 } |
359 } | 363 } |
OLD | NEW |