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

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

Issue 2463903002: Simplify handling of watch events for the new analysis driver. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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';
(...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 } 1372 }
1373 } 1373 }
1374 } 1374 }
1375 1375
1376 // If the file went away and was replaced by a folder before we 1376 // If the file went away and was replaced by a folder before we
1377 // had a chance to process the event, resource might be a Folder. In 1377 // had a chance to process the event, resource might be a Folder. In
1378 // that case don't add it. 1378 // that case don't add it.
1379 if (resource is File) { 1379 if (resource is File) {
1380 File file = resource; 1380 File file = resource;
1381 if (_shouldFileBeAnalyzed(file)) { 1381 if (_shouldFileBeAnalyzed(file)) {
1382 ChangeSet changeSet = new ChangeSet(); 1382 if (enableNewAnalysisDriver) {
1383 Source source = createSourceInContext(info.context, file); 1383 info.analysisDriver.addFile(path);
1384 changeSet.addedSource(source); 1384 } else {
1385 callbacks.applyChangesToContext(info.folder, changeSet); 1385 ChangeSet changeSet = new ChangeSet();
1386 info.sources[path] = source; 1386 Source source = createSourceInContext(info.context, file);
1387 changeSet.addedSource(source);
1388 callbacks.applyChangesToContext(info.folder, changeSet);
1389 info.sources[path] = source;
1390 }
1387 } 1391 }
1388 } 1392 }
1389 break; 1393 break;
1390 case ChangeType.REMOVE: 1394 case ChangeType.REMOVE:
1391 1395
1392 // If package spec info is removed, check to see if we can merge context s. 1396 // If package spec info is removed, check to see if we can merge context s.
1393 // Note that it's important to verify that there is NEITHER a .packages nor a 1397 // Note that it's important to verify that there is NEITHER a .packages nor a
1394 // lingering pubspec.yaml before merging. 1398 // lingering pubspec.yaml before merging.
1395 if (!info.isTopLevel) { 1399 if (!info.isTopLevel) {
1396 String directoryPath = absolutePathContext.dirname(path); 1400 String directoryPath = absolutePathContext.dirname(path);
(...skipping 16 matching lines...) Expand all
1413 .getFile( 1417 .getFile(
1414 absolutePathContext.append(directoryPath, PUBSPEC_NAME)) 1418 absolutePathContext.append(directoryPath, PUBSPEC_NAME))
1415 .exists) { 1419 .exists) {
1416 _mergeContext(info); 1420 _mergeContext(info);
1417 return; 1421 return;
1418 } 1422 }
1419 } 1423 }
1420 } 1424 }
1421 } 1425 }
1422 1426
1423 List<Source> sources = info.context.getSourcesWithFullName(path); 1427 if (enableNewAnalysisDriver) {
1424 if (!sources.isEmpty) { 1428 info.analysisDriver.removeFile(path);
1425 ChangeSet changeSet = new ChangeSet(); 1429 } else {
1426 sources.forEach((Source source) { 1430 List<Source> sources = info.context.getSourcesWithFullName(path);
1427 changeSet.removedSource(source); 1431 if (!sources.isEmpty) {
1428 }); 1432 ChangeSet changeSet = new ChangeSet();
1429 callbacks.applyChangesToContext(info.folder, changeSet); 1433 sources.forEach((Source source) {
1430 info.sources.remove(path); 1434 changeSet.removedSource(source);
1435 });
1436 callbacks.applyChangesToContext(info.folder, changeSet);
1437 info.sources.remove(path);
1438 }
1431 } 1439 }
1432 break; 1440 break;
1433 case ChangeType.MODIFY: 1441 case ChangeType.MODIFY:
1434 List<Source> sources = info.context.getSourcesWithFullName(path); 1442 if (enableNewAnalysisDriver) {
1435 if (!sources.isEmpty) { 1443 info.analysisDriver.changeFile(path);
1436 ChangeSet changeSet = new ChangeSet(); 1444 } else {
1437 sources.forEach((Source source) { 1445 List<Source> sources = info.context.getSourcesWithFullName(path);
1438 changeSet.changedSource(source); 1446 if (!sources.isEmpty) {
1439 }); 1447 ChangeSet changeSet = new ChangeSet();
1440 callbacks.applyChangesToContext(info.folder, changeSet); 1448 sources.forEach((Source source) {
1449 changeSet.changedSource(source);
1450 });
1451 callbacks.applyChangesToContext(info.folder, changeSet);
1452 }
1441 } 1453 }
1442 break; 1454 break;
1443 } 1455 }
1444 _checkForPackagespecUpdate(path, info, info.folder); 1456 _checkForPackagespecUpdate(path, info, info.folder);
1445 _checkForAnalysisOptionsUpdate(path, info, event.type); 1457 _checkForAnalysisOptionsUpdate(path, info, event.type);
1446 } 1458 }
1447 1459
1448 /** 1460 /**
1449 * Determine whether the given [path], when interpreted relative to the 1461 * Determine whether the given [path], when interpreted relative to the
1450 * context root [root], contains a folder whose name starts with '.'. 1462 * context root [root], contains a folder whose name starts with '.'.
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 } 1870 }
1859 return _embedderLocator; 1871 return _embedderLocator;
1860 } 1872 }
1861 1873
1862 @override 1874 @override
1863 SdkExtensionFinder getSdkExtensionFinder(ResourceProvider resourceProvider) { 1875 SdkExtensionFinder getSdkExtensionFinder(ResourceProvider resourceProvider) {
1864 return _sdkExtensionFinder ??= 1876 return _sdkExtensionFinder ??=
1865 new SdkExtensionFinder(buildPackageMap(resourceProvider)); 1877 new SdkExtensionFinder(buildPackageMap(resourceProvider));
1866 } 1878 }
1867 } 1879 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698