Chromium Code Reviews| 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 library analyzer.src.task.general; | 5 library analyzer.src.task.general; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; | 7 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; |
| 8 import 'package:analyzer/src/generated/java_engine.dart'; | 8 import 'package:analyzer/src/generated/java_engine.dart'; |
| 9 import 'package:analyzer/src/generated/source.dart'; | 9 import 'package:analyzer/src/generated/source.dart'; |
| 10 import 'package:analyzer/task/general.dart'; | 10 import 'package:analyzer/task/general.dart'; |
| 11 import 'package:analyzer/task/model.dart'; | 11 import 'package:analyzer/task/model.dart'; |
| 12 import 'package:analyzer/src/generated/element.dart'; | |
| 12 | 13 |
| 13 /** | 14 /** |
| 14 * A task that gets the contents of the source associated with an analysis | 15 * A task that gets the contents of the source associated with an analysis |
| 15 * target. | 16 * target. |
| 16 */ | 17 */ |
| 17 class GetContentTask extends SourceBasedAnalysisTask { | 18 class GetContentTask extends SourceBasedAnalysisTask { |
| 18 /** | 19 /** |
| 19 * The task descriptor describing this kind of task. | 20 * The task descriptor describing this kind of task. |
| 20 */ | 21 */ |
| 21 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor('GetContentTask', | 22 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor('GetContentTask', |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 * Create a [GetContentTask] based on the given [target] in the given | 57 * Create a [GetContentTask] based on the given [target] in the given |
| 57 * [context]. | 58 * [context]. |
| 58 */ | 59 */ |
| 59 static GetContentTask createTask( | 60 static GetContentTask createTask( |
| 60 AnalysisContext context, AnalysisTarget target) { | 61 AnalysisContext context, AnalysisTarget target) { |
| 61 return new GetContentTask(context, target); | 62 return new GetContentTask(context, target); |
| 62 } | 63 } |
| 63 } | 64 } |
| 64 | 65 |
| 65 /** | 66 /** |
| 67 * A base class for analysis tasks whose target is expected to be an element. | |
| 68 */ | |
| 69 abstract class ElementBasedAnalysisTask extends AnalysisTask { | |
|
scheglov
2015/05/08 18:46:08
I'm not sure that this is a right place for this t
Brian Wilkerson
2015/05/08 19:22:38
Agreed.
Paul Berry
2015/05/08 19:44:22
Done.
| |
| 70 /** | |
| 71 * Initialize a newly created task to perform analysis within the given | |
| 72 * [context] in order to produce results for the given [element]. | |
| 73 */ | |
| 74 ElementBasedAnalysisTask(AnalysisContext context, Element element) | |
| 75 : super(context, element); | |
| 76 | |
| 77 @override | |
| 78 String get description { | |
| 79 Source source = target.source; | |
| 80 String sourceName = source == null ? '<unknown source>' : source.fullName; | |
| 81 return '${descriptor.name} for element $target in source $sourceName'; | |
| 82 } | |
| 83 } | |
| 84 | |
| 85 /** | |
| 66 * A base class for analysis tasks whose target is expected to be a source. | 86 * A base class for analysis tasks whose target is expected to be a source. |
| 67 */ | 87 */ |
| 68 abstract class SourceBasedAnalysisTask extends AnalysisTask { | 88 abstract class SourceBasedAnalysisTask extends AnalysisTask { |
| 69 /** | 89 /** |
| 70 * Initialize a newly created task to perform analysis within the given | 90 * Initialize a newly created task to perform analysis within the given |
| 71 * [context] in order to produce results for the given [target]. | 91 * [context] in order to produce results for the given [target]. |
| 72 */ | 92 */ |
| 73 SourceBasedAnalysisTask(AnalysisContext context, AnalysisTarget target) | 93 SourceBasedAnalysisTask(AnalysisContext context, AnalysisTarget target) |
| 74 : super(context, target); | 94 : super(context, target); |
| 75 | 95 |
| 76 @override | 96 @override |
| 77 String get description { | 97 String get description { |
| 78 Source source = target.source; | 98 Source source = target.source; |
| 79 String sourceName = source == null ? '<unknown source>' : source.fullName; | 99 String sourceName = source == null ? '<unknown source>' : source.fullName; |
| 80 return '${descriptor.name} for source $sourceName'; | 100 return '${descriptor.name} for source $sourceName'; |
| 81 } | 101 } |
| 82 } | 102 } |
| OLD | NEW |