Make the change to ContextRoot non-breaking.
In 4cf51e6c1afd4d7863e1c0572a74a44b5269b106, a new argument was added
to the ContextRoot constructor, changing its signature in a breaking
way.
In theory this should not have broken other packages, because
ContextRoot is declared inside analyzer/lib/src. But it turns out
that two packages are known to import from analyzer/lib/src and
construct ContextRoot: angular_analyzer_plugin and
built_value_generator. To avoid breaking these packages, we need to
add the new constructor parameter as an optional (named) parameter.
Some time after after angular_analyzer_plugin and
built_value_generator have been updated, I'll send a later CL to mark
the named parameter as @required.
Change-Id: I5be063dd47a3dfefba08cb444687b91bf2ba3625
Reviewed-on: https://dart-review.googlesource.com/56603
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
diff --git a/pkg/analysis_server/lib/src/context_manager.dart b/pkg/analysis_server/lib/src/context_manager.dart
index db27347..05d4310 100644
--- a/pkg/analysis_server/lib/src/context_manager.dart
+++ b/pkg/analysis_server/lib/src/context_manager.dart
@@ -1129,8 +1129,9 @@
pathContext.isWithin(includedPath, excludedPath))
.toList();
processOptionsForDriver(info, options, optionMap);
- ContextRoot contextRoot =
- new ContextRoot(pathContext, folder.path, containedExcludedPaths);
+ ContextRoot contextRoot = new ContextRoot(
+ folder.path, containedExcludedPaths,
+ pathContext: pathContext);
if (optionsFile != null) {
contextRoot.optionsFilePath = optionsFile.path;
}
diff --git a/pkg/analysis_server/test/abstract_context.dart b/pkg/analysis_server/test/abstract_context.dart
index 8060d58..f4b1cc7 100644
--- a/pkg/analysis_server/test/abstract_context.dart
+++ b/pkg/analysis_server/test/abstract_context.dart
@@ -137,8 +137,8 @@
resourceProvider,
new MemoryByteStore(),
fileContentOverlay,
- new ContextRoot(resourceProvider.pathContext,
- resourceProvider.convertPath('/project'), []),
+ new ContextRoot(resourceProvider.convertPath('/project'), [],
+ pathContext: resourceProvider.pathContext),
sourceFactory,
new AnalysisOptionsImpl()..strongMode = true);
scheduler.start();
diff --git a/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart b/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart
index 5fd654d..f5cb609 100644
--- a/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart
+++ b/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart
@@ -34,7 +34,7 @@
}
ContextRoot _newContextRoot(String root, {List<String> exclude: const []}) {
- return new ContextRoot(path.context, root, exclude);
+ return new ContextRoot(root, exclude, pathContext: path.context);
}
@reflectiveTest
diff --git a/pkg/analysis_server/test/src/plugin/plugin_watcher_test.dart b/pkg/analysis_server/test/src/plugin/plugin_watcher_test.dart
index 0951011..694d46e 100644
--- a/pkg/analysis_server/test/src/plugin/plugin_watcher_test.dart
+++ b/pkg/analysis_server/test/src/plugin/plugin_watcher_test.dart
@@ -50,8 +50,8 @@
newFile(
'/pkg2/${PluginLocator.toolsFolderName}/${PluginLocator.defaultPluginFolderName}/bin/plugin.dart');
- ContextRoot contextRoot =
- new ContextRoot(resourceProvider.pathContext, pkg1Path, []);
+ ContextRoot contextRoot = new ContextRoot(pkg1Path, [],
+ pathContext: resourceProvider.pathContext);
TestDriver driver = new TestDriver(resourceProvider, contextRoot);
driver.analysisOptions.enabledPluginNames = ['pkg2'];
watcher.addedDriver(driver, contextRoot);
@@ -80,8 +80,8 @@
String pkg1Path = newFolder('/pkg1').path;
newFile('/pkg1/lib/test1.dart');
- ContextRoot contextRoot =
- new ContextRoot(resourceProvider.pathContext, pkg1Path, []);
+ ContextRoot contextRoot = new ContextRoot(pkg1Path, [],
+ pathContext: resourceProvider.pathContext);
TestDriver driver = new TestDriver(resourceProvider, contextRoot);
driver.analysisOptions.enabledPluginNames = ['pkg3'];
watcher.addedDriver(driver, contextRoot);
@@ -102,8 +102,8 @@
test_removedDriver() {
String pkg1Path = newFolder('/pkg1').path;
- ContextRoot contextRoot =
- new ContextRoot(resourceProvider.pathContext, pkg1Path, []);
+ ContextRoot contextRoot = new ContextRoot(pkg1Path, [],
+ pathContext: resourceProvider.pathContext);
TestDriver driver = new TestDriver(resourceProvider, contextRoot);
watcher.addedDriver(driver, contextRoot);
watcher.removedDriver(driver);
diff --git a/pkg/analyzer/lib/src/context/context_root.dart b/pkg/analyzer/lib/src/context/context_root.dart
index 1c32428..ebb208b7 100644
--- a/pkg/analyzer/lib/src/context/context_root.dart
+++ b/pkg/analyzer/lib/src/context/context_root.dart
@@ -38,7 +38,8 @@
/**
* Initialize a newly created context root.
*/
- ContextRoot(this.pathContext, this.root, this.exclude);
+ ContextRoot(this.root, this.exclude, {path.Context pathContext})
+ : pathContext = pathContext ?? path.context;
@override
int get hashCode {
diff --git a/pkg/analyzer/lib/src/dart/analysis/context_builder.dart b/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
index 2d54d53..bf4d9ba 100644
--- a/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
@@ -80,9 +80,8 @@
builder.performanceLog = performanceLog;
old.ContextRoot oldContextRoot = new old.ContextRoot(
- resourceProvider.pathContext,
- contextRoot.root.path,
- contextRoot.excludedPaths.toList());
+ contextRoot.root.path, contextRoot.excludedPaths.toList(),
+ pathContext: resourceProvider.pathContext);
AnalysisDriver driver = builder.buildDriver(oldContextRoot);
DriverBasedAnalysisContext context =
new DriverBasedAnalysisContext(resourceProvider, contextRoot, driver);
diff --git a/pkg/analyzer/lib/src/dart/analysis/context_locator.dart b/pkg/analyzer/lib/src/dart/analysis/context_locator.dart
index 5d290be..5f36fcb 100644
--- a/pkg/analyzer/lib/src/dart/analysis/context_locator.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/context_locator.dart
@@ -101,9 +101,8 @@
List<AnalysisContext> contextList = <AnalysisContext>[];
for (ContextRoot root in roots) {
old.ContextRoot contextRoot = new old.ContextRoot(
- resourceProvider.pathContext,
- root.root.path,
- root.excludedPaths.toList());
+ root.root.path, root.excludedPaths.toList(),
+ pathContext: resourceProvider.pathContext);
AnalysisDriver driver = builder.buildDriver(contextRoot);
DriverBasedAnalysisContext context =
new DriverBasedAnalysisContext(resourceProvider, root, driver);
diff --git a/pkg/analyzer/test/src/context/builder_test.dart b/pkg/analyzer/test/src/context/builder_test.dart
index dc970a1..558578c 100644
--- a/pkg/analyzer/test/src/context/builder_test.dart
+++ b/pkg/analyzer/test/src/context/builder_test.dart
@@ -891,7 +891,7 @@
- empty_constructor_bodies
''');
- ContextRoot root = new ContextRoot(pathContext, path, []);
+ ContextRoot root = new ContextRoot(path, [], pathContext: pathContext);
builder.getAnalysisOptions(path, contextRoot: root);
expect(root.optionsFilePath, equals(filePath));
}