| 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(InternalAnalysisContext context, this.source, this.librar
y, this.unit) |
| 44 : super(context); |
| 45 |
| 46 @override |
| 47 accept(AnalysisTaskVisitor visitor) { |
| 48 return visitor.visitBuildUnitElementTask(this); |
| 49 } |
| 50 |
| 51 /** |
| 52 * Return the compilation unit from which the element model was built. |
| 53 */ |
| 54 CompilationUnit getCompilationUnit() { |
| 55 return unit; |
| 56 } |
| 57 |
| 58 /** |
| 59 * Return the source that is to be parsed. |
| 60 */ |
| 61 Source getSource() { |
| 62 return source; |
| 63 } |
| 64 |
| 65 /** |
| 66 * Return the compilation unit element that was produced, or `null` if the |
| 67 * task has not yet been performed or if an exception occurred. |
| 68 */ |
| 69 CompilationUnitElement getUnitElement() { |
| 70 return unitElement; |
| 71 } |
| 72 |
| 73 @override |
| 74 void internalPerform() { |
| 75 CompilationUnitBuilder builder = new CompilationUnitBuilder(); |
| 76 unitElement = builder.buildCompilationUnit(source, unit); |
| 77 } |
| 78 |
| 79 @override |
| 80 String get taskDescription { |
| 81 if (source == null) { |
| 82 return "build the unit element model for null source"; |
| 83 } |
| 84 return "build the unit element model for " + source.fullName; |
| 85 } |
| 86 } |
| OLD | NEW |