| OLD | NEW |
| 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:io' as io; | 10 import 'dart:io' as io; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 import 'package:analyzer/src/context/builder.dart'; | 33 import 'package:analyzer/src/context/builder.dart'; |
| 34 import 'package:analyzer/src/dart/ast/utilities.dart'; | 34 import 'package:analyzer/src/dart/ast/utilities.dart'; |
| 35 import 'package:analyzer/src/dart/sdk/sdk.dart'; | 35 import 'package:analyzer/src/dart/sdk/sdk.dart'; |
| 36 import 'package:analyzer/src/generated/engine.dart'; | 36 import 'package:analyzer/src/generated/engine.dart'; |
| 37 import 'package:analyzer/src/generated/java_engine.dart'; | 37 import 'package:analyzer/src/generated/java_engine.dart'; |
| 38 import 'package:analyzer/src/generated/java_io.dart'; | 38 import 'package:analyzer/src/generated/java_io.dart'; |
| 39 import 'package:analyzer/src/generated/sdk.dart'; | 39 import 'package:analyzer/src/generated/sdk.dart'; |
| 40 import 'package:analyzer/src/generated/source.dart'; | 40 import 'package:analyzer/src/generated/source.dart'; |
| 41 import 'package:analyzer/src/generated/source_io.dart'; | 41 import 'package:analyzer/src/generated/source_io.dart'; |
| 42 import 'package:analyzer/src/generated/utilities_general.dart'; | 42 import 'package:analyzer/src/generated/utilities_general.dart'; |
| 43 import 'package:analyzer/src/summary/pub_summary.dart'; |
| 43 import 'package:analyzer/src/task/dart.dart'; | 44 import 'package:analyzer/src/task/dart.dart'; |
| 44 import 'package:analyzer/src/util/glob.dart'; | 45 import 'package:analyzer/src/util/glob.dart'; |
| 45 import 'package:analyzer/task/dart.dart'; | 46 import 'package:analyzer/task/dart.dart'; |
| 46 import 'package:plugin/plugin.dart'; | 47 import 'package:plugin/plugin.dart'; |
| 47 import 'package:yaml/yaml.dart'; | 48 import 'package:yaml/yaml.dart'; |
| 48 | 49 |
| 49 typedef void OptionUpdater(AnalysisOptionsImpl options); | 50 typedef void OptionUpdater(AnalysisOptionsImpl options); |
| 50 | 51 |
| 51 /** | 52 /** |
| 52 * Enum representing reasons why analysis might be done for a given file. | 53 * Enum representing reasons why analysis might be done for a given file. |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 StreamController<ContextsChangedEvent> _onContextsChangedController = | 293 StreamController<ContextsChangedEvent> _onContextsChangedController = |
| 293 new StreamController<ContextsChangedEvent>.broadcast(); | 294 new StreamController<ContextsChangedEvent>.broadcast(); |
| 294 | 295 |
| 295 /** | 296 /** |
| 296 * The file resolver provider used to override the way file URI's are | 297 * The file resolver provider used to override the way file URI's are |
| 297 * resolved in some contexts. | 298 * resolved in some contexts. |
| 298 */ | 299 */ |
| 299 ResolverProvider fileResolverProvider; | 300 ResolverProvider fileResolverProvider; |
| 300 | 301 |
| 301 /** | 302 /** |
| 303 * The manager of pub package summaries. |
| 304 */ |
| 305 PubSummaryManager pubSummaryManager; |
| 306 |
| 307 /** |
| 302 * Initialize a newly created server to receive requests from and send | 308 * Initialize a newly created server to receive requests from and send |
| 303 * responses to the given [channel]. | 309 * responses to the given [channel]. |
| 304 * | 310 * |
| 305 * If [rethrowExceptions] is true, then any exceptions thrown by analysis are | 311 * If [rethrowExceptions] is true, then any exceptions thrown by analysis are |
| 306 * propagated up the call stack. The default is true to allow analysis | 312 * propagated up the call stack. The default is true to allow analysis |
| 307 * exceptions to show up in unit tests, but it should be set to false when | 313 * exceptions to show up in unit tests, but it should be set to false when |
| 308 * running a full analysis server. | 314 * running a full analysis server. |
| 309 */ | 315 */ |
| 310 AnalysisServer( | 316 AnalysisServer( |
| 311 this.channel, | 317 this.channel, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 _onPriorityChangeController = | 362 _onPriorityChangeController = |
| 357 new StreamController<PriorityChangeEvent>.broadcast(); | 363 new StreamController<PriorityChangeEvent>.broadcast(); |
| 358 running = true; | 364 running = true; |
| 359 onAnalysisStarted.first.then((_) { | 365 onAnalysisStarted.first.then((_) { |
| 360 onAnalysisComplete.then((_) { | 366 onAnalysisComplete.then((_) { |
| 361 performanceAfterStartup = new ServerPerformance(); | 367 performanceAfterStartup = new ServerPerformance(); |
| 362 _performance = performanceAfterStartup; | 368 _performance = performanceAfterStartup; |
| 363 }); | 369 }); |
| 364 }); | 370 }); |
| 365 _setupIndexInvalidation(); | 371 _setupIndexInvalidation(); |
| 372 pubSummaryManager = |
| 373 new PubSummaryManager(resourceProvider, '${io.pid}.temp'); |
| 366 Notification notification = | 374 Notification notification = |
| 367 new ServerConnectedParams(VERSION, io.pid).toNotification(); | 375 new ServerConnectedParams(VERSION, io.pid).toNotification(); |
| 368 channel.sendNotification(notification); | 376 channel.sendNotification(notification); |
| 369 channel.listen(handleRequest, onDone: done, onError: error); | 377 channel.listen(handleRequest, onDone: done, onError: error); |
| 370 handlers = serverPlugin.createDomains(this); | 378 handlers = serverPlugin.createDomains(this); |
| 371 } | 379 } |
| 372 | 380 |
| 373 /** | 381 /** |
| 374 * Return the [AnalysisContext]s that are being used to analyze the analysis | 382 * Return the [AnalysisContext]s that are being used to analyze the analysis |
| 375 * roots. | 383 * roots. |
| (...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1587 AnalysisContext addContext( | 1595 AnalysisContext addContext( |
| 1588 Folder folder, AnalysisOptions options, FolderDisposition disposition) { | 1596 Folder folder, AnalysisOptions options, FolderDisposition disposition) { |
| 1589 InternalAnalysisContext context = | 1597 InternalAnalysisContext context = |
| 1590 AnalysisEngine.instance.createAnalysisContext(); | 1598 AnalysisEngine.instance.createAnalysisContext(); |
| 1591 context.contentCache = analysisServer.overlayState; | 1599 context.contentCache = analysisServer.overlayState; |
| 1592 analysisServer.folderMap[folder] = context; | 1600 analysisServer.folderMap[folder] = context; |
| 1593 context.fileResolverProvider = analysisServer.fileResolverProvider; | 1601 context.fileResolverProvider = analysisServer.fileResolverProvider; |
| 1594 context.sourceFactory = | 1602 context.sourceFactory = |
| 1595 _createSourceFactory(context, options, disposition, folder); | 1603 _createSourceFactory(context, options, disposition, folder); |
| 1596 context.analysisOptions = options; | 1604 context.analysisOptions = options; |
| 1605 |
| 1606 // TODO(scheglov) use linked bundles |
| 1607 analysisServer.pubSummaryManager.getLinkedBundles(context); |
| 1608 |
| 1597 analysisServer._onContextsChangedController | 1609 analysisServer._onContextsChangedController |
| 1598 .add(new ContextsChangedEvent(added: [context])); | 1610 .add(new ContextsChangedEvent(added: [context])); |
| 1599 analysisServer.schedulePerformAnalysisOperation(context); | 1611 analysisServer.schedulePerformAnalysisOperation(context); |
| 1600 | 1612 |
| 1601 return context; | 1613 return context; |
| 1602 } | 1614 } |
| 1603 | 1615 |
| 1604 @override | 1616 @override |
| 1605 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { | 1617 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { |
| 1606 AnalysisContext context = analysisServer.folderMap[contextFolder]; | 1618 AnalysisContext context = analysisServer.folderMap[contextFolder]; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1791 /** | 1803 /** |
| 1792 * The [PerformanceTag] for time spent in server request handlers. | 1804 * The [PerformanceTag] for time spent in server request handlers. |
| 1793 */ | 1805 */ |
| 1794 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); | 1806 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); |
| 1795 | 1807 |
| 1796 /** | 1808 /** |
| 1797 * The [PerformanceTag] for time spent in split store microtasks. | 1809 * The [PerformanceTag] for time spent in split store microtasks. |
| 1798 */ | 1810 */ |
| 1799 static PerformanceTag splitStore = new PerformanceTag('splitStore'); | 1811 static PerformanceTag splitStore = new PerformanceTag('splitStore'); |
| 1800 } | 1812 } |
| OLD | NEW |