| 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_plugin/protocol/protocol_generated.dart'; | 5 import 'package:analyzer_plugin/protocol/protocol_generated.dart'; |
| 6 import 'package:analyzer_plugin/src/protocol/protocol_internal.dart'; | 6 import 'package:analyzer_plugin/src/protocol/protocol_internal.dart'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * An interface for enumerated types in the protocol. | 9 * An interface for enumerated types in the protocol. |
| 10 * | 10 * |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 | 266 |
| 267 /** | 267 /** |
| 268 * A collection of utility methods that create instances of the generated class | 268 * A collection of utility methods that create instances of the generated class |
| 269 * [RequestError]. | 269 * [RequestError]. |
| 270 * | 270 * |
| 271 * Clients may not extend, implement or mix-in this class. | 271 * Clients may not extend, implement or mix-in this class. |
| 272 */ | 272 */ |
| 273 class RequestErrorFactory { | 273 class RequestErrorFactory { |
| 274 // /** | 274 /** |
| 275 // * Initialize a newly created instance to represent the | 275 * Return a request error representing an error condition caused by a |
| 276 // * GET_ERRORS_INVALID_FILE error condition. | 276 * [request] that had an invalid edit object. |
| 277 // */ | 277 */ |
| 278 // Response.getErrorsInvalidFile(Request request) | 278 static RequestError invalidOverlayChangeInvalidEdit() => new RequestError( |
| 279 // : this(request.id, | 279 RequestErrorCode.INVALID_OVERLAY_CHANGE, |
| 280 // error: new RequestError(RequestErrorCode.GET_ERRORS_INVALID_FILE, | 280 'Invalid overlay change: invalid edit'); |
| 281 // 'Error during `analysis.getErrors`: invalid file.')); | |
| 282 // | |
| 283 // /** | |
| 284 // * Initialize a newly created instance to represent the | |
| 285 // * GET_NAVIGATION_INVALID_FILE error condition. | |
| 286 // */ | |
| 287 // Response.getNavigationInvalidFile(Request request) | |
| 288 // : this(request.id, | |
| 289 // error: new RequestError( | |
| 290 // RequestErrorCode.GET_NAVIGATION_INVALID_FILE, | |
| 291 // 'Error during `analysis.getNavigation`: invalid file.')); | |
| 292 // | |
| 293 // /** | |
| 294 // * Initialize a newly created instance to represent the | |
| 295 // * GET_REACHABLE_SOURCES_INVALID_FILE error condition. | |
| 296 // */ | |
| 297 // Response.getReachableSourcesInvalidFile(Request request) | |
| 298 // : this(request.id, | |
| 299 // error: new RequestError( | |
| 300 // RequestErrorCode.GET_REACHABLE_SOURCES_INVALID_FILE, | |
| 301 // 'Error during `analysis.getReachableSources`: invalid file.')); | |
| 302 // | |
| 303 // /** | |
| 304 // * Initialize a newly created instance to represent an error condition cause
d | |
| 305 // * by an analysis.reanalyze [request] that specifies an analysis root that i
s | |
| 306 // * not in the current list of analysis roots. | |
| 307 // */ | |
| 308 // Response.invalidAnalysisRoot(Request request, String rootPath) | |
| 309 // : this(request.id, | |
| 310 // error: new RequestError(RequestErrorCode.INVALID_ANALYSIS_ROOT, | |
| 311 // "Invalid analysis root: $rootPath")); | |
| 312 // | |
| 313 // /** | |
| 314 // * Initialize a newly created instance to represent an error condition cause
d | |
| 315 // * by a [request] that specifies an execution context whose context root doe
s | |
| 316 // * not exist. | |
| 317 // */ | |
| 318 // Response.invalidExecutionContext(Request request, String contextId) | |
| 319 // : this(request.id, | |
| 320 // error: new RequestError(RequestErrorCode.INVALID_EXECUTION_CONTEXT, | |
| 321 // "Invalid execution context: $contextId")); | |
| 322 // | |
| 323 // /** | |
| 324 // * Initialize a newly created instance to represent the | |
| 325 // * INVALID_FILE_PATH_FORMAT error condition. | |
| 326 // */ | |
| 327 // Response.invalidFilePathFormat(Request request, path) | |
| 328 // : this(request.id, | |
| 329 // error: new RequestError(RequestErrorCode.INVALID_FILE_PATH_FORMAT, | |
| 330 // 'Invalid file path format: $path')); | |
| 331 | 281 |
| 332 /** | 282 /** |
| 333 * Return a request error representing an error condition caused by a | 283 * Return a request error representing an error condition caused by a |
| 334 * [request] that had invalid parameter. [path] is the path to the | 284 * [request] that attempted to change an existing overlay when no overlay |
| 285 * existed. |
| 286 */ |
| 287 static RequestError invalidOverlayChangeNoContent() => new RequestError( |
| 288 RequestErrorCode.INVALID_OVERLAY_CHANGE, |
| 289 'Invalid overlay change: no content to change'); |
| 290 |
| 291 /** |
| 292 * Return a request error representing an error condition caused by a |
| 293 * [request] that had an invalid parameter. The [path] is the path to the |
| 335 * invalid parameter, in Javascript notation (e.g. "foo.bar" means that the | 294 * invalid parameter, in Javascript notation (e.g. "foo.bar" means that the |
| 336 * parameter "foo" contained a key "bar" whose value was the wrong type). | 295 * parameter "foo" contained a key "bar" whose value was the wrong type). The |
| 337 * [expectation] is a description of the type of data that was expected. | 296 * [expectation] is a description of the type of data that was expected. |
| 338 */ | 297 */ |
| 339 static RequestError invalidParameter( | 298 static RequestError invalidParameter( |
| 340 Request request, String path, String expectation) => | 299 Request request, String path, String expectation) => |
| 341 new RequestError(RequestErrorCode.INVALID_PARAMETER, | 300 new RequestError(RequestErrorCode.INVALID_PARAMETER, |
| 342 "Invalid parameter '$path'. $expectation."); | 301 "Invalid parameter '$path'. $expectation."); |
| 343 | 302 |
| 344 // /** | |
| 345 // * Initialize a newly created instance to represent an error condition cause
d | |
| 346 // * by a malformed request. | |
| 347 // */ | |
| 348 // Response.invalidRequestFormat() | |
| 349 // : this('', | |
| 350 // error: new RequestError( | |
| 351 // RequestErrorCode.INVALID_REQUEST, 'Invalid request')); | |
| 352 // | |
| 353 // /** | |
| 354 // * Initialize a newly created instance to represent an error condition cause
d | |
| 355 // * by a request that requires an index, but indexing is disabled. | |
| 356 // */ | |
| 357 // Response.noIndexGenerated(Request request) | |
| 358 // : this(request.id, | |
| 359 // error: new RequestError( | |
| 360 // RequestErrorCode.NO_INDEX_GENERATED, 'Indexing is disabled')); | |
| 361 // | |
| 362 // /** | |
| 363 // * Initialize a newly created instance to represent the | |
| 364 // * ORGANIZE_DIRECTIVES_ERROR error condition. | |
| 365 // */ | |
| 366 // Response.organizeDirectivesError(Request request, String message) | |
| 367 // : this(request.id, | |
| 368 // error: new RequestError( | |
| 369 // RequestErrorCode.ORGANIZE_DIRECTIVES_ERROR, message)); | |
| 370 // | |
| 371 // /** | |
| 372 // * Initialize a newly created instance to represent the | |
| 373 // * REFACTORING_REQUEST_CANCELLED error condition. | |
| 374 // */ | |
| 375 // Response.refactoringRequestCancelled(Request request) | |
| 376 // : this(request.id, | |
| 377 // error: new RequestError( | |
| 378 // RequestErrorCode.REFACTORING_REQUEST_CANCELLED, | |
| 379 // 'The `edit.getRefactoring` request was cancelled.')); | |
| 380 | |
| 381 /** | 303 /** |
| 382 * Return a request error representing an error that occurred in the plugin. | 304 * Return a request error representing an error that occurred in the plugin. |
| 383 */ | 305 */ |
| 384 static RequestError pluginError(Request request, exception, stackTrace) => | 306 static RequestError pluginError(Request request, exception, stackTrace) => |
| 385 new RequestError(RequestErrorCode.PLUGIN_ERROR, exception.toString(), | 307 new RequestError(RequestErrorCode.PLUGIN_ERROR, exception.toString(), |
| 386 stackTrace: stackTrace); | 308 stackTrace: stackTrace); |
| 387 | 309 |
| 388 // /** | |
| 389 // * Initialize a newly created instance to represent the | |
| 390 // * SORT_MEMBERS_INVALID_FILE error condition. | |
| 391 // */ | |
| 392 // Response.sortMembersInvalidFile(Request request) | |
| 393 // : this(request.id, | |
| 394 // error: new RequestError(RequestErrorCode.SORT_MEMBERS_INVALID_FILE, | |
| 395 // 'Error during `edit.sortMembers`: invalid file.')); | |
| 396 // | |
| 397 // /** | |
| 398 // * Initialize a newly created instance to represent the | |
| 399 // * SORT_MEMBERS_PARSE_ERRORS error condition. | |
| 400 // */ | |
| 401 // Response.sortMembersParseErrors(Request request, int numErrors) | |
| 402 // : this(request.id, | |
| 403 // error: new RequestError(RequestErrorCode.SORT_MEMBERS_PARSE_ERRORS, | |
| 404 // 'Error during `edit.sortMembers`: file has $numErrors scan/parse err
ors.')); | |
| 405 // | |
| 406 // /** | |
| 407 // * Initialize a newly created instance to represent an error condition cause
d | |
| 408 // * by a `analysis.setPriorityFiles` [request] that includes one or more file
s | |
| 409 // * that are not being analyzed. | |
| 410 // */ | |
| 411 // Response.unanalyzedPriorityFiles(String requestId, String fileNames) | |
| 412 // : this(requestId, | |
| 413 // error: new RequestError(RequestErrorCode.UNANALYZED_PRIORITY_FILES, | |
| 414 // "Unanalyzed files cannot be a priority: '$fileNames'")); | |
| 415 | |
| 416 /** | 310 /** |
| 417 * Return a request error representing an error condition caused by a | 311 * Return a request error representing an error condition caused by a |
| 418 * [request] that cannot be handled by any known handlers. | 312 * [request] that cannot be handled by any known handlers. |
| 419 */ | 313 */ |
| 420 static RequestError unknownRequest(Request request) => | 314 static RequestError unknownRequest(Request request) => |
| 421 new RequestError(RequestErrorCode.UNKNOWN_REQUEST, 'Unknown request'); | 315 new RequestError(RequestErrorCode.UNKNOWN_REQUEST, 'Unknown request'); |
| 422 | |
| 423 // /** | |
| 424 // * Initialize a newly created instance to represent an error condition cause
d | |
| 425 // * by a [request] referencing a source that does not exist. | |
| 426 // */ | |
| 427 // Response.unknownSource(Request request) | |
| 428 // : this(request.id, | |
| 429 // error: new RequestError( | |
| 430 // RequestErrorCode.UNKNOWN_SOURCE, 'Unknown source')); | |
| 431 // | |
| 432 // /** | |
| 433 // * Initialize a newly created instance to represent an error condition cause
d | |
| 434 // * by a [request] for a service that is not supported. | |
| 435 // */ | |
| 436 // Response.unsupportedFeature(String requestId, String message) | |
| 437 // : this(requestId, | |
| 438 // error: new RequestError( | |
| 439 // RequestErrorCode.UNSUPPORTED_FEATURE, message)); | |
| 440 } | 316 } |
| 441 | 317 |
| 442 /** | 318 /** |
| 443 * An exception that occurred during the handling of a request that requires | 319 * An exception that occurred during the handling of a request that requires |
| 444 * that an error be returned to the server. | 320 * that an error be returned to the server. |
| 445 * | 321 * |
| 446 * Clients may not extend, implement or mix-in this class. | 322 * Clients may not extend, implement or mix-in this class. |
| 447 */ | 323 */ |
| 448 class RequestFailure implements Exception { | 324 class RequestFailure implements Exception { |
| 449 /** | 325 /** |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 jsonObject[ID] = id; | 450 jsonObject[ID] = id; |
| 575 if (error != null) { | 451 if (error != null) { |
| 576 jsonObject[ERROR] = error.toJson(); | 452 jsonObject[ERROR] = error.toJson(); |
| 577 } | 453 } |
| 578 if (result != null) { | 454 if (result != null) { |
| 579 jsonObject[RESULT] = result; | 455 jsonObject[RESULT] = result; |
| 580 } | 456 } |
| 581 return jsonObject; | 457 return jsonObject; |
| 582 } | 458 } |
| 583 } | 459 } |
| OLD | NEW |