diff --git a/source_gen/CHANGELOG.md b/source_gen/CHANGELOG.md index 164747ba..f77168b8 100644 --- a/source_gen/CHANGELOG.md +++ b/source_gen/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.4 + +* Fix warnings with latest analyzer, require analyzer 2.x. + ## 1.0.3 * Allow the latest version of `package:analyzer`. diff --git a/source_gen/lib/src/utils.dart b/source_gen/lib/src/utils.dart index 765494f3..44679ccb 100644 --- a/source_gen/lib/src/utils.dart +++ b/source_gen/lib/src/utils.dart @@ -38,14 +38,9 @@ String typeNameOf(DartType type) { } /// Returns a name suitable for `part of "..."` when pointing to [element]. -/// -/// Returns `null` if [element] is missing identifier. String nameOfPartial(LibraryElement element, AssetId source) { - // TODO(scheglov) Remove when switched to newer package:analyzer. - // ignore:unnecessary_non_null_assertion, unnecessary_null_comparison - if (element.name != null && element.name!.isNotEmpty) { - // ignore:unnecessary_non_null_assertion - return element.name!; + if (element.name.isNotEmpty) { + return element.name; } final sourceUrl = p.basename(source.uri.toString()); diff --git a/source_gen/pubspec.yaml b/source_gen/pubspec.yaml index c55f0f9a..5a311baa 100644 --- a/source_gen/pubspec.yaml +++ b/source_gen/pubspec.yaml @@ -1,5 +1,5 @@ name: source_gen -version: 1.0.3 +version: 1.0.4 description: >- Source code generation builders and utilities for the Dart build system repository: https://github.com/dart-lang/source_gen @@ -8,7 +8,7 @@ environment: sdk: ">=2.12.0 <3.0.0" dependencies: - analyzer: '>=1.7.0 <3.0.0' + analyzer: ^2.0.0 async: ^2.5.0 build: ^2.0.0 dart_style: ^2.0.0 diff --git a/source_gen/test/src/comment_generator.dart b/source_gen/test/src/comment_generator.dart index ae95b911..4aed0504 100644 --- a/source_gen/test/src/comment_generator.dart +++ b/source_gen/test/src/comment_generator.dart @@ -15,9 +15,7 @@ class CommentGenerator extends Generator { Future generate(LibraryReader library, _) async { final output = []; if (forLibrary) { - // TODO(scheglov) Remove when switched to newer package:analyzer. - // ignore:unnecessary_non_null_assertion - var name = library.element.name!; + var name = library.element.name; if (name.isEmpty) { name = library.element.source.uri.pathSegments.last; }