Make ParsedLibraryResult.units non-nullable.
Change-Id: I49ee1c8881c8c49f64404363c8e94e931e2968c3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206562 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
672d66cea0
commit
46b6bbe9da
@@ -1,5 +1,6 @@
|
||||
## 2.1.0
|
||||
* Changed `AnalysisResult.path` to be non-nullable.
|
||||
* Changed `ParsedLibraryResult.units` to be non-nullable.
|
||||
|
||||
## 2.0.0
|
||||
* Removed deprecated `Scope.lookup2()`.
|
||||
|
||||
@@ -162,9 +162,7 @@ class NotPathOfUriResult
|
||||
abstract class ParsedLibraryResult
|
||||
implements SomeParsedLibraryResult, AnalysisResult {
|
||||
/// The parsed units of the library.
|
||||
///
|
||||
/// TODO(migration): should not be null, probably empty list
|
||||
List<ParsedUnitResult>? get units;
|
||||
List<ParsedUnitResult> get units;
|
||||
|
||||
/// Return the declaration of the [element], or `null` if the [element]
|
||||
/// is synthetic. Throw [ArgumentError] if the [element] is not defined in
|
||||
|
||||
@@ -76,7 +76,7 @@ class LibraryElementResultImpl implements LibraryElementResult {
|
||||
class ParsedLibraryResultImpl extends AnalysisResultImpl
|
||||
implements ParsedLibraryResult {
|
||||
@override
|
||||
final List<ParsedUnitResult>? units;
|
||||
final List<ParsedUnitResult> units;
|
||||
|
||||
ParsedLibraryResultImpl(
|
||||
AnalysisSession session, String path, Uri uri, this.units)
|
||||
@@ -101,7 +101,7 @@ class ParsedLibraryResultImpl extends AnalysisResultImpl
|
||||
}
|
||||
|
||||
var elementPath = element.source!.fullName;
|
||||
var unitResult = units!.firstWhere(
|
||||
var unitResult = units.firstWhere(
|
||||
(r) => r.path == elementPath,
|
||||
orElse: () {
|
||||
var elementStr = element.getDisplayString(withNullability: true);
|
||||
|
||||
@@ -1403,10 +1403,10 @@ class B {}
|
||||
var result = driver.getParsedLibrary2(testFile);
|
||||
result as ParsedLibraryResult;
|
||||
expect(result.units, hasLength(1));
|
||||
expect(result.units![0].path, testFile);
|
||||
expect(result.units![0].content, content);
|
||||
expect(result.units![0].unit, isNotNull);
|
||||
expect(result.units![0].errors, isEmpty);
|
||||
expect(result.units[0].path, testFile);
|
||||
expect(result.units[0].content, content);
|
||||
expect(result.units[0].unit, isNotNull);
|
||||
expect(result.units[0].errors, isEmpty);
|
||||
}
|
||||
|
||||
test_getParsedLibrary2_invalidPath_notAbsolute() async {
|
||||
@@ -1429,9 +1429,9 @@ class B {}
|
||||
result as ParsedLibraryResult;
|
||||
expect(result.uri, uri);
|
||||
expect(result.units, hasLength(1));
|
||||
expect(result.units![0].uri, uri);
|
||||
expect(result.units![0].path, testFile);
|
||||
expect(result.units![0].content, content);
|
||||
expect(result.units[0].uri, uri);
|
||||
expect(result.units[0].path, testFile);
|
||||
expect(result.units[0].content, content);
|
||||
}
|
||||
|
||||
test_getParsedLibraryByUri2_notLibrary() async {
|
||||
|
||||
@@ -233,7 +233,7 @@ class B {}
|
||||
|
||||
expect(parsedLibrary.units, hasLength(1));
|
||||
{
|
||||
var parsedUnit = parsedLibrary.units![0];
|
||||
var parsedUnit = parsedLibrary.units[0];
|
||||
expect(parsedUnit.session, session);
|
||||
expect(parsedUnit.path, testPath);
|
||||
expect(parsedUnit.uri, Uri.parse('package:test/test.dart'));
|
||||
@@ -288,21 +288,21 @@ class C3 {}
|
||||
expect(parsedLibrary.units, hasLength(3));
|
||||
|
||||
{
|
||||
var aUnit = parsedLibrary.units![0];
|
||||
var aUnit = parsedLibrary.units[0];
|
||||
expect(aUnit.path, a);
|
||||
expect(aUnit.uri, Uri.parse('package:test/a.dart'));
|
||||
expect(aUnit.unit.declarations, hasLength(1));
|
||||
}
|
||||
|
||||
{
|
||||
var bUnit = parsedLibrary.units![1];
|
||||
var bUnit = parsedLibrary.units[1];
|
||||
expect(bUnit.path, b);
|
||||
expect(bUnit.uri, Uri.parse('package:test/b.dart'));
|
||||
expect(bUnit.unit.declarations, hasLength(2));
|
||||
}
|
||||
|
||||
{
|
||||
var cUnit = parsedLibrary.units![2];
|
||||
var cUnit = parsedLibrary.units[2];
|
||||
expect(cUnit.path, c);
|
||||
expect(cUnit.uri, Uri.parse('package:test/c.dart'));
|
||||
expect(cUnit.unit.declarations, hasLength(3));
|
||||
@@ -378,15 +378,15 @@ part 'c.dart';
|
||||
|
||||
expect(parsedLibrary.units, hasLength(3));
|
||||
expect(
|
||||
parsedLibrary.units![0].path,
|
||||
parsedLibrary.units[0].path,
|
||||
convertPath('/home/test/lib/test.dart'),
|
||||
);
|
||||
expect(
|
||||
parsedLibrary.units![1].path,
|
||||
parsedLibrary.units[1].path,
|
||||
convertPath('/home/test/lib/a.dart'),
|
||||
);
|
||||
expect(
|
||||
parsedLibrary.units![2].path,
|
||||
parsedLibrary.units[2].path,
|
||||
convertPath('/home/test/lib/c.dart'),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user