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

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

Issue 308703005: Extract constants into separate libarary. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 analysis.server; 5 library analysis.server;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/analysis_logger.dart'; 9 import 'package:analysis_server/src/analysis_logger.dart';
10 import 'package:analysis_server/src/channel.dart'; 10 import 'package:analysis_server/src/channel.dart';
11 import 'package:analysis_server/src/constants.dart';
11 import 'package:analysis_server/src/context_directory_manager.dart'; 12 import 'package:analysis_server/src/context_directory_manager.dart';
12 import 'package:analysis_server/src/domain_analysis.dart'; 13 import 'package:analysis_server/src/domain_analysis.dart';
13 import 'package:analysis_server/src/protocol.dart'; 14 import 'package:analysis_server/src/protocol.dart';
14 import 'package:analysis_server/src/resource.dart'; 15 import 'package:analysis_server/src/resource.dart';
15 import 'package:analyzer/src/generated/ast.dart'; 16 import 'package:analyzer/src/generated/ast.dart';
16 import 'package:analyzer/src/generated/engine.dart'; 17 import 'package:analyzer/src/generated/engine.dart';
17 import 'package:analyzer/src/generated/error.dart'; 18 import 'package:analyzer/src/generated/error.dart';
18 import 'package:analyzer/src/generated/java_core.dart'; 19 import 'package:analyzer/src/generated/java_core.dart';
19 import 'package:analyzer/src/generated/source.dart'; 20 import 'package:analyzer/src/generated/source.dart';
20 import 'package:analyzer/src/generated/sdk.dart'; 21 import 'package:analyzer/src/generated/sdk.dart';
(...skipping 25 matching lines...) Expand all
46 analysisServer.folderMap[contextFolder].context.applyChanges(changeSet); 47 analysisServer.folderMap[contextFolder].context.applyChanges(changeSet);
47 } 48 }
48 } 49 }
49 50
50 /** 51 /**
51 * Instances of the class [AnalysisServer] implement a server that listens on a 52 * Instances of the class [AnalysisServer] implement a server that listens on a
52 * [CommunicationChannel] for analysis requests and process them. 53 * [CommunicationChannel] for analysis requests and process them.
53 */ 54 */
54 class AnalysisServer { 55 class AnalysisServer {
55 /** 56 /**
56 * The name of the parameter whose value is a list of errors.
57 */
58 static const String ERRORS_PARAM = 'errors';
59
60 /**
61 * The name of the parameter whose value is a file path.
62 */
63 static const String FILE_PARAM = 'file';
64
65 /**
66 * The event name of the connected notification.
67 */
68 static const String CONNECTED_NOTIFICATION = 'server.connected';
69
70 /**
71 * The event name of the status notification.
72 */
73 static const String STATUS_NOTIFICATION = 'server.status';
74
75 /**
76 * The channel from which requests are received and to which responses should 57 * The channel from which requests are received and to which responses should
77 * be sent. 58 * be sent.
78 */ 59 */
79 final ServerCommunicationChannel channel; 60 final ServerCommunicationChannel channel;
80 61
81 /** 62 /**
82 * [ContextDirectoryManager] which handles the mapping from analysis roots 63 * [ContextDirectoryManager] which handles the mapping from analysis roots
83 * to context directories. 64 * to context directories.
84 */ 65 */
85 AnalysisServerContextDirectoryManager contextDirectoryManager; 66 AnalysisServerContextDirectoryManager contextDirectoryManager;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 Set<ServerService> serverServices = new Set<ServerService>(); 120 Set<ServerService> serverServices = new Set<ServerService>();
140 121
141 /** 122 /**
142 * Initialize a newly created server to receive requests from and send 123 * Initialize a newly created server to receive requests from and send
143 * responses to the given [channel]. 124 * responses to the given [channel].
144 */ 125 */
145 AnalysisServer(this.channel, ResourceProvider resourceProvider) { 126 AnalysisServer(this.channel, ResourceProvider resourceProvider) {
146 contextDirectoryManager = new AnalysisServerContextDirectoryManager(this, re sourceProvider); 127 contextDirectoryManager = new AnalysisServerContextDirectoryManager(this, re sourceProvider);
147 AnalysisEngine.instance.logger = new AnalysisLogger(); 128 AnalysisEngine.instance.logger = new AnalysisLogger();
148 running = true; 129 running = true;
149 Notification notification = new Notification(CONNECTED_NOTIFICATION); 130 Notification notification = new Notification(NOTIFICATION_CONNECTED);
150 channel.sendNotification(notification); 131 channel.sendNotification(notification);
151 channel.listen(handleRequest, onDone: done, onError: error); 132 channel.listen(handleRequest, onDone: done, onError: error);
152 } 133 }
153 134
154 /** 135 /**
155 * If [running] is true, add the given [context] to the list of analysis 136 * If [running] is true, add the given [context] to the list of analysis
156 * contexts for which analysis work needs to be performed, and ensure that 137 * contexts for which analysis work needs to be performed, and ensure that
157 * the work will be performed. 138 * the work will be performed.
158 */ 139 */
159 void addContextToWorkQueue(AnalysisContext context) { 140 void addContextToWorkQueue(AnalysisContext context) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 */ 241 */
261 void sendNotices(List<ChangeNotice> notices) { 242 void sendNotices(List<ChangeNotice> notices) {
262 for (int i = 0; i < notices.length; i++) { 243 for (int i = 0; i < notices.length; i++) {
263 ChangeNotice notice = notices[i]; 244 ChangeNotice notice = notices[i];
264 Source source = notice.source; 245 Source source = notice.source;
265 CompilationUnit dartUnit = notice.compilationUnit; 246 CompilationUnit dartUnit = notice.compilationUnit;
266 // TODO(scheglov) use subscriptions to determine notifications to send 247 // TODO(scheglov) use subscriptions to determine notifications to send
267 if (!source.isInSystemLibrary) { 248 if (!source.isInSystemLibrary) {
268 // errors 249 // errors
269 { 250 {
270 Notification notification = new Notification(AnalysisDomainHandler.ERR ORS_NOTIFICATION); 251 Notification notification = new Notification(NOTIFICATION_ERRORS);
271 notification.setParameter(FILE_PARAM, source.fullName); 252 notification.setParameter(FILE, source.fullName);
272 notification.setParameter(ERRORS_PARAM, notice.errors.map(errorToJson) .toList()); 253 notification.setParameter(ERRORS, notice.errors.map(errorToJson).toLis t());
273 sendNotification(notification); 254 sendNotification(notification);
274 } 255 }
275 // highlights 256 // highlights
276 if (dartUnit != null) { 257 if (dartUnit != null) {
277 Notification notification = new Notification(AnalysisDomainHandler.HIG HLIGHTS_NOTIFICATION); 258 Notification notification = new Notification(NOTIFICATION_HIGHLIGHTS);
278 notification.setParameter(FILE_PARAM, source.fullName); 259 notification.setParameter(FILE, source.fullName);
279 notification.setParameter( 260 notification.setParameter(
280 AnalysisDomainHandler.REGIONS_PARAM, 261 REGIONS,
281 new DartUnitHighlightsComputer(dartUnit).compute()); 262 new DartUnitHighlightsComputer(dartUnit).compute());
282 sendNotification(notification); 263 sendNotification(notification);
283 } 264 }
284 } 265 }
285 } 266 }
286 } 267 }
287 268
288 /** 269 /**
289 * Send status notification to the client. The `contextId` indicates 270 * Send status notification to the client. The `contextId` indicates
290 * the current context being analyzed or `null` if analysis is complete. 271 * the current context being analyzed or `null` if analysis is complete.
291 */ 272 */
292 void sendStatusNotification(String contextId) { 273 void sendStatusNotification(String contextId) {
293 if (contextId == lastStatusNotificationContextId) { 274 if (contextId == lastStatusNotificationContextId) {
294 return; 275 return;
295 } 276 }
296 lastStatusNotificationContextId = contextId; 277 lastStatusNotificationContextId = contextId;
297 Notification notification = new Notification(STATUS_NOTIFICATION); 278 Notification notification = new Notification(NOTIFICATION_STATUS);
298 Map<String, Object> analysis = new Map(); 279 Map<String, Object> analysis = new Map();
299 if (contextId != null) { 280 if (contextId != null) {
300 analysis['analyzing'] = true; 281 analysis['analyzing'] = true;
301 // TODO(danrubel): replace contextId with real analysisTarget 282 // TODO(danrubel): replace contextId with real analysisTarget
302 analysis['analysisTarget'] = contextId; 283 analysis['analysisTarget'] = contextId;
303 } else { 284 } else {
304 analysis['analyzing'] = false; 285 analysis['analyzing'] = false;
305 } 286 }
306 notification.params['analysis'] = analysis; 287 notification.params['analysis'] = analysis;
307 channel.sendNotification(notification); 288 channel.sendNotification(notification);
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 /** 474 /**
494 * An enumeration of the services provided by the server domain. 475 * An enumeration of the services provided by the server domain.
495 */ 476 */
496 class ServerService extends Enum2<ServerService> { 477 class ServerService extends Enum2<ServerService> {
497 static const ServerService STATUS = const ServerService('STATUS', 0); 478 static const ServerService STATUS = const ServerService('STATUS', 0);
498 479
499 static const List<ServerService> VALUES = const [STATUS]; 480 static const List<ServerService> VALUES = const [STATUS];
500 481
501 const ServerService(String name, int ordinal) : super(name, ordinal); 482 const ServerService(String name, int ordinal) : super(name, ordinal);
502 } 483 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_manager.dart ('k') | pkg/analysis_server/lib/src/constants.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698