@@ -887,9 +887,9 @@ class ContextManagerImpl implements ContextManager {
887887 }
888888
889889 void _checkForPackagespecUpdate (String path, ContextInfo info) {
890- // Check to see if this is the .packages file for this context and if so,
891- // update the context's source factory.
892- if (pathContext. basename (path) == PACKAGE_SPEC_NAME ) {
890+ // Check to see if this is `.dart_tool/package_config.json` or `.packages`
891+ // file for this context and if so, update the context's source factory.
892+ if (_isPackageConfigJsonFilePath (path) || _isDotPackagesFilePath (path) ) {
893893 var driver = info.analysisDriver;
894894 if (driver == null ) {
895895 // I suspect that this happens as a result of a race condition: server
@@ -1249,6 +1249,9 @@ class ContextManagerImpl implements ContextManager {
12491249 if (info.hasDependency (path)) {
12501250 _recomputeFolderDisposition (info);
12511251 }
1252+
1253+ _checkForPackagespecUpdate (path, info);
1254+
12521255 // maybe excluded globally
12531256 if (_isExcluded (path) ||
12541257 _isContainedInDotFolder (info.folder.path, path) ||
@@ -1283,7 +1286,7 @@ class ContextManagerImpl implements ContextManager {
12831286 return ;
12841287 }
12851288 }
1286- if (_isPackagespec (path)) {
1289+ if (_isDotPackagesFilePath (path)) {
12871290 // Check for a sibling pubspec.yaml file.
12881291 if (! resourceProvider
12891292 .getFile (pathContext.join (directoryPath, PUBSPEC_NAME ))
@@ -1323,7 +1326,7 @@ class ContextManagerImpl implements ContextManager {
13231326 return ;
13241327 }
13251328 }
1326- if (_isPackagespec (path)) {
1329+ if (_isDotPackagesFilePath (path)) {
13271330 // Check for a sibling pubspec.yaml file.
13281331 if (! resourceProvider
13291332 .getFile (pathContext.join (directoryPath, PUBSPEC_NAME ))
@@ -1352,7 +1355,6 @@ class ContextManagerImpl implements ContextManager {
13521355 }
13531356 }
13541357 }
1355- _checkForPackagespecUpdate (path, info);
13561358 _checkForAnalysisOptionsUpdate (path, info);
13571359 _checkForDataFileUpdate (path, info);
13581360 _checkForPubspecUpdate (path, info);
@@ -1388,6 +1390,10 @@ class ContextManagerImpl implements ContextManager {
13881390 /// to specify data-driven fixes.
13891391 bool _isDataFile (String path) => pathContext.basename (path) == dataFileName;
13901392
1393+ bool _isDotPackagesFilePath (String path) {
1394+ return pathContext.basename (path) == PACKAGE_SPEC_NAME ;
1395+ }
1396+
13911397 /// Returns `true` if the given [path] is excluded by [excludedPaths] .
13921398 bool _isExcluded (String path) => _isExcludedBy (excludedPaths, path);
13931399
@@ -1415,8 +1421,12 @@ class ContextManagerImpl implements ContextManager {
14151421
14161422 bool _isManifest (String path) => pathContext.basename (path) == MANIFEST_NAME ;
14171423
1418- bool _isPackagespec (String path) =>
1419- pathContext.basename (path) == PACKAGE_SPEC_NAME ;
1424+ bool _isPackageConfigJsonFilePath (String path) {
1425+ var components = pathContext.split (path);
1426+ return components.length > 2 &&
1427+ components[components.length - 1 ] == 'package_config.json' &&
1428+ components[components.length - 2 ] == '.dart_tool' ;
1429+ }
14201430
14211431 bool _isPubspec (String path) => pathContext.basename (path) == PUBSPEC_NAME ;
14221432
@@ -1477,8 +1487,13 @@ class ContextManagerImpl implements ContextManager {
14771487 var builder = callbacks.createContextBuilder (info.folder);
14781488 var options = builder.getAnalysisOptions (contextRoot,
14791489 contextRoot: driver.contextRoot);
1490+ var packages = builder.createPackageMap (contextRoot);
14801491 var factory = builder.createSourceFactory (contextRoot);
1481- driver.configure (analysisOptions: options, sourceFactory: factory );
1492+ driver.configure (
1493+ analysisOptions: options,
1494+ packages: packages,
1495+ sourceFactory: factory ,
1496+ );
14821497 callbacks.analysisOptionsUpdated (driver);
14831498 }
14841499
0 commit comments