Skip to content

Commit e27cf7f

Browse files
pqCommit Queue
authored andcommitted
[element model] migrate use_full_hex_values_for_flutter_colors
Bug: https://github.com/dart-lang/linter/issues/5099 Change-Id: I1d1b29f36f56663ee06c1dffee78ac07bc0cd8e1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390302 Auto-Submit: Phil Quitslund <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]>
1 parent 0d470ac commit e27cf7f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

pkg/linter/lib/src/extensions.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,19 @@ extension ConstructorElementExtension on ConstructorElement {
277277
name == constructorName;
278278
}
279279

280+
extension ConstructorElementExtension2 on ConstructorElement2 {
281+
/// Returns whether `this` is the same element as the [className] constructor
282+
/// named [constructorName] declared in [uri].
283+
bool isSameAs({
284+
required String uri,
285+
required String className,
286+
required String constructorName,
287+
}) =>
288+
library2?.name == uri &&
289+
enclosingElement2.name == className &&
290+
name == constructorName;
291+
}
292+
280293
extension DartTypeExtension on DartType? {
281294
bool extendsClass(String? className, String library) {
282295
var self = this;

pkg/linter/lib/src/rules/use_full_hex_values_for_flutter_colors.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class _Visitor extends SimpleAstVisitor<void> {
4040

4141
@override
4242
void visitInstanceCreationExpression(InstanceCreationExpression node) {
43-
var element = node.constructorName.staticElement;
43+
var element = node.constructorName.element;
4444
if (element != null &&
4545
element.isSameAs(
4646
uri: 'dart.ui', className: 'Color', constructorName: '')) {

0 commit comments

Comments
 (0)