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

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

Issue 2382033003: Revert "Remove unused option in server API" (Closed)
Patch Set: Created 4 years, 2 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 context.directory.manager; 5 library context.directory.manager;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'dart:core'; 10 import 'dart:core';
11 11
12 import 'package:analysis_server/src/analysis_server.dart';
12 import 'package:analyzer/exception/exception.dart'; 13 import 'package:analyzer/exception/exception.dart';
13 import 'package:analyzer/file_system/file_system.dart'; 14 import 'package:analyzer/file_system/file_system.dart';
14 import 'package:analyzer/instrumentation/instrumentation.dart'; 15 import 'package:analyzer/instrumentation/instrumentation.dart';
15 import 'package:analyzer/plugin/options.dart'; 16 import 'package:analyzer/plugin/options.dart';
16 import 'package:analyzer/plugin/resolver_provider.dart'; 17 import 'package:analyzer/plugin/resolver_provider.dart';
17 import 'package:analyzer/source/analysis_options_provider.dart'; 18 import 'package:analyzer/source/analysis_options_provider.dart';
18 import 'package:analyzer/source/config.dart'; 19 import 'package:analyzer/source/config.dart';
20 import 'package:analyzer/source/package_map_provider.dart';
19 import 'package:analyzer/source/package_map_resolver.dart'; 21 import 'package:analyzer/source/package_map_resolver.dart';
20 import 'package:analyzer/source/path_filter.dart'; 22 import 'package:analyzer/source/path_filter.dart';
23 import 'package:analyzer/source/pub_package_map_provider.dart';
21 import 'package:analyzer/source/sdk_ext.dart'; 24 import 'package:analyzer/source/sdk_ext.dart';
22 import 'package:analyzer/src/context/builder.dart'; 25 import 'package:analyzer/src/context/builder.dart';
23 import 'package:analyzer/src/context/context.dart' as context; 26 import 'package:analyzer/src/context/context.dart' as context;
24 import 'package:analyzer/src/dart/sdk/sdk.dart'; 27 import 'package:analyzer/src/dart/sdk/sdk.dart';
25 import 'package:analyzer/src/generated/engine.dart'; 28 import 'package:analyzer/src/generated/engine.dart';
26 import 'package:analyzer/src/generated/java_io.dart'; 29 import 'package:analyzer/src/generated/java_io.dart';
27 import 'package:analyzer/src/generated/sdk.dart'; 30 import 'package:analyzer/src/generated/sdk.dart';
28 import 'package:analyzer/src/generated/source.dart'; 31 import 'package:analyzer/src/generated/source.dart';
29 import 'package:analyzer/src/generated/source_io.dart'; 32 import 'package:analyzer/src/generated/source_io.dart';
30 import 'package:analyzer/src/task/options.dart'; 33 import 'package:analyzer/src/task/options.dart';
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 AnalysisContext addContext(Folder folder, AnalysisOptions options); 327 AnalysisContext addContext(Folder folder, AnalysisOptions options);
325 328
326 /** 329 /**
327 * Called when the set of files associated with a context have changed (or 330 * Called when the set of files associated with a context have changed (or
328 * some of those files have been modified). [changeSet] is the set of 331 * some of those files have been modified). [changeSet] is the set of
329 * changes that need to be applied to the context. 332 * changes that need to be applied to the context.
330 */ 333 */
331 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet); 334 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet);
332 335
333 /** 336 /**
337 * Signals that the context manager has started to compute a package map (if
338 * [computing] is `true`) or has finished (if [computing] is `false`).
339 */
340 void computingPackageMap(bool computing);
341
342 /**
334 * Create and return a context builder that can be used to create a context 343 * Create and return a context builder that can be used to create a context
335 * for the files in the given [folder] when analyzed using the given [options] . 344 * for the files in the given [folder] when analyzed using the given [options] .
336 */ 345 */
337 ContextBuilder createContextBuilder(Folder folder, AnalysisOptions options); 346 ContextBuilder createContextBuilder(Folder folder, AnalysisOptions options);
338 347
339 /** 348 /**
340 * Called when the context manager changes the folder with which a context is 349 * Called when the context manager changes the folder with which a context is
341 * associated. Currently this is mostly FYI, and used only in tests. 350 * associated. Currently this is mostly FYI, and used only in tests.
342 */ 351 */
343 void moveContext(Folder from, Folder to); 352 void moveContext(Folder from, Folder to);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 Map<String, String> normalizedPackageRoots = <String, String>{}; 448 Map<String, String> normalizedPackageRoots = <String, String>{};
440 449
441 /** 450 /**
442 * A function that will return a [UriResolver] that can be used to resolve 451 * A function that will return a [UriResolver] that can be used to resolve
443 * `package:` URI's within a given folder, or `null` if we should fall back 452 * `package:` URI's within a given folder, or `null` if we should fall back
444 * to the standard URI resolver. 453 * to the standard URI resolver.
445 */ 454 */
446 final ResolverProvider packageResolverProvider; 455 final ResolverProvider packageResolverProvider;
447 456
448 /** 457 /**
449 * Provider of analysis options. 458 * Provider which is used to determine the mapping from package name to
459 * package folder.
450 */ 460 */
461 final PubPackageMapProvider _packageMapProvider;
462
463 /// Provider of analysis options.
451 AnalysisOptionsProvider analysisOptionsProvider = 464 AnalysisOptionsProvider analysisOptionsProvider =
452 new AnalysisOptionsProvider(); 465 new AnalysisOptionsProvider();
453 466
454 /** 467 /**
455 * A list of the globs used to determine which files should be analyzed. 468 * A list of the globs used to determine which files should be analyzed.
456 */ 469 */
457 final List<Glob> analyzedFilesGlobs; 470 final List<Glob> analyzedFilesGlobs;
458 471
459 /** 472 /**
460 * The default options used to create new analysis contexts. 473 * The default options used to create new analysis contexts.
(...skipping 25 matching lines...) Expand all
486 * Stream subscription we are using to watch each analysis root directory for 499 * Stream subscription we are using to watch each analysis root directory for
487 * changes. 500 * changes.
488 */ 501 */
489 final Map<Folder, StreamSubscription<WatchEvent>> changeSubscriptions = 502 final Map<Folder, StreamSubscription<WatchEvent>> changeSubscriptions =
490 <Folder, StreamSubscription<WatchEvent>>{}; 503 <Folder, StreamSubscription<WatchEvent>>{};
491 504
492 ContextManagerImpl( 505 ContextManagerImpl(
493 this.resourceProvider, 506 this.resourceProvider,
494 this.sdkManager, 507 this.sdkManager,
495 this.packageResolverProvider, 508 this.packageResolverProvider,
509 this._packageMapProvider,
496 this.analyzedFilesGlobs, 510 this.analyzedFilesGlobs,
497 this._instrumentationService, 511 this._instrumentationService,
498 this.defaultContextOptions) { 512 this.defaultContextOptions) {
499 absolutePathContext = resourceProvider.absolutePathContext; 513 absolutePathContext = resourceProvider.absolutePathContext;
500 pathContext = resourceProvider.pathContext; 514 pathContext = resourceProvider.pathContext;
501 } 515 }
502 516
503 @override 517 @override
504 Iterable<AnalysisContext> get analysisContexts => folderMap.values; 518 Iterable<AnalysisContext> get analysisContexts => folderMap.values;
505 519
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 return new PackagesFileDisposition(packages); 976 return new PackagesFileDisposition(packages);
963 } 977 }
964 } 978 }
965 // The package root does not exist (or is not a folder). Since 979 // The package root does not exist (or is not a folder). Since
966 // [setRoots] ignores any package roots that don't exist (or aren't 980 // [setRoots] ignores any package roots that don't exist (or aren't
967 // folders), the only way we should be able to get here is due to a race 981 // folders), the only way we should be able to get here is due to a race
968 // condition. In any case, the package root folder is gone, so we can't 982 // condition. In any case, the package root folder is gone, so we can't
969 // resolve packages. 983 // resolve packages.
970 return new NoPackageFolderDisposition(packageRoot: packageRoot); 984 return new NoPackageFolderDisposition(packageRoot: packageRoot);
971 } else { 985 } else {
972 // Try .packages first. 986 PackageMapInfo packageMapInfo;
973 if (absolutePathContext.basename(packagespecFile.path) == 987 callbacks.computingPackageMap(true);
974 PACKAGE_SPEC_NAME) { 988 try {
975 Packages packages = _readPackagespec(packagespecFile); 989 // Try .packages first.
976 return new PackagesFileDisposition(packages); 990 if (absolutePathContext.basename(packagespecFile.path) ==
991 PACKAGE_SPEC_NAME) {
992 Packages packages = _readPackagespec(packagespecFile);
993 return new PackagesFileDisposition(packages);
994 }
995 if (packageResolverProvider != null) {
996 UriResolver resolver = packageResolverProvider(folder);
997 if (resolver != null) {
998 return new CustomPackageResolverDisposition(resolver);
999 }
1000 }
1001
1002 ServerPerformanceStatistics.pub.makeCurrentWhile(() {
1003 packageMapInfo = _packageMapProvider.computePackageMap(folder);
1004 });
1005 } finally {
1006 callbacks.computingPackageMap(false);
977 } 1007 }
978 if (packageResolverProvider != null) { 1008 for (String dependencyPath in packageMapInfo.dependencies) {
979 UriResolver resolver = packageResolverProvider(folder); 1009 addDependency(dependencyPath);
980 if (resolver != null) {
981 return new CustomPackageResolverDisposition(resolver);
982 }
983 } 1010 }
984 return new NoPackageFolderDisposition(); 1011 if (packageMapInfo.packageMap == null) {
1012 return new NoPackageFolderDisposition();
1013 }
1014 return new PackageMapDisposition(packageMapInfo.packageMap);
985 } 1015 }
986 } 1016 }
987 1017
988 /** 1018 /**
989 * Create a new empty context associated with [folder], having parent 1019 * Create a new empty context associated with [folder], having parent
990 * [parent] and using [packagespecFile] to resolve package URI's. 1020 * [parent] and using [packagespecFile] to resolve package URI's.
991 */ 1021 */
992 ContextInfo _createContext( 1022 ContextInfo _createContext(
993 ContextInfo parent, Folder folder, File packagespecFile) { 1023 ContextInfo parent, Folder folder, File packagespecFile) {
994 List<String> dependencies = <String>[]; 1024 List<String> dependencies = <String>[];
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 } 1815 }
1786 return _embedderLocator; 1816 return _embedderLocator;
1787 } 1817 }
1788 1818
1789 @override 1819 @override
1790 SdkExtensionFinder getSdkExtensionFinder(ResourceProvider resourceProvider) { 1820 SdkExtensionFinder getSdkExtensionFinder(ResourceProvider resourceProvider) {
1791 return _sdkExtensionFinder ??= 1821 return _sdkExtensionFinder ??=
1792 new SdkExtensionFinder(buildPackageMap(resourceProvider)); 1822 new SdkExtensionFinder(buildPackageMap(resourceProvider));
1793 } 1823 }
1794 } 1824 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | pkg/analysis_server/lib/src/socket_server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698