| 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 operation.analysis; | 5 library operation.analysis; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/operation/operation.dart'; | 7 import 'package:analysis_server/src/operation/operation.dart'; |
| 8 import 'package:analysis_server/src/analysis_server.dart'; | 8 import 'package:analysis_server/src/analysis_server.dart'; |
| 9 import 'package:analysis_server/src/computer/computer_highlights.dart'; | 9 import 'package:analysis_server/src/computer/computer_highlights.dart'; |
| 10 import 'package:analysis_server/src/computer/computer_navigation.dart'; | 10 import 'package:analysis_server/src/computer/computer_navigation.dart'; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 if (!source.isInSystemLibrary) { | 84 if (!source.isInSystemLibrary) { |
| 85 sendAnalysisNotificationErrors(server, file, notice.errors); | 85 sendAnalysisNotificationErrors(server, file, notice.errors); |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| 91 | 91 |
| 92 void sendAnalysisNotificationErrors(AnalysisServer server, | 92 void sendAnalysisNotificationErrors(AnalysisServer server, |
| 93 String file, List<AnalysisError> errors) { | 93 String file, List<AnalysisError> errors) { |
| 94 Notification notification = new Notification(NOTIFICATION_ERRORS); | 94 Notification notification = new Notification(ANALYSIS_ERRORS); |
| 95 notification.setParameter(FILE, file); | 95 notification.setParameter(FILE, file); |
| 96 notification.setParameter(ERRORS, errors.map(errorToJson).toList()); | 96 notification.setParameter(ERRORS, errors.map(errorToJson).toList()); |
| 97 server.sendNotification(notification); | 97 server.sendNotification(notification); |
| 98 } | 98 } |
| 99 | 99 |
| 100 | 100 |
| 101 void sendAnalysisNotificationHighlights(AnalysisServer server, | 101 void sendAnalysisNotificationHighlights(AnalysisServer server, |
| 102 String file, CompilationUnit dartUnit) { | 102 String file, CompilationUnit dartUnit) { |
| 103 Notification notification = new Notification(NOTIFICATION_HIGHLIGHTS); | 103 Notification notification = new Notification(ANALYSIS_HIGHLIGHTS); |
| 104 notification.setParameter(FILE, file); | 104 notification.setParameter(FILE, file); |
| 105 notification.setParameter( | 105 notification.setParameter( |
| 106 REGIONS, | 106 REGIONS, |
| 107 new DartUnitHighlightsComputer(dartUnit).compute()); | 107 new DartUnitHighlightsComputer(dartUnit).compute()); |
| 108 server.sendNotification(notification); | 108 server.sendNotification(notification); |
| 109 } | 109 } |
| 110 | 110 |
| 111 | 111 |
| 112 void sendAnalysisNotificationNavigation(AnalysisServer server, | 112 void sendAnalysisNotificationNavigation(AnalysisServer server, |
| 113 String file, CompilationUnit dartUnit) { | 113 String file, CompilationUnit dartUnit) { |
| 114 Notification notification = new Notification(NOTIFICATION_NAVIGATION); | 114 Notification notification = new Notification(ANALYSIS_NAVIGATION); |
| 115 notification.setParameter(FILE, file); | 115 notification.setParameter(FILE, file); |
| 116 notification.setParameter( | 116 notification.setParameter( |
| 117 REGIONS, | 117 REGIONS, |
| 118 new DartUnitNavigationComputer(dartUnit).compute()); | 118 new DartUnitNavigationComputer(dartUnit).compute()); |
| 119 server.sendNotification(notification); | 119 server.sendNotification(notification); |
| 120 } | 120 } |
| 121 | 121 |
| 122 | 122 |
| 123 void sendAnalysisNotificationOutline(AnalysisServer server, | 123 void sendAnalysisNotificationOutline(AnalysisServer server, |
| 124 String file, CompilationUnit dartUnit) { | 124 String file, CompilationUnit dartUnit) { |
| 125 Notification notification = new Notification(NOTIFICATION_OUTLINE); | 125 Notification notification = new Notification(ANALYSIS_OUTLINE); |
| 126 notification.setParameter(FILE, file); | 126 notification.setParameter(FILE, file); |
| 127 notification.setParameter( | 127 notification.setParameter( |
| 128 OUTLINE, | 128 OUTLINE, |
| 129 new DartUnitOutlineComputer(dartUnit).compute()); | 129 new DartUnitOutlineComputer(dartUnit).compute()); |
| 130 server.sendNotification(notification); | 130 server.sendNotification(notification); |
| 131 } | 131 } |
| 132 | 132 |
| 133 | 133 |
| 134 Map<String, Object> errorToJson(AnalysisError analysisError) { | 134 Map<String, Object> errorToJson(AnalysisError analysisError) { |
| 135 // TODO(paulberry): move this function into the AnalysisError class. | 135 // TODO(paulberry): move this function into the AnalysisError class. |
| 136 ErrorCode errorCode = analysisError.errorCode; | 136 ErrorCode errorCode = analysisError.errorCode; |
| 137 Map<String, Object> result = { | 137 Map<String, Object> result = { |
| 138 'file': analysisError.source.fullName, | 138 'file': analysisError.source.fullName, |
| 139 // TODO(scheglov) add Enum.fullName ? | 139 // TODO(scheglov) add Enum.fullName ? |
| 140 'errorCode': '${errorCode.runtimeType}.${(errorCode as Enum).name}', | 140 'errorCode': '${errorCode.runtimeType}.${(errorCode as Enum).name}', |
| 141 'offset': analysisError.offset, | 141 'offset': analysisError.offset, |
| 142 'length': analysisError.length, | 142 'length': analysisError.length, |
| 143 'message': analysisError.message | 143 'message': analysisError.message |
| 144 }; | 144 }; |
| 145 if (analysisError.correction != null) { | 145 if (analysisError.correction != null) { |
| 146 result['correction'] = analysisError.correction; | 146 result['correction'] = analysisError.correction; |
| 147 } | 147 } |
| 148 return result; | 148 return result; |
| 149 } | 149 } |
| OLD | NEW |