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

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

Issue 1241193002: Add '--useAnalysisHighlight2' option to generate version 2 of semantic highlight. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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
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 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:core' hide Resource; 9 import 'dart:core' hide Resource;
10 import 'dart:math' show max; 10 import 'dart:math' show max;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 static final String VERSION = '1.8.0'; 76 static final String VERSION = '1.8.0';
77 77
78 /** 78 /**
79 * The number of milliseconds to perform operations before inserting 79 * The number of milliseconds to perform operations before inserting
80 * a 1 millisecond delay so that the VM and dart:io can deliver content 80 * a 1 millisecond delay so that the VM and dart:io can deliver content
81 * to stdin. This should be removed once the underlying problem is fixed. 81 * to stdin. This should be removed once the underlying problem is fixed.
82 */ 82 */
83 static int performOperationDelayFreqency = 25; 83 static int performOperationDelayFreqency = 25;
84 84
85 /** 85 /**
86 * The options of this server instance.
87 */
88 AnalysisServerOptions options;
89
90 /**
86 * The channel from which requests are received and to which responses should 91 * The channel from which requests are received and to which responses should
87 * be sent. 92 * be sent.
88 */ 93 */
89 final ServerCommunicationChannel channel; 94 final ServerCommunicationChannel channel;
90 95
91 /** 96 /**
92 * The [ResourceProvider] using which paths are converted into [Resource]s. 97 * The [ResourceProvider] using which paths are converted into [Resource]s.
93 */ 98 */
94 final ResourceProvider resourceProvider; 99 final ResourceProvider resourceProvider;
95 100
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 * If a [contextManager] is provided, then the [packageResolverProvider] will 278 * If a [contextManager] is provided, then the [packageResolverProvider] will
274 * be ignored. 279 * be ignored.
275 * 280 *
276 * If [rethrowExceptions] is true, then any exceptions thrown by analysis are 281 * If [rethrowExceptions] is true, then any exceptions thrown by analysis are
277 * propagated up the call stack. The default is true to allow analysis 282 * propagated up the call stack. The default is true to allow analysis
278 * exceptions to show up in unit tests, but it should be set to false when 283 * exceptions to show up in unit tests, but it should be set to false when
279 * running a full analysis server. 284 * running a full analysis server.
280 */ 285 */
281 AnalysisServer(this.channel, this.resourceProvider, 286 AnalysisServer(this.channel, this.resourceProvider,
282 OptimizingPubPackageMapProvider packageMapProvider, Index _index, 287 OptimizingPubPackageMapProvider packageMapProvider, Index _index,
283 this.serverPlugin, AnalysisServerOptions analysisServerOptions, 288 this.serverPlugin, this.options, this.defaultSdk,
284 this.defaultSdk, this.instrumentationService, 289 this.instrumentationService, {ContextManager contextManager: null,
285 {ContextManager contextManager: null,
286 ResolverProvider packageResolverProvider: null, 290 ResolverProvider packageResolverProvider: null,
287 this.rethrowExceptions: true}) 291 this.rethrowExceptions: true})
288 : index = _index, 292 : index = _index,
289 searchEngine = _index != null ? createSearchEngine(_index) : null { 293 searchEngine = _index != null ? createSearchEngine(_index) : null {
290 _performance = performanceDuringStartup; 294 _performance = performanceDuringStartup;
291 operationQueue = new ServerOperationQueue(); 295 operationQueue = new ServerOperationQueue();
292 if (contextManager == null) { 296 if (contextManager == null) {
293 contextManager = new ServerContextManager(this, resourceProvider, 297 contextManager = new ServerContextManager(this, resourceProvider,
294 packageResolverProvider, packageMapProvider, instrumentationService); 298 packageResolverProvider, packageMapProvider, instrumentationService);
295 AnalysisOptionsImpl options = 299 AnalysisOptionsImpl analysisOptions =
296 (contextManager as ServerContextManager).defaultOptions; 300 (contextManager as ServerContextManager).defaultOptions;
297 options.incremental = true; 301 analysisOptions.incremental = true;
298 options.incrementalApi = 302 analysisOptions.incrementalApi = options.enableIncrementalResolutionApi;
299 analysisServerOptions.enableIncrementalResolutionApi; 303 analysisOptions.incrementalValidation =
300 options.incrementalValidation = 304 options.enableIncrementalResolutionValidation;
301 analysisServerOptions.enableIncrementalResolutionValidation; 305 analysisOptions.generateImplicitErrors = false;
302 options.generateImplicitErrors = false;
303 } else if (contextManager is! ServerContextManager) { 306 } else if (contextManager is! ServerContextManager) {
304 // TODO(brianwilkerson) Remove this when the interface is complete. 307 // TODO(brianwilkerson) Remove this when the interface is complete.
305 throw new StateError( 308 throw new StateError(
306 'The contextManager must be an instance of ServerContextManager'); 309 'The contextManager must be an instance of ServerContextManager');
307 } 310 }
308 this.contextManager = contextManager; 311 this.contextManager = contextManager;
309 _noErrorNotification = analysisServerOptions.noErrorNotification; 312 _noErrorNotification = options.noErrorNotification;
310 AnalysisEngine.instance.logger = new AnalysisLogger(); 313 AnalysisEngine.instance.logger = new AnalysisLogger();
311 _onAnalysisStartedController = new StreamController.broadcast(); 314 _onAnalysisStartedController = new StreamController.broadcast();
312 _onFileAnalyzedController = new StreamController.broadcast(); 315 _onFileAnalyzedController = new StreamController.broadcast();
313 _onPriorityChangeController = 316 _onPriorityChangeController =
314 new StreamController<PriorityChangeEvent>.broadcast(); 317 new StreamController<PriorityChangeEvent>.broadcast();
315 running = true; 318 running = true;
316 onAnalysisStarted.first.then((_) { 319 onAnalysisStarted.first.then((_) {
317 onAnalysisComplete.then((_) { 320 onAnalysisComplete.then((_) {
318 performanceAfterStartup = new ServerPerformance(); 321 performanceAfterStartup = new ServerPerformance();
319 _performance = performanceAfterStartup; 322 _performance = performanceAfterStartup;
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 } 1296 }
1294 performOperationPending = true; 1297 performOperationPending = true;
1295 } 1298 }
1296 } 1299 }
1297 1300
1298 class AnalysisServerOptions { 1301 class AnalysisServerOptions {
1299 bool enableIncrementalResolutionApi = false; 1302 bool enableIncrementalResolutionApi = false;
1300 bool enableIncrementalResolutionValidation = false; 1303 bool enableIncrementalResolutionValidation = false;
1301 bool noErrorNotification = false; 1304 bool noErrorNotification = false;
1302 bool noIndex = false; 1305 bool noIndex = false;
1306 bool useAnalysisHighlight2 = false;
1303 String fileReadMode = 'as-is'; 1307 String fileReadMode = 'as-is';
1304 } 1308 }
1305 1309
1306 /** 1310 /**
1307 * Information about a file - an [AnalysisContext] that analyses the file, 1311 * Information about a file - an [AnalysisContext] that analyses the file,
1308 * and the [Source] representing the file in this context. 1312 * and the [Source] representing the file in this context.
1309 */ 1313 */
1310 class ContextSourcePair { 1314 class ContextSourcePair {
1311 /** 1315 /**
1312 * A context that analysis the file. 1316 * A context that analysis the file.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 new StreamController<ContextsChangedEvent>.broadcast(); 1360 new StreamController<ContextsChangedEvent>.broadcast();
1357 } 1361 }
1358 1362
1359 /** 1363 /**
1360 * The stream that is notified when contexts are added or removed. 1364 * The stream that is notified when contexts are added or removed.
1361 */ 1365 */
1362 Stream<ContextsChangedEvent> get onContextsChanged => 1366 Stream<ContextsChangedEvent> get onContextsChanged =>
1363 _onContextsChangedController.stream; 1367 _onContextsChangedController.stream;
1364 1368
1365 @override 1369 @override
1366 AnalysisContext addContext(Folder folder, UriResolver packageUriResolver, Pack ages packages) { 1370 AnalysisContext addContext(
1371 Folder folder, UriResolver packageUriResolver, Packages packages) {
1367 InternalAnalysisContext context = 1372 InternalAnalysisContext context =
1368 AnalysisEngine.instance.createAnalysisContext(); 1373 AnalysisEngine.instance.createAnalysisContext();
1369 context.contentCache = analysisServer.overlayState; 1374 context.contentCache = analysisServer.overlayState;
1370 analysisServer.folderMap[folder] = context; 1375 analysisServer.folderMap[folder] = context;
1371 context.sourceFactory = _createSourceFactory(packageUriResolver, packages); 1376 context.sourceFactory = _createSourceFactory(packageUriResolver, packages);
1372 context.analysisOptions = new AnalysisOptionsImpl.from(defaultOptions); 1377 context.analysisOptions = new AnalysisOptionsImpl.from(defaultOptions);
1373 _onContextsChangedController 1378 _onContextsChangedController
1374 .add(new ContextsChangedEvent(added: [context])); 1379 .add(new ContextsChangedEvent(added: [context]));
1375 analysisServer.schedulePerformAnalysisOperation(context); 1380 analysisServer.schedulePerformAnalysisOperation(context);
1376 return context; 1381 return context;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 PubStatus pubStatus = new PubStatus(computing); 1459 PubStatus pubStatus = new PubStatus(computing);
1455 ServerStatusParams params = new ServerStatusParams(pub: pubStatus); 1460 ServerStatusParams params = new ServerStatusParams(pub: pubStatus);
1456 analysisServer.sendNotification(params.toNotification()); 1461 analysisServer.sendNotification(params.toNotification());
1457 } 1462 }
1458 } 1463 }
1459 1464
1460 /** 1465 /**
1461 * Set up a [SourceFactory] that resolves packages using the given 1466 * Set up a [SourceFactory] that resolves packages using the given
1462 * [packageUriResolver] and [packages] resolution strategy. 1467 * [packageUriResolver] and [packages] resolution strategy.
1463 */ 1468 */
1464 SourceFactory _createSourceFactory(UriResolver packageUriResolver, Packages pa ckages) { 1469 SourceFactory _createSourceFactory(
1470 UriResolver packageUriResolver, Packages packages) {
1465 UriResolver dartResolver = new DartUriResolver(analysisServer.defaultSdk); 1471 UriResolver dartResolver = new DartUriResolver(analysisServer.defaultSdk);
1466 UriResolver resourceResolver = new ResourceUriResolver(resourceProvider); 1472 UriResolver resourceResolver = new ResourceUriResolver(resourceProvider);
1467 List<UriResolver> resolvers = []; 1473 List<UriResolver> resolvers = [];
1468 resolvers.add(dartResolver); 1474 resolvers.add(dartResolver);
1469 if (packageUriResolver is PackageMapUriResolver) { 1475 if (packageUriResolver is PackageMapUriResolver) {
1470 UriResolver sdkExtResolver = 1476 UriResolver sdkExtResolver =
1471 new SdkExtUriResolver(packageUriResolver.packageMap); 1477 new SdkExtUriResolver(packageUriResolver.packageMap);
1472 resolvers.add(sdkExtResolver); 1478 resolvers.add(sdkExtResolver);
1473 } 1479 }
1474 if (packageUriResolver != null) { 1480 if (packageUriResolver != null) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 /** 1580 /**
1575 * The [PerformanceTag] for time spent in server request handlers. 1581 * The [PerformanceTag] for time spent in server request handlers.
1576 */ 1582 */
1577 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); 1583 static PerformanceTag serverRequests = new PerformanceTag('serverRequests');
1578 1584
1579 /** 1585 /**
1580 * The [PerformanceTag] for time spent in split store microtasks. 1586 * The [PerformanceTag] for time spent in split store microtasks.
1581 */ 1587 */
1582 static PerformanceTag splitStore = new PerformanceTag('splitStore'); 1588 static PerformanceTag splitStore = new PerformanceTag('splitStore');
1583 } 1589 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/doc/api.html ('k') | pkg/analysis_server/lib/src/computer/computer_highlights2.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698