OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'package:analyzer/dart/analysis/results.dart'; | 5 import 'package:analyzer/dart/analysis/results.dart'; |
6 import 'package:analyzer/error/error.dart'; | 6 import 'package:analyzer/error/error.dart'; |
7 import 'package:analyzer/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
8 import 'package:analyzer_plugin/protocol/protocol.dart'; | 8 import 'package:analyzer_plugin/protocol/protocol.dart'; |
9 import 'package:analyzer_plugin/protocol/protocol_generated.dart'; | 9 import 'package:analyzer_plugin/protocol/protocol_generated.dart'; |
10 import 'package:analyzer_plugin/src/utilities/fixes/fixes.dart'; | 10 import 'package:analyzer_plugin/src/utilities/fixes/fixes.dart'; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 } catch (exception, stackTrace) { | 101 } catch (exception, stackTrace) { |
102 notifications.add(new PluginErrorParams( | 102 notifications.add(new PluginErrorParams( |
103 false, exception.toString(), stackTrace.toString()) | 103 false, exception.toString(), stackTrace.toString()) |
104 .toNotification()); | 104 .toNotification()); |
105 } | 105 } |
106 } | 106 } |
107 EditGetFixesResult result = new EditGetFixesResult(collector.fixes); | 107 EditGetFixesResult result = new EditGetFixesResult(collector.fixes); |
108 return new GeneratorResult(result, notifications); | 108 return new GeneratorResult(result, notifications); |
109 } | 109 } |
110 } | 110 } |
| 111 |
| 112 /** |
| 113 * A description of a class of fixes. Instances are intended to hold the |
| 114 * information that is common across a number of fixes and to be shared by those |
| 115 * fixes. For example, if an unnecessary cast is found then one of the suggested |
| 116 * fixes will be to remove the cast. If there are multiple unnecessary casts in |
| 117 * a single file, then there will be multiple fixes, one per occurrence, but |
| 118 * they will all share the same kind. |
| 119 * |
| 120 * Clients may not extend, implement or mix-in this class. |
| 121 */ |
| 122 class FixKind { |
| 123 /** |
| 124 * The name of this kind of fix, used for debugging. |
| 125 */ |
| 126 final String name; |
| 127 |
| 128 /** |
| 129 * The priority of this kind of fix for the kind of error being addressed. |
| 130 */ |
| 131 final int priority; |
| 132 |
| 133 /** |
| 134 * A human-readable description of the changes that will be applied by this |
| 135 * kind of fix. The message can contain parameters, where each parameter is |
| 136 * represented by a zero-based index inside curly braces. For example, the |
| 137 * message `"Create a component named '{0}' in '{1}'"` contains two parameters
. |
| 138 */ |
| 139 final String message; |
| 140 |
| 141 /** |
| 142 * Initialize a newly created kind of fix to have the given [name], |
| 143 * [priority] and [message]. |
| 144 */ |
| 145 const FixKind(this.name, this.priority, this.message); |
| 146 |
| 147 @override |
| 148 String toString() => name; |
| 149 } |
OLD | NEW |