Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: pkg/analyzer/lib/src/task/general.dart

Issue 1041283002: GetContentTask should catch exceptions and wrap them into AnalysisExceptions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analyzer/test/src/task/general_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/source.dart'; 8 import 'package:analyzer/src/generated/source.dart';
9 import 'package:analyzer/task/general.dart'; 9 import 'package:analyzer/task/general.dart';
10 import 'package:analyzer/task/model.dart'; 10 import 'package:analyzer/task/model.dart';
11 import 'package:analyzer/src/generated/java_engine.dart';
11 12
12 /** 13 /**
13 * A task that gets the contents of the source associated with an analysis 14 * A task that gets the contents of the source associated with an analysis
14 * target. 15 * target.
15 */ 16 */
16 class GetContentTask extends SourceBasedAnalysisTask { 17 class GetContentTask extends SourceBasedAnalysisTask {
17 /** 18 /**
18 * The task descriptor describing this kind of task. 19 * The task descriptor describing this kind of task.
19 */ 20 */
20 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor('GET_CONTENT', 21 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor('GET_CONTENT',
21 createTask, buildInputs, <ResultDescriptor>[CONTENT, MODIFICATION_TIME]); 22 createTask, buildInputs, <ResultDescriptor>[CONTENT, MODIFICATION_TIME]);
22 23
23 /** 24 /**
24 * Initialize a newly created task to access the content of the source 25 * Initialize a newly created task to access the content of the source
25 * associated with the given [target] in the given [context]. 26 * associated with the given [target] in the given [context].
26 */ 27 */
27 GetContentTask(AnalysisContext context, AnalysisTarget target) 28 GetContentTask(AnalysisContext context, AnalysisTarget target)
28 : super(context, target); 29 : super(context, target);
29 30
30 @override 31 @override
31 TaskDescriptor get descriptor => DESCRIPTOR; 32 TaskDescriptor get descriptor => DESCRIPTOR;
32 33
33 @override 34 @override
34 internalPerform() { 35 internalPerform() {
35 Source source = getRequiredSource(); 36 Source source = getRequiredSource();
36 37 try {
37 TimestampedData<String> data = context.getContents(source); 38 TimestampedData<String> data = context.getContents(source);
38 outputs[CONTENT] = data.data; 39 outputs[CONTENT] = data.data;
39 outputs[MODIFICATION_TIME] = data.modificationTime; 40 outputs[MODIFICATION_TIME] = data.modificationTime;
41 } catch (exception, stackTrace) {
42 throw new AnalysisException('Could not get contents of $source',
43 new CaughtException(exception, stackTrace));
44 }
40 } 45 }
41 46
42 /** 47 /**
43 * Return a map from the names of the inputs of this kind of task to the task 48 * Return a map from the names of the inputs of this kind of task to the task
44 * input descriptors describing those inputs for a task with the given [target ]. 49 * input descriptors describing those inputs for a task with the given [target ].
45 */ 50 */
46 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { 51 static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
47 return <String, TaskInput>{}; 52 return <String, TaskInput>{};
48 } 53 }
49 54
(...skipping 18 matching lines...) Expand all
68 SourceBasedAnalysisTask(AnalysisContext context, AnalysisTarget target) 73 SourceBasedAnalysisTask(AnalysisContext context, AnalysisTarget target)
69 : super(context, target); 74 : super(context, target);
70 75
71 @override 76 @override
72 String get description { 77 String get description {
73 Source source = target.source; 78 Source source = target.source;
74 String sourceName = source == null ? '<unknown source>' : source.fullName; 79 String sourceName = source == null ? '<unknown source>' : source.fullName;
75 return '${descriptor.name} for source $sourceName'; 80 return '${descriptor.name} for source $sourceName';
76 } 81 }
77 } 82 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/task/general_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698