diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a1d9f4b05..79d79d90e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,7 +24,8 @@ jobs: strategy: matrix: channel: - - stable + # Disabled due to some outdated dependencies on Flutter stable + # - stable - master package_path: - examples/counter diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index 902ec6dc7..d8b8abf13 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -5,10 +5,6 @@ on: types: - opened - reopened - pull_request: - types: - - opened - - reopened jobs: add-to-project: diff --git a/.github/workflows/riverpod_lint.yml b/.github/workflows/riverpod_lint.yml index 82577c8c1..3747dcec7 100644 --- a/.github/workflows/riverpod_lint.yml +++ b/.github/workflows/riverpod_lint.yml @@ -24,7 +24,7 @@ jobs: strategy: matrix: channel: - - stable + - master package_path: - packages/riverpod_analyzer_utils - packages/riverpod_analyzer_utils_tests diff --git a/examples/counter/pubspec.yaml b/examples/counter/pubspec.yaml index 3f98f93b9..65a810905 100644 --- a/examples/counter/pubspec.yaml +++ b/examples/counter/pubspec.yaml @@ -25,7 +25,7 @@ dependencies: dev_dependencies: build_runner: ^2.3.3 build_verify: ^3.0.0 - custom_lint: ^0.4.0 + custom_lint: ^0.5.1 flutter_test: sdk: flutter freezed: ^2.3.2 diff --git a/examples/pub/pubspec_overrides.yaml b/examples/pub/pubspec_overrides.yaml index a804a5379..69216e274 100644 --- a/examples/pub/pubspec_overrides.yaml +++ b/examples/pub/pubspec_overrides.yaml @@ -12,3 +12,5 @@ dependency_overrides: path: ../../packages/riverpod_annotation riverpod_generator: path: ../../packages/riverpod_generator + # necessary for mockito + analyzer: ^6.0.0 \ No newline at end of file diff --git a/examples/stackoverflow/pubspec_overrides.yaml b/examples/stackoverflow/pubspec_overrides.yaml index a804a5379..6de56f5b5 100644 --- a/examples/stackoverflow/pubspec_overrides.yaml +++ b/examples/stackoverflow/pubspec_overrides.yaml @@ -12,3 +12,5 @@ dependency_overrides: path: ../../packages/riverpod_annotation riverpod_generator: path: ../../packages/riverpod_generator + # necessary for mockito + analyzer: ^6.0.0 diff --git a/packages/riverpod/pubspec.yaml b/packages/riverpod/pubspec.yaml index 8a311f395..17f06479b 100644 --- a/packages/riverpod/pubspec.yaml +++ b/packages/riverpod/pubspec.yaml @@ -18,7 +18,7 @@ dependencies: state_notifier: ^0.7.2 dev_dependencies: - analyzer: ^4.6.0 + analyzer: ^6.0.0 expect_error: ^1.0.0 mockito: ^5.0.0 test: ^1.16.0 diff --git a/packages/riverpod/pubspec_overrides.yaml b/packages/riverpod/pubspec_overrides.yaml new file mode 100644 index 000000000..5fe406c11 --- /dev/null +++ b/packages/riverpod/pubspec_overrides.yaml @@ -0,0 +1,3 @@ +dependency_overrides: + # necessary for mockito + analyzer: ^6.0.0 diff --git a/packages/riverpod_analyzer_utils/CHANGELOG.md b/packages/riverpod_analyzer_utils/CHANGELOG.md index f493f64e3..935bb0011 100644 --- a/packages/riverpod_analyzer_utils/CHANGELOG.md +++ b/packages/riverpod_analyzer_utils/CHANGELOG.md @@ -1,3 +1,7 @@ +## Unreleased patch + +Support analyzer 6.0.0 + ## 0.3.1 - 2023-05-12 - Upgrade `custom_lint_core` to 0.4.0 diff --git a/packages/riverpod_analyzer_utils/pubspec.yaml b/packages/riverpod_analyzer_utils/pubspec.yaml index c056ab498..02ac1024b 100644 --- a/packages/riverpod_analyzer_utils/pubspec.yaml +++ b/packages/riverpod_analyzer_utils/pubspec.yaml @@ -10,10 +10,10 @@ environment: sdk: ">=2.18.0 <3.0.0" dependencies: - analyzer: ^5.12.0 + analyzer: ^6.0.0 collection: ^1.16.0 crypto: ^3.0.2 - custom_lint_core: ^0.4.0 + custom_lint_core: ^0.5.1 freezed_annotation: ^2.2.0 meta: ^1.7.0 path: ^1.8.0 diff --git a/packages/riverpod_analyzer_utils_tests/pubspec.yaml b/packages/riverpod_analyzer_utils_tests/pubspec.yaml index 76dd64f71..1c3aae867 100644 --- a/packages/riverpod_analyzer_utils_tests/pubspec.yaml +++ b/packages/riverpod_analyzer_utils_tests/pubspec.yaml @@ -7,7 +7,7 @@ environment: sdk: ">=2.18.0 <3.0.0" dependencies: - analyzer: ^5.12.0 + analyzer: ^6.0.0 collection: ^1.16.0 freezed_annotation: ^2.2.0 meta: ^1.7.0 diff --git a/packages/riverpod_analyzer_utils_tests/test/generator_provider_declaration_test.dart b/packages/riverpod_analyzer_utils_tests/test/generator_provider_declaration_test.dart index c40c3ceab..85e4c9771 100644 --- a/packages/riverpod_analyzer_utils_tests/test/generator_provider_declaration_test.dart +++ b/packages/riverpod_analyzer_utils_tests/test/generator_provider_declaration_test.dart @@ -140,13 +140,13 @@ int sixth(SixthRef ref) => 0; errors[4].message, 'Unsupported dependency. Only functions and classes annotated by @riverpod are supported.', ); - expect(errors[4].targetElement.toString(), 'int sixth(dynamic ref)'); + expect(errors[4].targetElement.toString(), 'int sixth(InvalidType ref)'); expect( errors[5].message, 'Failed to parse dependency Type (int*)', ); - expect(errors[5].targetElement?.toString(), 'int sixth(dynamic ref)'); + expect(errors[5].targetElement?.toString(), 'int sixth(InvalidType ref)'); }); testSource('Decode name', runGenerator: true, source: r''' diff --git a/packages/riverpod_cli/lib/src/migrate/unified_syntax.dart b/packages/riverpod_cli/lib/src/migrate/unified_syntax.dart index 33987de3f..6a56c06b4 100644 --- a/packages/riverpod_cli/lib/src/migrate/unified_syntax.dart +++ b/packages/riverpod_cli/lib/src/migrate/unified_syntax.dart @@ -104,7 +104,7 @@ class RiverpodProviderUsageInfo extends GeneralizingAstVisitor void visitFunctionDeclaration(FunctionDeclaration node) { try { currentFunctionInfo = ProviderFunction( - name: node.name.name, + name: node.name.lexeme, path: node.declaredElement!.declaration.location!.components.join('/'), line: node.name.offset, ); @@ -121,7 +121,7 @@ class RiverpodProviderUsageInfo extends GeneralizingAstVisitor void visitMethodDeclaration(MethodDeclaration node) { try { currentFunctionInfo = ProviderFunction( - name: node.name.name, + name: node.name.lexeme, path: node.declaredElement!.declaration.location!.components.join('/'), line: node.name.offset, ); @@ -226,7 +226,7 @@ class RiverpodUnifiedSyntaxChangesMigrationSuggestor try { foundProviderUsage.add(false); methodDecls.clear(); - final name = node.extendsClause?.superclass.name.name; + final name = node.extendsClause?.superclass.name2.lexeme; if (name == 'StatelessWidget') { withinClass = ClassType.stateless; } else if (name == 'State') { @@ -240,9 +240,9 @@ class RiverpodUnifiedSyntaxChangesMigrationSuggestor withinClass = ClassType.none; } if (name == 'StatefulWidget') { - statefulDeclarations[node.name.name] = node; - if (statefulNeedsMigration.contains(node.name.name)) { - migrateStateful(node.name.name); + statefulDeclarations[node.name.lexeme] = node; + if (statefulNeedsMigration.contains(node.name.lexeme)) { + migrateStateful(node.name.lexeme); } } } catch (e, st) { @@ -334,8 +334,8 @@ class RiverpodUnifiedSyntaxChangesMigrationSuggestor } else if (withinClass == ClassType.stateful) { yieldPatch( 'ConsumerState', - classDecl.extendsClause!.superclass.name.offset, - classDecl.extendsClause!.superclass.name.end, + classDecl.extendsClause!.superclass.name2.offset, + classDecl.extendsClause!.superclass.name2.end, ); migrateStateful( @@ -384,7 +384,7 @@ class RiverpodUnifiedSyntaxChangesMigrationSuggestor node.functionExpression.parameters!.rightParenthesis.offset, ); } - functionDecls[node.name.name] = node; + functionDecls[node.name.lexeme] = node; } catch (e, st) { addError('migrating function declaration $node\n$e\n$st'); } @@ -405,7 +405,7 @@ class RiverpodUnifiedSyntaxChangesMigrationSuggestor node.parameters!.rightParenthesis.offset, ); } - methodDecls[node.name.name] = node; + methodDecls[node.name.lexeme] = node; } catch (e, st) { addError('migrating function declaration $node\n$e\n$st'); } @@ -496,7 +496,7 @@ class RiverpodUnifiedSyntaxChangesMigrationSuggestor bool inAutoDisposeProvider = false; String providerTypeArgs = ''; @override - void visitTypeName(TypeName node) { + void visitNamedType(NamedType node) { final typeName = node.type?.getDisplayString(withNullability: true); try { @@ -506,47 +506,47 @@ class RiverpodUnifiedSyntaxChangesMigrationSuggestor case ProviderType.stream: yieldPatch( '${autoDisposePrefix}StreamProviderRef<$providerTypeArgs>', - node.name.offset, - node.name.end, + node.name2.offset, + node.name2.end, ); break; case ProviderType.future: yieldPatch( '${autoDisposePrefix}FutureProviderRef<$providerTypeArgs>', - node.name.offset, - node.name.end, + node.name2.offset, + node.name2.end, ); break; case ProviderType.plain: yieldPatch( '${autoDisposePrefix}ProviderRef<$providerTypeArgs>', - node.name.offset, - node.name.end, + node.name2.offset, + node.name2.end, ); break; case ProviderType.state: yieldPatch( '${autoDisposePrefix}StateProviderRef<$providerTypeArgs>', - node.name.offset, - node.name.end, + node.name2.offset, + node.name2.end, ); break; case ProviderType.statenotifier: yieldPatch( '${autoDisposePrefix}StateNotifierProviderRef<$providerTypeArgs>', - node.name.offset, - node.name.end, + node.name2.offset, + node.name2.end, ); break; case ProviderType.changenotifier: yieldPatch( '${autoDisposePrefix}ChangeNotifierProviderRef<$providerTypeArgs>', - node.name.offset, - node.name.end, + node.name2.offset, + node.name2.end, ); break; case ProviderType.none: - yieldPatch('Ref', node.name.offset, node.name.end); + yieldPatch('Ref', node.name2.offset, node.name2.end); break; } } @@ -554,7 +554,7 @@ class RiverpodUnifiedSyntaxChangesMigrationSuggestor addError('when visiting type $typeName\n$e\n$st'); } - super.visitTypeName(node); + super.visitNamedType(node); } void updateProviderType(String type, DartType staticType) { @@ -785,7 +785,7 @@ class RiverpodUnifiedSyntaxChangesMigrationSuggestor void visitFunctionDeclaration(FunctionDeclaration node) { try { final func = ProviderFunction( - name: node.name.name, + name: node.name.lexeme, path: node.declaredElement!.declaration.location!.components.join('/'), line: node.name.offset, ); @@ -793,8 +793,8 @@ class RiverpodUnifiedSyntaxChangesMigrationSuggestor migrateFunctionDeclaration(node); } - functionDecls[node.name.name] = node; - migrateOnChangeFunction(node.name.name); + functionDecls[node.name.lexeme] = node; + migrateOnChangeFunction(node.name.lexeme); } catch (e, st) { addError('before visiting function declaration\n$e\n$st'); } @@ -804,14 +804,14 @@ class RiverpodUnifiedSyntaxChangesMigrationSuggestor @override void visitMethodDeclaration(MethodDeclaration node) { try { - if (node.name.name == 'build') { + if (node.name.lexeme == 'build') { buildParams = node.parameters; functionBody = node.body; if (withinClass == ClassType.consumer) { // Consumer should be migrated regardless if providers are watched / read or not migrateParams(buildParams); } - } else if (node.name.name == 'didUpdateProvider') { + } else if (node.name.lexeme == 'didUpdateProvider') { yieldPatch( ', ProviderContainer container', node.parameters!.parameters.last.end, @@ -824,17 +824,17 @@ class RiverpodUnifiedSyntaxChangesMigrationSuggestor ); } final func = ProviderFunction( - name: node.name.name, + name: node.name.lexeme, path: node.declaredElement!.declaration.location!.components.join('/'), line: node.name.offset, ); - if (node.name.name != 'build' && + if (node.name.lexeme != 'build' && RiverpodProviderUsageInfo.shouldMigrate(func)) { migrateMethodDeclaration(node); } - methodDecls[node.name.name] = node; - migrateOnChangeFunction(node.name.name); + methodDecls[node.name.lexeme] = node; + migrateOnChangeFunction(node.name.lexeme); } catch (e, st) { addError('before visiting method declaration\n$e\n$st'); } @@ -977,7 +977,8 @@ class RiverpodUnifiedSyntaxChangesMigrationSuggestor statefulDeclaration.extendsClause!.superclass.end, ); final method = statefulDeclaration.members.firstWhereOrNull( - (m) => m is MethodDeclaration && m.name.name.contains('createState'), + (m) => + m is MethodDeclaration && m.name.lexeme.contains('createState'), ) as MethodDeclaration?; if (method != null && diff --git a/packages/riverpod_cli/pubspec.yaml b/packages/riverpod_cli/pubspec.yaml index eecbaebc7..22a73409c 100644 --- a/packages/riverpod_cli/pubspec.yaml +++ b/packages/riverpod_cli/pubspec.yaml @@ -11,7 +11,7 @@ environment: sdk: '>=2.12.0 <3.0.0' dependencies: - analyzer: "^1.5.0" + analyzer: ^6.0.0 args: ^2.0.0 codemod: ^1.0.1 collection: ^1.15.0 diff --git a/packages/riverpod_cli/pubspec_overrides.yaml b/packages/riverpod_cli/pubspec_overrides.yaml new file mode 100644 index 000000000..d22881871 --- /dev/null +++ b/packages/riverpod_cli/pubspec_overrides.yaml @@ -0,0 +1,3 @@ +dependency_overrides: + # necessary for codemod + analyzer: ^6.0.0 \ No newline at end of file diff --git a/packages/riverpod_generator/CHANGELOG.md b/packages/riverpod_generator/CHANGELOG.md index 6868571b7..d522a2399 100644 --- a/packages/riverpod_generator/CHANGELOG.md +++ b/packages/riverpod_generator/CHANGELOG.md @@ -1,3 +1,7 @@ +## Unreleased patch + +Support analyzer 6.0.0 + ## 2.2.4 - 2023-07-25 Disable all lints in generated files. diff --git a/packages/riverpod_generator/pubspec.yaml b/packages/riverpod_generator/pubspec.yaml index b96e4c33a..6a1f260d3 100644 --- a/packages/riverpod_generator/pubspec.yaml +++ b/packages/riverpod_generator/pubspec.yaml @@ -10,7 +10,7 @@ environment: sdk: ">=2.17.0 <3.0.0" dependencies: - analyzer: ">4.2.0 <6.0.0" + analyzer: ^6.0.0 build: ^2.0.0 build_config: ^1.0.0 collection: ^1.15.0 diff --git a/packages/riverpod_graph/CHANGELOG.md b/packages/riverpod_graph/CHANGELOG.md new file mode 100644 index 000000000..e25dd454e --- /dev/null +++ b/packages/riverpod_graph/CHANGELOG.md @@ -0,0 +1,3 @@ +## Unreleased patch + +Support analyzer 6.0.0 \ No newline at end of file diff --git a/packages/riverpod_graph/lib/src/analyze.dart b/packages/riverpod_graph/lib/src/analyze.dart index 2006742fd..1fd2e01d7 100644 --- a/packages/riverpod_graph/lib/src/analyze.dart +++ b/packages/riverpod_graph/lib/src/analyze.dart @@ -434,7 +434,7 @@ class ProviderDependencyVisitor extends RecursiveAstVisitor { final buildMethod = classDeclaration.members .whereType() .firstWhere( - (method) => method.name.name == 'build', + (method) => method.name.lexeme == 'build', ); // Instead of continuing with the current node, we visit the one of // the referenced constructor. diff --git a/packages/riverpod_graph/pubspec.yaml b/packages/riverpod_graph/pubspec.yaml index bea5adeb6..5872e87f2 100644 --- a/packages/riverpod_graph/pubspec.yaml +++ b/packages/riverpod_graph/pubspec.yaml @@ -11,7 +11,7 @@ environment: sdk: ">=2.15.0 <3.0.0" dependencies: - analyzer: ">=4.0.0 <4.1.0" + analyzer: ^6.0.0 args: ^2.4.0 collection: ^1.0.0 path: ^1.8.2 diff --git a/packages/riverpod_lint/CHANGELOG.md b/packages/riverpod_lint/CHANGELOG.md index 8d7947a5d..41a3ad9b2 100644 --- a/packages/riverpod_lint/CHANGELOG.md +++ b/packages/riverpod_lint/CHANGELOG.md @@ -5,6 +5,7 @@ - Added `avoid_ref_inside_state_dispose` (thanks to @LeonardoRosaa). This warns if a `WidgetRef` is used in `State.dispose`, which would result in a runtime error. +- Support analyzer 6.0.0 ## 1.4.0 - 2023-07-25 diff --git a/packages/riverpod_lint/pubspec.yaml b/packages/riverpod_lint/pubspec.yaml index bf96073fe..83520233d 100644 --- a/packages/riverpod_lint/pubspec.yaml +++ b/packages/riverpod_lint/pubspec.yaml @@ -11,10 +11,10 @@ environment: sdk: ">=2.17.0 <3.0.0" dependencies: - analyzer: ^5.12.0 + analyzer: ^6.0.0 analyzer_plugin: ^0.11.2 collection: ^1.16.0 - custom_lint_builder: ^0.4.0 + custom_lint_builder: ^0.5.1 meta: ^1.7.0 path: ^1.8.1 riverpod: ^2.3.6 diff --git a/packages/riverpod_lint/pubspec_overrides.yaml b/packages/riverpod_lint/pubspec_overrides.yaml index 82a782285..9ce45e33b 100644 --- a/packages/riverpod_lint/pubspec_overrides.yaml +++ b/packages/riverpod_lint/pubspec_overrides.yaml @@ -4,3 +4,5 @@ dependency_overrides: path: ../riverpod riverpod_analyzer_utils: path: ../riverpod_analyzer_utils + # necessary due to outdated mockito dependency + analyzer: ^6.0.0 diff --git a/packages/riverpod_lint_flutter_test/pubspec.yaml b/packages/riverpod_lint_flutter_test/pubspec.yaml index a45f51040..0d4df4dff 100644 --- a/packages/riverpod_lint_flutter_test/pubspec.yaml +++ b/packages/riverpod_lint_flutter_test/pubspec.yaml @@ -14,9 +14,9 @@ dependencies: json_annotation: ^4.8.0 dev_dependencies: - build_runner: any + build_runner: ^2.4.6 build_verify: ^3.0.0 - custom_lint: ^0.4.0 + custom_lint: ^0.5.1 flutter_test: sdk: flutter freezed: ^2.3.2 @@ -36,4 +36,3 @@ dependency_overrides: path: ../hooks_riverpod riverpod_annotation: path: ../riverpod_annotation - \ No newline at end of file