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

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

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