| 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): |
| (...skipping 13 matching lines...) Expand all Loading... |
| 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/source/package_map_resolver.dart'; |
| 29 import 'package:analyzer/src/codegen/tools.dart'; | 29 import 'package:analyzer/src/codegen/tools.dart'; |
| 30 import 'package:analyzer/src/context/builder.dart'; | 30 import 'package:analyzer/src/context/builder.dart'; |
| 31 import 'package:analyzer/src/dart/sdk/sdk.dart'; | 31 import 'package:analyzer/src/dart/sdk/sdk.dart'; |
| 32 import 'package:analyzer/src/generated/constant.dart'; | 32 import 'package:analyzer/src/generated/constant.dart'; |
| 33 import 'package:analyzer/src/generated/engine.dart'; | 33 import 'package:analyzer/src/generated/engine.dart'; |
| 34 import 'package:analyzer/src/generated/java_io.dart'; |
| 34 import 'package:analyzer/src/generated/sdk.dart'; | 35 import 'package:analyzer/src/generated/sdk.dart'; |
| 35 import 'package:analyzer/src/generated/source.dart'; | 36 import 'package:analyzer/src/generated/source.dart'; |
| 36 import 'package:analyzer/src/generated/source_io.dart'; | 37 import 'package:analyzer/src/generated/source_io.dart'; |
| 37 import 'package:path/path.dart' as path; | 38 import 'package:path/path.dart' as path; |
| 38 import 'package:path/path.dart'; | 39 import 'package:path/path.dart'; |
| 39 | 40 |
| 40 /** | 41 /** |
| 41 * Generate the target .dot file. | 42 * Generate the target .dot file. |
| 42 */ | 43 */ |
| 43 main() { | 44 main() { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 resourceProvider = PhysicalResourceProvider.INSTANCE; | 154 resourceProvider = PhysicalResourceProvider.INSTANCE; |
| 154 DartSdk sdk = new FolderBasedDartSdk(resourceProvider, | 155 DartSdk sdk = new FolderBasedDartSdk(resourceProvider, |
| 155 FolderBasedDartSdk.defaultSdkDirectory(resourceProvider)); | 156 FolderBasedDartSdk.defaultSdkDirectory(resourceProvider)); |
| 156 context = AnalysisEngine.instance.createAnalysisContext(); | 157 context = AnalysisEngine.instance.createAnalysisContext(); |
| 157 String packageRootPath; | 158 String packageRootPath; |
| 158 if (Platform.packageRoot != null) { | 159 if (Platform.packageRoot != null) { |
| 159 packageRootPath = Uri.parse(Platform.packageRoot).toFilePath(); | 160 packageRootPath = Uri.parse(Platform.packageRoot).toFilePath(); |
| 160 } else { | 161 } else { |
| 161 packageRootPath = path.join(rootDir, 'packages'); | 162 packageRootPath = path.join(rootDir, 'packages'); |
| 162 } | 163 } |
| 163 ContextBuilder builder = new ContextBuilder(resourceProvider, null, null); | 164 JavaFile packagesDir = new JavaFile(packageRootPath); |
| 164 List<UriResolver> uriResolvers = [ | 165 List<UriResolver> uriResolvers = [ |
| 165 new DartUriResolver(sdk), | 166 new DartUriResolver(sdk), |
| 166 new PackageMapUriResolver( | 167 new PackageUriResolver(<JavaFile>[packagesDir]), |
| 167 resourceProvider, | |
| 168 builder | |
| 169 .convertPackagesToMap(builder.createPackageMap(packageRootPath))), | |
| 170 new ResourceUriResolver(PhysicalResourceProvider.INSTANCE) | 168 new ResourceUriResolver(PhysicalResourceProvider.INSTANCE) |
| 171 ]; | 169 ]; |
| 172 context.sourceFactory = new SourceFactory(uriResolvers); | 170 context.sourceFactory = new SourceFactory(uriResolvers); |
| 173 Source dartDartSource = | 171 Source dartDartSource = |
| 174 setupSource(path.join('lib', 'src', 'task', 'dart.dart')); | 172 setupSource(path.join('lib', 'src', 'task', 'dart.dart')); |
| 175 Source taskSource = setupSource(path.join('lib', 'plugin', 'task.dart')); | 173 Source taskSource = setupSource(path.join('lib', 'plugin', 'task.dart')); |
| 176 Source modelSource = setupSource(path.join('lib', 'task', 'model.dart')); | 174 Source modelSource = setupSource(path.join('lib', 'task', 'model.dart')); |
| 177 Source enginePluginSource = | 175 Source enginePluginSource = |
| 178 setupSource(path.join('lib', 'src', 'plugin', 'engine_plugin.dart')); | 176 setupSource(path.join('lib', 'src', 'plugin', 'engine_plugin.dart')); |
| 179 CompilationUnitElement modelElement = getUnit(modelSource).element; | 177 CompilationUnitElement modelElement = getUnit(modelSource).element; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 @override | 352 @override |
| 355 visitIdentifier(Identifier node) { | 353 visitIdentifier(Identifier node) { |
| 356 Element element = node.staticElement; | 354 Element element = node.staticElement; |
| 357 if (element is PropertyAccessorElement && | 355 if (element is PropertyAccessorElement && |
| 358 element.isGetter && | 356 element.isGetter && |
| 359 element.returnType.isSubtypeOf(type)) { | 357 element.returnType.isSubtypeOf(type)) { |
| 360 callback(element); | 358 callback(element); |
| 361 } | 359 } |
| 362 } | 360 } |
| 363 } | 361 } |
| OLD | NEW |