Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI jobs #3763

Merged
merged 17 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build_resolvers/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Bump the min sdk to 3.5.0.
- Fix SDK summary reads when multiple isolates are using build resolvers (not
recommended).
- Fix analyzer deprecations.

## 2.4.2

Expand Down
10 changes: 6 additions & 4 deletions build_resolvers/lib/src/resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ class PerActionResolver implements ReleasableResolver {
// `BuildStep.canRead`. They'd still be reachable by crawling the element
// model manually.
yield current;
final toCrawl = current.importedLibraries
.followedBy(current.exportedLibraries)
.where((l) => !seen.contains(l))
final toCrawl = current.definingCompilationUnit.libraryImports
.map((import) => import.library)
.followedBy(current.definingCompilationUnit.libraryExports
.map((export) => export.library))
.where((library) => !seen.contains(library))
.toSet();
toVisit.addAll(toCrawl);
seen.addAll(toCrawl);
Expand Down Expand Up @@ -279,7 +281,7 @@ class AnalyzerResolver implements ReleasableResolver {
Future<List<ErrorsResult>> _syntacticErrorsFor(LibraryElement element) async {
final existingSources = [element.source];

for (final part in element.parts) {
for (final part in element.definingCompilationUnit.parts) {
var uri = part.uri;
// There may be no source if the part doesn't exist. That's not important
// for us since we only care about existing file syntax.
Expand Down
27 changes: 19 additions & 8 deletions build_resolvers/test/resolver_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ void main() {
''',
}, (resolver) async {
var lib = await resolver.libraryFor(entryPoint);
expect(lib.importedLibraries.length, 2);
var libA = lib.importedLibraries.where((l) => l.name == 'a').single;
expect(lib.definingCompilationUnit.libraryImports.length, 2);
var libA = lib
..definingCompilationUnit
.libraryImports
.where((l) => l.library.name == 'a')
.single;
expect(libA.getClass('Foo'), isNull);
}, resolvers: AnalyzerResolvers());
});
Expand All @@ -64,8 +68,12 @@ void main() {
''',
}, (resolver) async {
var lib = await resolver.libraryFor(entryPoint);
expect(lib.importedLibraries.length, 2);
var libB = lib.importedLibraries.where((l) => l.name == 'b').single;
expect(lib.definingCompilationUnit.libraryImports.length, 2);
var libB = lib
..definingCompilationUnit
.libraryImports
.where((l) => l.library.name == 'b')
.single;
expect(libB.getClass('Foo'), isNull);
}, resolvers: AnalyzerResolvers());
});
Expand Down Expand Up @@ -257,8 +265,11 @@ void main() {
} ''',
}, (resolver) async {
var lib = await resolver.libraryFor(entryPoint);
expect(lib.parts.length, 1);
expect(lib.parts.whereType<DirectiveUriWithSource>(), isEmpty);
expect(lib.definingCompilationUnit.parts.length, 1);
expect(
lib.definingCompilationUnit.parts
.whereType<DirectiveUriWithSource>(),
isEmpty);
}, resolvers: AnalyzerResolvers());
});

Expand Down Expand Up @@ -454,8 +465,8 @@ void main() {
''',
}, (resolver) async {
var entry = await resolver.libraryFor(AssetId('a', 'lib/a.dart'));
var classDefinition = entry.importedLibraries
.map((l) => l.getClass('SomeClass'))
var classDefinition = entry.definingCompilationUnit.libraryImports
.map((l) => l.library.getClass('SomeClass'))
.singleWhere((c) => c != null)!;
expect(await resolver.assetIdForElement(classDefinition),
AssetId('a', 'lib/b.dart'));
Expand Down
7 changes: 4 additions & 3 deletions build_runner_core/test/generate/resolver_reuse_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ void main() {
await buildStep.canRead(buildStep.inputId.addExtension('.foo'));
// Check that the `.imported.dart` library is still reachable
// through the resolver.
var importedLibrary = inputLibrary.importedLibraries.firstWhere(
(l) => l.source.uri.path.endsWith('.imported.dart'));
var classNames = importedLibrary.definingCompilationUnit.classes
var importedLibrary =
inputLibrary.definingCompilationUnit.libraryImports.firstWhere(
(l) => l.librarySource.uri.path.endsWith('.imported.dart'));
var classNames = importedLibrary.enclosingElement3.classes
.map((c) => c.name)
.toList();
return buildStep.writeAsString(
Expand Down
Loading