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

Side by Side Diff: pkg/analysis_server/lib/src/domain_completion.dart

Issue 492563002: Make more use of generated classes in analysis server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 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 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 domain.completion; 5 library domain.completion;
6 6
7 import 'package:analysis_server/src/analysis_server.dart'; 7 import 'package:analysis_server/src/analysis_server.dart';
8 import 'package:analysis_server/src/constants.dart'; 8 import 'package:analysis_server/src/constants.dart';
9 import 'package:analysis_server/src/protocol.dart'; 9 import 'package:analysis_server/src/protocol.dart';
10 import 'package:analysis_server/src/protocol2.dart' show
11 CompletionGetSuggestionsParams;
10 import 'package:analysis_server/src/services/completion/completion_manager.dart' ; 12 import 'package:analysis_server/src/services/completion/completion_manager.dart' ;
11 import 'package:analysis_server/src/services/completion/completion_suggestion.da rt'; 13 import 'package:analysis_server/src/services/completion/completion_suggestion.da rt';
12 14
13 /** 15 /**
14 * Instances of the class [CompletionDomainHandler] implement a [RequestHandler] 16 * Instances of the class [CompletionDomainHandler] implement a [RequestHandler]
15 * that handles requests in the search domain. 17 * that handles requests in the search domain.
16 */ 18 */
17 class CompletionDomainHandler implements RequestHandler { 19 class CompletionDomainHandler implements RequestHandler {
18 /** 20 /**
19 * The analysis server that is using this handler to process requests. 21 * The analysis server that is using this handler to process requests.
(...skipping 20 matching lines...) Expand all
40 } on RequestFailure catch (exception) { 42 } on RequestFailure catch (exception) {
41 return exception.response; 43 return exception.response;
42 } 44 }
43 return null; 45 return null;
44 } 46 }
45 47
46 /** 48 /**
47 * Process a `completion.getSuggestions` request. 49 * Process a `completion.getSuggestions` request.
48 */ 50 */
49 Response processRequest(Request request) { 51 Response processRequest(Request request) {
50 // extract param 52 // extract params
51 String file = request.getRequiredParameter(FILE).asString(); 53 var params = new CompletionGetSuggestionsParams.fromRequest(request);
52 int offset = request.getRequiredParameter(OFFSET).asInt();
53 // schedule completion analysis 54 // schedule completion analysis
54 String completionId = (_nextCompletionId++).toString(); 55 String completionId = (_nextCompletionId++).toString();
55 CompletionManager.create( 56 CompletionManager.create(
56 server.getAnalysisContext(file), 57 server.getAnalysisContext(params.file),
57 server.getSource(file), 58 server.getSource(params.file),
58 offset, 59 params.offset,
59 server.searchEngine).results().listen((CompletionResult result) { 60 server.searchEngine).results().listen((CompletionResult result) {
60 sendCompletionNotification( 61 sendCompletionNotification(
61 completionId, 62 completionId,
62 result.replacementOffset, 63 result.replacementOffset,
63 result.replacementLength, 64 result.replacementLength,
64 result.suggestions, 65 result.suggestions,
65 result.last); 66 result.last);
66 }); 67 });
67 // initial response without results 68 // initial response without results
68 return new Response(request.id)..setResult(ID, completionId); 69 return new Response(request.id)..setResult(ID, completionId);
69 } 70 }
70 71
71 /** 72 /**
72 * Send completion notification results. 73 * Send completion notification results.
73 */ 74 */
74 void sendCompletionNotification(String completionId, int replacementOffset, 75 void sendCompletionNotification(String completionId, int replacementOffset,
75 int replacementLength, Iterable<CompletionSuggestion> results, bool isLast ) { 76 int replacementLength, Iterable<CompletionSuggestion> results, bool isLast ) {
76 Notification notification = new Notification(COMPLETION_RESULTS); 77 Notification notification = new Notification(COMPLETION_RESULTS);
77 notification.setParameter(ID, completionId); 78 notification.setParameter(ID, completionId);
78 notification.setParameter(REPLACEMENT_OFFSET, replacementOffset); 79 notification.setParameter(REPLACEMENT_OFFSET, replacementOffset);
79 notification.setParameter(REPLACEMENT_LENGTH, replacementLength); 80 notification.setParameter(REPLACEMENT_LENGTH, replacementLength);
80 notification.setParameter(RESULTS, results); 81 notification.setParameter(RESULTS, results);
81 notification.setParameter(LAST, isLast); 82 notification.setParameter(LAST, isLast);
82 server.sendNotification(notification); 83 server.sendNotification(notification);
83 } 84 }
84 } 85 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698