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 * The ".dot" file is output to standard out. To convert it to a pdf, store it | 10 * The ".dot" file is output to standard out. To convert it to a pdf, store it |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 new PackageUriResolver(<JavaFile>[packagesDir]), | 87 new PackageUriResolver(<JavaFile>[packagesDir]), |
88 new FileUriResolver() | 88 new FileUriResolver() |
89 ]; | 89 ]; |
90 context.sourceFactory = new SourceFactory(uriResolvers); | 90 context.sourceFactory = new SourceFactory(uriResolvers); |
91 Source taskSource = | 91 Source taskSource = |
92 setupSource(path.join('lib', 'src', 'task', 'dart.dart')); | 92 setupSource(path.join('lib', 'src', 'task', 'dart.dart')); |
93 Source modelSource = setupSource(path.join('lib', 'task', 'model.dart')); | 93 Source modelSource = setupSource(path.join('lib', 'task', 'model.dart')); |
94 CompilationUnitElement modelElement = getUnit(modelSource).element; | 94 CompilationUnitElement modelElement = getUnit(modelSource).element; |
95 InterfaceType analysisTaskType = modelElement.getType('AnalysisTask').type; | 95 InterfaceType analysisTaskType = modelElement.getType('AnalysisTask').type; |
96 DartType dynamicType = context.typeProvider.dynamicType; | 96 DartType dynamicType = context.typeProvider.dynamicType; |
97 resultDescriptorType = modelElement.getType('ResultDescriptor').type | 97 resultDescriptorType = modelElement |
| 98 .getType('ResultDescriptor') |
| 99 .type |
98 .substitute4([dynamicType]); | 100 .substitute4([dynamicType]); |
99 CompilationUnit taskUnit = getUnit(taskSource); | 101 CompilationUnit taskUnit = getUnit(taskSource); |
100 CompilationUnitElement taskUnitElement = taskUnit.element; | 102 CompilationUnitElement taskUnitElement = taskUnit.element; |
101 print('digraph G {'); | 103 print('digraph G {'); |
102 Set<String> results = new Set<String>(); | 104 Set<String> results = new Set<String>(); |
103 for (ClassElement cls in taskUnitElement.types) { | 105 for (ClassElement cls in taskUnitElement.types) { |
104 if (!cls.isAbstract && cls.type.isSubtypeOf(analysisTaskType)) { | 106 if (!cls.isAbstract && cls.type.isSubtypeOf(analysisTaskType)) { |
105 String task = cls.name; | 107 String task = cls.name; |
106 // TODO(paulberry): node is deprecated. What am I supposed to do | 108 // TODO(paulberry): node is deprecated. What am I supposed to do |
107 // instead? | 109 // instead? |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 @override | 148 @override |
147 visitIdentifier(Identifier node) { | 149 visitIdentifier(Identifier node) { |
148 Element element = node.staticElement; | 150 Element element = node.staticElement; |
149 if (element is PropertyAccessorElement && | 151 if (element is PropertyAccessorElement && |
150 element.isGetter && | 152 element.isGetter && |
151 element.returnType.isSubtypeOf(resultDescriptorType)) { | 153 element.returnType.isSubtypeOf(resultDescriptorType)) { |
152 callback(element); | 154 callback(element); |
153 } | 155 } |
154 } | 156 } |
155 } | 157 } |
OLD | NEW |