From 5c9e8529a858211c65714b3fdc8c1f7f43761a72 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Tue, 25 Feb 2025 11:19:20 -0800 Subject: [PATCH 1/4] Introduce an analyzer plugin for the test package. --- pkgs/test_analyzer_plugin/README.md | 13 +++++ pkgs/test_analyzer_plugin/lib/main.dart | 20 +++++++ pkgs/test_analyzer_plugin/lib/src/fixes.dart | 58 +++++++++++++++++++ pkgs/test_analyzer_plugin/lib/src/rules.dart | 53 +++++++++++++++++ .../lib/src/utilities.dart | 37 ++++++++++++ pkgs/test_analyzer_plugin/pubspec.yaml | 12 ++++ 6 files changed, 193 insertions(+) create mode 100644 pkgs/test_analyzer_plugin/README.md create mode 100644 pkgs/test_analyzer_plugin/lib/main.dart create mode 100644 pkgs/test_analyzer_plugin/lib/src/fixes.dart create mode 100644 pkgs/test_analyzer_plugin/lib/src/rules.dart create mode 100644 pkgs/test_analyzer_plugin/lib/src/utilities.dart create mode 100644 pkgs/test_analyzer_plugin/pubspec.yaml diff --git a/pkgs/test_analyzer_plugin/README.md b/pkgs/test_analyzer_plugin/README.md new file mode 100644 index 000000000..1f157181a --- /dev/null +++ b/pkgs/test_analyzer_plugin/README.md @@ -0,0 +1,13 @@ +# test_analyzer_plugin + +This package is an analyzer plugin that provides additional static analysis for +usage of the test package. + +This analyzer plugin provides the following additional analysis: + +* Report a warning when a `test` or a `group` is declared inside a `test` + declaration. This can _sometimes_ be detected at runtime. This warning is + reported statically. + +* Offer a quick fix in the IDE for the above warning, which moves the violating + `test` or `group` declaration below the containing `test` declaration. \ No newline at end of file diff --git a/pkgs/test_analyzer_plugin/lib/main.dart b/pkgs/test_analyzer_plugin/lib/main.dart new file mode 100644 index 000000000..a7445cf0b --- /dev/null +++ b/pkgs/test_analyzer_plugin/lib/main.dart @@ -0,0 +1,20 @@ +// Copyright (c) 2025, 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. + +import 'package:analysis_server_plugin/plugin.dart'; +import 'package:analysis_server_plugin/registry.dart'; + +import 'src/fixes.dart'; +import 'src/rules.dart'; + +final plugin = TestPackagePlugin(); + +class TestPackagePlugin extends Plugin { + @override + void register(PluginRegistry registry) { + registry.registerWarningRule(TestInTestRule()); + registry.registerFixForRule( + TestInTestRule.code, MoveBelowEnclosingTestCall.new); + } +} diff --git a/pkgs/test_analyzer_plugin/lib/src/fixes.dart b/pkgs/test_analyzer_plugin/lib/src/fixes.dart new file mode 100644 index 000000000..98af4aa3e --- /dev/null +++ b/pkgs/test_analyzer_plugin/lib/src/fixes.dart @@ -0,0 +1,58 @@ +// Copyright (c) 2025, 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. + +import 'package:analysis_server_plugin/edit/dart/correction_producer.dart'; +import 'package:analysis_server_plugin/edit/dart/dart_fix_kind_priority.dart'; +import 'package:analyzer/dart/ast/ast.dart'; +import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart'; +import 'package:analyzer_plugin/utilities/fixes/fixes.dart'; +import 'package:analyzer_plugin/utilities/range_factory.dart'; + +import 'utilities.dart'; + +class MoveBelowEnclosingTestCall extends ResolvedCorrectionProducer { + static const _wrapInQuotesKind = FixKind( + 'dart.fix.moveBelowEnclosingTestCall', + DartFixKindPriority.standard, + "Move below the enclosing 'test' call"); + + MoveBelowEnclosingTestCall({required super.context}); + + @override + CorrectionApplicability get applicability => + // This fix may break code by moving references to variables away from the + // scope in which they are declared. + CorrectionApplicability.singleLocation; + + @override + FixKind get fixKind => _wrapInQuotesKind; + + @override + Future compute(ChangeBuilder builder) async { + var methodCall = node; + if (methodCall is! MethodInvocation) return; + AstNode? enclosingTestCall = findEnclosingTestCall(methodCall); + if (enclosingTestCall == null) return; + + if (enclosingTestCall.parent is ExpressionStatement) { + // Move the 'test' call to below the outer 'test' call _statement_. + enclosingTestCall = enclosingTestCall.parent!; + } + + if (methodCall.parent is ExpressionStatement) { + // Move the whole statement (don't leave the semicolon dangling). + methodCall = methodCall.parent!; + } + + await builder.addDartFileEdit(file, (builder) { + var indent = utils.getLinePrefix(enclosingTestCall!.offset); + var source = utils.getRangeText(range.node(methodCall)); + + // Move the source for `methodCall` wholsale to be just after `enclosingTestCall`. + builder.addDeletion(range.deletionRange(methodCall)); + builder.addSimpleInsertion( + enclosingTestCall.end, '$eol$eol$indent$source'); + }); + } +} diff --git a/pkgs/test_analyzer_plugin/lib/src/rules.dart b/pkgs/test_analyzer_plugin/lib/src/rules.dart new file mode 100644 index 000000000..bf4634ec0 --- /dev/null +++ b/pkgs/test_analyzer_plugin/lib/src/rules.dart @@ -0,0 +1,53 @@ +// Copyright (c) 2025, 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. + +import 'package:analyzer/dart/ast/ast.dart'; +import 'package:analyzer/dart/ast/visitor.dart'; +import 'package:analyzer/src/dart/error/lint_codes.dart'; +import 'package:analyzer/src/lint/linter.dart'; + +import 'utilities.dart'; + +class TestInTestRule extends AnalysisRule { + static const LintCode code = LintCode( + 'test_in_test', + "Do not declare a 'test' or a 'group' inside a 'test'", + correctionMessage: "Try moving 'test' or 'group' outside of 'test'", + ); + + TestInTestRule() + : super( + name: 'test_in_test', + description: + 'Tests and groups declared inside of a test are not properly ' + 'registered in the test framework.', + ); + + @override + LintCode get lintCode => code; + + @override + void registerNodeProcessors( + NodeLintRegistry registry, LinterContext context) { + var visitor = _Visitor(this); + registry.addMethodInvocation(this, visitor); + } +} + +class _Visitor extends SimpleAstVisitor { + final AnalysisRule rule; + + _Visitor(this.rule); + + @override + void visitMethodInvocation(MethodInvocation node) { + if (!node.methodName.isTest && !node.methodName.isGroup) { + return; + } + var enclosingTestCall = findEnclosingTestCall(node); + if (enclosingTestCall != null) { + rule.reportLint(node); + } + } +} diff --git a/pkgs/test_analyzer_plugin/lib/src/utilities.dart b/pkgs/test_analyzer_plugin/lib/src/utilities.dart new file mode 100644 index 000000000..0de22044c --- /dev/null +++ b/pkgs/test_analyzer_plugin/lib/src/utilities.dart @@ -0,0 +1,37 @@ +// Copyright (c) 2025, 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. + +import 'package:analyzer/dart/ast/ast.dart'; + +/// Finds an enclosing call to the 'test' function, if there is one. +MethodInvocation? findEnclosingTestCall(MethodInvocation node) { + var ancestor = node.parent?.thisOrAncestorOfType(); + while (ancestor != null) { + if (ancestor.methodName.isTest) { + return ancestor; + } + ancestor = ancestor.parent?.thisOrAncestorOfType(); + } + return null; +} + +extension SimpleIdentifierExtension on SimpleIdentifier { + /// Whether this identifier represents the 'test' function from the + /// 'test_core' package. + bool get isTest { + final element = this.element; + if (element == null) return false; + if (element.name3 != 'test') return false; + return element.library2?.uri.path.startsWith('test_core/') ?? false; + } + + /// Whether this identifier represents the 'group' function from the + /// 'test_core' package. + bool get isGroup { + final element = this.element; + if (element == null) return false; + if (element.name3 != 'group') return false; + return element.library2?.uri.path.startsWith('test_core/') ?? false; + } +} diff --git a/pkgs/test_analyzer_plugin/pubspec.yaml b/pkgs/test_analyzer_plugin/pubspec.yaml new file mode 100644 index 000000000..9a434a305 --- /dev/null +++ b/pkgs/test_analyzer_plugin/pubspec.yaml @@ -0,0 +1,12 @@ +name: test_analyzer_plugin +description: An analyzer plugin to report improper usage of the test package. +version: 1.0.0 +publish_to: none + +environment: + sdk: '>=3.6.0 <4.0.0' + +dependencies: + analysis_server_plugin: any + analyzer: ^7.2.0 + From 1b527ed3663d39fd1b06df8f32182ec4feda6619 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Tue, 4 Mar 2025 10:56:59 -0800 Subject: [PATCH 2/4] feedback --- pkgs/test_analyzer_plugin/lib/src/fixes.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_analyzer_plugin/lib/src/fixes.dart b/pkgs/test_analyzer_plugin/lib/src/fixes.dart index 98af4aa3e..87d35f55b 100644 --- a/pkgs/test_analyzer_plugin/lib/src/fixes.dart +++ b/pkgs/test_analyzer_plugin/lib/src/fixes.dart @@ -12,7 +12,7 @@ import 'package:analyzer_plugin/utilities/range_factory.dart'; import 'utilities.dart'; class MoveBelowEnclosingTestCall extends ResolvedCorrectionProducer { - static const _wrapInQuotesKind = FixKind( + static const _moveBelowEnclosingTestCallKind = FixKind( 'dart.fix.moveBelowEnclosingTestCall', DartFixKindPriority.standard, "Move below the enclosing 'test' call"); @@ -26,7 +26,7 @@ class MoveBelowEnclosingTestCall extends ResolvedCorrectionProducer { CorrectionApplicability.singleLocation; @override - FixKind get fixKind => _wrapInQuotesKind; + FixKind get fixKind => _moveBelowEnclosingTestCallKind; @override Future compute(ChangeBuilder builder) async { From 4b491b2f7d753d1fcbb06a22ebcaaa777795fa47 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Tue, 8 Jul 2025 12:13:24 -0700 Subject: [PATCH 3/4] Add another rule: non_nullable_is_not_null_rule --- pkgs/test_analyzer_plugin/lib/main.dart | 17 +++- .../rules/non_nullable_is_not_null_rule.dart | 81 ++++++++++++++++++ .../test_in_test_rule.dart} | 14 ++-- .../lib/src/utilities.dart | 31 ++++++- pkgs/test_analyzer_plugin/pubspec.yaml | 17 ++++ .../rules/non_nullable_is_not_null_test.dart | 84 +++++++++++++++++++ 6 files changed, 235 insertions(+), 9 deletions(-) create mode 100644 pkgs/test_analyzer_plugin/lib/src/rules/non_nullable_is_not_null_rule.dart rename pkgs/test_analyzer_plugin/lib/src/{rules.dart => rules/test_in_test_rule.dart} (76%) create mode 100644 pkgs/test_analyzer_plugin/test/rules/non_nullable_is_not_null_test.dart diff --git a/pkgs/test_analyzer_plugin/lib/main.dart b/pkgs/test_analyzer_plugin/lib/main.dart index a7445cf0b..952ea3575 100644 --- a/pkgs/test_analyzer_plugin/lib/main.dart +++ b/pkgs/test_analyzer_plugin/lib/main.dart @@ -6,7 +6,8 @@ import 'package:analysis_server_plugin/plugin.dart'; import 'package:analysis_server_plugin/registry.dart'; import 'src/fixes.dart'; -import 'src/rules.dart'; +import 'src/rules/non_nullable_is_not_null_rule.dart'; +import 'src/rules/test_in_test_rule.dart'; final plugin = TestPackagePlugin(); @@ -16,5 +17,19 @@ class TestPackagePlugin extends Plugin { registry.registerWarningRule(TestInTestRule()); registry.registerFixForRule( TestInTestRule.code, MoveBelowEnclosingTestCall.new); + + registry.registerWarningRule(NonNullableIsNotNullRule()); + // Should we register a fix for this rule? The only automatic fix I can + // think of would be to delete the entire statement: + // `expect(a, isNotNull);` or `expect(a, isNull);`. + + // TODO(srawlins): More rules to catch: + // * `expect(7, contains(6))` - should only use `hasLength` with `Iterable` + // or `String`. + // * `expect(7, hasLength(3))` - should only use `hasLength` with `Iterable` + // or `String`. + // * `expect([].isEmpty, isFalse)` - should use `isEmpty` matcher. + // * `expect([].isNotEmpty, isTrue)` - should use `isNotEmpty` matcher. + // * `expect([].contains(7), isFalse)` - should use `contains` matcher. } } diff --git a/pkgs/test_analyzer_plugin/lib/src/rules/non_nullable_is_not_null_rule.dart b/pkgs/test_analyzer_plugin/lib/src/rules/non_nullable_is_not_null_rule.dart new file mode 100644 index 000000000..ddd6d6a49 --- /dev/null +++ b/pkgs/test_analyzer_plugin/lib/src/rules/non_nullable_is_not_null_rule.dart @@ -0,0 +1,81 @@ +// Copyright (c) 2025, 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. + +import 'package:analyzer/analysis_rule/analysis_rule.dart'; +import 'package:analyzer/analysis_rule/rule_context.dart'; +import 'package:analyzer/analysis_rule/rule_visitor_registry.dart'; +import 'package:analyzer/dart/ast/ast.dart'; +import 'package:analyzer/dart/ast/visitor.dart'; +import 'package:analyzer/dart/element/type_system.dart'; +import 'package:analyzer/error/error.dart'; + +import '../utilities.dart'; + +// TODO(srawlins): Several others; use same name or just different codes? +// * `expect(null, isNotNull)` - always false +// * `expect(null, isNull)` - always true +// * `expect(7, isNull)` - always false +class NonNullableIsNotNullRule extends MultiAnalysisRule { + static const LintCode nonNullableIsNotNullCode = LintCode( + 'non_nullable_is_not_null', + 'Do not check whether a non-nullable value isNotNull', + correctionMessage: 'Try changing the expectation, or removing it', + ); + + static const LintCode nonNullableIsNullCode = LintCode( + 'non_nullable_is_null', + 'Do not check whether a non-nullable value isNull', + correctionMessage: 'Try changing the expectation, or removing it', + ); + + NonNullableIsNotNullRule() + : super( + name: 'non_nullable_is_not_null', + description: "Non-nullable values will always pass an 'isNotNull' " + "expectation and never pass an 'isNull' expectation.", + ); + + @override + List get diagnosticCodes => [nonNullableIsNotNullCode]; + + @override + void registerNodeProcessors( + RuleVisitorRegistry registry, RuleContext context) { + var visitor = _Visitor(this, context.typeSystem); + registry.addMethodInvocation(this, visitor); + } +} + +class _Visitor extends SimpleAstVisitor { + final MultiAnalysisRule rule; + + final TypeSystem typeSystem; + + _Visitor(this.rule, this.typeSystem); + + @override + void visitMethodInvocation(MethodInvocation node) { + if (!node.methodName.isExpect) { + return; + } + + if (node.argumentList.arguments + case [var actual, SimpleIdentifier matcher]) { + var actualType = actual.staticType; + if (actualType == null) return; + if (typeSystem.isNonNullable(actualType)) { + if (matcher.isNotNull) { + // The actual value will always match this matcher. + rule.reportAtNode(matcher, + diagnosticCode: + NonNullableIsNotNullRule.nonNullableIsNotNullCode); + } else if (matcher.isNull) { + // The actual value will never match this matcher. + rule.reportAtNode(matcher, + diagnosticCode: NonNullableIsNotNullRule.nonNullableIsNullCode); + } + } + } + } +} diff --git a/pkgs/test_analyzer_plugin/lib/src/rules.dart b/pkgs/test_analyzer_plugin/lib/src/rules/test_in_test_rule.dart similarity index 76% rename from pkgs/test_analyzer_plugin/lib/src/rules.dart rename to pkgs/test_analyzer_plugin/lib/src/rules/test_in_test_rule.dart index bf4634ec0..9c3ae89cf 100644 --- a/pkgs/test_analyzer_plugin/lib/src/rules.dart +++ b/pkgs/test_analyzer_plugin/lib/src/rules/test_in_test_rule.dart @@ -2,12 +2,14 @@ // 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. +import 'package:analyzer/analysis_rule/analysis_rule.dart'; +import 'package:analyzer/analysis_rule/rule_context.dart'; +import 'package:analyzer/analysis_rule/rule_visitor_registry.dart'; import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/ast/visitor.dart'; -import 'package:analyzer/src/dart/error/lint_codes.dart'; -import 'package:analyzer/src/lint/linter.dart'; +import 'package:analyzer/error/error.dart'; -import 'utilities.dart'; +import '../utilities.dart'; class TestInTestRule extends AnalysisRule { static const LintCode code = LintCode( @@ -25,11 +27,11 @@ class TestInTestRule extends AnalysisRule { ); @override - LintCode get lintCode => code; + LintCode get diagnosticCode => code; @override void registerNodeProcessors( - NodeLintRegistry registry, LinterContext context) { + RuleVisitorRegistry registry, RuleContext context) { var visitor = _Visitor(this); registry.addMethodInvocation(this, visitor); } @@ -47,7 +49,7 @@ class _Visitor extends SimpleAstVisitor { } var enclosingTestCall = findEnclosingTestCall(node); if (enclosingTestCall != null) { - rule.reportLint(node); + rule.reportAtNode(node); } } } diff --git a/pkgs/test_analyzer_plugin/lib/src/utilities.dart b/pkgs/test_analyzer_plugin/lib/src/utilities.dart index 0de22044c..5226a4949 100644 --- a/pkgs/test_analyzer_plugin/lib/src/utilities.dart +++ b/pkgs/test_analyzer_plugin/lib/src/utilities.dart @@ -23,7 +23,7 @@ extension SimpleIdentifierExtension on SimpleIdentifier { final element = this.element; if (element == null) return false; if (element.name3 != 'test') return false; - return element.library2?.uri.path.startsWith('test_core/') ?? false; + return element.library?.uri.path.startsWith('test_core/') ?? false; } /// Whether this identifier represents the 'group' function from the @@ -32,6 +32,33 @@ extension SimpleIdentifierExtension on SimpleIdentifier { final element = this.element; if (element == null) return false; if (element.name3 != 'group') return false; - return element.library2?.uri.path.startsWith('test_core/') ?? false; + return element.library?.uri.path.startsWith('test_core/') ?? false; + } + + /// Whether this identifier represents the 'expect' function from the + /// 'matcher' package. + bool get isExpect { + final element = this.element; + if (element == null) return false; + if (element.name3 != 'expect') return false; + return element.library?.uri.path.startsWith('matcher/') ?? false; + } + + /// Whether this identifier represents the 'isNotNull' constant from the + /// 'matcher' package. + bool get isNotNull { + final element = this.element; + if (element == null) return false; + if (element.name3 != 'isNotNull') return false; + return element.library?.uri.path.startsWith('matcher/') ?? false; + } + + /// Whether this identifier represents the 'isNull' constant from the + /// 'matcher' package. + bool get isNull { + final element = this.element; + if (element == null) return false; + if (element.name3 != 'isNull') return false; + return element.library?.uri.path.startsWith('matcher/') ?? false; } } diff --git a/pkgs/test_analyzer_plugin/pubspec.yaml b/pkgs/test_analyzer_plugin/pubspec.yaml index 9a434a305..69e1131bf 100644 --- a/pkgs/test_analyzer_plugin/pubspec.yaml +++ b/pkgs/test_analyzer_plugin/pubspec.yaml @@ -9,4 +9,21 @@ environment: dependencies: analysis_server_plugin: any analyzer: ^7.2.0 + analyzer_plugin: + analyzer_testing: +dev_dependencies: + test: any + test_reflective_loader: any + +dependency_overrides: + _fe_analyzer_shared: + path: /Users/srawlins/code/dart-sdk/sdk/pkg/_fe_analyzer_shared + analysis_server_plugin: + path: /Users/srawlins/code/dart-sdk/sdk/pkg/analysis_server_plugin + analyzer: + path: /Users/srawlins/code/dart-sdk/sdk/pkg/analyzer + analyzer_plugin: + path: /Users/srawlins/code/dart-sdk/sdk/pkg/analyzer_plugin + analyzer_testing: + path: /Users/srawlins/code/dart-sdk/sdk/pkg/analyzer_testing diff --git a/pkgs/test_analyzer_plugin/test/rules/non_nullable_is_not_null_test.dart b/pkgs/test_analyzer_plugin/test/rules/non_nullable_is_not_null_test.dart new file mode 100644 index 000000000..98828b171 --- /dev/null +++ b/pkgs/test_analyzer_plugin/test/rules/non_nullable_is_not_null_test.dart @@ -0,0 +1,84 @@ +// Copyright (c) 2023, 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: non_constant_identifier_names + +import 'package:analyzer/src/lint/registry.dart'; +import 'package:analyzer/utilities/package_config_file_builder.dart'; +import 'package:analyzer_testing/analysis_rule/analysis_rule.dart'; +import 'package:test_analyzer_plugin/src/rules/non_nullable_is_not_null_rule.dart'; +import 'package:test_reflective_loader/test_reflective_loader.dart'; + +void main() { + defineReflectiveSuite(() { + defineReflectiveTests(NonNullableIsNotNullTest); + }); +} + +@reflectiveTest +class NonNullableIsNotNullTest extends AnalysisRuleTest { + @override + void setUp() { + Registry.ruleRegistry.registerLintRule(NonNullableIsNotNullRule()); + + super.setUp(); + + var matcherPath = '/packages/matcher'; + newFile('$matcherPath/lib/matcher.dart', ''' +void expect(dynamic actual, dynamic matcher) {} + +const isNotNull = 0; +const isNull = 0; +'''); + writeTestPackageConfig( + PackageConfigFileBuilder() + ..add(name: 'matcher', rootPath: convertPath(matcherPath)), + ); + } + + @override + String get analysisRule => 'non_nullable_is_not_null'; + + void test_nullableValue_isNotNullMatcher() async { + await assertNoDiagnostics(r''' +import 'package:matcher/matcher.dart'; +void f(String? p) { + expect(p, isNotNull); +} +'''); + } + + void test_nonNullableValue_isNotNullMatcher() async { + await assertDiagnostics( + r''' +import 'package:matcher/matcher.dart'; +void f() { + expect(123, isNotNull); +} +''', + [lint(64, 9)], + ); + } + + void test_nullableValue_isNullMatcher() async { + await assertNoDiagnostics(r''' +import 'package:matcher/matcher.dart'; +void f(String? p) { + expect(p, isNull); +} +'''); + } + + void test_nonNullableValue_isNullMatcher() async { + await assertDiagnostics( + r''' +import 'package:matcher/matcher.dart'; +void f() { + expect(123, isNull); +} +''', + [lint(64, 6, name: 'non_nullable_is_null')], + ); + } +} From 20ca5de49beb08dedfb2db25b20c679a325391cd Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Fri, 15 Aug 2025 11:04:48 -0700 Subject: [PATCH 4/4] Bump to analysis_server_plugin 0.2.2 --- pkgs/test_analyzer_plugin/lib/src/fixes.dart | 2 +- .../lib/src/utilities.dart | 10 +++---- pkgs/test_analyzer_plugin/pubspec.yaml | 30 +++++++++---------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/pkgs/test_analyzer_plugin/lib/src/fixes.dart b/pkgs/test_analyzer_plugin/lib/src/fixes.dart index 87d35f55b..a470c6404 100644 --- a/pkgs/test_analyzer_plugin/lib/src/fixes.dart +++ b/pkgs/test_analyzer_plugin/lib/src/fixes.dart @@ -52,7 +52,7 @@ class MoveBelowEnclosingTestCall extends ResolvedCorrectionProducer { // Move the source for `methodCall` wholsale to be just after `enclosingTestCall`. builder.addDeletion(range.deletionRange(methodCall)); builder.addSimpleInsertion( - enclosingTestCall.end, '$eol$eol$indent$source'); + enclosingTestCall.end, '$defaultEol$defaultEol$indent$source'); }); } } diff --git a/pkgs/test_analyzer_plugin/lib/src/utilities.dart b/pkgs/test_analyzer_plugin/lib/src/utilities.dart index 5226a4949..3ff142b3d 100644 --- a/pkgs/test_analyzer_plugin/lib/src/utilities.dart +++ b/pkgs/test_analyzer_plugin/lib/src/utilities.dart @@ -22,7 +22,7 @@ extension SimpleIdentifierExtension on SimpleIdentifier { bool get isTest { final element = this.element; if (element == null) return false; - if (element.name3 != 'test') return false; + if (element.name != 'test') return false; return element.library?.uri.path.startsWith('test_core/') ?? false; } @@ -31,7 +31,7 @@ extension SimpleIdentifierExtension on SimpleIdentifier { bool get isGroup { final element = this.element; if (element == null) return false; - if (element.name3 != 'group') return false; + if (element.name != 'group') return false; return element.library?.uri.path.startsWith('test_core/') ?? false; } @@ -40,7 +40,7 @@ extension SimpleIdentifierExtension on SimpleIdentifier { bool get isExpect { final element = this.element; if (element == null) return false; - if (element.name3 != 'expect') return false; + if (element.name != 'expect') return false; return element.library?.uri.path.startsWith('matcher/') ?? false; } @@ -49,7 +49,7 @@ extension SimpleIdentifierExtension on SimpleIdentifier { bool get isNotNull { final element = this.element; if (element == null) return false; - if (element.name3 != 'isNotNull') return false; + if (element.name != 'isNotNull') return false; return element.library?.uri.path.startsWith('matcher/') ?? false; } @@ -58,7 +58,7 @@ extension SimpleIdentifierExtension on SimpleIdentifier { bool get isNull { final element = this.element; if (element == null) return false; - if (element.name3 != 'isNull') return false; + if (element.name != 'isNull') return false; return element.library?.uri.path.startsWith('matcher/') ?? false; } } diff --git a/pkgs/test_analyzer_plugin/pubspec.yaml b/pkgs/test_analyzer_plugin/pubspec.yaml index 69e1131bf..9c7051546 100644 --- a/pkgs/test_analyzer_plugin/pubspec.yaml +++ b/pkgs/test_analyzer_plugin/pubspec.yaml @@ -7,23 +7,23 @@ environment: sdk: '>=3.6.0 <4.0.0' dependencies: - analysis_server_plugin: any - analyzer: ^7.2.0 - analyzer_plugin: - analyzer_testing: + analysis_server_plugin: ^0.2.2 + analyzer: ^8.0.0 + analyzer_plugin: ^0.13.6 + analyzer_testing: ^0.1.2 dev_dependencies: test: any test_reflective_loader: any -dependency_overrides: - _fe_analyzer_shared: - path: /Users/srawlins/code/dart-sdk/sdk/pkg/_fe_analyzer_shared - analysis_server_plugin: - path: /Users/srawlins/code/dart-sdk/sdk/pkg/analysis_server_plugin - analyzer: - path: /Users/srawlins/code/dart-sdk/sdk/pkg/analyzer - analyzer_plugin: - path: /Users/srawlins/code/dart-sdk/sdk/pkg/analyzer_plugin - analyzer_testing: - path: /Users/srawlins/code/dart-sdk/sdk/pkg/analyzer_testing + #dependency_overrides: + # _fe_analyzer_shared: + # path: /Users/srawlins/code/dart-sdk/sdk/pkg/_fe_analyzer_shared + # analysis_server_plugin: + # path: /Users/srawlins/code/dart-sdk/sdk/pkg/analysis_server_plugin + # analyzer: + # path: /Users/srawlins/code/dart-sdk/sdk/pkg/analyzer + # analyzer_plugin: + # path: /Users/srawlins/code/dart-sdk/sdk/pkg/analyzer_plugin + # analyzer_testing: + # path: /Users/srawlins/code/dart-sdk/sdk/pkg/analyzer_testing