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

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

Issue 1115843003: restructure internal request to implement CompletionRequest API, (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/completion/completion_core.dart'
10 show CompletionRequest;
9 import 'package:analysis_server/src/analysis_server.dart'; 11 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/constants.dart'; 12 import 'package:analysis_server/src/constants.dart';
11 import 'package:analysis_server/src/protocol.dart'; 13 import 'package:analysis_server/src/protocol.dart';
12 import 'package:analysis_server/src/services/completion/completion_manager.dart' ; 14 import 'package:analysis_server/src/services/completion/completion_manager.dart' ;
13 import 'package:analysis_server/src/services/search/search_engine.dart'; 15 import 'package:analysis_server/src/services/search/search_engine.dart';
14 import 'package:analyzer/src/generated/engine.dart'; 16 import 'package:analyzer/src/generated/engine.dart';
15 import 'package:analyzer/src/generated/source.dart'; 17 import 'package:analyzer/src/generated/source.dart';
16 18
17 export 'package:analysis_server/src/services/completion/completion_manager.dart' 19 export 'package:analysis_server/src/services/completion/completion_manager.dart'
18 show CompletionPerformance, CompletionRequest, OperationPerformance; 20 show CompletionPerformance, CompletionRequest, OperationPerformance;
19 21
20 /** 22 /**
21 * Instances of the class [CompletionDomainHandler] implement a [RequestHandler] 23 * Instances of the class [CompletionDomainHandler] implement a [RequestHandler]
22 * that handles requests in the search domain. 24 * that handles requests in the search domain.
23 */ 25 */
24 class CompletionDomainHandler implements RequestHandler { 26 class CompletionDomainHandler implements RequestHandler {
25 /** 27 /**
28 * The maximum number of performance measurements to keep.
29 */
30 static const int performanceListMaxLength = 50;
31
32 /**
26 * The analysis server that is using this handler to process requests. 33 * The analysis server that is using this handler to process requests.
27 */ 34 */
28 final AnalysisServer server; 35 final AnalysisServer server;
29 36
30 /** 37 /**
31 * The [SearchEngine] for this server. 38 * The [SearchEngine] for this server.
32 */ 39 */
33 SearchEngine searchEngine; 40 SearchEngine searchEngine;
34 41
35 /** 42 /**
(...skipping 18 matching lines...) Expand all
54 CompletionPerformance performance; 61 CompletionPerformance performance;
55 62
56 /** 63 /**
57 * A list of code completion peformance measurements for the latest 64 * A list of code completion peformance measurements for the latest
58 * completion operation up to [performanceListMaxLength] measurements. 65 * completion operation up to [performanceListMaxLength] measurements.
59 */ 66 */
60 final List<CompletionPerformance> performanceList = 67 final List<CompletionPerformance> performanceList =
61 new List<CompletionPerformance>(); 68 new List<CompletionPerformance>();
62 69
63 /** 70 /**
64 * The maximum number of performance measurements to keep.
65 */
66 static const int performanceListMaxLength = 50;
67
68 /**
69 * Performance for the last priority change event. 71 * Performance for the last priority change event.
70 */ 72 */
71 CompletionPerformance computeCachePerformance; 73 CompletionPerformance computeCachePerformance;
72 74
73 /** 75 /**
74 * Initialize a new request handler for the given [server]. 76 * Initialize a new request handler for the given [server].
75 */ 77 */
76 CompletionDomainHandler(this.server) { 78 CompletionDomainHandler(this.server) {
77 server.onContextsChanged.listen(contextsChanged); 79 server.onContextsChanged.listen(contextsChanged);
78 server.onPriorityChange.listen(priorityChanged); 80 server.onPriorityChange.listen(priorityChanged);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 AnalysisContext context = contextSource.context; 180 AnalysisContext context = contextSource.context;
179 Source source = contextSource.source; 181 Source source = contextSource.source;
180 if (context == null || !context.exists(source)) { 182 if (context == null || !context.exists(source)) {
181 return new Response.unknownSource(request); 183 return new Response.unknownSource(request);
182 } 184 }
183 recordRequest(performance, context, source, params.offset); 185 recordRequest(performance, context, source, params.offset);
184 if (manager == null) { 186 if (manager == null) {
185 manager = completionManagerFor(context, source); 187 manager = completionManagerFor(context, source);
186 } 188 }
187 CompletionRequest completionRequest = 189 CompletionRequest completionRequest =
188 new CompletionRequest(params.offset, performance); 190 new CompletionRequestImpl(server, context, source, params.offset);
189 int notificationCount = 0; 191 int notificationCount = 0;
190 manager.results(completionRequest).listen((CompletionResult result) { 192 manager.results(completionRequest).listen((CompletionResult result) {
191 ++notificationCount; 193 ++notificationCount;
192 performance.logElapseTime("notification $notificationCount send", () { 194 performance.logElapseTime("notification $notificationCount send", () {
193 sendCompletionNotification(completionId, result.replacementOffset, 195 sendCompletionNotification(completionId, result.replacementOffset,
194 result.replacementLength, result.suggestions, result.last); 196 result.replacementLength, result.suggestions, result.last);
195 }); 197 });
196 if (notificationCount == 1) { 198 if (notificationCount == 1) {
197 performance.logFirstNotificationComplete('notification 1 complete'); 199 performance.logFirstNotificationComplete('notification 1 complete');
198 performance.suggestionCountFirst = result.suggestions.length; 200 performance.suggestionCountFirst = result.suggestions.length;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 if (_sourcesChangedSubscription != null) { 272 if (_sourcesChangedSubscription != null) {
271 _sourcesChangedSubscription.cancel(); 273 _sourcesChangedSubscription.cancel();
272 _sourcesChangedSubscription = null; 274 _sourcesChangedSubscription = null;
273 } 275 }
274 if (_manager != null) { 276 if (_manager != null) {
275 _manager.dispose(); 277 _manager.dispose();
276 _manager = null; 278 _manager = null;
277 } 279 }
278 } 280 }
279 } 281 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698