From a4dcd25e220d2afe28abf4306aa92d3e11fa7cc7 Mon Sep 17 00:00:00 2001 From: pq Date: Mon, 30 Sep 2024 21:01:54 +0000 Subject: [PATCH] [element model] migrate `valid_regexps` Bug: https://github.com/dart-lang/linter/issues/5099 Change-Id: I447de40607f9ef4fd49b80c406b75285b28839f2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387604 Commit-Queue: Phil Quitslund Reviewed-by: Brian Wilkerson --- pkg/linter/lib/src/rules/valid_regexps.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/linter/lib/src/rules/valid_regexps.dart b/pkg/linter/lib/src/rules/valid_regexps.dart index ace886c63dbd..0366cdfd45a3 100644 --- a/pkg/linter/lib/src/rules/valid_regexps.dart +++ b/pkg/linter/lib/src/rules/valid_regexps.dart @@ -35,12 +35,12 @@ class _Visitor extends SimpleAstVisitor { @override void visitInstanceCreationExpression(InstanceCreationExpression node) { - var element = node.constructorName.staticElement?.enclosingElement3; - if (element?.name == 'RegExp' && element?.library.name == 'dart.core') { + var element = node.constructorName.element?.enclosingElement2; + if (element == null) return; + + if (element.name == 'RegExp' && (element.library2?.isDartCore ?? false)) { var args = node.argumentList.arguments; - if (args.isEmpty) { - return; - } + if (args.isEmpty) return; bool isTrue(Expression e) => e is BooleanLiteral && e.value;