Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions example/lib/src/multiplier_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// 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 until analyzer 7 support is dropped.

import 'package:analyzer/dart/element/element2.dart';
import 'package:build/build.dart';
import 'package:source_gen/source_gen.dart';
Expand Down
1 change: 1 addition & 0 deletions example/lib/src/property_product_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class PropertyProductGenerator extends Generator {
String generate(LibraryReader library, BuildStep buildStep) {
final productNames = topLevelNumVariables(
library,
// ignore: deprecated_member_use until analyzer 7 support is dropped.
).map((element) => element.name3).join(' * ');

return '''
Expand Down
1 change: 1 addition & 0 deletions example/lib/src/property_sum_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class PropertySumGenerator extends Generator {
String generate(LibraryReader library, BuildStep buildStep) {
final sumNames = topLevelNumVariables(
library,
// ignore: deprecated_member_use until analyzer 7 support is dropped.
).map((element) => element.name3).join(' + ');

return '''
Expand Down
2 changes: 2 additions & 0 deletions example/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// 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 until analyzer 7 support is dropped.

import 'package:analyzer/dart/element/element2.dart';
import 'package:source_gen/source_gen.dart';

Expand Down
4 changes: 2 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ environment:
sdk: ^3.7.0

dependencies:
analyzer: ^7.4.0
build: ^3.0.0-dev
analyzer: '>=7.4.0 <8.0.0'
build: ^3.0.0
source_gen: any

dev_dependencies:
Expand Down
2 changes: 1 addition & 1 deletion example_usage/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies:
path: ../example

dev_dependencies:
build_runner: ^2.0.0
build_runner: ^2.6.0
build_verify: ^3.0.0
dart_flutter_team_lints: ^3.1.0
test: ^1.25.9
2 changes: 1 addition & 1 deletion source_gen/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 3.1.0-wip
## 3.1.0

- Prepare to stop using `dart:mirrors`: deprecate `TypeChecker.fromRuntime`.
It will be removed in version `4.0.0`. Add `TypeChecker.typeNamed` which is
Expand Down
4 changes: 4 additions & 0 deletions source_gen/lib/src/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import 'dart:convert';

import 'package:analyzer/dart/ast/ast.dart';
// ignore: deprecated_member_use until analyzer 7 support is dropped.
import 'package:analyzer/dart/element/element2.dart';
import 'package:build/build.dart';
import 'package:dart_style/dart_style.dart';
Expand Down Expand Up @@ -109,6 +110,7 @@ class _Builder extends Builder {
}

Future<void> _generateForLibrary(
// ignore: deprecated_member_use until analyzer 7 support is dropped.
LibraryElement2 library,
BuildStep buildStep,
) async {
Expand Down Expand Up @@ -355,6 +357,7 @@ class LibraryBuilder extends _Builder {
}

Stream<GeneratedOutput> _generate(
// ignore: deprecated_member_use until analyzer 7 support is dropped.
LibraryElement2 library,
List<Generator> generators,
BuildStep buildStep,
Expand Down Expand Up @@ -440,6 +443,7 @@ const partIdRegExpLiteral = r'[A-Za-z_\d-]+';

final _partIdRegExp = RegExp('^$partIdRegExpLiteral\$');

// ignore: deprecated_member_use until analyzer 7 support is dropped.
String languageOverrideForLibrary(LibraryElement2 library) {
final override = library.languageVersion.override;
return override == null
Expand Down
2 changes: 2 additions & 0 deletions source_gen/lib/src/constants/reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

import 'package:analyzer/dart/constant/value.dart';
// ignore: deprecated_member_use until analyzer 7 support is dropped.
import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/dart/element/type.dart';

Expand Down Expand Up @@ -268,6 +269,7 @@ class _DartObjectConstant extends ConstantReader {
ConstantReader read(String field) {
final reader = peek(field);
if (reader == null) {
// ignore: deprecated_member_use until analyzer 7 support is dropped.
assertHasField(objectValue.type!.element3 as InterfaceElement2, field);
return const _NullConstant();
}
Expand Down
2 changes: 2 additions & 0 deletions source_gen/lib/src/constants/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// 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 until analyzer 7 support is dropped.

import 'package:analyzer/dart/constant/value.dart';
import 'package:analyzer/dart/element/element2.dart';

Expand Down
6 changes: 5 additions & 1 deletion source_gen/lib/src/generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import 'dart:async';

import 'package:analyzer/dart/ast/ast.dart';
// ignore: deprecated_member_use until analyzer 7 support is dropped.
import 'package:analyzer/dart/element/element2.dart';
import 'package:build/build.dart';
import 'package:source_span/source_span.dart';
Expand Down Expand Up @@ -46,7 +47,8 @@ class InvalidGenerationSource implements Exception {
/// May be an empty string if unknown.
final String todo;

/// The [Element2] associated with this error, if any.
/// The `Element2` associated with this error, if any.
/// ignore: deprecated_member_use until analyzer 7 support is dropped.
final Element2? element;

/// The [ElementDirective] associated with this error, if any.
Expand All @@ -62,12 +64,14 @@ class InvalidGenerationSource implements Exception {
this.message, {
Annotatable? annotatable,
this.todo = '',
// ignore: deprecated_member_use until analyzer 7 support is dropped.
Element2? element,
ElementDirective? elementDirective,
Fragment? fragment,
this.node,
}) : element =
element ??
// ignore: deprecated_member_use until analyzer 7 support is dropped.
(annotatable is Element2 ? annotatable : null) as Element2?,
elementDirective =
elementDirective ??
Expand Down
4 changes: 3 additions & 1 deletion source_gen/lib/src/generator_for_annotation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'dart:async';

// ignore: deprecated_member_use until analyzer 7 support is dropped.
import 'package:analyzer/dart/element/element2.dart';
import 'package:build/build.dart';

Expand Down Expand Up @@ -38,7 +39,7 @@ import 'type_checker.dart';
/// Elements which are not at the top level, such as the members of a class or
/// extension, are not searched for annotations. To operate on, for instance,
/// annotated fields of a class ensure that the class itself is annotated with
/// [T] and use the [Element2] to iterate over fields. The [TypeChecker] utility
/// [T] and use the `Element2` to iterate over fields. The [TypeChecker] utility
/// may be helpful to check which elements have a given annotation.
abstract class GeneratorForAnnotation<T> extends Generator {
final bool throwOnUnresolved;
Expand Down Expand Up @@ -126,6 +127,7 @@ abstract class GeneratorForAnnotation<T> extends Generator {
/// Implementations should return `null` when no content is generated. Empty
/// or whitespace-only [String] instances are also ignored.
dynamic generateForAnnotatedElement(
// ignore: deprecated_member_use until analyzer 7 support is dropped.
Element2 element,
ConstantReader annotation,
BuildStep buildStep,
Expand Down
2 changes: 2 additions & 0 deletions source_gen/lib/src/library.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// 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 until analyzer 7 support is dropped.

import 'package:analyzer/dart/element/element2.dart';
import 'package:build/build.dart';
import 'package:path/path.dart' as p;
Expand Down
2 changes: 2 additions & 0 deletions source_gen/lib/src/span_for_element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// 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 until analyzer 7 support is dropped.

import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element2.dart';
import 'package:source_span/source_span.dart';
Expand Down
2 changes: 2 additions & 0 deletions source_gen/lib/src/type_checker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// 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 until analyzer 7 support is dropped.

import 'dart:mirrors' hide SourceLocation;

import 'package:analyzer/dart/analysis/results.dart';
Expand Down
2 changes: 2 additions & 0 deletions source_gen/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import 'dart:io';

// ignore_for_file: deprecated_member_use until analyzer 7 support is dropped.

import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/dart/element/type.dart';
Expand Down
2 changes: 1 addition & 1 deletion source_gen/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: source_gen
version: 3.1.0-wip
version: 3.1.0
description: >-
Source code generation builders and utilities for the Dart build system
repository: https://github.com/dart-lang/source_gen/tree/master/source_gen
Expand Down
2 changes: 2 additions & 0 deletions source_gen/test/constants/utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// 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 until analyzer 7 support is dropped.

import 'package:analyzer/dart/constant/value.dart';
import 'package:analyzer/dart/element/element2.dart';
import 'package:build_test/build_test.dart';
Expand Down
2 changes: 2 additions & 0 deletions source_gen/test/constants_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// 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 until analyzer 7 support is dropped.

import 'package:analyzer/dart/constant/value.dart';
import 'package:build_test/build_test.dart';
import 'package:source_gen/source_gen.dart';
Expand Down
2 changes: 2 additions & 0 deletions source_gen/test/external_only_type_checker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// 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 until analyzer 7 support is dropped.

// The tests in this file are only ran externally, as the behavior only works
// externally. Internally this test is skipped.

Expand Down
4 changes: 4 additions & 0 deletions source_gen/test/generator_for_annotation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
@Timeout.factor(3)
library;

// ignore_for_file: deprecated_member_use until analyzer 7 support is dropped.

import 'package:analyzer/dart/analysis/utilities.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element2.dart';
Expand Down Expand Up @@ -170,6 +172,8 @@ $dartFormatWidth
LibraryImport() => '// LibraryImport',
LibraryExport() => '// LibraryExport',
PartInclude() => '// PartInclude',
// ignore: unreachable_switch_case on analyzer 7, needed on 8.
ElementDirective() => '// ElementDirective',
},
elementBehavior: (element) => '// ${element.runtimeType}',
),
Expand Down
2 changes: 2 additions & 0 deletions source_gen/test/library/find_type_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// 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 until analyzer 7 support is dropped.

import 'package:analyzer/dart/element/element2.dart';
import 'package:build/build.dart';
import 'package:build_test/build_test.dart';
Expand Down
2 changes: 2 additions & 0 deletions source_gen/test/library/path_to_url_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// 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 until analyzer 7 support is dropped.

// Increase timeouts on this test which resolves source code and can be slow.
import 'package:analyzer/dart/element/element2.dart';
import 'package:source_gen/source_gen.dart';
Expand Down
2 changes: 2 additions & 0 deletions source_gen/test/span_for_element_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// 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 until analyzer 7 support is dropped.

import 'package:analyzer/dart/element/element2.dart';
import 'package:build/build.dart';
import 'package:build_test/build_test.dart';
Expand Down
2 changes: 2 additions & 0 deletions source_gen/test/src/comment_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// 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 until analyzer 7 support is dropped.

import 'package:analyzer/dart/element/element2.dart';
import 'package:source_gen/source_gen.dart';

Expand Down
1 change: 1 addition & 0 deletions source_gen/test/type_checker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

// ignore_for_file: unreachable_from_main
// ignore_for_file: deprecated_member_use until analyzer 7 support is dropped.

// Increase timeouts on this test which resolves source code and can be slow.
@Timeout.factor(2.0)
Expand Down
2 changes: 2 additions & 0 deletions source_gen/test/utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
@Timeout.factor(2.0)
library;

// ignore_for_file: deprecated_member_use until analyzer 7 support is dropped.

import 'package:analyzer/dart/element/element2.dart';
import 'package:build_test/build_test.dart';
import 'package:source_gen/src/utils.dart';
Expand Down
Loading