Skip to content

Commit 3dd79c8

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Don't make sdkPath required yet in implementations.
It would be a breaking change. dart-lang/pub#2563 (comment) Change-Id: Ia2b75b5ed863753629340e6d2a4e273adc84bad2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155001 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 5017944 commit 3dd79c8

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

pkg/analyzer/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
find SDK, for example using `package:cli_util`.
55
* Fixed `LintDriver` for the new way to access `WorkspacePackage`.
66
* Deprecated `Scope.lookup()`, use `Scope.lookup2()` instead.
7+
* Updated implementations of `ContextBuilder.createContext()` and
8+
`ContextLocator.locateContexts` to use the current SDK if `sdkPath`
9+
is not provided.
710

811
## 0.39.13
912
* Added 'dart/sdk/build_sdk_summary.dart' with `buildSdkSummary`.

pkg/analyzer/lib/src/dart/analysis/context_builder.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import 'package:analyzer/src/dart/analysis/performance_logger.dart'
2222
show PerformanceLog;
2323
import 'package:analyzer/src/generated/sdk.dart' show DartSdkManager;
2424
import 'package:analyzer/src/generated/source.dart' show ContentCache;
25+
import 'package:cli_util/cli_util.dart';
2526
import 'package:meta/meta.dart';
2627

2728
/// An implementation of a context builder.
@@ -44,8 +45,10 @@ class ContextBuilderImpl implements ContextBuilder {
4445
List<String> librarySummaryPaths,
4546
@deprecated PerformanceLog performanceLog,
4647
@deprecated AnalysisDriverScheduler scheduler,
47-
@required String sdkPath,
48+
String sdkPath,
4849
String sdkSummaryPath}) {
50+
// TODO(scheglov) Remove this, and make `sdkPath` required.
51+
sdkPath ??= getSdkPath();
4952
ArgumentError.checkNotNull(sdkPath, 'sdkPath');
5053

5154
var byteStore = MemoryByteStore();

pkg/analyzer/lib/src/dart/analysis/context_locator.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import 'package:analyzer/src/dart/analysis/performance_logger.dart'
2626
import 'package:analyzer/src/generated/sdk.dart' show DartSdkManager;
2727
import 'package:analyzer/src/task/options.dart';
2828
import 'package:analyzer/src/util/yaml.dart';
29+
import 'package:cli_util/cli_util.dart';
2930
import 'package:glob/glob.dart';
3031
import 'package:meta/meta.dart';
3132
import 'package:path/path.dart';
@@ -56,7 +57,9 @@ class ContextLocatorImpl implements ContextLocator {
5657
List<String> excludedPaths = const <String>[],
5758
String optionsFile,
5859
String packagesFile,
59-
@required String sdkPath}) {
60+
String sdkPath}) {
61+
// TODO(scheglov) Remove this, and make `sdkPath` required.
62+
sdkPath ??= getSdkPath();
6063
ArgumentError.checkNotNull(sdkPath, 'sdkPath');
6164

6265
List<ContextRoot> roots = locateRoots(

0 commit comments

Comments
 (0)