| 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:math' show max; | 10 import 'dart:math' show max; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 import 'package:analyzer/source/package_map_resolver.dart'; | 28 import 'package:analyzer/source/package_map_resolver.dart'; |
| 29 import 'package:analyzer/source/sdk_ext.dart'; | 29 import 'package:analyzer/source/sdk_ext.dart'; |
| 30 import 'package:analyzer/src/generated/ast.dart'; | 30 import 'package:analyzer/src/generated/ast.dart'; |
| 31 import 'package:analyzer/src/generated/element.dart'; | 31 import 'package:analyzer/src/generated/element.dart'; |
| 32 import 'package:analyzer/src/generated/engine.dart'; | 32 import 'package:analyzer/src/generated/engine.dart'; |
| 33 import 'package:analyzer/src/generated/java_engine.dart'; | 33 import 'package:analyzer/src/generated/java_engine.dart'; |
| 34 import 'package:analyzer/src/generated/sdk.dart'; | 34 import 'package:analyzer/src/generated/sdk.dart'; |
| 35 import 'package:analyzer/src/generated/source.dart'; | 35 import 'package:analyzer/src/generated/source.dart'; |
| 36 import 'package:analyzer/src/generated/source_io.dart'; | 36 import 'package:analyzer/src/generated/source_io.dart'; |
| 37 import 'package:analyzer/src/generated/utilities_general.dart'; | 37 import 'package:analyzer/src/generated/utilities_general.dart'; |
| 38 import 'package:package_config/packages.dart'; |
| 38 import 'package:plugin/plugin.dart'; | 39 import 'package:plugin/plugin.dart'; |
| 39 | 40 |
| 40 typedef void OptionUpdater(AnalysisOptionsImpl options); | 41 typedef void OptionUpdater(AnalysisOptionsImpl options); |
| 41 | 42 |
| 42 /** | 43 /** |
| 43 * Enum representing reasons why analysis might be done for a given file. | 44 * Enum representing reasons why analysis might be done for a given file. |
| 44 */ | 45 */ |
| 45 class AnalysisDoneReason { | 46 class AnalysisDoneReason { |
| 46 /** | 47 /** |
| 47 * Analysis of the file completed successfully. | 48 * Analysis of the file completed successfully. |
| (...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 new StreamController<ContextsChangedEvent>.broadcast(); | 1356 new StreamController<ContextsChangedEvent>.broadcast(); |
| 1356 } | 1357 } |
| 1357 | 1358 |
| 1358 /** | 1359 /** |
| 1359 * The stream that is notified when contexts are added or removed. | 1360 * The stream that is notified when contexts are added or removed. |
| 1360 */ | 1361 */ |
| 1361 Stream<ContextsChangedEvent> get onContextsChanged => | 1362 Stream<ContextsChangedEvent> get onContextsChanged => |
| 1362 _onContextsChangedController.stream; | 1363 _onContextsChangedController.stream; |
| 1363 | 1364 |
| 1364 @override | 1365 @override |
| 1365 AnalysisContext addContext(Folder folder, UriResolver packageUriResolver) { | 1366 AnalysisContext addContext(Folder folder, UriResolver packageUriResolver, Pack
ages packages) { |
| 1366 InternalAnalysisContext context = | 1367 InternalAnalysisContext context = |
| 1367 AnalysisEngine.instance.createAnalysisContext(); | 1368 AnalysisEngine.instance.createAnalysisContext(); |
| 1368 context.contentCache = analysisServer.overlayState; | 1369 context.contentCache = analysisServer.overlayState; |
| 1369 analysisServer.folderMap[folder] = context; | 1370 analysisServer.folderMap[folder] = context; |
| 1370 context.sourceFactory = _createSourceFactory(packageUriResolver); | 1371 context.sourceFactory = _createSourceFactory(packageUriResolver, packages); |
| 1371 context.analysisOptions = new AnalysisOptionsImpl.from(defaultOptions); | 1372 context.analysisOptions = new AnalysisOptionsImpl.from(defaultOptions); |
| 1372 _onContextsChangedController | 1373 _onContextsChangedController |
| 1373 .add(new ContextsChangedEvent(added: [context])); | 1374 .add(new ContextsChangedEvent(added: [context])); |
| 1374 analysisServer.schedulePerformAnalysisOperation(context); | 1375 analysisServer.schedulePerformAnalysisOperation(context); |
| 1375 return context; | 1376 return context; |
| 1376 } | 1377 } |
| 1377 | 1378 |
| 1378 @override | 1379 @override |
| 1379 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { | 1380 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { |
| 1380 AnalysisContext context = analysisServer.folderMap[contextFolder]; | 1381 AnalysisContext context = analysisServer.folderMap[contextFolder]; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1433 // links causing the analyzer to thrash, just ignore links to | 1434 // links causing the analyzer to thrash, just ignore links to |
| 1434 // non-existent files. | 1435 // non-existent files. |
| 1435 return file.exists; | 1436 return file.exists; |
| 1436 } | 1437 } |
| 1437 } | 1438 } |
| 1438 return false; | 1439 return false; |
| 1439 } | 1440 } |
| 1440 | 1441 |
| 1441 @override | 1442 @override |
| 1442 void updateContextPackageUriResolver( | 1443 void updateContextPackageUriResolver( |
| 1443 Folder contextFolder, UriResolver packageUriResolver) { | 1444 Folder contextFolder, UriResolver packageUriResolver, Packages packages) { |
| 1444 AnalysisContext context = analysisServer.folderMap[contextFolder]; | 1445 AnalysisContext context = analysisServer.folderMap[contextFolder]; |
| 1445 context.sourceFactory = _createSourceFactory(packageUriResolver); | 1446 context.sourceFactory = _createSourceFactory(packageUriResolver, packages); |
| 1446 _onContextsChangedController | 1447 _onContextsChangedController |
| 1447 .add(new ContextsChangedEvent(changed: [context])); | 1448 .add(new ContextsChangedEvent(changed: [context])); |
| 1448 analysisServer.schedulePerformAnalysisOperation(context); | 1449 analysisServer.schedulePerformAnalysisOperation(context); |
| 1449 } | 1450 } |
| 1450 | 1451 |
| 1451 void _computingPackageMap(bool computing) { | 1452 void _computingPackageMap(bool computing) { |
| 1452 if (analysisServer.serverServices.contains(ServerService.STATUS)) { | 1453 if (analysisServer.serverServices.contains(ServerService.STATUS)) { |
| 1453 PubStatus pubStatus = new PubStatus(computing); | 1454 PubStatus pubStatus = new PubStatus(computing); |
| 1454 ServerStatusParams params = new ServerStatusParams(pub: pubStatus); | 1455 ServerStatusParams params = new ServerStatusParams(pub: pubStatus); |
| 1455 analysisServer.sendNotification(params.toNotification()); | 1456 analysisServer.sendNotification(params.toNotification()); |
| 1456 } | 1457 } |
| 1457 } | 1458 } |
| 1458 | 1459 |
| 1459 /** | 1460 /** |
| 1460 * Set up a [SourceFactory] that resolves packages using the given | 1461 * Set up a [SourceFactory] that resolves packages using the given |
| 1461 * [packageUriResolver]. | 1462 * [packageUriResolver] and [packages] resolution strategy. |
| 1462 */ | 1463 */ |
| 1463 SourceFactory _createSourceFactory(UriResolver packageUriResolver) { | 1464 SourceFactory _createSourceFactory(UriResolver packageUriResolver, Packages pa
ckages) { |
| 1464 UriResolver dartResolver = new DartUriResolver(analysisServer.defaultSdk); | 1465 UriResolver dartResolver = new DartUriResolver(analysisServer.defaultSdk); |
| 1465 UriResolver resourceResolver = new ResourceUriResolver(resourceProvider); | 1466 UriResolver resourceResolver = new ResourceUriResolver(resourceProvider); |
| 1466 List<UriResolver> resolvers = []; | 1467 List<UriResolver> resolvers = []; |
| 1467 resolvers.add(dartResolver); | 1468 resolvers.add(dartResolver); |
| 1468 if (packageUriResolver is PackageMapUriResolver) { | 1469 if (packageUriResolver is PackageMapUriResolver) { |
| 1469 UriResolver sdkExtResolver = | 1470 UriResolver sdkExtResolver = |
| 1470 new SdkExtUriResolver(packageUriResolver.packageMap); | 1471 new SdkExtUriResolver(packageUriResolver.packageMap); |
| 1471 resolvers.add(sdkExtResolver); | 1472 resolvers.add(sdkExtResolver); |
| 1472 } | 1473 } |
| 1473 if (packageUriResolver != null) { | 1474 if (packageUriResolver != null) { |
| 1474 resolvers.add(packageUriResolver); | 1475 resolvers.add(packageUriResolver); |
| 1475 } | 1476 } |
| 1476 resolvers.add(resourceResolver); | 1477 resolvers.add(resourceResolver); |
| 1477 return new SourceFactory(resolvers); | 1478 return new SourceFactory(resolvers, packages); |
| 1478 } | 1479 } |
| 1479 } | 1480 } |
| 1480 | 1481 |
| 1481 /** | 1482 /** |
| 1482 * A class used by [AnalysisServer] to record performance information | 1483 * A class used by [AnalysisServer] to record performance information |
| 1483 * such as request latency. | 1484 * such as request latency. |
| 1484 */ | 1485 */ |
| 1485 class ServerPerformance { | 1486 class ServerPerformance { |
| 1486 | 1487 |
| 1487 /** | 1488 /** |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1573 /** | 1574 /** |
| 1574 * The [PerformanceTag] for time spent in server request handlers. | 1575 * The [PerformanceTag] for time spent in server request handlers. |
| 1575 */ | 1576 */ |
| 1576 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); | 1577 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); |
| 1577 | 1578 |
| 1578 /** | 1579 /** |
| 1579 * The [PerformanceTag] for time spent in split store microtasks. | 1580 * The [PerformanceTag] for time spent in split store microtasks. |
| 1580 */ | 1581 */ |
| 1581 static PerformanceTag splitStore = new PerformanceTag('splitStore'); | 1582 static PerformanceTag splitStore = new PerformanceTag('splitStore'); |
| 1582 } | 1583 } |
| OLD | NEW |