diff --git a/build_runner/test/build/build_step_impl_test.dart b/build_runner/test/build/build_step_impl_test.dart index 0d0049095..1e15ff943 100644 --- a/build_runner/test/build/build_step_impl_test.dart +++ b/build_runner/test/build/build_step_impl_test.dart @@ -1,7 +1,6 @@ // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// ignore_for_file: deprecated_member_use @TestOn('vm') library; @@ -147,18 +146,18 @@ void main() { final resolver = buildStep.resolver; final aLib = await resolver.libraryFor(primary); - expect(aLib.name3, 'a'); - expect(aLib.firstFragment.libraryImports2.length, 2); + expect(aLib.name, 'a'); + expect(aLib.firstFragment.libraryImports.length, 2); expect( - aLib.firstFragment.libraryImports2.any( - (import) => import.importedLibrary2!.name3 == 'b', + aLib.firstFragment.libraryImports.any( + (import) => import.importedLibrary!.name == 'b', ), isTrue, ); final bLib = await resolver.findLibraryByName('b'); - expect(bLib!.name3, 'b'); - expect(bLib.firstFragment.libraryImports2.length, 1); + expect(bLib!.name, 'b'); + expect(bLib.firstFragment.libraryImports.length, 1); await buildStep.complete(); }); diff --git a/build_runner/test/build/resolution_test.dart b/build_runner/test/build/resolution_test.dart index 8506e1c88..50b14ec6b 100644 --- a/build_runner/test/build/resolution_test.dart +++ b/build_runner/test/build/resolution_test.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// ignore_for_file: deprecated_member_use - import 'dart:async'; import 'package:build/build.dart'; @@ -57,7 +55,7 @@ class ListClassesAndHierarchyBuilder implements Builder { final outputId = buildStep.inputId.changeExtension('.txt'); for (final type in types) { output - ..write('${type.name3}: [') + ..write('${type.name}: [') ..writeAll(type.allSupertypes.map((t) => t.element.name), ', ') ..writeln(']'); } diff --git a/build_runner/test/build/resolver/resolver_test.dart b/build_runner/test/build/resolver/resolver_test.dart index 3ba010bc1..42415ef8b 100644 --- a/build_runner/test/build/resolver/resolver_test.dart +++ b/build_runner/test/build/resolver/resolver_test.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// ignore_for_file: deprecated_member_use - import 'dart:io' show Platform; import 'dart:isolate'; @@ -69,13 +67,13 @@ void runTests(ResolversFactory resolversFactory) { }, (resolver) async { final lib = await resolver.libraryFor(entryPoint); - expect(lib.firstFragment.libraryImports2.length, 2); + expect(lib.firstFragment.libraryImports.length, 2); final libA = lib - ..firstFragment.libraryImports2 - .where((l) => l.importedLibrary2!.name3 == 'a') + ..firstFragment.libraryImports + .where((l) => l.importedLibrary!.name == 'a') .single; - expect(libA.getClass2('Foo'), isNull); + expect(libA.getClass('Foo'), isNull); }, resolvers: createResolvers(), ); @@ -113,13 +111,13 @@ void runTests(ResolversFactory resolversFactory) { }, (resolver) async { final lib = await resolver.libraryFor(entryPoint); - expect(lib.firstFragment.libraryImports2.length, 2); + expect(lib.firstFragment.libraryImports.length, 2); final libB = lib - ..firstFragment.libraryImports2 - .where((l) => l.importedLibrary2!.name3 == 'b') + ..firstFragment.libraryImports + .where((l) => l.importedLibrary!.name == 'b') .single; - expect(libB.getClass2('Foo'), isNull); + expect(libB.getClass('Foo'), isNull); }, resolvers: createResolvers(), ); @@ -162,8 +160,8 @@ void runTests(ResolversFactory resolversFactory) { }, (resolver) async { final lib = await resolver.libraryFor(entryPoint); - expect(lib.getClass2('A'), isNotNull); - expect(lib.getClass2('B'), isNull); + expect(lib.getClass('A'), isNotNull); + expect(lib.getClass('B'), isNull); }, resolvers: resolvers, ); @@ -179,8 +177,8 @@ void runTests(ResolversFactory resolversFactory) { }, (resolver) async { final lib = await resolver.libraryFor(entryPoint); - expect(lib.getClass2('A'), isNull); - expect(lib.getClass2('B'), isNotNull); + expect(lib.getClass('A'), isNull); + expect(lib.getClass('B'), isNotNull); }, resolvers: resolvers, ); @@ -200,8 +198,8 @@ void runTests(ResolversFactory resolversFactory) { }, (resolver) async { final lib = await resolver.libraryFor(entryPoint); - expect(lib.getClass2('A'), isNotNull); - expect(lib.getClass2('B'), isNull); + expect(lib.getClass('A'), isNotNull); + expect(lib.getClass('B'), isNull); }, resolvers: resolvers, ); @@ -221,8 +219,8 @@ void runTests(ResolversFactory resolversFactory) { }, (resolver) async { final lib = await resolver.libraryFor(entryPoint); - expect(lib.getClass2('A'), isNull); - expect(lib.getClass2('B'), isNotNull); + expect(lib.getClass('A'), isNull); + expect(lib.getClass('B'), isNotNull); }, resolvers: resolvers, ); @@ -246,14 +244,14 @@ void runTests(ResolversFactory resolversFactory) { final sourcesWithoutB = Map.of(sources)..remove('a|web/b.dart'); await resolveSources(sourcesWithoutB, (resolver) async { final lib = await resolver.libraryFor(entryPoint); - final clazz = lib.getClass2('A'); + final clazz = lib.getClass('A'); expect(clazz, isNotNull); expect(clazz!.interfaces, isEmpty); }, resolvers: resolvers); await resolveSources(sources, (resolver) async { final lib = await resolver.libraryFor(entryPoint); - final clazz = lib.getClass2('A'); + final clazz = lib.getClass('A'); expect(clazz, isNotNull); expect(clazz!.interfaces, hasLength(1)); expect(clazz.interfaces.first.getDisplayString(), 'C'); @@ -454,21 +452,21 @@ void runTests(ResolversFactory resolversFactory) { expect(main, isNotNull); final other = await resolver.libraryFor(otherId); - expect(other.name3, 'other'); + expect(other.name, 'other'); }); }); test('are included in library stream', () { return runWith((resolver) async { await expectLater( - resolver.libraries.map((l) => l.name3), + resolver.libraries.map((l) => l.name), neverEmits('other'), ); await resolver.libraryFor(otherId); await expectLater( - resolver.libraries.map((l) => l.name3), + resolver.libraries.map((l) => l.name), emitsThrough('other'), ); }); @@ -516,7 +514,7 @@ void runTests(ResolversFactory resolversFactory) { }, (resolver) async { final lib = await resolver.libraryFor(entryPoint); - final clazz = lib.getClass2('A'); + final clazz = lib.getClass('A'); expect(clazz, isNotNull); expect(clazz!.interfaces, isEmpty); }, @@ -537,7 +535,7 @@ void runTests(ResolversFactory resolversFactory) { }, (resolver) async { final lib = await resolver.libraryFor(entryPoint); - final clazz = lib.getClass2('A'); + final clazz = lib.getClass('A'); expect(clazz, isNotNull); expect(clazz!.interfaces, hasLength(1)); expect(clazz.interfaces.first.getDisplayString(), 'B'); @@ -562,7 +560,7 @@ void runTests(ResolversFactory resolversFactory) { }, (resolver) async { final lib = await resolver.libraryFor(entryPoint); - final clazz = lib.getClass2('A'); + final clazz = lib.getClass('A'); expect(clazz, isNotNull); expect(clazz!.interfaces, hasLength(1)); expect(clazz.interfaces.first.getDisplayString(), 'B'); @@ -582,7 +580,7 @@ void runTests(ResolversFactory resolversFactory) { }, (resolver) async { final lib = await resolver.libraryFor(entryPoint); - final clazz = lib.getClass2('A'); + final clazz = lib.getClass('A'); expect(clazz, isNotNull); expect(clazz!.interfaces, isEmpty); }, @@ -608,7 +606,7 @@ void runTests(ResolversFactory resolversFactory) { final libs = await resolver.libraries.where((l) => !l.isInSdk).toList(); expect( - libs.map((l) => l.name3), + libs.map((l) => l.name), unorderedEquals(['a.main', 'a.a', 'a.b', 'a.c', 'a.d']), ); }, @@ -673,12 +671,7 @@ void runTests(ResolversFactory resolversFactory) { (resolver) async { final main = (await resolver.findLibraryByName('web.main'))!; final meta = - main - .getClass2('Foo')! - .supertype! - .element3 - .metadata2 - .annotations[0]; + main.getClass('Foo')!.supertype!.element.metadata.annotations[0]; expect(meta, isNotNull); expect(meta.computeConstantValue()?.toIntValue(), 0); }, @@ -700,8 +693,7 @@ void runTests(ResolversFactory resolversFactory) { import 'package:a/a.dart'; ''', }, (resolver) async { - final libs = - await resolver.libraries.map((lib) => lib.name3).toList(); + final libs = await resolver.libraries.map((lib) => lib.name).toList(); expect(libs.contains('a'), isTrue); expect(libs.contains('b'), isTrue); }, @@ -725,8 +717,8 @@ void runTests(ResolversFactory resolversFactory) { (resolver) async { final entry = await resolver.libraryFor(AssetId('a', 'lib/a.dart')); final classDefinition = - entry.firstFragment.libraryImports2 - .map((l) => l.importedLibrary2!.getClass2('SomeClass')) + entry.firstFragment.libraryImports + .map((l) => l.importedLibrary!.getClass('SomeClass')) .singleWhere((c) => c != null)!; expect( await resolver.assetIdForElement(classDefinition), @@ -758,11 +750,11 @@ void runTests(ResolversFactory resolversFactory) { final entry = await resolver.libraryFor(AssetId('a', 'lib/a.dart')); final element = entry.topLevelFunctions - .firstWhere((e) => e.name3 == 'main') - .metadata2 + .firstWhere((e) => e.name == 'main') + .metadata .annotations .single - .element2!; + .element!; await expectLater( () => resolver.assetIdForElement(element), throwsA(isA()), @@ -795,7 +787,7 @@ int? get x => 1; ); final errors = await lib.session.getErrors('/a/web/main.dart') as ErrorsResult; - expect(errors.errors, isEmpty); + expect(errors.diagnostics, isEmpty); }, resolvers: createResolvers(), ), @@ -819,7 +811,7 @@ int? get x => 1; await resolver.assetIdForElement(lib), ); expect( - await newLib.session.getResolvedLibraryByElement2(newLib), + await newLib.session.getResolvedLibraryByElement(newLib), isA(), ); }, resolvers: resolvers); @@ -1042,7 +1034,7 @@ int? get x => 1; await resolveSources({'a|lib/a.dart': ''}, (resolver) async { final convert = await resolver.findLibraryByName('dart.convert'); expect(convert, isNotNull); - expect(convert!.getClass2('Codec'), isNotNull); + expect(convert!.getClass('Codec'), isNotNull); final allLibraries = await resolver.libraries.toList(); expect( allLibraries.map((e) => e.uri.toString()), @@ -1141,14 +1133,14 @@ int? get x => 1; }, (resolver) async { final entry = await resolver.libraryFor(AssetId('a', 'lib/a.dart')); - final classDefinition = entry.getClass2('MyClass')!; - final color = classDefinition.getField2('color')!; + final classDefinition = entry.getClass('MyClass')!; + final color = classDefinition.getField('color')!; if (isFlutter) { expect(color.type.element!.name, equals('Color')); expect(color.type.element!.library!.name, equals('dart.ui')); expect( - color.type.element3!.library2!.uri.toString(), + color.type.element!.library!.uri.toString(), equals('dart:ui'), ); } else { diff --git a/build_runner/test/build/resolver_reuse_test.dart b/build_runner/test/build/resolver_reuse_test.dart index 576cec78a..d4f020403 100644 --- a/build_runner/test/build/resolver_reuse_test.dart +++ b/build_runner/test/build/resolver_reuse_test.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// ignore_for_file: deprecated_member_use - import 'dart:async'; import 'package:build/build.dart'; @@ -54,15 +52,15 @@ void main() { // Check that the `.imported.dart` library is still reachable // through the resolver. final importedLibrary = - inputLibrary.firstFragment.libraryImports2 + inputLibrary.firstFragment.libraryImports .firstWhere( - (l) => l.importedLibrary2!.uri.path.endsWith( + (l) => l.importedLibrary!.uri.path.endsWith( '.imported.dart', ), ) - .importedLibrary2!; + .importedLibrary!; final classNames = - importedLibrary.classes.map((c) => c.name3).toList(); + importedLibrary.classes.map((c) => c.name).toList(); return buildStep.writeAsString( buildStep.inputId.addExtension('.bar'), '$classNames', @@ -107,7 +105,7 @@ void main() { if (buildStep.inputId.path != 'lib/a.dart') return; final library = await buildStep.inputLibrary; final annotation = - library.topLevelFunctions.single.metadata2.annotations.single + library.topLevelFunctions.single.metadata.annotations.single .computeConstantValue(); await buildStep.writeAsString( buildStep.inputId.changeExtension('.g2.dart'), diff --git a/build_runner/test/invalidation/invalidation_tester.dart b/build_runner/test/invalidation/invalidation_tester.dart index 13acf7c5f..31a3d3334 100644 --- a/build_runner/test/invalidation/invalidation_tester.dart +++ b/build_runner/test/invalidation/invalidation_tester.dart @@ -6,7 +6,7 @@ import 'dart:async'; import 'dart:convert'; import 'dart:math'; -import 'package:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/element.dart'; import 'package:build/build.dart'; import 'package:build_runner/src/constants.dart'; import 'package:build_runner/src/logging/build_log.dart'; @@ -603,17 +603,16 @@ extension AssetIdExtension on AssetId { AssetId(package, path.replaceAll(RegExp('$from\$'), to)); } -// ignore_for_file: deprecated_member_use -extension TransitiveLibrariesExtension on LibraryElement2 { +extension TransitiveLibrariesExtension on LibraryElement { /// Finds all transitive imports from this library, excluding SDK libraries. - Set get transitiveImports { - final result = Set.identity(); + Set get transitiveImports { + final result = Set.identity(); final work = [this]; while (work.isNotEmpty) { final current = work.removeLast(); // For each library found, add its direct dependencies. - for (final library in current.firstFragment.importedLibraries2) { + for (final library in current.firstFragment.importedLibraries) { if (library.isInSdk) continue; if (result.add(library)) { work.add(library); diff --git a/build_test/test/resolve_source_test.dart b/build_test/test/resolve_source_test.dart index c4f6abd66..bd60b78e1 100644 --- a/build_test/test/resolve_source_test.dart +++ b/build_test/test/resolve_source_test.dart @@ -2,12 +2,10 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// ignore_for_file: deprecated_member_use - import 'dart:async'; import 'package:analyzer/dart/analysis/results.dart'; -import 'package:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/type.dart'; import 'package:build/build.dart'; import 'package:build_test/build_test.dart'; @@ -22,7 +20,7 @@ void main() { class Foo {} ''', (resolver) => resolver.findLibraryNotNull('example')); - expect(libExample.getClass2('Foo'), isNotNull); + expect(libExample.getClass('Foo'), isNotNull); }); test('a simple dart file with dart: dependencies', () async { @@ -33,7 +31,7 @@ void main() { abstract class Foo implements LinkedHashMap {} ''', (resolver) => resolver.findLibraryNotNull('example')); - final classFoo = libExample.getClass2('Foo')!; + final classFoo = libExample.getClass('Foo')!; expect( classFoo.allSupertypes.map(_toStringId), contains('dart:collection#LinkedHashMap'), @@ -55,7 +53,7 @@ void main() { }, (resolver) => resolver.findLibraryNotNull('example'), ); - final classFoo = libExample.getClass2('Foo')!; + final classFoo = libExample.getClass('Foo')!; expect( classFoo.allSupertypes.map(_toStringId), contains(endsWith(':collection#Equality')), @@ -81,7 +79,7 @@ void main() { (resolver) => resolver.findLibraryNotNull('example'), resolverFor: mock, ); - final type = library.getClass2('ExamplePrime'); + final type = library.getClass('ExamplePrime'); expect(type, isNotNull); expect(type!.supertype!.element.name, 'Example'); }); @@ -101,7 +99,7 @@ void main() { }, (resolver) async { final libExample = await resolver.findLibraryNotNull('example'); - final classFoo = libExample.getClass2('Foo')!; + final classFoo = libExample.getClass('Foo')!; expect( classFoo.allSupertypes.map(_toStringId), contains(endsWith(':collection#Equality')), @@ -134,7 +132,7 @@ void main() { ) as ErrorsResult; expect( - errors.errors.map((e) => e.message), + errors.diagnostics.map((e) => e.message), contains( contains( 'This requires the \'digit-separators\' language feature to be ' @@ -156,7 +154,7 @@ void main() { readAllSourcesFromFilesystem: true, (resolver) async { final libExample = await resolver.findLibraryNotNull('example'); - final classFoo = libExample.getClass2('Foo')!; + final classFoo = libExample.getClass('Foo')!; expect( classFoo.allSupertypes.map(_toStringId), contains(endsWith(':collection#Equality')), @@ -173,7 +171,7 @@ void main() { asset, (resolver) => resolver.findLibraryNotNull('example_lib'), ); - expect(libExample.getClass2('Example'), isNotNull); + expect(libExample.getClass('Example'), isNotNull); }); }); @@ -197,10 +195,10 @@ void main() { } String _toStringId(InterfaceType t) => - '${t.element3.library2.uri.toString().split('/').first}#${t.element.name}'; + '${t.element.library.uri.toString().split('/').first}#${t.element.name}'; extension on Resolver { - Future findLibraryNotNull(String name) async { + Future findLibraryNotNull(String name) async { return (await findLibraryByName(name))!; } }