| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library analysis_server.edit.fix.fix_dart; |
| 6 |
| 7 import 'package:analysis_server/edit/fix/fix_core.dart'; |
| 8 import 'package:analyzer/src/generated/ast.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/error.dart'; |
| 11 import 'package:analyzer/src/generated/source.dart'; |
| 12 |
| 13 /** |
| 14 * A [FixContributor] that can be used to contribute fixes for errors in Dart |
| 15 * files. |
| 16 */ |
| 17 abstract class DartFixContributor extends FixContributor { |
| 18 @override |
| 19 List<Fix> computeFixes(AnalysisContext context, AnalysisError error) { |
| 20 Source source = error.source; |
| 21 if (!AnalysisEngine.isDartFileName(source.fullName)) { |
| 22 return Fix.EMPTY_LIST; |
| 23 } |
| 24 List<Source> libraries = context.getLibrariesContaining(source); |
| 25 if (libraries.isEmpty) { |
| 26 return Fix.EMPTY_LIST; |
| 27 } |
| 28 CompilationUnit unit = |
| 29 context.resolveCompilationUnit2(source, libraries[0]); |
| 30 if (unit == null) { |
| 31 return Fix.EMPTY_LIST; |
| 32 } |
| 33 return internalComputeFixes(unit, error); |
| 34 } |
| 35 |
| 36 /** |
| 37 * Return a list of fixes for the given [error]. The error was reported |
| 38 * against the given compilation [unit]. |
| 39 */ |
| 40 List<Fix> internalComputeFixes(CompilationUnit unit, AnalysisError error); |
| 41 } |
| OLD | NEW |