Index: pkg/analysis_server/lib/src/domain_analysis.dart |
diff --git a/pkg/analysis_server/lib/src/domain_analysis.dart b/pkg/analysis_server/lib/src/domain_analysis.dart |
index 499fd9955970437209426febd9f342df00d611b9..dca9ae0060e0009c98b3665c043a27fd3f20d2f2 100644 |
--- a/pkg/analysis_server/lib/src/domain_analysis.dart |
+++ b/pkg/analysis_server/lib/src/domain_analysis.dart |
@@ -21,6 +21,7 @@ import 'package:analysis_server/src/services/dependencies/library_dependencies.d |
import 'package:analysis_server/src/services/dependencies/reachable_source_collector.dart'; |
import 'package:analyzer/dart/ast/ast.dart'; |
import 'package:analyzer/dart/element/element.dart'; |
+import 'package:analyzer/error/error.dart' as engine; |
import 'package:analyzer/exception/exception.dart'; |
import 'package:analyzer/file_system/file_system.dart'; |
import 'package:analyzer/src/dart/analysis/driver.dart'; |
@@ -48,39 +49,49 @@ class AnalysisDomainHandler implements RequestHandler { |
/** |
* Implement the `analysis.getErrors` request. |
*/ |
- Response getErrors(Request request) { |
+ Future<Null> getErrors(Request request) async { |
String file = new AnalysisGetErrorsParams.fromRequest(request).file; |
+ |
+ void send(engine.AnalysisOptions analysisOptions, LineInfo lineInfo, |
+ List<engine.AnalysisError> errors) { |
+ if (lineInfo == null) { |
+ server.sendResponse(new Response.getErrorsInvalidFile(request)); |
+ } else { |
+ List<AnalysisError> protocolErrors = |
+ doAnalysisError_listFromEngine(analysisOptions, lineInfo, errors); |
+ server.sendResponse( |
+ new AnalysisGetErrorsResult(protocolErrors).toResponse(request.id)); |
+ } |
+ } |
+ |
+ if (server.options.enableNewAnalysisDriver) { |
+ var result = await server.getAnalysisResult(file); |
+ send(result?.driver?.analysisOptions, result?.lineInfo, result?.errors); |
+ return; |
+ } |
+ |
Future<AnalysisDoneReason> completionFuture = |
server.onFileAnalysisComplete(file); |
if (completionFuture == null) { |
- return new Response.getErrorsInvalidFile(request); |
+ server.sendResponse(new Response.getErrorsInvalidFile(request)); |
} |
- completionFuture.then((AnalysisDoneReason reason) { |
+ completionFuture.then((AnalysisDoneReason reason) async { |
switch (reason) { |
case AnalysisDoneReason.COMPLETE: |
engine.AnalysisErrorInfo errorInfo = server.getErrors(file); |
- List<AnalysisError> errors; |
if (errorInfo == null) { |
server.sendResponse(new Response.getErrorsInvalidFile(request)); |
} else { |
engine.AnalysisContext context = server.getAnalysisContext(file); |
- errors = doAnalysisError_listFromEngine( |
- context, errorInfo.lineInfo, errorInfo.errors); |
- server.sendResponse( |
- new AnalysisGetErrorsResult(errors).toResponse(request.id)); |
+ send(context.analysisOptions, errorInfo.lineInfo, errorInfo.errors); |
} |
break; |
case AnalysisDoneReason.CONTEXT_REMOVED: |
// The active contexts have changed, so try again. |
- Response response = getErrors(request); |
- if (response != Response.DELAYED_RESPONSE) { |
- server.sendResponse(response); |
- } |
+ await getErrors(request); |
break; |
} |
}); |
- // delay response |
- return Response.DELAYED_RESPONSE; |
} |
/** |
@@ -198,7 +209,8 @@ class AnalysisDomainHandler implements RequestHandler { |
try { |
String requestName = request.method; |
if (requestName == ANALYSIS_GET_ERRORS) { |
- return getErrors(request); |
+ getErrors(request); |
+ return Response.DELAYED_RESPONSE; |
} else if (requestName == ANALYSIS_GET_HOVER) { |
getHover(request); |
return Response.DELAYED_RESPONSE; |