| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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 domain.analysis; | 5 library domain.analysis; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/analysis_server.dart'; | 9 import 'package:analysis_server/src/analysis_server.dart'; |
| 10 import 'package:analysis_server/src/computer/computer_hover.dart'; | 10 import 'package:analysis_server/src/computer/computer_hover.dart'; |
| 11 import 'package:analysis_server/src/computer/error.dart'; |
| 11 import 'package:analysis_server/src/constants.dart'; | 12 import 'package:analysis_server/src/constants.dart'; |
| 12 import 'package:analysis_server/src/operation/operation_analysis.dart'; | |
| 13 import 'package:analysis_server/src/protocol.dart'; | 13 import 'package:analysis_server/src/protocol.dart'; |
| 14 import 'package:analysis_services/constants.dart'; | 14 import 'package:analysis_services/constants.dart'; |
| 15 import 'package:analyzer/src/generated/ast.dart'; | 15 import 'package:analyzer/src/generated/ast.dart'; |
| 16 import 'package:analyzer/src/generated/engine.dart'; | 16 import 'package:analyzer/src/generated/engine.dart'; |
| 17 import 'package:analyzer/src/generated/error.dart'; | 17 |
| 18 | 18 |
| 19 /** | 19 /** |
| 20 * Instances of the class [AnalysisDomainHandler] implement a [RequestHandler] | 20 * Instances of the class [AnalysisDomainHandler] implement a [RequestHandler] |
| 21 * that handles requests in the `analysis` domain. | 21 * that handles requests in the `analysis` domain. |
| 22 */ | 22 */ |
| 23 class AnalysisDomainHandler implements RequestHandler { | 23 class AnalysisDomainHandler implements RequestHandler { |
| 24 /** | 24 /** |
| 25 * The analysis server that is using this handler to process requests. | 25 * The analysis server that is using this handler to process requests. |
| 26 */ | 26 */ |
| 27 final AnalysisServer server; | 27 final AnalysisServer server; |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * Initialize a newly created handler to handle requests for the given [server
]. | 30 * Initialize a newly created handler to handle requests for the given [server
]. |
| 31 */ | 31 */ |
| 32 AnalysisDomainHandler(this.server); | 32 AnalysisDomainHandler(this.server); |
| 33 | 33 |
| 34 /** | 34 /** |
| 35 * Implement the `analysis.getErrors` request. | 35 * Implement the `analysis.getErrors` request. |
| 36 */ | 36 */ |
| 37 Response getErrors(Request request) { | 37 Response getErrors(Request request) { |
| 38 String file = request.getRequiredParameter(FILE).asString(); | 38 String file = request.getRequiredParameter(FILE).asString(); |
| 39 server.onFileAnalysisComplete(file).then((_) { | 39 server.onFileAnalysisComplete(file).then((_) { |
| 40 Response response = new Response(request.id); | 40 Response response = new Response(request.id); |
| 41 AnalysisErrorInfo errorInfo = server.getErrors(file); | 41 AnalysisErrorInfo errorInfo = server.getErrors(file); |
| 42 if (errorInfo == null) { | 42 if (errorInfo == null) { |
| 43 response.setResult(ERRORS, []); | 43 response.setResult(ERRORS, []); |
| 44 } else { | 44 } else { |
| 45 response.setResult(ERRORS, errorInfo.errors.map((AnalysisError error) { | 45 response.setResult(ERRORS, engineErrorInfoToJson(errorInfo)); |
| 46 return errorToJson(errorInfo.lineInfo, error); | |
| 47 }).toList()); | |
| 48 } | 46 } |
| 49 server.sendResponse(response); | 47 server.sendResponse(response); |
| 50 }).catchError((message) { | 48 }).catchError((message) { |
| 51 if (message is! String) { | 49 if (message is! String) { |
| 52 AnalysisEngine.instance.logger.logError( | 50 AnalysisEngine.instance.logger.logError( |
| 53 'Illegal error message during getErrors: $message'); | 51 'Illegal error message during getErrors: $message'); |
| 54 message = ''; | 52 message = ''; |
| 55 } | 53 } |
| 56 Response response = new Response.getErrorsError(request, message); | 54 Response response = new Response.getErrorsError(request, message); |
| 57 response.setResult(ERRORS, []); | 55 response.setResult(ERRORS, []); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 | 256 |
| 259 /** | 257 /** |
| 260 * A description of the change to the content of a file. | 258 * A description of the change to the content of a file. |
| 261 */ | 259 */ |
| 262 class ContentChange { | 260 class ContentChange { |
| 263 String content; | 261 String content; |
| 264 int offset; | 262 int offset; |
| 265 int oldLength; | 263 int oldLength; |
| 266 int newLength; | 264 int newLength; |
| 267 } | 265 } |
| OLD | NEW |