| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 setupSource(path.join('lib', 'src', 'plugin', 'engine_plugin.dart')); | 182 setupSource(path.join('lib', 'src', 'plugin', 'engine_plugin.dart')); |
| 183 CompilationUnitElement modelElement = getUnit(modelSource).element; | 183 CompilationUnitElement modelElement = getUnit(modelSource).element; |
| 184 InterfaceType analysisTaskType = modelElement.getType('AnalysisTask').type; | 184 InterfaceType analysisTaskType = modelElement.getType('AnalysisTask').type; |
| 185 DartType dynamicType = context.typeProvider.dynamicType; | 185 DartType dynamicType = context.typeProvider.dynamicType; |
| 186 resultDescriptorType = modelElement | 186 resultDescriptorType = modelElement |
| 187 .getType('ResultDescriptor') | 187 .getType('ResultDescriptor') |
| 188 .type | 188 .type |
| 189 .instantiate([dynamicType]); | 189 .instantiate([dynamicType]); |
| 190 listOfResultDescriptorType = | 190 listOfResultDescriptorType = |
| 191 context.typeProvider.listType.instantiate([resultDescriptorType]); | 191 context.typeProvider.listType.instantiate([resultDescriptorType]); |
| 192 CompilationUnitElement enginePluginUnitElement = | 192 CompilationUnit enginePluginUnit = getUnit(enginePluginSource); |
| 193 getUnit(enginePluginSource).element; | 193 enginePluginClass = enginePluginUnit.element.getType('EnginePlugin'); |
| 194 enginePluginClass = enginePluginUnitElement.getType('EnginePlugin'); | |
| 195 extensionPointIdType = | 194 extensionPointIdType = |
| 196 enginePluginUnitElement.getType('ExtensionPointId').type; | 195 enginePluginUnit.element.getType('ExtensionPointId').type; |
| 197 CompilationUnit dartDartUnit = getUnit(dartDartSource); | 196 CompilationUnit dartDartUnit = getUnit(dartDartSource); |
| 198 CompilationUnitElement dartDartUnitElement = dartDartUnit.element; | |
| 199 CompilationUnit taskUnit = getUnit(taskSource); | 197 CompilationUnit taskUnit = getUnit(taskSource); |
| 200 taskUnitElement = taskUnit.element; | 198 taskUnitElement = taskUnit.element; |
| 201 Set<String> results = new Set<String>(); | 199 Set<String> results = new Set<String>(); |
| 202 Set<String> resultLists = new Set<String>(); | 200 Set<String> resultLists = new Set<String>(); |
| 203 for (ClassElement cls in dartDartUnitElement.types) { | 201 for (CompilationUnitMember dartUnitMember in dartDartUnit.declarations) { |
| 204 if (!cls.isAbstract && cls.type.isSubtypeOf(analysisTaskType)) { | 202 if (dartUnitMember is ClassDeclaration) { |
| 205 String task = cls.name; | 203 ClassDeclaration clazz = dartUnitMember; |
| 206 AstNode buildInputsAst = cls.getMethod('buildInputs').computeNode(); | 204 if (!clazz.isAbstract && |
| 207 findResultDescriptors(buildInputsAst, (String input) { | 205 clazz.element.type.isSubtypeOf(analysisTaskType)) { |
| 208 results.add(input); | 206 String task = clazz.name.name; |
| 209 lines.add(' $input -> $task'); | 207 |
| 210 }); | 208 MethodDeclaration buildInputsAst; |
| 211 findResultDescriptorLists(buildInputsAst, (String input) { | 209 VariableDeclaration descriptorField; |
| 212 resultLists.add(input); | 210 for (ClassMember classMember in clazz.members) { |
| 213 lines.add(' $input -> $task'); | 211 if (classMember is MethodDeclaration && |
| 214 }); | 212 classMember.name.name == 'buildInputs') { |
| 215 findResultDescriptors(cls.getField('DESCRIPTOR').computeNode(), | 213 buildInputsAst = classMember; |
| 216 (String out) { | 214 } |
| 217 results.add(out); | 215 if (classMember is FieldDeclaration) { |
| 218 lines.add(' $task -> $out'); | 216 for (VariableDeclaration field in classMember.fields.variables) { |
| 219 }); | 217 if (field.name.name == 'DESCRIPTOR') { |
| 218 descriptorField = field; |
| 219 } |
| 220 } |
| 221 } |
| 222 } |
| 223 |
| 224 findResultDescriptors(buildInputsAst, (String input) { |
| 225 results.add(input); |
| 226 lines.add(' $input -> $task'); |
| 227 }); |
| 228 findResultDescriptorLists(buildInputsAst, (String input) { |
| 229 resultLists.add(input); |
| 230 lines.add(' $input -> $task'); |
| 231 }); |
| 232 findResultDescriptors(descriptorField, (String out) { |
| 233 results.add(out); |
| 234 lines.add(' $task -> $out'); |
| 235 }); |
| 236 } |
| 220 } | 237 } |
| 221 } | 238 } |
| 222 AstNode enginePluginAst = enginePluginUnitElement.computeNode(); | |
| 223 for (String resultList in resultLists) { | 239 for (String resultList in resultLists) { |
| 224 lines.add(' $resultList [shape=hexagon]'); | 240 lines.add(' $resultList [shape=hexagon]'); |
| 225 TopLevelVariableElement extensionIdVariable = _getExtensionId(resultList); | 241 TopLevelVariableElement extensionIdVariable = _getExtensionId(resultList); |
| 226 findExtensions(enginePluginAst, extensionIdVariable, (String extension) { | 242 findExtensions(enginePluginUnit, extensionIdVariable, (String extension) { |
| 227 results.add(extension); | 243 results.add(extension); |
| 228 lines.add(' $extension -> $resultList'); | 244 lines.add(' $extension -> $resultList'); |
| 229 }); | 245 }); |
| 230 } | 246 } |
| 231 for (String result in results) { | 247 for (String result in results) { |
| 232 lines.add(' $result [shape=box]'); | 248 lines.add(' $result [shape=box]'); |
| 233 } | 249 } |
| 234 lines.sort(); | 250 lines.sort(); |
| 235 return lines.join('\n'); | 251 return lines.join('\n'); |
| 236 } | 252 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 @override | 374 @override |
| 359 visitIdentifier(Identifier node) { | 375 visitIdentifier(Identifier node) { |
| 360 Element element = node.staticElement; | 376 Element element = node.staticElement; |
| 361 if (element is PropertyAccessorElement && | 377 if (element is PropertyAccessorElement && |
| 362 element.isGetter && | 378 element.isGetter && |
| 363 element.returnType.isSubtypeOf(type)) { | 379 element.returnType.isSubtypeOf(type)) { |
| 364 callback(element); | 380 callback(element); |
| 365 } | 381 } |
| 366 } | 382 } |
| 367 } | 383 } |
| OLD | NEW |