| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 library engine.task.dart; | |
| 6 | |
| 7 import 'package:analyzer/src/generated/ast.dart'; | |
| 8 import 'package:analyzer/src/generated/element.dart'; | |
| 9 import 'package:analyzer/src/generated/engine.dart'; | |
| 10 import 'package:analyzer/src/generated/resolver.dart'; | |
| 11 import 'package:analyzer/src/generated/source.dart'; | |
| 12 | |
| 13 /** | |
| 14 * A `BuildUnitElementTask` builds a compilation unit element for a single | |
| 15 * compilation unit. | |
| 16 */ | |
| 17 class BuildUnitElementTask extends AnalysisTask { | |
| 18 /** | |
| 19 * The source for which an element model will be built. | |
| 20 */ | |
| 21 final Source source; | |
| 22 | |
| 23 /** | |
| 24 * The source of the library in which an element model will be built. | |
| 25 */ | |
| 26 final Source library; | |
| 27 | |
| 28 /** | |
| 29 * The compilation unit from which an element model will be built. | |
| 30 */ | |
| 31 final CompilationUnit unit; | |
| 32 | |
| 33 /** | |
| 34 * The element model that was built. | |
| 35 */ | |
| 36 CompilationUnitElement unitElement; | |
| 37 | |
| 38 /** | |
| 39 * Initialize a newly created task to build a compilation unit element for | |
| 40 * the given [source] in the given [library] based on the compilation [unit] | |
| 41 * that was parsed. | |
| 42 */ | |
| 43 BuildUnitElementTask( | |
| 44 InternalAnalysisContext context, this.source, this.library, this.unit) | |
| 45 : super(context); | |
| 46 | |
| 47 @override | |
| 48 String get taskDescription { | |
| 49 if (source == null) { | |
| 50 return "build the unit element model for null source"; | |
| 51 } | |
| 52 return "build the unit element model for " + source.fullName; | |
| 53 } | |
| 54 | |
| 55 @override | |
| 56 accept(AnalysisTaskVisitor visitor) { | |
| 57 return visitor.visitBuildUnitElementTask(this); | |
| 58 } | |
| 59 | |
| 60 /** | |
| 61 * Return the compilation unit from which the element model was built. | |
| 62 */ | |
| 63 CompilationUnit getCompilationUnit() { | |
| 64 return unit; | |
| 65 } | |
| 66 | |
| 67 /** | |
| 68 * Return the source that is to be parsed. | |
| 69 */ | |
| 70 Source getSource() { | |
| 71 return source; | |
| 72 } | |
| 73 | |
| 74 /** | |
| 75 * Return the compilation unit element that was produced, or `null` if the | |
| 76 * task has not yet been performed or if an exception occurred. | |
| 77 */ | |
| 78 CompilationUnitElement getUnitElement() { | |
| 79 return unitElement; | |
| 80 } | |
| 81 | |
| 82 @override | |
| 83 void internalPerform() { | |
| 84 CompilationUnitBuilder builder = new CompilationUnitBuilder(); | |
| 85 unitElement = builder.buildCompilationUnit(source, unit, library); | |
| 86 } | |
| 87 } | |
| OLD | NEW |