Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: pkg/analysis_server/lib/src/domain_analysis.dart

Issue 2566013002: Implement 'analysis.getErrors' for the new driver. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/operation/operation_analysis.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/operation/operation_analysis.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698