| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to | |
| 6 // significant change. Please see the README file for more information. | |
| 7 | |
| 8 library services.proposal; | |
| 9 | |
| 10 import 'package:analyzer/src/generated/java_core.dart'; | |
| 11 import 'package:analyzer/src/generated/java_io.dart'; | |
| 12 import 'package:analyzer/src/generated/source.dart'; | |
| 13 import 'change.dart'; | |
| 14 | |
| 15 /** | |
| 16 * [CorrectionProposal] for adding new dependency into pubspec. | |
| 17 */ | |
| 18 class AddDependencyCorrectionProposal extends CorrectionProposal { | |
| 19 final JavaFile file; | |
| 20 | |
| 21 final String packageName; | |
| 22 | |
| 23 AddDependencyCorrectionProposal(this.file, this.packageName, CorrectionKind ki
nd, List<Object> arguments) : super(kind, arguments); | |
| 24 } | |
| 25 | |
| 26 /** | |
| 27 * [CorrectionProposal] with some [Change]. | |
| 28 */ | |
| 29 class ChangeCorrectionProposal extends CorrectionProposal { | |
| 30 final Change change; | |
| 31 | |
| 32 ChangeCorrectionProposal(this.change, CorrectionKind kind, List<Object> argume
nts) : super(kind, arguments); | |
| 33 } | |
| 34 | |
| 35 /** | |
| 36 * Enumeration of images used by correction processors. | |
| 37 */ | |
| 38 class CorrectionImage extends Enum<CorrectionImage> { | |
| 39 static const CorrectionImage IMG_CORRECTION_CHANGE = const CorrectionImage('IM
G_CORRECTION_CHANGE', 0); | |
| 40 | |
| 41 static const CorrectionImage IMG_CORRECTION_CLASS = const CorrectionImage('IMG
_CORRECTION_CLASS', 1); | |
| 42 | |
| 43 static const List<CorrectionImage> values = const [IMG_CORRECTION_CHANGE, IMG_
CORRECTION_CLASS]; | |
| 44 | |
| 45 const CorrectionImage(String name, int ordinal) : super(name, ordinal); | |
| 46 } | |
| 47 | |
| 48 /** | |
| 49 * Identifier of [CorrectionProposal]. | |
| 50 */ | |
| 51 class CorrectionKind extends Enum<CorrectionKind> { | |
| 52 static const CorrectionKind QA_ADD_PART_DIRECTIVE = const CorrectionKind.con1(
'QA_ADD_PART_DIRECTIVE', 0, 30, "Add 'part' directive"); | |
| 53 | |
| 54 static const CorrectionKind QA_ADD_TYPE_ANNOTATION = const CorrectionKind.con1
('QA_ADD_TYPE_ANNOTATION', 1, 30, "Add type annotation"); | |
| 55 | |
| 56 static const CorrectionKind QA_ASSIGN_TO_LOCAL_VARIABLE = const CorrectionKind
.con1('QA_ASSIGN_TO_LOCAL_VARIABLE', 2, 30, "Assign value to new local variable"
); | |
| 57 | |
| 58 static const CorrectionKind QA_CONVERT_INTO_BLOCK_BODY = const CorrectionKind.
con1('QA_CONVERT_INTO_BLOCK_BODY', 3, 30, "Convert into block body"); | |
| 59 | |
| 60 static const CorrectionKind QA_CONVERT_INTO_EXPRESSION_BODY = const Correction
Kind.con1('QA_CONVERT_INTO_EXPRESSION_BODY', 4, 30, "Convert into expression bod
y"); | |
| 61 | |
| 62 static const CorrectionKind QA_CONVERT_INTO_IS_NOT = const CorrectionKind.con1
('QA_CONVERT_INTO_IS_NOT', 5, 30, "Convert into is!"); | |
| 63 | |
| 64 static const CorrectionKind QA_CONVERT_INTO_IS_NOT_EMPTY = const CorrectionKin
d.con1('QA_CONVERT_INTO_IS_NOT_EMPTY', 6, 30, "Convert into 'isNotEmpty'"); | |
| 65 | |
| 66 static const CorrectionKind QA_EXCHANGE_OPERANDS = const CorrectionKind.con1('
QA_EXCHANGE_OPERANDS', 7, 30, "Exchange operands"); | |
| 67 | |
| 68 static const CorrectionKind QA_EXTRACT_CLASS = const CorrectionKind.con1('QA_E
XTRACT_CLASS', 8, 30, "Extract class into file '%s'"); | |
| 69 | |
| 70 static const CorrectionKind QA_IMPORT_ADD_SHOW = const CorrectionKind.con1('QA
_IMPORT_ADD_SHOW', 9, 30, "Add explicit 'show' combinator"); | |
| 71 | |
| 72 static const CorrectionKind QA_INVERT_IF_STATEMENT = const CorrectionKind.con1
('QA_INVERT_IF_STATEMENT', 10, 30, "Invert 'if' statement"); | |
| 73 | |
| 74 static const CorrectionKind QA_JOIN_IF_WITH_INNER = const CorrectionKind.con1(
'QA_JOIN_IF_WITH_INNER', 11, 30, "Join 'if' statement with inner 'if' statement"
); | |
| 75 | |
| 76 static const CorrectionKind QA_JOIN_IF_WITH_OUTER = const CorrectionKind.con1(
'QA_JOIN_IF_WITH_OUTER', 12, 30, "Join 'if' statement with outer 'if' statement"
); | |
| 77 | |
| 78 static const CorrectionKind QA_JOIN_VARIABLE_DECLARATION = const CorrectionKin
d.con1('QA_JOIN_VARIABLE_DECLARATION', 13, 30, "Join variable declaration"); | |
| 79 | |
| 80 static const CorrectionKind QA_REMOVE_TYPE_ANNOTATION = const CorrectionKind.c
on1('QA_REMOVE_TYPE_ANNOTATION', 14, 29, "Remove type annotation"); | |
| 81 | |
| 82 static const CorrectionKind QA_REPLACE_CONDITIONAL_WITH_IF_ELSE = const Correc
tionKind.con1('QA_REPLACE_CONDITIONAL_WITH_IF_ELSE', 15, 30, "Replace conditiona
l with 'if-else'"); | |
| 83 | |
| 84 static const CorrectionKind QA_REPLACE_IF_ELSE_WITH_CONDITIONAL = const Correc
tionKind.con1('QA_REPLACE_IF_ELSE_WITH_CONDITIONAL', 16, 30, "Replace 'if-else'
with conditional ('c ? x : y')"); | |
| 85 | |
| 86 static const CorrectionKind QA_SPLIT_AND_CONDITION = const CorrectionKind.con1
('QA_SPLIT_AND_CONDITION', 17, 30, "Split && condition"); | |
| 87 | |
| 88 static const CorrectionKind QA_SPLIT_VARIABLE_DECLARATION = const CorrectionKi
nd.con1('QA_SPLIT_VARIABLE_DECLARATION', 18, 30, "Split variable declaration"); | |
| 89 | |
| 90 static const CorrectionKind QA_SURROUND_WITH_BLOCK = const CorrectionKind.con1
('QA_SURROUND_WITH_BLOCK', 19, 30, "Surround with block"); | |
| 91 | |
| 92 static const CorrectionKind QA_SURROUND_WITH_DO_WHILE = const CorrectionKind.c
on1('QA_SURROUND_WITH_DO_WHILE', 20, 30, "Surround with 'do-while'"); | |
| 93 | |
| 94 static const CorrectionKind QA_SURROUND_WITH_FOR = const CorrectionKind.con1('
QA_SURROUND_WITH_FOR', 21, 30, "Surround with 'for'"); | |
| 95 | |
| 96 static const CorrectionKind QA_SURROUND_WITH_FOR_IN = const CorrectionKind.con
1('QA_SURROUND_WITH_FOR_IN', 22, 30, "Surround with 'for-in'"); | |
| 97 | |
| 98 static const CorrectionKind QA_SURROUND_WITH_IF = const CorrectionKind.con1('Q
A_SURROUND_WITH_IF', 23, 30, "Surround with 'if'"); | |
| 99 | |
| 100 static const CorrectionKind QA_SURROUND_WITH_TRY_CATCH = const CorrectionKind.
con1('QA_SURROUND_WITH_TRY_CATCH', 24, 30, "Surround with 'try-catch'"); | |
| 101 | |
| 102 static const CorrectionKind QA_SURROUND_WITH_TRY_FINALLY = const CorrectionKin
d.con1('QA_SURROUND_WITH_TRY_FINALLY', 25, 30, "Surround with 'try-finally'"); | |
| 103 | |
| 104 static const CorrectionKind QA_SURROUND_WITH_WHILE = const CorrectionKind.con1
('QA_SURROUND_WITH_WHILE', 26, 30, "Surround with 'while'"); | |
| 105 | |
| 106 static const CorrectionKind QF_ADD_PACKAGE_DEPENDENCY = const CorrectionKind.c
on1('QF_ADD_PACKAGE_DEPENDENCY', 27, 50, "Add dependency on package '%s'"); | |
| 107 | |
| 108 static const CorrectionKind QF_ADD_SUPER_CONSTRUCTOR_INVOCATION = const Correc
tionKind.con1('QF_ADD_SUPER_CONSTRUCTOR_INVOCATION', 28, 50, "Add super construc
tor %s invocation"); | |
| 109 | |
| 110 static const CorrectionKind QF_CHANGE_TO = const CorrectionKind.con1('QF_CHANG
E_TO', 29, 51, "Change to '%s'"); | |
| 111 | |
| 112 static const CorrectionKind QF_CHANGE_TO_STATIC_ACCESS = const CorrectionKind.
con1('QF_CHANGE_TO_STATIC_ACCESS', 30, 50, "Change access to static using '%s'")
; | |
| 113 | |
| 114 static const CorrectionKind QF_CREATE_CLASS = const CorrectionKind.con2('QF_CR
EATE_CLASS', 31, 50, "Create class '%s'", CorrectionImage.IMG_CORRECTION_CLASS); | |
| 115 | |
| 116 static const CorrectionKind QF_CREATE_CONSTRUCTOR = const CorrectionKind.con1(
'QF_CREATE_CONSTRUCTOR', 32, 50, "Create constructor '%s'"); | |
| 117 | |
| 118 static const CorrectionKind QF_CREATE_CONSTRUCTOR_SUPER = const CorrectionKind
.con1('QF_CREATE_CONSTRUCTOR_SUPER', 33, 50, "Create constructor to call %s"); | |
| 119 | |
| 120 static const CorrectionKind QF_CREATE_FUNCTION = const CorrectionKind.con1('QF
_CREATE_FUNCTION', 34, 49, "Create function '%s'"); | |
| 121 | |
| 122 static const CorrectionKind QF_CREATE_METHOD = const CorrectionKind.con1('QF_C
REATE_METHOD', 35, 50, "Create method '%s'"); | |
| 123 | |
| 124 static const CorrectionKind QF_CREATE_MISSING_OVERRIDES = const CorrectionKind
.con1('QF_CREATE_MISSING_OVERRIDES', 36, 50, "Create %d missing override(s)"); | |
| 125 | |
| 126 static const CorrectionKind QF_CREATE_NO_SUCH_METHOD = const CorrectionKind.co
n1('QF_CREATE_NO_SUCH_METHOD', 37, 49, "Create 'noSuchMethod' method"); | |
| 127 | |
| 128 static const CorrectionKind QF_CREATE_PART = const CorrectionKind.con1('QF_CRE
ATE_PART', 38, 50, "Create part '%s'"); | |
| 129 | |
| 130 static const CorrectionKind QF_IMPORT_LIBRARY_PREFIX = const CorrectionKind.co
n1('QF_IMPORT_LIBRARY_PREFIX', 39, 51, "Use imported library '%s' with prefix '%
s'"); | |
| 131 | |
| 132 static const CorrectionKind QF_IMPORT_LIBRARY_PROJECT = const CorrectionKind.c
on1('QF_IMPORT_LIBRARY_PROJECT', 40, 51, "Import library '%s'"); | |
| 133 | |
| 134 static const CorrectionKind QF_IMPORT_LIBRARY_SDK = const CorrectionKind.con1(
'QF_IMPORT_LIBRARY_SDK', 41, 51, "Import library '%s'"); | |
| 135 | |
| 136 static const CorrectionKind QF_IMPORT_LIBRARY_SHOW = const CorrectionKind.con1
('QF_IMPORT_LIBRARY_SHOW', 42, 51, "Update library '%s' import"); | |
| 137 | |
| 138 static const CorrectionKind QF_INSERT_SEMICOLON = const CorrectionKind.con1('Q
F_INSERT_SEMICOLON', 43, 50, "Insert ';'"); | |
| 139 | |
| 140 static const CorrectionKind QF_MAKE_CLASS_ABSTRACT = const CorrectionKind.con1
('QF_MAKE_CLASS_ABSTRACT', 44, 50, "Make class '%s' abstract"); | |
| 141 | |
| 142 static const CorrectionKind QF_REMOVE_PARAMETERS_IN_GETTER_DECLARATION = const
CorrectionKind.con1('QF_REMOVE_PARAMETERS_IN_GETTER_DECLARATION', 45, 50, "Remo
ve parameters in getter declaration"); | |
| 143 | |
| 144 static const CorrectionKind QF_REMOVE_PARENTHESIS_IN_GETTER_INVOCATION = const
CorrectionKind.con1('QF_REMOVE_PARENTHESIS_IN_GETTER_INVOCATION', 46, 50, "Remo
ve parentheses in getter invocation"); | |
| 145 | |
| 146 static const CorrectionKind QF_REMOVE_UNNECASSARY_CAST = const CorrectionKind.
con1('QF_REMOVE_UNNECASSARY_CAST', 47, 50, "Remove unnecessary cast"); | |
| 147 | |
| 148 static const CorrectionKind QF_REMOVE_UNUSED_IMPORT = const CorrectionKind.con
1('QF_REMOVE_UNUSED_IMPORT', 48, 50, "Remove unused import"); | |
| 149 | |
| 150 static const CorrectionKind QF_REPLACE_BOOLEAN_WITH_BOOL = const CorrectionKin
d.con1('QF_REPLACE_BOOLEAN_WITH_BOOL', 49, 50, "Replace 'boolean' with 'bool'"); | |
| 151 | |
| 152 static const CorrectionKind QF_USE_CONST = const CorrectionKind.con1('QF_USE_C
ONST', 50, 50, "Change to constant"); | |
| 153 | |
| 154 static const CorrectionKind QF_USE_EFFECTIVE_INTEGER_DIVISION = const Correcti
onKind.con1('QF_USE_EFFECTIVE_INTEGER_DIVISION', 51, 50, "Use effective integer
division ~/"); | |
| 155 | |
| 156 static const CorrectionKind QF_USE_EQ_EQ_NULL = const CorrectionKind.con1('QF_
USE_EQ_EQ_NULL', 52, 50, "Use == null instead of 'is Null'"); | |
| 157 | |
| 158 static const CorrectionKind QF_USE_NOT_EQ_NULL = const CorrectionKind.con1('QF
_USE_NOT_EQ_NULL', 53, 50, "Use != null instead of 'is! Null'"); | |
| 159 | |
| 160 static const List<CorrectionKind> values = const [ | |
| 161 QA_ADD_PART_DIRECTIVE, | |
| 162 QA_ADD_TYPE_ANNOTATION, | |
| 163 QA_ASSIGN_TO_LOCAL_VARIABLE, | |
| 164 QA_CONVERT_INTO_BLOCK_BODY, | |
| 165 QA_CONVERT_INTO_EXPRESSION_BODY, | |
| 166 QA_CONVERT_INTO_IS_NOT, | |
| 167 QA_CONVERT_INTO_IS_NOT_EMPTY, | |
| 168 QA_EXCHANGE_OPERANDS, | |
| 169 QA_EXTRACT_CLASS, | |
| 170 QA_IMPORT_ADD_SHOW, | |
| 171 QA_INVERT_IF_STATEMENT, | |
| 172 QA_JOIN_IF_WITH_INNER, | |
| 173 QA_JOIN_IF_WITH_OUTER, | |
| 174 QA_JOIN_VARIABLE_DECLARATION, | |
| 175 QA_REMOVE_TYPE_ANNOTATION, | |
| 176 QA_REPLACE_CONDITIONAL_WITH_IF_ELSE, | |
| 177 QA_REPLACE_IF_ELSE_WITH_CONDITIONAL, | |
| 178 QA_SPLIT_AND_CONDITION, | |
| 179 QA_SPLIT_VARIABLE_DECLARATION, | |
| 180 QA_SURROUND_WITH_BLOCK, | |
| 181 QA_SURROUND_WITH_DO_WHILE, | |
| 182 QA_SURROUND_WITH_FOR, | |
| 183 QA_SURROUND_WITH_FOR_IN, | |
| 184 QA_SURROUND_WITH_IF, | |
| 185 QA_SURROUND_WITH_TRY_CATCH, | |
| 186 QA_SURROUND_WITH_TRY_FINALLY, | |
| 187 QA_SURROUND_WITH_WHILE, | |
| 188 QF_ADD_PACKAGE_DEPENDENCY, | |
| 189 QF_ADD_SUPER_CONSTRUCTOR_INVOCATION, | |
| 190 QF_CHANGE_TO, | |
| 191 QF_CHANGE_TO_STATIC_ACCESS, | |
| 192 QF_CREATE_CLASS, | |
| 193 QF_CREATE_CONSTRUCTOR, | |
| 194 QF_CREATE_CONSTRUCTOR_SUPER, | |
| 195 QF_CREATE_FUNCTION, | |
| 196 QF_CREATE_METHOD, | |
| 197 QF_CREATE_MISSING_OVERRIDES, | |
| 198 QF_CREATE_NO_SUCH_METHOD, | |
| 199 QF_CREATE_PART, | |
| 200 QF_IMPORT_LIBRARY_PREFIX, | |
| 201 QF_IMPORT_LIBRARY_PROJECT, | |
| 202 QF_IMPORT_LIBRARY_SDK, | |
| 203 QF_IMPORT_LIBRARY_SHOW, | |
| 204 QF_INSERT_SEMICOLON, | |
| 205 QF_MAKE_CLASS_ABSTRACT, | |
| 206 QF_REMOVE_PARAMETERS_IN_GETTER_DECLARATION, | |
| 207 QF_REMOVE_PARENTHESIS_IN_GETTER_INVOCATION, | |
| 208 QF_REMOVE_UNNECASSARY_CAST, | |
| 209 QF_REMOVE_UNUSED_IMPORT, | |
| 210 QF_REPLACE_BOOLEAN_WITH_BOOL, | |
| 211 QF_USE_CONST, | |
| 212 QF_USE_EFFECTIVE_INTEGER_DIVISION, | |
| 213 QF_USE_EQ_EQ_NULL, | |
| 214 QF_USE_NOT_EQ_NULL]; | |
| 215 | |
| 216 final int relevance; | |
| 217 | |
| 218 final String message; | |
| 219 | |
| 220 final CorrectionImage image; | |
| 221 | |
| 222 const CorrectionKind.con1(String name, int ordinal, int relevance, String mess
age) : this.con2(name, ordinal, relevance, message, CorrectionImage.IMG_CORRECTI
ON_CHANGE); | |
| 223 | |
| 224 const CorrectionKind.con2(String name, int ordinal, this.relevance, this.messa
ge, this.image) : super(name, ordinal); | |
| 225 } | |
| 226 | |
| 227 /** | |
| 228 * Proposal for some change. | |
| 229 */ | |
| 230 class CorrectionProposal { | |
| 231 /** | |
| 232 * An empty array of [CorrectionProposal]s. | |
| 233 */ | |
| 234 static List<CorrectionProposal> EMPTY_ARRAY = new List<CorrectionProposal>(0); | |
| 235 | |
| 236 final CorrectionKind kind; | |
| 237 | |
| 238 String _name; | |
| 239 | |
| 240 CorrectionProposal(this.kind, List<Object> arguments) { | |
| 241 this._name = formatList(kind.message, arguments); | |
| 242 } | |
| 243 | |
| 244 /** | |
| 245 * @return the name to display for user. | |
| 246 */ | |
| 247 String get name => _name; | |
| 248 } | |
| 249 | |
| 250 /** | |
| 251 * [CorrectionProposal] to create new file. | |
| 252 */ | |
| 253 class CreateFileCorrectionProposal extends CorrectionProposal { | |
| 254 final JavaFile file; | |
| 255 | |
| 256 final String content; | |
| 257 | |
| 258 CreateFileCorrectionProposal(this.file, this.content, CorrectionKind kind, Lis
t<Object> arguments) : super(kind, arguments); | |
| 259 } | |
| 260 | |
| 261 /** | |
| 262 * Proposal for linked position. | |
| 263 */ | |
| 264 class LinkedPositionProposal { | |
| 265 final CorrectionImage icon; | |
| 266 | |
| 267 final String text; | |
| 268 | |
| 269 LinkedPositionProposal(this.icon, this.text); | |
| 270 } | |
| 271 | |
| 272 /** | |
| 273 * [CorrectionProposal] with single [Source] change. | |
| 274 */ | |
| 275 class SourceCorrectionProposal extends CorrectionProposal { | |
| 276 final SourceChange change; | |
| 277 | |
| 278 Map<String, List<SourceRange>> _linkedPositions = {}; | |
| 279 | |
| 280 Map<String, List<LinkedPositionProposal>> _linkedPositionProposals = {}; | |
| 281 | |
| 282 SourceRange endRange; | |
| 283 | |
| 284 SourceCorrectionProposal(this.change, CorrectionKind kind, List<Object> argume
nts) : super(kind, arguments); | |
| 285 | |
| 286 /** | |
| 287 * @return the [Map] or position IDs to their proposals. | |
| 288 */ | |
| 289 Map<String, List<LinkedPositionProposal>> get linkedPositionProposals => _link
edPositionProposals; | |
| 290 | |
| 291 /** | |
| 292 * @return the [Map] of position IDs to their locations. | |
| 293 */ | |
| 294 Map<String, List<SourceRange>> get linkedPositions => _linkedPositions; | |
| 295 | |
| 296 /** | |
| 297 * Sets [Map] of position IDs to their proposals. | |
| 298 */ | |
| 299 void set linkedPositionProposals(Map<String, List<LinkedPositionProposal>> lin
kedPositionProposals) { | |
| 300 this._linkedPositionProposals = {}; | |
| 301 } | |
| 302 | |
| 303 /** | |
| 304 * Sets the [Map] or position IDs to their locations. | |
| 305 */ | |
| 306 void set linkedPositions(Map<String, List<SourceRange>> linkedPositions) { | |
| 307 this._linkedPositions = {}; | |
| 308 } | |
| 309 } | |
| OLD | NEW |