anchor.diff:  // 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 'dart:collection';
  +
   import 'package:analyzer/dart/ast/ast.dart';
   import 'package:analyzer/dart/ast/standard_resolution_map.dart';
   import 'package:analyzer/dart/ast/visitor.dart';
  +import 'package:analyzer/dart/element/element.dart';
   import 'package:linter/src/analyzer.dart';
   import 'package:linter/src/util/dart_type_utilities.dart';
   
  
positive.code: ```
  ''';
  
  bool _isMutated(
          VariableDeclaration variable, CompilationUnit compilationUnit) =>
      DartTypeUtilities
          .traverseNodesInDFS(compilationUnit)
          .any((n) =>
              (n is AssignmentExpression &&
                  DartTypeUtilities
                          .getCanonicalElementFromIdentifier(n.leftHandSide) ==
                      variable.element) ||
              (n is PrefixExpression &&
                  DartTypeUtilities
                          .getCanonicalElementFromIdentifier(n.operand) ==
                      variable.element) ||
              (n is PostfixExpression &&
                  DartTypeUtilities
                          .getCanonicalElementFromIdentifier(n.operand) ==
                      variable.element));
  
  class PreferFinalFields extends LintRule {
    _Visitor _visitor;
  
    PreferFinalFields()
        : super(
              name: 'prefer_final_fields',
              description: _desc,
              details: _details,
              group: Group.style) {
      _visitor = new _Visitor(this);
    }
  
    @override
    AstVisitor getVisitor() => _visitor;
  }
  
  class _Visitor extends SimpleAstVisitor {
    final LintRule rule;
    _Visitor(this.rule);
  
    @override
    void visitFieldDeclaration(FieldDeclaration node) {
      final fields = node.fields;
      if (fields.isFinal || fields.isConst) {
        return;
      }
  
      CompilationUnit compilationUnit =
          node.getAncestor((a) => a is CompilationUnit);
      if (compilationUnit == null) {
        return;
      }
  
  
negative.code:         return;
        }
  
        if (_isMutated(variable)) {
          return;
        }
  
        rule.reportLint(variable);
      });
    }
  
    bool _isMutated(VariableDeclaration variable) =>
        _mutatedElements.contains(variable.element);
  }
  