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

Side by Side Diff: pkg/analyzer_plugin/lib/plugin/assist_mixin.dart

Issue 3008433002: Unify lots of copied code in one utility method (Closed)
Patch Set: Created 3 years, 4 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
« no previous file with comments | « no previous file | pkg/analyzer_plugin/lib/plugin/completion_mixin.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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:analyzer/dart/analysis/results.dart'; 7 import 'package:analyzer/dart/analysis/results.dart';
8 import 'package:analyzer/src/dart/analysis/driver.dart'; 8 import 'package:analyzer/src/dart/analysis/driver.dart';
9 import 'package:analyzer_plugin/plugin/plugin.dart'; 9 import 'package:analyzer_plugin/plugin/plugin.dart';
10 import 'package:analyzer_plugin/protocol/protocol.dart'; 10 import 'package:analyzer_plugin/protocol/protocol.dart';
(...skipping 12 matching lines...) Expand all
23 abstract class AssistsMixin implements ServerPlugin { 23 abstract class AssistsMixin implements ServerPlugin {
24 /** 24 /**
25 * Return a list containing the assist contributors that should be used to 25 * Return a list containing the assist contributors that should be used to
26 * create assists for the file with the given [path]. 26 * create assists for the file with the given [path].
27 */ 27 */
28 List<AssistContributor> getAssistContributors(String path); 28 List<AssistContributor> getAssistContributors(String path);
29 29
30 /** 30 /**
31 * Return the assist request that should be passes to the contributors 31 * Return the assist request that should be passes to the contributors
32 * returned from [getAssistContributors]. 32 * returned from [getAssistContributors].
33 *
34 * Throw a [RequestFailure] if the request could not be created.
33 */ 35 */
34 Future<AssistRequest> getAssistRequest(EditGetAssistsParams parameters); 36 Future<AssistRequest> getAssistRequest(EditGetAssistsParams parameters);
35 37
36 @override 38 @override
37 Future<EditGetAssistsResult> handleEditGetAssists( 39 Future<EditGetAssistsResult> handleEditGetAssists(
38 EditGetAssistsParams parameters) async { 40 EditGetAssistsParams parameters) async {
39 String path = parameters.file; 41 String path = parameters.file;
40 AssistRequest request = await getAssistRequest(parameters); 42 AssistRequest request = await getAssistRequest(parameters);
41 AssistGenerator generator = 43 AssistGenerator generator =
42 new AssistGenerator(getAssistContributors(path)); 44 new AssistGenerator(getAssistContributors(path));
(...skipping 10 matching lines...) Expand all
53 * 55 *
54 * Clients may not extend or implement this class, but are allowed to use it as 56 * Clients may not extend or implement this class, but are allowed to use it as
55 * a mix-in when creating a subclass of [ServerPlugin] that also uses 57 * a mix-in when creating a subclass of [ServerPlugin] that also uses
56 * [AssistsMixin] as a mix-in. 58 * [AssistsMixin] as a mix-in.
57 */ 59 */
58 abstract class DartAssistsMixin implements AssistsMixin { 60 abstract class DartAssistsMixin implements AssistsMixin {
59 @override 61 @override
60 Future<AssistRequest> getAssistRequest( 62 Future<AssistRequest> getAssistRequest(
61 EditGetAssistsParams parameters) async { 63 EditGetAssistsParams parameters) async {
62 String path = parameters.file; 64 String path = parameters.file;
63 AnalysisDriver driver = driverForPath(path); 65 ResolveResult result = await getResolveResult(path);
64 if (driver == null) {
65 // Return an error from the request.
66 throw new RequestFailure(
67 RequestErrorFactory.pluginError('Failed to analyze $path', null));
68 }
69 ResolveResult result = await driver.getResult(path);
70 return new DartAssistRequestImpl( 66 return new DartAssistRequestImpl(
71 resourceProvider, parameters.offset, parameters.length, result); 67 resourceProvider, parameters.offset, parameters.length, result);
72 } 68 }
73 } 69 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer_plugin/lib/plugin/completion_mixin.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698