Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Commit

Permalink
Adjust lint reporting to use Token
Browse files Browse the repository at this point in the history
  • Loading branch information
eernstg committed Sep 14, 2023
1 parent 5fea1b8 commit b9933d8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/src/rules/avoid_unstable_final_fields.dart
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ abstract class _AbstractVisitor extends ThrowingAstVisitor<void> {
return false;
}

void doReportLint(ClassMember node, AstNode name) {
List<DiagnosticMessage> _computeContextMessages() {
var contextMessages = <DiagnosticMessage>[];
for (var cause in causes) {
var length = cause.nameLength;
Expand All @@ -193,14 +193,18 @@ abstract class _AbstractVisitor extends ThrowingAstVisitor<void> {
contextMessages.add(
DiagnosticMessageImpl(
filePath: cause.library.source.fullName,
message: "The declaration of '$name' that requires this "
message: 'The declaration that requires this '
'declaration to be stable is',
offset: offset,
length: length,
url: null),
);
}
rule.reportLint(name, contextMessages: contextMessages);
return contextMessages;
}

void doReportLint(Token? name) {
rule.reportLintForToken(name, contextMessages: _computeContextMessages());
}

// The following visitor methods will only be executed in the situation
Expand Down Expand Up @@ -638,7 +642,7 @@ class _FieldVisitor extends _AbstractVisitor {
libraryUri ??= declaredElement.library.source.uri;
name ??= Name(libraryUri, declaredElement.name);
if (_inheritsStability(interfaceElement, name)) {
doReportLint(node, variable.name);
doReportLint(variable.name2);
}
}
}
Expand All @@ -660,7 +664,7 @@ class _MethodVisitor extends _AbstractVisitor {
var name = Name(libraryUri, declaredElement.name);
if (!_inheritsStability(enclosingElement, name)) return;
node.body.accept(this);
if (!isStable) doReportLint(node, node.name);
if (!isStable) doReportLint(node.name2);
} else {
// Extensions cannot override anything.
}
Expand Down

0 comments on commit b9933d8

Please sign in to comment.