| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'dart:core'; | 7 import 'dart:core'; |
| 8 import 'dart:io' as io; | 8 import 'dart:io' as io; |
| 9 import 'dart:math' show max; | 9 import 'dart:math' show max; |
| 10 | 10 |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 */ | 313 */ |
| 314 Set<String> prevAnalyzedFiles; | 314 Set<String> prevAnalyzedFiles; |
| 315 | 315 |
| 316 /** | 316 /** |
| 317 * The default options used to create new analysis contexts. This object is | 317 * The default options used to create new analysis contexts. This object is |
| 318 * also referenced by the ContextManager. | 318 * also referenced by the ContextManager. |
| 319 */ | 319 */ |
| 320 final AnalysisOptionsImpl defaultContextOptions = new AnalysisOptionsImpl(); | 320 final AnalysisOptionsImpl defaultContextOptions = new AnalysisOptionsImpl(); |
| 321 | 321 |
| 322 /** | 322 /** |
| 323 * The controller for sending [ContextsChangedEvent]s. | |
| 324 */ | |
| 325 StreamController<ContextsChangedEvent> _onContextsChangedController = | |
| 326 new StreamController<ContextsChangedEvent>.broadcast(); | |
| 327 | |
| 328 /** | |
| 329 * The file resolver provider used to override the way file URI's are | 323 * The file resolver provider used to override the way file URI's are |
| 330 * resolved in some contexts. | 324 * resolved in some contexts. |
| 331 */ | 325 */ |
| 332 ResolverProvider fileResolverProvider; | 326 ResolverProvider fileResolverProvider; |
| 333 | 327 |
| 334 /** | 328 /** |
| 335 * The package resolver provider used to override the way package URI's are | 329 * The package resolver provider used to override the way package URI's are |
| 336 * resolved in some contexts. | 330 * resolved in some contexts. |
| 337 */ | 331 */ |
| 338 ResolverProvider packageResolverProvider; | 332 ResolverProvider packageResolverProvider; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 searchEngine = new SearchEngineImpl(driverMap.values); | 471 searchEngine = new SearchEngineImpl(driverMap.values); |
| 478 Notification notification = new ServerConnectedParams(VERSION, io.pid, | 472 Notification notification = new ServerConnectedParams(VERSION, io.pid, |
| 479 sessionId: instrumentationService.sessionId) | 473 sessionId: instrumentationService.sessionId) |
| 480 .toNotification(); | 474 .toNotification(); |
| 481 channel.sendNotification(notification); | 475 channel.sendNotification(notification); |
| 482 channel.listen(handleRequest, onDone: done, onError: error); | 476 channel.listen(handleRequest, onDone: done, onError: error); |
| 483 handlers = serverPlugin.createDomains(this); | 477 handlers = serverPlugin.createDomains(this); |
| 484 } | 478 } |
| 485 | 479 |
| 486 /** | 480 /** |
| 487 * Return the [AnalysisContext]s that are being used to analyze the analysis | |
| 488 * roots. | |
| 489 */ | |
| 490 Iterable<AnalysisContext> get analysisContexts => | |
| 491 contextManager.analysisContexts; | |
| 492 | |
| 493 /** | |
| 494 * Return a list of the globs used to determine which files should be analyzed
. | 481 * Return a list of the globs used to determine which files should be analyzed
. |
| 495 */ | 482 */ |
| 496 List<Glob> get analyzedFilesGlobs { | 483 List<Glob> get analyzedFilesGlobs { |
| 497 if (_analyzedFilesGlobs == null) { | 484 if (_analyzedFilesGlobs == null) { |
| 498 _analyzedFilesGlobs = <Glob>[]; | 485 _analyzedFilesGlobs = <Glob>[]; |
| 499 List<String> patterns = serverPlugin.analyzedFilePatterns; | 486 List<String> patterns = serverPlugin.analyzedFilePatterns; |
| 500 for (String pattern in patterns) { | 487 for (String pattern in patterns) { |
| 501 try { | 488 try { |
| 502 _analyzedFilesGlobs | 489 _analyzedFilesGlobs |
| 503 .add(new Glob(resourceProvider.pathContext.separator, pattern)); | 490 .add(new Glob(resourceProvider.pathContext.separator, pattern)); |
| 504 } catch (exception, stackTrace) { | 491 } catch (exception, stackTrace) { |
| 505 AnalysisEngine.instance.logger.logError( | 492 AnalysisEngine.instance.logger.logError( |
| 506 'Invalid glob pattern: "$pattern"', | 493 'Invalid glob pattern: "$pattern"', |
| 507 new CaughtException(exception, stackTrace)); | 494 new CaughtException(exception, stackTrace)); |
| 508 } | 495 } |
| 509 } | 496 } |
| 510 } | 497 } |
| 511 return _analyzedFilesGlobs; | 498 return _analyzedFilesGlobs; |
| 512 } | 499 } |
| 513 | 500 |
| 514 /** | 501 /** |
| 515 * A table mapping [Folder]s to the [AnalysisDriver]s associated with them. | 502 * A table mapping [Folder]s to the [AnalysisDriver]s associated with them. |
| 516 */ | 503 */ |
| 517 Map<Folder, nd.AnalysisDriver> get driverMap => contextManager.driverMap; | 504 Map<Folder, nd.AnalysisDriver> get driverMap => contextManager.driverMap; |
| 518 | 505 |
| 519 /** | 506 /** |
| 520 * Return a table mapping [Folder]s to the [AnalysisContext]s associated with | |
| 521 * them. | |
| 522 */ | |
| 523 Map<Folder, AnalysisContext> get folderMap => contextManager.folderMap; | |
| 524 | |
| 525 /** | |
| 526 * The [Future] that completes when analysis is complete. | 507 * The [Future] that completes when analysis is complete. |
| 527 */ | 508 */ |
| 528 Future get onAnalysisComplete { | 509 Future get onAnalysisComplete { |
| 529 if (isAnalysisComplete()) { | 510 if (isAnalysisComplete()) { |
| 530 return new Future.value(); | 511 return new Future.value(); |
| 531 } | 512 } |
| 532 if (_onAnalysisCompleteCompleter == null) { | 513 if (_onAnalysisCompleteCompleter == null) { |
| 533 _onAnalysisCompleteCompleter = new Completer(); | 514 _onAnalysisCompleteCompleter = new Completer(); |
| 534 } | 515 } |
| 535 return _onAnalysisCompleteCompleter.future; | 516 return _onAnalysisCompleteCompleter.future; |
| 536 } | 517 } |
| 537 | 518 |
| 538 /** | 519 /** |
| 539 * The stream that is notified with `true` when analysis is started. | 520 * The stream that is notified with `true` when analysis is started. |
| 540 */ | 521 */ |
| 541 Stream<bool> get onAnalysisStarted { | 522 Stream<bool> get onAnalysisStarted { |
| 542 return _onAnalysisStartedController.stream; | 523 return _onAnalysisStartedController.stream; |
| 543 } | 524 } |
| 544 | 525 |
| 545 /** | 526 /** |
| 546 * The stream that is notified when contexts are added or removed. | |
| 547 */ | |
| 548 Stream<ContextsChangedEvent> get onContextsChanged => | |
| 549 _onContextsChangedController.stream; | |
| 550 | |
| 551 /** | |
| 552 * The stream that is notified when a single file has been added. This exists | 527 * The stream that is notified when a single file has been added. This exists |
| 553 * as a temporary stopgap for plugins, until the official plugin API is | 528 * as a temporary stopgap for plugins, until the official plugin API is |
| 554 * complete. | 529 * complete. |
| 555 */ | 530 */ |
| 556 Stream get onFileAdded => _onFileAddedController.stream; | 531 Stream get onFileAdded => _onFileAddedController.stream; |
| 557 | 532 |
| 558 /** | 533 /** |
| 559 * The stream that is notified when a single file has been analyzed. | 534 * The stream that is notified when a single file has been analyzed. |
| 560 */ | 535 */ |
| 561 Stream get onFileAnalyzed => _onFileAnalyzedController.stream; | 536 Stream get onFileAnalyzed => _onFileAnalyzedController.stream; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 | 655 |
| 681 /** | 656 /** |
| 682 * Return the [AstProvider] for the given [path]. | 657 * Return the [AstProvider] for the given [path]. |
| 683 */ | 658 */ |
| 684 AstProvider getAstProvider(String path) { | 659 AstProvider getAstProvider(String path) { |
| 685 nd.AnalysisDriver analysisDriver = getAnalysisDriver(path); | 660 nd.AnalysisDriver analysisDriver = getAnalysisDriver(path); |
| 686 return new AstProviderForDriver(analysisDriver); | 661 return new AstProviderForDriver(analysisDriver); |
| 687 } | 662 } |
| 688 | 663 |
| 689 /** | 664 /** |
| 690 * Return the [AnalysisContext] for the "innermost" context whose associated | |
| 691 * folder is or contains the given path. ("innermost" refers to the nesting | |
| 692 * of contexts, so if there is a context for path /foo and a context for | |
| 693 * path /foo/bar, then the innermost context containing /foo/bar/baz.dart is | |
| 694 * the context for /foo/bar.) | |
| 695 * | |
| 696 * If no context contains the given path, `null` is returned. | |
| 697 */ | |
| 698 AnalysisContext getContainingContext(String path) { | |
| 699 return contextManager.getContextFor(path); | |
| 700 } | |
| 701 | |
| 702 /** | |
| 703 * Return the [nd.AnalysisDriver] for the "innermost" context whose associated | 665 * Return the [nd.AnalysisDriver] for the "innermost" context whose associated |
| 704 * folder is or contains the given path. ("innermost" refers to the nesting | 666 * folder is or contains the given path. ("innermost" refers to the nesting |
| 705 * of contexts, so if there is a context for path /foo and a context for | 667 * of contexts, so if there is a context for path /foo and a context for |
| 706 * path /foo/bar, then the innermost context containing /foo/bar/baz.dart is | 668 * path /foo/bar, then the innermost context containing /foo/bar/baz.dart is |
| 707 * the context for /foo/bar.) | 669 * the context for /foo/bar.) |
| 708 * | 670 * |
| 709 * If no context contains the given path, `null` is returned. | 671 * If no context contains the given path, `null` is returned. |
| 710 */ | 672 */ |
| 711 nd.AnalysisDriver getContainingDriver(String path) { | 673 nd.AnalysisDriver getContainingDriver(String path) { |
| 712 return contextManager.getDriverFor(path); | 674 return contextManager.getDriverFor(path); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 /** | 725 /** |
| 764 * Return a [Future] that completes with the resolved [CompilationUnit] for | 726 * Return a [Future] that completes with the resolved [CompilationUnit] for |
| 765 * the Dart file with the given [path], or with `null` if the file is not a | 727 * the Dart file with the given [path], or with `null` if the file is not a |
| 766 * Dart file or cannot be resolved. | 728 * Dart file or cannot be resolved. |
| 767 */ | 729 */ |
| 768 Future<CompilationUnit> getResolvedCompilationUnit(String path) async { | 730 Future<CompilationUnit> getResolvedCompilationUnit(String path) async { |
| 769 nd.AnalysisResult result = await getAnalysisResult(path); | 731 nd.AnalysisResult result = await getAnalysisResult(path); |
| 770 return result?.unit; | 732 return result?.unit; |
| 771 } | 733 } |
| 772 | 734 |
| 773 // TODO(brianwilkerson) Add the following method after 'prioritySources' has | |
| 774 // been added to InternalAnalysisContext. | |
| 775 // /** | |
| 776 // * Return a list containing the full names of all of the sources that are | |
| 777 // * priority sources. | |
| 778 // */ | |
| 779 // List<String> getPriorityFiles() { | |
| 780 // List<String> priorityFiles = new List<String>(); | |
| 781 // folderMap.values.forEach((ContextDirectory directory) { | |
| 782 // InternalAnalysisContext context = directory.context; | |
| 783 // context.prioritySources.forEach((Source source) { | |
| 784 // priorityFiles.add(source.fullName); | |
| 785 // }); | |
| 786 // }); | |
| 787 // return priorityFiles; | |
| 788 // } | |
| 789 | |
| 790 /** | 735 /** |
| 791 * Handle a [request] that was read from the communication channel. | 736 * Handle a [request] that was read from the communication channel. |
| 792 */ | 737 */ |
| 793 void handleRequest(Request request) { | 738 void handleRequest(Request request) { |
| 794 _performance.logRequest(request); | 739 _performance.logRequest(request); |
| 795 runZoned(() { | 740 runZoned(() { |
| 796 ServerPerformanceStatistics.serverRequests.makeCurrentWhile(() { | 741 ServerPerformanceStatistics.serverRequests.makeCurrentWhile(() { |
| 797 int count = handlers.length; | 742 int count = handlers.length; |
| 798 for (int i = 0; i < count; i++) { | 743 for (int i = 0; i < count; i++) { |
| 799 try { | 744 try { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 | 862 |
| 918 /** | 863 /** |
| 919 * Trigger reanalysis of all files in the given list of analysis [roots], or | 864 * Trigger reanalysis of all files in the given list of analysis [roots], or |
| 920 * everything if the analysis roots is `null`. | 865 * everything if the analysis roots is `null`. |
| 921 */ | 866 */ |
| 922 void reanalyze(List<Resource> roots) { | 867 void reanalyze(List<Resource> roots) { |
| 923 // Clear any operations that are pending. | 868 // Clear any operations that are pending. |
| 924 if (roots == null) { | 869 if (roots == null) { |
| 925 operationQueue.clear(); | 870 operationQueue.clear(); |
| 926 } else { | 871 } else { |
| 927 for (AnalysisContext context in _getContexts(roots)) { | 872 // TODO(brianwilkerson) All of the contexts returned by _getContexts will |
| 928 operationQueue.contextRemoved(context); | 873 // be null. If we are still using the operation queue, then this needs to |
| 929 } | 874 // be changed to use drivers. |
| 875 // for (AnalysisContext context in _getContexts(roots)) { |
| 876 // operationQueue.contextRemoved(context); |
| 877 // } |
| 930 } | 878 } |
| 931 // Instruct the contextDirectoryManager to rebuild all contexts from | 879 // Instruct the contextDirectoryManager to rebuild all contexts from |
| 932 // scratch. | 880 // scratch. |
| 933 contextManager.refresh(roots); | 881 contextManager.refresh(roots); |
| 934 } | 882 } |
| 935 | 883 |
| 936 /** | 884 /** |
| 937 * Schedule cache consistency validation in [context]. | 885 * Schedule cache consistency validation in [context]. |
| 938 * The most of the validation must be done asynchronously. | 886 * The most of the validation must be done asynchronously. |
| 939 */ | 887 */ |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1307 if (resourceProvider is PhysicalResourceProvider) { | 1255 if (resourceProvider is PhysicalResourceProvider) { |
| 1308 Folder stateLocation = | 1256 Folder stateLocation = |
| 1309 resourceProvider.getStateLocation('.analysis-driver'); | 1257 resourceProvider.getStateLocation('.analysis-driver'); |
| 1310 if (stateLocation != null) { | 1258 if (stateLocation != null) { |
| 1311 return stateLocation.path; | 1259 return stateLocation.path; |
| 1312 } | 1260 } |
| 1313 } | 1261 } |
| 1314 return null; | 1262 return null; |
| 1315 } | 1263 } |
| 1316 | 1264 |
| 1317 /** | |
| 1318 * Return a set of all contexts whose associated folder is contained within, | |
| 1319 * or equal to, one of the resources in the given list of [resources]. | |
| 1320 */ | |
| 1321 Set<AnalysisContext> _getContexts(List<Resource> resources) { | |
| 1322 Set<AnalysisContext> contexts = new HashSet<AnalysisContext>(); | |
| 1323 resources.forEach((Resource resource) { | |
| 1324 if (resource is Folder) { | |
| 1325 contexts.addAll(contextManager.contextsInAnalysisRoot(resource)); | |
| 1326 } | |
| 1327 }); | |
| 1328 return contexts; | |
| 1329 } | |
| 1330 | |
| 1331 bool _hasAnalysisServiceSubscription(AnalysisService service, String file) { | 1265 bool _hasAnalysisServiceSubscription(AnalysisService service, String file) { |
| 1332 return analysisServices[service]?.contains(file) ?? false; | 1266 return analysisServices[service]?.contains(file) ?? false; |
| 1333 } | 1267 } |
| 1334 | 1268 |
| 1335 _scheduleAnalysisImplementedNotification() async { | 1269 _scheduleAnalysisImplementedNotification() async { |
| 1336 Set<String> files = analysisServices[AnalysisService.IMPLEMENTED]; | 1270 Set<String> files = analysisServices[AnalysisService.IMPLEMENTED]; |
| 1337 if (files != null) { | 1271 if (files != null) { |
| 1338 scheduleImplementedNotification(this, files); | 1272 scheduleImplementedNotification(this, files); |
| 1339 } | 1273 } |
| 1340 } | 1274 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1371 * Listen for context events and invalidate index. | 1305 * Listen for context events and invalidate index. |
| 1372 * | 1306 * |
| 1373 * It is possible that this method will do more in the future, e.g. listening | 1307 * It is possible that this method will do more in the future, e.g. listening |
| 1374 * for summary information and linking pre-indexed packages into the index, | 1308 * for summary information and linking pre-indexed packages into the index, |
| 1375 * but for now we only invalidate project specific index information. | 1309 * but for now we only invalidate project specific index information. |
| 1376 */ | 1310 */ |
| 1377 void _setupIndexInvalidation() { | 1311 void _setupIndexInvalidation() { |
| 1378 if (index == null) { | 1312 if (index == null) { |
| 1379 return; | 1313 return; |
| 1380 } | 1314 } |
| 1381 onContextsChanged.listen((ContextsChangedEvent event) { | 1315 // TODO(brianwilkerson) onContextsChanged never has anything written to it. |
| 1382 // TODO(brianwilkerson) `onContextsChanged` should never have anything | 1316 // Figure out whether we need something like this under the new analysis |
| 1383 // written to it. Figure out whether we need something like this under the | 1317 // driver, and remove this method if not. |
| 1384 // new analysis driver, and remove this method if not. | 1318 // onContextsChanged.listen((ContextsChangedEvent event) { |
| 1385 // for (AnalysisContext context in event.added) { | 1319 // for (AnalysisContext context in event.added) { |
| 1386 // context | 1320 // context |
| 1387 // .onResultChanged(RESOLVED_UNIT3) | 1321 // .onResultChanged(RESOLVED_UNIT3) |
| 1388 // .listen((ResultChangedEvent event) { | 1322 // .listen((ResultChangedEvent event) { |
| 1389 // if (event.wasComputed) { | 1323 // if (event.wasComputed) { |
| 1390 // Object value = event.value; | 1324 // Object value = event.value; |
| 1391 // if (value is CompilationUnit) { | 1325 // if (value is CompilationUnit) { |
| 1392 // index.indexDeclarations(value); | 1326 // index.indexDeclarations(value); |
| 1393 // } | 1327 // } |
| 1394 // } | 1328 // } |
| 1395 // }); | 1329 // }); |
| 1396 // context | 1330 // context |
| 1397 // .onResultChanged(RESOLVED_UNIT) | 1331 // .onResultChanged(RESOLVED_UNIT) |
| 1398 // .listen((ResultChangedEvent event) { | 1332 // .listen((ResultChangedEvent event) { |
| 1399 // if (event.wasInvalidated) { | 1333 // if (event.wasInvalidated) { |
| 1400 // LibrarySpecificUnit target = event.target; | 1334 // LibrarySpecificUnit target = event.target; |
| 1401 // index.removeUnit(event.context, target.library, target.unit); | 1335 // index.removeUnit(event.context, target.library, target.unit); |
| 1402 // } | 1336 // } |
| 1403 // }); | 1337 // }); |
| 1404 // } | 1338 // } |
| 1405 // for (AnalysisContext context in event.removed) { | 1339 // for (AnalysisContext context in event.removed) { |
| 1406 // index.removeContext(context); | 1340 // index.removeContext(context); |
| 1407 // } | 1341 // } |
| 1408 }); | 1342 // }); |
| 1409 } | 1343 } |
| 1410 } | 1344 } |
| 1411 | 1345 |
| 1412 class AnalysisServerOptions { | 1346 class AnalysisServerOptions { |
| 1413 bool enableIncrementalResolutionApi = false; | 1347 bool enableIncrementalResolutionApi = false; |
| 1414 bool enableIncrementalResolutionValidation = false; | 1348 bool enableIncrementalResolutionValidation = false; |
| 1415 bool useAnalysisHighlight2 = false; | 1349 bool useAnalysisHighlight2 = false; |
| 1416 String fileReadMode = 'as-is'; | 1350 String fileReadMode = 'as-is'; |
| 1417 String newAnalysisDriverLog; | 1351 String newAnalysisDriverLog; |
| 1418 | 1352 |
| 1419 String clientId; | 1353 String clientId; |
| 1420 String clientVersion; | 1354 String clientVersion; |
| 1421 | 1355 |
| 1422 // IDE options | 1356 // IDE options |
| 1423 bool enableVerboseFlutterCompletions = false; | 1357 bool enableVerboseFlutterCompletions = false; |
| 1424 } | 1358 } |
| 1425 | 1359 |
| 1426 /** | 1360 /** |
| 1427 * Information about a file - an [AnalysisContext] that analyses the file, | |
| 1428 * and the [Source] representing the file in this context. | |
| 1429 */ | |
| 1430 class ContextSourcePair { | |
| 1431 /** | |
| 1432 * A context that analysis the file. | |
| 1433 * May be `null` if the file is not analyzed by any context. | |
| 1434 */ | |
| 1435 final AnalysisContext context; | |
| 1436 | |
| 1437 /** | |
| 1438 * The source that corresponds to the file. | |
| 1439 * May be `null` if the file is not a regular file. | |
| 1440 * If the file cannot be found in the [context], then it has a `file` uri. | |
| 1441 */ | |
| 1442 final Source source; | |
| 1443 | |
| 1444 ContextSourcePair(this.context, this.source); | |
| 1445 } | |
| 1446 | |
| 1447 /** | |
| 1448 * A [PriorityChangeEvent] indicates the set the priority files has changed. | 1361 * A [PriorityChangeEvent] indicates the set the priority files has changed. |
| 1449 */ | 1362 */ |
| 1450 class PriorityChangeEvent { | 1363 class PriorityChangeEvent { |
| 1451 final Source firstSource; | 1364 final Source firstSource; |
| 1452 | 1365 |
| 1453 PriorityChangeEvent(this.firstSource); | 1366 PriorityChangeEvent(this.firstSource); |
| 1454 } | 1367 } |
| 1455 | 1368 |
| 1456 class ServerContextManagerCallbacks extends ContextManagerCallbacks { | 1369 class ServerContextManagerCallbacks extends ContextManagerCallbacks { |
| 1457 final AnalysisServer analysisServer; | 1370 final AnalysisServer analysisServer; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1569 if (result.contextKey != null) { | 1482 if (result.contextKey != null) { |
| 1570 message += ' context: ${result.contextKey}'; | 1483 message += ' context: ${result.contextKey}'; |
| 1571 } | 1484 } |
| 1572 AnalysisEngine.instance.logger.logError(message, result.exception); | 1485 AnalysisEngine.instance.logger.logError(message, result.exception); |
| 1573 }); | 1486 }); |
| 1574 analysisServer.driverMap[folder] = analysisDriver; | 1487 analysisServer.driverMap[folder] = analysisDriver; |
| 1575 return analysisDriver; | 1488 return analysisDriver; |
| 1576 } | 1489 } |
| 1577 | 1490 |
| 1578 @override | 1491 @override |
| 1579 AnalysisContext addContext(Folder folder, AnalysisOptions options) { | |
| 1580 ContextBuilder builder = createContextBuilder(folder, options); | |
| 1581 AnalysisContext context = builder.buildContext(folder.path); | |
| 1582 | |
| 1583 analysisServer.folderMap[folder] = context; | |
| 1584 analysisServer._onContextsChangedController | |
| 1585 .add(new ContextsChangedEvent(added: [context])); | |
| 1586 analysisServer.schedulePerformAnalysisOperation(context); | |
| 1587 | |
| 1588 return context; | |
| 1589 } | |
| 1590 | |
| 1591 @override | |
| 1592 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { | 1492 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { |
| 1593 nd.AnalysisDriver analysisDriver = analysisServer.driverMap[contextFolder]; | 1493 nd.AnalysisDriver analysisDriver = analysisServer.driverMap[contextFolder]; |
| 1594 if (analysisDriver != null) { | 1494 if (analysisDriver != null) { |
| 1595 changeSet.addedSources.forEach((source) { | 1495 changeSet.addedSources.forEach((source) { |
| 1596 analysisDriver.addFile(source.fullName); | 1496 analysisDriver.addFile(source.fullName); |
| 1597 // temporary plugin support: | 1497 // temporary plugin support: |
| 1598 analysisServer._onFileAddedController.add(source.fullName); | 1498 analysisServer._onFileAddedController.add(source.fullName); |
| 1599 }); | 1499 }); |
| 1600 changeSet.changedSources.forEach((source) { | 1500 changeSet.changedSources.forEach((source) { |
| 1601 analysisDriver.changeFile(source.fullName); | 1501 analysisDriver.changeFile(source.fullName); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1663 // Context managers manage folders and contexts themselves. | 1563 // Context managers manage folders and contexts themselves. |
| 1664 } | 1564 } |
| 1665 | 1565 |
| 1666 @override | 1566 @override |
| 1667 void removeContext(Folder folder, List<String> flushedFiles) { | 1567 void removeContext(Folder folder, List<String> flushedFiles) { |
| 1668 sendAnalysisNotificationFlushResults(analysisServer, flushedFiles); | 1568 sendAnalysisNotificationFlushResults(analysisServer, flushedFiles); |
| 1669 nd.AnalysisDriver driver = analysisServer.driverMap.remove(folder); | 1569 nd.AnalysisDriver driver = analysisServer.driverMap.remove(folder); |
| 1670 driver.dispose(); | 1570 driver.dispose(); |
| 1671 } | 1571 } |
| 1672 | 1572 |
| 1673 @override | |
| 1674 void updateContextPackageUriResolver(AnalysisContext context) { | |
| 1675 analysisServer._onContextsChangedController | |
| 1676 .add(new ContextsChangedEvent(changed: [context])); | |
| 1677 analysisServer.schedulePerformAnalysisOperation(context); | |
| 1678 } | |
| 1679 | |
| 1680 List<HighlightRegion> _computeHighlightRegions(CompilationUnit unit) { | 1573 List<HighlightRegion> _computeHighlightRegions(CompilationUnit unit) { |
| 1681 if (analysisServer.options.useAnalysisHighlight2) { | 1574 if (analysisServer.options.useAnalysisHighlight2) { |
| 1682 return new DartUnitHighlightsComputer2(unit).compute(); | 1575 return new DartUnitHighlightsComputer2(unit).compute(); |
| 1683 } else { | 1576 } else { |
| 1684 return new DartUnitHighlightsComputer(unit).compute(); | 1577 return new DartUnitHighlightsComputer(unit).compute(); |
| 1685 } | 1578 } |
| 1686 } | 1579 } |
| 1687 | 1580 |
| 1688 String _computeLibraryName(CompilationUnit unit) { | 1581 String _computeLibraryName(CompilationUnit unit) { |
| 1689 for (Directive directive in unit.directives) { | 1582 for (Directive directive in unit.directives) { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1870 /** | 1763 /** |
| 1871 * The [PerformanceTag] for time spent in server request handlers. | 1764 * The [PerformanceTag] for time spent in server request handlers. |
| 1872 */ | 1765 */ |
| 1873 static PerformanceTag serverRequests = server.createChild('requests'); | 1766 static PerformanceTag serverRequests = server.createChild('requests'); |
| 1874 | 1767 |
| 1875 /** | 1768 /** |
| 1876 * The [PerformanceTag] for time spent in split store microtasks. | 1769 * The [PerformanceTag] for time spent in split store microtasks. |
| 1877 */ | 1770 */ |
| 1878 static PerformanceTag splitStore = new PerformanceTag('splitStore'); | 1771 static PerformanceTag splitStore = new PerformanceTag('splitStore'); |
| 1879 } | 1772 } |
| OLD | NEW |