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'; | 9 import 'dart:core'; |
10 import 'dart:io' as io; | 10 import 'dart:io' as io; |
11 import 'dart:math' show max; | 11 import 'dart:math' show max; |
12 | 12 |
13 import 'package:analysis_server/plugin/protocol/protocol.dart' | 13 import 'package:analysis_server/plugin/protocol/protocol.dart' |
14 hide AnalysisOptions, Element; | 14 hide AnalysisOptions, Element; |
15 import 'package:analysis_server/src/analysis_logger.dart'; | 15 import 'package:analysis_server/src/analysis_logger.dart'; |
16 import 'package:analysis_server/src/channel/channel.dart'; | 16 import 'package:analysis_server/src/channel/channel.dart'; |
17 import 'package:analysis_server/src/computer/new_notifications.dart'; | |
17 import 'package:analysis_server/src/context_manager.dart'; | 18 import 'package:analysis_server/src/context_manager.dart'; |
18 import 'package:analysis_server/src/operation/operation.dart'; | 19 import 'package:analysis_server/src/operation/operation.dart'; |
19 import 'package:analysis_server/src/operation/operation_analysis.dart'; | 20 import 'package:analysis_server/src/operation/operation_analysis.dart'; |
20 import 'package:analysis_server/src/operation/operation_queue.dart'; | 21 import 'package:analysis_server/src/operation/operation_queue.dart'; |
21 import 'package:analysis_server/src/plugin/server_plugin.dart'; | 22 import 'package:analysis_server/src/plugin/server_plugin.dart'; |
22 import 'package:analysis_server/src/services/correction/namespace.dart'; | 23 import 'package:analysis_server/src/services/correction/namespace.dart'; |
23 import 'package:analysis_server/src/services/index/index.dart'; | 24 import 'package:analysis_server/src/services/index/index.dart'; |
24 import 'package:analysis_server/src/services/search/search_engine.dart'; | 25 import 'package:analysis_server/src/services/search/search_engine.dart'; |
25 import 'package:analysis_server/src/services/search/search_engine_internal.dart' ; | 26 import 'package:analysis_server/src/services/search/search_engine_internal.dart' ; |
26 import 'package:analysis_server/src/single_context_manager.dart'; | 27 import 'package:analysis_server/src/single_context_manager.dart'; |
27 import 'package:analyzer/dart/ast/ast.dart'; | 28 import 'package:analyzer/dart/ast/ast.dart'; |
28 import 'package:analyzer/dart/element/element.dart'; | 29 import 'package:analyzer/dart/element/element.dart'; |
29 import 'package:analyzer/exception/exception.dart'; | 30 import 'package:analyzer/exception/exception.dart'; |
30 import 'package:analyzer/file_system/file_system.dart'; | 31 import 'package:analyzer/file_system/file_system.dart'; |
31 import 'package:analyzer/instrumentation/instrumentation.dart'; | 32 import 'package:analyzer/instrumentation/instrumentation.dart'; |
32 import 'package:analyzer/plugin/resolver_provider.dart'; | 33 import 'package:analyzer/plugin/resolver_provider.dart'; |
33 import 'package:analyzer/source/pub_package_map_provider.dart'; | 34 import 'package:analyzer/source/pub_package_map_provider.dart'; |
34 import 'package:analyzer/src/context/builder.dart'; | 35 import 'package:analyzer/src/context/builder.dart'; |
36 import 'package:analyzer/src/dart/analysis/byte_store.dart'; | |
37 import 'package:analyzer/src/dart/analysis/file_byte_store.dart'; | |
38 import 'package:analyzer/src/dart/analysis/driver.dart' as nd; | |
35 import 'package:analyzer/src/dart/ast/utilities.dart'; | 39 import 'package:analyzer/src/dart/ast/utilities.dart'; |
36 import 'package:analyzer/src/generated/engine.dart'; | 40 import 'package:analyzer/src/generated/engine.dart'; |
37 import 'package:analyzer/src/generated/sdk.dart'; | 41 import 'package:analyzer/src/generated/sdk.dart'; |
38 import 'package:analyzer/src/generated/source.dart'; | 42 import 'package:analyzer/src/generated/source.dart'; |
39 import 'package:analyzer/src/generated/source_io.dart'; | 43 import 'package:analyzer/src/generated/source_io.dart'; |
40 import 'package:analyzer/src/generated/utilities_general.dart'; | 44 import 'package:analyzer/src/generated/utilities_general.dart'; |
41 import 'package:analyzer/src/summary/pub_summary.dart'; | 45 import 'package:analyzer/src/summary/pub_summary.dart'; |
42 import 'package:analyzer/src/task/dart.dart'; | 46 import 'package:analyzer/src/task/dart.dart'; |
43 import 'package:analyzer/src/util/glob.dart'; | 47 import 'package:analyzer/src/util/glob.dart'; |
44 import 'package:analyzer/task/dart.dart'; | 48 import 'package:analyzer/task/dart.dart'; |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
300 * The package resolver provider used to override the way package URI's are | 304 * The package resolver provider used to override the way package URI's are |
301 * resolved in some contexts. | 305 * resolved in some contexts. |
302 */ | 306 */ |
303 ResolverProvider packageResolverProvider; | 307 ResolverProvider packageResolverProvider; |
304 | 308 |
305 /** | 309 /** |
306 * The manager of pub package summaries. | 310 * The manager of pub package summaries. |
307 */ | 311 */ |
308 PubSummaryManager pubSummaryManager; | 312 PubSummaryManager pubSummaryManager; |
309 | 313 |
314 ByteStore byteStore; | |
315 | |
316 /** | |
317 * A table mapping [Folder]s to the [AnalysisDriver]s associated with them. | |
318 */ | |
319 final Map<Folder, nd.AnalysisDriver> driverMap = | |
Brian Wilkerson
2016/10/31 15:42:58
I would prefer to see this added to ContextManager
scheglov
2016/10/31 16:54:20
Done.
| |
320 new HashMap<Folder, nd.AnalysisDriver>(); | |
321 | |
310 /** | 322 /** |
311 * Initialize a newly created server to receive requests from and send | 323 * Initialize a newly created server to receive requests from and send |
312 * responses to the given [channel]. | 324 * responses to the given [channel]. |
313 * | 325 * |
314 * If [rethrowExceptions] is true, then any exceptions thrown by analysis are | 326 * If [rethrowExceptions] is true, then any exceptions thrown by analysis are |
315 * propagated up the call stack. The default is true to allow analysis | 327 * propagated up the call stack. The default is true to allow analysis |
316 * exceptions to show up in unit tests, but it should be set to false when | 328 * exceptions to show up in unit tests, but it should be set to false when |
317 * running a full analysis server. | 329 * running a full analysis server. |
318 */ | 330 */ |
319 AnalysisServer( | 331 AnalysisServer( |
(...skipping 14 matching lines...) Expand all Loading... | |
334 _performance = performanceDuringStartup; | 346 _performance = performanceDuringStartup; |
335 defaultContextOptions.incremental = true; | 347 defaultContextOptions.incremental = true; |
336 defaultContextOptions.incrementalApi = | 348 defaultContextOptions.incrementalApi = |
337 options.enableIncrementalResolutionApi; | 349 options.enableIncrementalResolutionApi; |
338 defaultContextOptions.incrementalValidation = | 350 defaultContextOptions.incrementalValidation = |
339 options.enableIncrementalResolutionValidation; | 351 options.enableIncrementalResolutionValidation; |
340 defaultContextOptions.finerGrainedInvalidation = | 352 defaultContextOptions.finerGrainedInvalidation = |
341 options.finerGrainedInvalidation; | 353 options.finerGrainedInvalidation; |
342 defaultContextOptions.generateImplicitErrors = false; | 354 defaultContextOptions.generateImplicitErrors = false; |
343 operationQueue = new ServerOperationQueue(); | 355 operationQueue = new ServerOperationQueue(); |
356 byteStore = new MemoryCachingByteStore( | |
357 new FileByteStore(resourceProvider.getStateLocation('analysis-driver')), | |
358 1024); | |
344 if (useSingleContextManager) { | 359 if (useSingleContextManager) { |
345 contextManager = new SingleContextManager(resourceProvider, sdkManager, | 360 contextManager = new SingleContextManager(resourceProvider, sdkManager, |
346 packageResolverProvider, analyzedFilesGlobs, defaultContextOptions); | 361 packageResolverProvider, analyzedFilesGlobs, defaultContextOptions); |
347 } else { | 362 } else { |
348 contextManager = new ContextManagerImpl( | 363 contextManager = new ContextManagerImpl( |
349 resourceProvider, | 364 resourceProvider, |
350 sdkManager, | 365 sdkManager, |
351 packageResolverProvider, | 366 packageResolverProvider, |
352 packageMapProvider, | 367 packageMapProvider, |
353 analyzedFilesGlobs, | 368 analyzedFilesGlobs, |
354 instrumentationService, | 369 instrumentationService, |
355 defaultContextOptions); | 370 defaultContextOptions, |
371 options.enableNewAnalysisDriver); | |
356 } | 372 } |
357 this.fileResolverProvider = fileResolverProvider; | 373 this.fileResolverProvider = fileResolverProvider; |
358 this.packageResolverProvider = packageResolverProvider; | 374 this.packageResolverProvider = packageResolverProvider; |
359 ServerContextManagerCallbacks contextManagerCallbacks = | 375 ServerContextManagerCallbacks contextManagerCallbacks = |
360 new ServerContextManagerCallbacks(this, resourceProvider); | 376 new ServerContextManagerCallbacks(this, resourceProvider); |
361 contextManager.callbacks = contextManagerCallbacks; | 377 contextManager.callbacks = contextManagerCallbacks; |
362 _noErrorNotification = options.noErrorNotification; | 378 _noErrorNotification = options.noErrorNotification; |
363 AnalysisEngine.instance.logger = new AnalysisLogger(this); | 379 AnalysisEngine.instance.logger = new AnalysisLogger(this); |
364 _onAnalysisStartedController = new StreamController.broadcast(); | 380 _onAnalysisStartedController = new StreamController.broadcast(); |
365 _onFileAnalyzedController = new StreamController.broadcast(); | 381 _onFileAnalyzedController = new StreamController.broadcast(); |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1079 throw new RequestFailure( | 1095 throw new RequestFailure( |
1080 new Response.unsupportedFeature(requestId, e.message)); | 1096 new Response.unsupportedFeature(requestId, e.message)); |
1081 } | 1097 } |
1082 } | 1098 } |
1083 | 1099 |
1084 /** | 1100 /** |
1085 * Implementation for `analysis.setSubscriptions`. | 1101 * Implementation for `analysis.setSubscriptions`. |
1086 */ | 1102 */ |
1087 void setAnalysisSubscriptions( | 1103 void setAnalysisSubscriptions( |
1088 Map<AnalysisService, Set<String>> subscriptions) { | 1104 Map<AnalysisService, Set<String>> subscriptions) { |
1105 if (options.enableNewAnalysisDriver) { | |
1106 // TODO(scheglov) implement for the new analysis driver | |
1107 return; | |
1108 } | |
1089 // send notifications for already analyzed sources | 1109 // send notifications for already analyzed sources |
1090 subscriptions.forEach((service, Set<String> newFiles) { | 1110 subscriptions.forEach((service, Set<String> newFiles) { |
1091 Set<String> oldFiles = analysisServices[service]; | 1111 Set<String> oldFiles = analysisServices[service]; |
1092 Set<String> todoFiles = | 1112 Set<String> todoFiles = |
1093 oldFiles != null ? newFiles.difference(oldFiles) : newFiles; | 1113 oldFiles != null ? newFiles.difference(oldFiles) : newFiles; |
1094 for (String file in todoFiles) { | 1114 for (String file in todoFiles) { |
1095 if (contextManager.isIgnored(file)) { | 1115 if (contextManager.isIgnored(file)) { |
1096 continue; | 1116 continue; |
1097 } | 1117 } |
1098 // prepare context | 1118 // prepare context |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1168 .contains(GeneralAnalysisService.ANALYZED_FILES)) { | 1188 .contains(GeneralAnalysisService.ANALYZED_FILES)) { |
1169 prevAnalyzedFiles = null; | 1189 prevAnalyzedFiles = null; |
1170 } | 1190 } |
1171 generalAnalysisServices = newServices; | 1191 generalAnalysisServices = newServices; |
1172 } | 1192 } |
1173 | 1193 |
1174 /** | 1194 /** |
1175 * Set the priority files to the given [files]. | 1195 * Set the priority files to the given [files]. |
1176 */ | 1196 */ |
1177 void setPriorityFiles(String requestId, List<String> files) { | 1197 void setPriorityFiles(String requestId, List<String> files) { |
1198 if (options.enableNewAnalysisDriver) { | |
1199 driverMap.values.forEach((driver){ | |
1200 driver.priorityFiles = files; | |
1201 }); | |
1202 // TODO(scheglov) implement for the new analysis driver | |
Brian Wilkerson
2016/10/31 15:42:58
The formatting of the lines above the comment look
scheglov
2016/10/31 16:54:20
I think it's done.
I'm removing the comment.
| |
1203 return; | |
1204 } | |
1178 // Note: when a file is a priority file, that information needs to be | 1205 // Note: when a file is a priority file, that information needs to be |
1179 // propagated to all contexts that analyze the file, so that all contexts | 1206 // propagated to all contexts that analyze the file, so that all contexts |
1180 // will be able to do incremental resolution of the file. See | 1207 // will be able to do incremental resolution of the file. See |
1181 // dartbug.com/22209. | 1208 // dartbug.com/22209. |
1182 Map<AnalysisContext, List<Source>> sourceMap = | 1209 Map<AnalysisContext, List<Source>> sourceMap = |
1183 new HashMap<AnalysisContext, List<Source>>(); | 1210 new HashMap<AnalysisContext, List<Source>>(); |
1184 List<String> unanalyzed = new List<String>(); | 1211 List<String> unanalyzed = new List<String>(); |
1185 Source firstSource = null; | 1212 Source firstSource = null; |
1186 files.forEach((String file) { | 1213 files.forEach((String file) { |
1187 if (contextManager.isIgnored(file)) { | 1214 if (contextManager.isIgnored(file)) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1287 break; | 1314 break; |
1288 } | 1315 } |
1289 operation.perform(this); | 1316 operation.perform(this); |
1290 } | 1317 } |
1291 } | 1318 } |
1292 | 1319 |
1293 /** | 1320 /** |
1294 * Implementation for `analysis.updateContent`. | 1321 * Implementation for `analysis.updateContent`. |
1295 */ | 1322 */ |
1296 void updateContent(String id, Map<String, dynamic> changes) { | 1323 void updateContent(String id, Map<String, dynamic> changes) { |
1324 if (options.enableNewAnalysisDriver) { | |
1325 changes.forEach((file, change) { | |
1326 Source source = resourceProvider.getFile(file).createSource(); | |
1327 // Prepare the new contents. | |
1328 String oldContents = overlayState.getContents(source); | |
1329 String newContents; | |
1330 if (change is AddContentOverlay) { | |
1331 newContents = change.content; | |
1332 } else if (change is ChangeContentOverlay) { | |
1333 if (oldContents == null) { | |
1334 // The client may only send a ChangeContentOverlay if there is | |
1335 // already an existing overlay for the source. | |
1336 throw new RequestFailure(new Response(id, | |
1337 error: new RequestError(RequestErrorCode.INVALID_OVERLAY_CHANGE, | |
1338 'Invalid overlay change'))); | |
1339 } | |
1340 try { | |
1341 newContents = SourceEdit.applySequence(oldContents, change.edits); | |
1342 } on RangeError { | |
1343 throw new RequestFailure(new Response(id, | |
1344 error: new RequestError(RequestErrorCode.INVALID_OVERLAY_CHANGE, | |
1345 'Invalid overlay change'))); | |
1346 } | |
1347 } else if (change is RemoveContentOverlay) { | |
1348 newContents = null; | |
1349 } else { | |
1350 // Protocol parsing should have ensured that we never get here. | |
1351 throw new AnalysisException('Illegal change type'); | |
1352 } | |
1353 | |
1354 overlayState.setContents(source, newContents); | |
1355 | |
1356 driverMap.values.forEach((driver) { | |
1357 driver.changeFile(file); | |
1358 }); | |
1359 // TODO(scheglov) implement other cases | |
1360 }); | |
1361 return; | |
1362 } | |
1297 changes.forEach((file, change) { | 1363 changes.forEach((file, change) { |
1298 ContextSourcePair contextSource = getContextSourcePair(file); | 1364 ContextSourcePair contextSource = getContextSourcePair(file); |
1299 Source source = contextSource.source; | 1365 Source source = contextSource.source; |
1300 operationQueue.sourceAboutToChange(source); | 1366 operationQueue.sourceAboutToChange(source); |
1301 // Prepare the new contents. | 1367 // Prepare the new contents. |
1302 String oldContents = overlayState.getContents(source); | 1368 String oldContents = overlayState.getContents(source); |
1303 String newContents; | 1369 String newContents; |
1304 if (change is AddContentOverlay) { | 1370 if (change is AddContentOverlay) { |
1305 newContents = change.content; | 1371 newContents = change.content; |
1306 } else if (change is ChangeContentOverlay) { | 1372 } else if (change is ChangeContentOverlay) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1399 } | 1465 } |
1400 } | 1466 } |
1401 }); | 1467 }); |
1402 } | 1468 } |
1403 | 1469 |
1404 /** | 1470 /** |
1405 * Use the given updaters to update the values of the options in every | 1471 * Use the given updaters to update the values of the options in every |
1406 * existing analysis context. | 1472 * existing analysis context. |
1407 */ | 1473 */ |
1408 void updateOptions(List<OptionUpdater> optionUpdaters) { | 1474 void updateOptions(List<OptionUpdater> optionUpdaters) { |
1475 if (options.enableNewAnalysisDriver) { | |
1476 // TODO(scheglov) implement for the new analysis driver | |
1477 return; | |
1478 } | |
1409 // | 1479 // |
1410 // Update existing contexts. | 1480 // Update existing contexts. |
1411 // | 1481 // |
1412 for (AnalysisContext context in analysisContexts) { | 1482 for (AnalysisContext context in analysisContexts) { |
1413 AnalysisOptionsImpl options = | 1483 AnalysisOptionsImpl options = |
1414 new AnalysisOptionsImpl.from(context.analysisOptions); | 1484 new AnalysisOptionsImpl.from(context.analysisOptions); |
1415 optionUpdaters.forEach((OptionUpdater optionUpdater) { | 1485 optionUpdaters.forEach((OptionUpdater optionUpdater) { |
1416 optionUpdater(options); | 1486 optionUpdater(options); |
1417 }); | 1487 }); |
1418 context.analysisOptions = options; | 1488 context.analysisOptions = options; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1542 for (AnalysisContext context in event.removed) { | 1612 for (AnalysisContext context in event.removed) { |
1543 index.removeContext(context); | 1613 index.removeContext(context); |
1544 } | 1614 } |
1545 }); | 1615 }); |
1546 } | 1616 } |
1547 } | 1617 } |
1548 | 1618 |
1549 class AnalysisServerOptions { | 1619 class AnalysisServerOptions { |
1550 bool enableIncrementalResolutionApi = false; | 1620 bool enableIncrementalResolutionApi = false; |
1551 bool enableIncrementalResolutionValidation = false; | 1621 bool enableIncrementalResolutionValidation = false; |
1622 bool enableNewAnalysisDriver = false; | |
1552 bool enablePubSummaryManager = false; | 1623 bool enablePubSummaryManager = false; |
1553 bool finerGrainedInvalidation = false; | 1624 bool finerGrainedInvalidation = false; |
1554 bool noErrorNotification = false; | 1625 bool noErrorNotification = false; |
1555 bool noIndex = false; | 1626 bool noIndex = false; |
1556 bool useAnalysisHighlight2 = false; | 1627 bool useAnalysisHighlight2 = false; |
1557 String fileReadMode = 'as-is'; | 1628 String fileReadMode = 'as-is'; |
1558 } | 1629 } |
1559 | 1630 |
1560 /** | 1631 /** |
1561 * Information about a file - an [AnalysisContext] that analyses the file, | 1632 * Information about a file - an [AnalysisContext] that analyses the file, |
(...skipping 29 matching lines...) Expand all Loading... | |
1591 final AnalysisServer analysisServer; | 1662 final AnalysisServer analysisServer; |
1592 | 1663 |
1593 /** | 1664 /** |
1594 * The [ResourceProvider] by which paths are converted into [Resource]s. | 1665 * The [ResourceProvider] by which paths are converted into [Resource]s. |
1595 */ | 1666 */ |
1596 final ResourceProvider resourceProvider; | 1667 final ResourceProvider resourceProvider; |
1597 | 1668 |
1598 ServerContextManagerCallbacks(this.analysisServer, this.resourceProvider); | 1669 ServerContextManagerCallbacks(this.analysisServer, this.resourceProvider); |
1599 | 1670 |
1600 @override | 1671 @override |
1672 nd.AnalysisDriver addAnalysisDriver(Folder folder, AnalysisOptions options) { | |
1673 SourceFactory sourceFactory; | |
1674 AnalysisOptions analysisOptions; | |
1675 { | |
1676 ContextBuilder builder = createContextBuilder(folder, options); | |
1677 AnalysisContext context = builder.buildContext(folder.path); | |
1678 sourceFactory = context.sourceFactory; | |
1679 analysisOptions = context.analysisOptions; | |
1680 context.dispose(); | |
1681 } | |
1682 nd.AnalysisDriver analysisDriver = new nd.AnalysisDriver( | |
1683 new nd.PerformanceLog(io.stdout), | |
1684 resourceProvider, | |
1685 analysisServer.byteStore, | |
1686 analysisServer.overlayState, | |
1687 sourceFactory, | |
1688 analysisOptions); | |
1689 analysisDriver.name = folder.shortName; | |
1690 analysisDriver.status.listen((status) { | |
1691 // TODO(scheglov) send server status | |
1692 }); | |
1693 analysisDriver.results.listen((result) { | |
1694 new_sendErrorNotification(analysisServer, result); | |
1695 // { | |
Brian Wilkerson
2016/10/31 15:42:58
Add a comment explaining why this code was left in
scheglov
2016/10/31 16:54:20
Done.
| |
1696 // var unit = result.unit; | |
1697 // if (unit != null) { | |
1698 // print('[results][${analysisDriver.name}] ${result.path}'); | |
1699 // sendAnalysisNotificationHighlights(analysisServer, result.path, unit ); | |
1700 // { | |
1701 // NavigationCollectorImpl collector = | |
1702 // computeSimpleDartNavigation(unit); | |
1703 // var params = new protocol.AnalysisNavigationParams(result.path, | |
1704 // collector.regions, collector.targets, collector.files); | |
1705 // analysisServer.sendNotification(params.toNotification()); | |
1706 // } | |
1707 // } | |
1708 // } | |
1709 }); | |
1710 analysisServer.driverMap[folder] = analysisDriver; | |
1711 return analysisDriver; | |
1712 } | |
1713 | |
1714 @override | |
1601 AnalysisContext addContext(Folder folder, AnalysisOptions options) { | 1715 AnalysisContext addContext(Folder folder, AnalysisOptions options) { |
1602 ContextBuilder builder = createContextBuilder(folder, options); | 1716 ContextBuilder builder = createContextBuilder(folder, options); |
1603 AnalysisContext context = builder.buildContext(folder.path); | 1717 AnalysisContext context = builder.buildContext(folder.path); |
1604 | 1718 |
1605 analysisServer.folderMap[folder] = context; | 1719 analysisServer.folderMap[folder] = context; |
1606 analysisServer._onContextsChangedController | 1720 analysisServer._onContextsChangedController |
1607 .add(new ContextsChangedEvent(added: [context])); | 1721 .add(new ContextsChangedEvent(added: [context])); |
1608 analysisServer.schedulePerformAnalysisOperation(context); | 1722 analysisServer.schedulePerformAnalysisOperation(context); |
1609 | 1723 |
1610 return context; | 1724 return context; |
1611 } | 1725 } |
1612 | 1726 |
1613 @override | 1727 @override |
1614 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { | 1728 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { |
1615 AnalysisContext context = analysisServer.folderMap[contextFolder]; | 1729 if (analysisServer.options.enableNewAnalysisDriver) { |
1616 if (context != null) { | 1730 nd.AnalysisDriver analysisDriver = |
1617 context.applyChanges(changeSet); | 1731 analysisServer.driverMap[contextFolder]; |
1618 analysisServer.schedulePerformAnalysisOperation(context); | 1732 if (analysisDriver != null) { |
1619 List<String> flushedFiles = new List<String>(); | 1733 changeSet.addedSources.forEach((source) { |
1620 for (Source source in changeSet.removedSources) { | 1734 analysisDriver.addFile(source.fullName); |
1621 flushedFiles.add(source.fullName); | 1735 }); |
1736 changeSet.changedSources.forEach((source) { | |
1737 analysisDriver.changeFile(source.fullName); | |
1738 }); | |
1739 changeSet.removedSources.forEach((source) { | |
1740 analysisDriver.removeFile(source.fullName); | |
1741 }); | |
1622 } | 1742 } |
1623 sendAnalysisNotificationFlushResults(analysisServer, flushedFiles); | 1743 } else { |
1744 AnalysisContext context = analysisServer.folderMap[contextFolder]; | |
1745 if (context != null) { | |
1746 context.applyChanges(changeSet); | |
1747 analysisServer.schedulePerformAnalysisOperation(context); | |
1748 List<String> flushedFiles = new List<String>(); | |
1749 for (Source source in changeSet.removedSources) { | |
1750 flushedFiles.add(source.fullName); | |
1751 } | |
1752 sendAnalysisNotificationFlushResults(analysisServer, flushedFiles); | |
1753 } | |
1624 } | 1754 } |
1625 } | 1755 } |
1626 | 1756 |
1627 @override | 1757 @override |
1628 void computingPackageMap(bool computing) => | 1758 void computingPackageMap(bool computing) => |
1629 analysisServer._computingPackageMap(computing); | 1759 analysisServer._computingPackageMap(computing); |
1630 | 1760 |
1631 @override | 1761 @override |
1632 ContextBuilder createContextBuilder(Folder folder, AnalysisOptions options) { | 1762 ContextBuilder createContextBuilder(Folder folder, AnalysisOptions options) { |
1633 String defaultPackageFilePath = null; | 1763 String defaultPackageFilePath = null; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1782 /** | 1912 /** |
1783 * The [PerformanceTag] for time spent in server request handlers. | 1913 * The [PerformanceTag] for time spent in server request handlers. |
1784 */ | 1914 */ |
1785 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); | 1915 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); |
1786 | 1916 |
1787 /** | 1917 /** |
1788 * The [PerformanceTag] for time spent in split store microtasks. | 1918 * The [PerformanceTag] for time spent in split store microtasks. |
1789 */ | 1919 */ |
1790 static PerformanceTag splitStore = new PerformanceTag('splitStore'); | 1920 static PerformanceTag splitStore = new PerformanceTag('splitStore'); |
1791 } | 1921 } |
OLD | NEW |