Skip to content

Commit

Permalink
fix analyzer warnings, require analyzer 2.x (#544)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakemac53 authored Jul 19, 2021
1 parent 91a8195 commit b4136e0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
4 changes: 4 additions & 0 deletions source_gen/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down
9 changes: 2 additions & 7 deletions source_gen/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions source_gen/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions source_gen/test/src/comment_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ class CommentGenerator extends Generator {
Future<String> generate(LibraryReader library, _) async {
final output = <String>[];
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;
}
Expand Down

0 comments on commit b4136e0

Please sign in to comment.