| 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.plugin.edit.utilities.change_builder_dart; | |
| 6 | |
| 7 import 'package:analysis_server/plugin/edit/utilities/change_builder_core.dart'; | |
| 8 import 'package:analysis_server/src/utilities/change_builder_dart.dart'; | |
| 9 import 'package:analyzer/src/generated/ast.dart'; | |
| 10 import 'package:analyzer/src/generated/element.dart'; | |
| 11 import 'package:analyzer/src/generated/engine.dart'; | |
| 12 | |
| 13 /** | |
| 14 * A [ChangeBuilder] used to build changes in Dart files. | |
| 15 * | |
| 16 * Clients may not extend, implement or mix-in this class. | |
| 17 */ | |
| 18 abstract class DartChangeBuilder extends ChangeBuilder { | |
| 19 /** | |
| 20 * Initialize a newly created change builder. | |
| 21 */ | |
| 22 factory DartChangeBuilder(AnalysisContext context) = DartChangeBuilderImpl; | |
| 23 } | |
| 24 | |
| 25 /** | |
| 26 * An [EditBuilder] used to build edits in Dart files. | |
| 27 * | |
| 28 * Clients may not extend, implement or mix-in this class. | |
| 29 */ | |
| 30 abstract class DartEditBuilder extends EditBuilder { | |
| 31 /** | |
| 32 * The group-id used for the name of a declaration. | |
| 33 */ | |
| 34 static const String NAME_GROUP_ID = 'NAME'; | |
| 35 | |
| 36 /** | |
| 37 * The group-id used for the return type of a function, getter or method. | |
| 38 */ | |
| 39 static const String RETURN_TYPE_GROUP_ID = 'RETURN_TYPE'; | |
| 40 | |
| 41 /** | |
| 42 * The group-id used for the name of the superclass in a class declaration. | |
| 43 */ | |
| 44 static const String SUPERCLASS_GROUP_ID = 'SUPERCLASS'; | |
| 45 | |
| 46 /** | |
| 47 * Write the code for a declaration of a class with the given [name]. If a | |
| 48 * list of [interfaces] is provided, then the class will implement those | |
| 49 * interfaces. If [isAbstract] is `true`, then the class will be abstract. If | |
| 50 * a [memberWriter] is provided, then it will be invoked to allow members to | |
| 51 * be generated. (The members will automatically be preceeded and followed by | |
| 52 * end-of-line markers.) If a list of [mixins] is provided, then the class | |
| 53 * will mix in those classes. If a [nameGroupName] is provided, then the name | |
| 54 * of the class will be included in the linked edit group with that name. If a | |
| 55 * [superclass] is given then it will be the superclass of the class. (If a | |
| 56 * list of [mixins] is provided but no [superclass] is given then the class | |
| 57 * will extend `Object`.) | |
| 58 */ | |
| 59 void writeClassDeclaration(String name, | |
| 60 {Iterable<DartType> interfaces, | |
| 61 bool isAbstract: false, | |
| 62 void memberWriter(), | |
| 63 Iterable<DartType> mixins, | |
| 64 String nameGroupName, | |
| 65 DartType superclass}); | |
| 66 | |
| 67 /** | |
| 68 * Write the code for a declaration of a field with the given [name]. If an | |
| 69 * [initializerWriter] is provided, it will be invoked to write the content of | |
| 70 * the initializer. (The equal sign separating the field name from the | |
| 71 * initializer expression will automatically be written.) If [isConst] is | |
| 72 * `true`, then the declaration will be preceeded by the `const` keyword. If | |
| 73 * [isFinal] is `true`, then the declaration will be preceeded by the `final` | |
| 74 * keyword. (If both [isConst] and [isFinal] are `true`, then only the `const` | |
| 75 * keyword will be written.) If [isStatic] is `true`, then the declaration | |
| 76 * will be preceeded by the `static` keyword. If a [nameGroupName] is | |
| 77 * provided, the name of the field will be included in the linked edit group | |
| 78 * with that name. If a [type] is provided, then it will be used as the type | |
| 79 * of the field. (The keyword `var` will be provided automatically when | |
| 80 * required.) If a [typeGroupName] is provided, then if a type was written | |
| 81 * it will be in the linked edit group with that name. | |
| 82 */ | |
| 83 void writeFieldDeclaration(String name, | |
| 84 {void initializerWriter(), | |
| 85 bool isConst: false, | |
| 86 bool isFinal: false, | |
| 87 bool isStatic: false, | |
| 88 String nameGroupName, | |
| 89 DartType type, | |
| 90 String typeGroupName}); | |
| 91 | |
| 92 /** | |
| 93 * Write the code for a declaration of a getter with the given [name]. If a | |
| 94 * [bodyWriter] is provided, it will be invoked to write the body of the | |
| 95 * getter. (The space between the name and the body will automatically be | |
| 96 * written.) If [isStatic] is `true`, then the declaration will be preceeded | |
| 97 * by the `static` keyword. If a [nameGroupName] is provided, the name of the | |
| 98 * getter will be included in the linked edit group with that name. If a | |
| 99 * [returnType] is provided, then it will be used as the return type of the | |
| 100 * getter. If a [returnTypeGroupName] is provided, then if a return type was | |
| 101 * written it will be in the linked edit group with that name. | |
| 102 */ | |
| 103 void writeGetterDeclaration(String name, | |
| 104 {void bodyWriter(), | |
| 105 bool isStatic: false, | |
| 106 String nameGroupName, | |
| 107 DartType returnType, | |
| 108 String returnTypeGroupName}); | |
| 109 | |
| 110 /** | |
| 111 * Append a placeholder for an override of the specified inherited [member]. | |
| 112 */ | |
| 113 void writeOverrideOfInheritedMember(ExecutableElement member); | |
| 114 | |
| 115 /** | |
| 116 * Write the code for a list of [parameters], including the surrounding | |
| 117 * parentheses. | |
| 118 */ | |
| 119 void writeParameters(Iterable<ParameterElement> parameters); | |
| 120 | |
| 121 /** | |
| 122 * Write the code for a list of parameters that would match the given list of | |
| 123 * [arguments], including the surrounding parentheses. | |
| 124 */ | |
| 125 void writeParametersMatchingArguments(ArgumentList arguments); | |
| 126 | |
| 127 /** | |
| 128 * Write the code for a single parameter with the given [type] and [name]. | |
| 129 * The [type] can be `null` if no type is to be specified for the parameter. | |
| 130 */ | |
| 131 void writeParameterSource(DartType type, String name); | |
| 132 | |
| 133 /** | |
| 134 * Write the code for a type annotation for the given [type]. If the [type] is | |
| 135 * either `null` or represents the type 'dynamic', then the behavior depends | |
| 136 * on whether a type is [required]. If [required] is `true`, then 'var' will | |
| 137 * be written; otherwise, nothing is written. | |
| 138 * | |
| 139 * If the [groupName] is not `null`, then the name of the type (including type | |
| 140 * parameters) will be included as a region in the linked edit group with that | |
| 141 * name. If the [groupName] is not `null` and [addSupertypeProposals] is | |
| 142 * `true`, then all of the supertypes of the [type] will be added as | |
| 143 * suggestions for alternatives to the type name. | |
| 144 */ | |
| 145 bool writeType(DartType type, | |
| 146 {bool addSupertypeProposals: false, | |
| 147 String groupName, | |
| 148 bool required: false}); | |
| 149 } | |
| 150 | |
| 151 /** | |
| 152 * A [FileEditBuilder] used to build edits for Dart files. | |
| 153 * | |
| 154 * Clients may not extend, implement or mix-in this class. | |
| 155 */ | |
| 156 abstract class DartFileEditBuilder extends FileEditBuilder {} | |
| OLD | NEW |