| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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 library analysis_server.edit.assist.assist_core; | 5 library analysis_server.edit.assist.assist_core; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol.dart' show SourceChange; | 7 import 'package:analysis_server/src/protocol.dart' show SourceChange; |
| 8 import 'package:analyzer/src/generated/engine.dart'; | 8 import 'package:analyzer/src/generated/engine.dart'; |
| 9 import 'package:analyzer/src/generated/source.dart'; | 9 import 'package:analyzer/src/generated/source.dart'; |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * A description of a single proposed assist. | 12 * A description of a single proposed assist. |
| 13 * |
| 14 * Clients are not expected to subtype this class. |
| 13 */ | 15 */ |
| 14 class Assist { | 16 class Assist { |
| 15 /** | 17 /** |
| 16 * An empty list of assists. | 18 * An empty list of assists. |
| 17 */ | 19 */ |
| 18 static const List<Assist> EMPTY_LIST = const <Assist>[]; | 20 static const List<Assist> EMPTY_LIST = const <Assist>[]; |
| 19 | 21 |
| 20 /** | 22 /** |
| 21 * A comparator that can be used to sort assists by their relevance. The most | 23 * A comparator that can be used to sort assists by their relevance. The most |
| 22 * relevant assists will be sorted before assists with a lower relevance. | 24 * relevant assists will be sorted before assists with a lower relevance. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 41 Assist(this.kind, this.change); | 43 Assist(this.kind, this.change); |
| 42 | 44 |
| 43 @override | 45 @override |
| 44 String toString() { | 46 String toString() { |
| 45 return 'Assist(kind=$kind, change=$change)'; | 47 return 'Assist(kind=$kind, change=$change)'; |
| 46 } | 48 } |
| 47 } | 49 } |
| 48 | 50 |
| 49 /** | 51 /** |
| 50 * An object used to produce assists for a specific location. | 52 * An object used to produce assists for a specific location. |
| 53 * |
| 54 * Clients are expected to subtype this class when implementing plugins. |
| 51 */ | 55 */ |
| 52 abstract class AssistContributor { | 56 abstract class AssistContributor { |
| 53 /** | 57 /** |
| 54 * Return a list of assists for a location in the given [source]. The location | 58 * Return a list of assists for a location in the given [source]. The location |
| 55 * is specified by the [offset] and [length] of the selected region. The | 59 * is specified by the [offset] and [length] of the selected region. The |
| 56 * [context] can be used to get additional information that is useful for | 60 * [context] can be used to get additional information that is useful for |
| 57 * computing assists. | 61 * computing assists. |
| 58 */ | 62 */ |
| 59 List<Assist> computeAssists( | 63 List<Assist> computeAssists( |
| 60 AnalysisContext context, Source source, int offset, int length); | 64 AnalysisContext context, Source source, int offset, int length); |
| 61 } | 65 } |
| 62 | 66 |
| 63 /** | 67 /** |
| 64 * A description of a class of assists. Instances are intended to hold the | 68 * A description of a class of assists. Instances are intended to hold the |
| 65 * information that is common across a number of assists and to be shared by | 69 * information that is common across a number of assists and to be shared by |
| 66 * those assists. | 70 * those assists. |
| 71 * |
| 72 * Clients are not expected to subtype this class. |
| 67 */ | 73 */ |
| 68 class AssistKind { | 74 class AssistKind { |
| 69 /** | 75 /** |
| 70 * The name of this kind of assist, used for debugging. | 76 * The name of this kind of assist, used for debugging. |
| 71 */ | 77 */ |
| 72 final String name; | 78 final String name; |
| 73 | 79 |
| 74 /** | 80 /** |
| 75 * The relevance of this kind of assist for the kind of error being addressed. | 81 * The relevance of this kind of assist for the kind of error being addressed. |
| 76 */ | 82 */ |
| 77 final int relevance; | 83 final int relevance; |
| 78 | 84 |
| 79 /** | 85 /** |
| 80 * A human-readable description of the changes that will be applied by this | 86 * A human-readable description of the changes that will be applied by this |
| 81 * kind of assist. | 87 * kind of assist. |
| 82 */ | 88 */ |
| 83 final String message; | 89 final String message; |
| 84 | 90 |
| 85 /** | 91 /** |
| 86 * Initialize a newly created kind of assist to have the given [name], | 92 * Initialize a newly created kind of assist to have the given [name], |
| 87 * [relevance] and [message]. | 93 * [relevance] and [message]. |
| 88 */ | 94 */ |
| 89 const AssistKind(this.name, this.relevance, this.message); | 95 const AssistKind(this.name, this.relevance, this.message); |
| 90 | 96 |
| 91 @override | 97 @override |
| 92 String toString() => name; | 98 String toString() => name; |
| 93 } | 99 } |
| OLD | NEW |