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

Side by Side Diff: pkg/analysis_server/lib/src/operation/operation_analysis.dart

Issue 314493002: Navigation computer and two variants of tests for it. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/computers.dart'; 9 import 'package:analysis_server/src/computers.dart';
10 import 'package:analysis_server/src/constants.dart'; 10 import 'package:analysis_server/src/constants.dart';
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 for (int i = 0; i < notices.length; i++) { 65 for (int i = 0; i < notices.length; i++) {
66 ChangeNotice notice = notices[i]; 66 ChangeNotice notice = notices[i];
67 Source source = notice.source; 67 Source source = notice.source;
68 CompilationUnit dartUnit = notice.compilationUnit; 68 CompilationUnit dartUnit = notice.compilationUnit;
69 // TODO(scheglov) use default subscriptions 69 // TODO(scheglov) use default subscriptions
70 String file = source.fullName; 70 String file = source.fullName;
71 if (dartUnit != null) { 71 if (dartUnit != null) {
72 if (server.hasAnalysisSubscription(AnalysisService.HIGHLIGHTS, file)) { 72 if (server.hasAnalysisSubscription(AnalysisService.HIGHLIGHTS, file)) {
73 sendAnalysisNotificationHighlights(server, file, dartUnit); 73 sendAnalysisNotificationHighlights(server, file, dartUnit);
74 } 74 }
75 // TODO(scheglov) only is subscribed
Brian Wilkerson 2014/06/03 22:04:48 Can we do this now, or is there a reason to wait?
76 sendAnalysisNotificationNavigation(server, file, dartUnit);
75 } 77 }
76 if (!source.isInSystemLibrary) { 78 if (!source.isInSystemLibrary) {
77 sendAnalysisNotificationErrors(server, file, notice.errors); 79 sendAnalysisNotificationErrors(server, file, notice.errors);
78 } 80 }
79 } 81 }
80 } 82 }
81 } 83 }
82 84
83 void sendAnalysisNotificationErrors(AnalysisServer server, 85 void sendAnalysisNotificationErrors(AnalysisServer server,
84 String file, List<AnalysisError> errors) { 86 String file, List<AnalysisError> errors) {
85 Notification notification = new Notification(NOTIFICATION_ERRORS); 87 Notification notification = new Notification(NOTIFICATION_ERRORS);
86 notification.setParameter(FILE, file); 88 notification.setParameter(FILE, file);
87 notification.setParameter(ERRORS, errors.map(errorToJson).toList()); 89 notification.setParameter(ERRORS, errors.map(errorToJson).toList());
88 server.sendNotification(notification); 90 server.sendNotification(notification);
89 } 91 }
90 92
91 void sendAnalysisNotificationHighlights(AnalysisServer server, 93 void sendAnalysisNotificationHighlights(AnalysisServer server,
92 String file, CompilationUnit dartUnit) { 94 String file, CompilationUnit dartUnit) {
93 Notification notification = new Notification(NOTIFICATION_HIGHLIGHTS); 95 Notification notification = new Notification(NOTIFICATION_HIGHLIGHTS);
94 notification.setParameter(FILE, file); 96 notification.setParameter(FILE, file);
95 notification.setParameter( 97 notification.setParameter(
96 REGIONS, 98 REGIONS,
97 new DartUnitHighlightsComputer(dartUnit).compute()); 99 new DartUnitHighlightsComputer(dartUnit).compute());
98 server.sendNotification(notification); 100 server.sendNotification(notification);
99 } 101 }
100 102
103 void sendAnalysisNotificationNavigation(AnalysisServer server,
104 String file, CompilationUnit dartUnit) {
105 Notification notification = new Notification(NOTIFICATION_NAVIGATION);
106 notification.setParameter(FILE, file);
107 notification.setParameter(
108 REGIONS,
109 new DartUnitNavigationComputer(dartUnit).compute());
110 server.sendNotification(notification);
111 }
112
101 Map<String, Object> errorToJson(AnalysisError analysisError) { 113 Map<String, Object> errorToJson(AnalysisError analysisError) {
102 // TODO(paulberry): move this function into the AnalysisError class. 114 // TODO(paulberry): move this function into the AnalysisError class.
103 ErrorCode errorCode = analysisError.errorCode; 115 ErrorCode errorCode = analysisError.errorCode;
104 Map<String, Object> result = { 116 Map<String, Object> result = {
105 'file': analysisError.source.fullName, 117 'file': analysisError.source.fullName,
106 // TODO(scheglov) add Enum.fullName ? 118 // TODO(scheglov) add Enum.fullName ?
107 'errorCode': '${errorCode.runtimeType}.${(errorCode as Enum).name}', 119 'errorCode': '${errorCode.runtimeType}.${(errorCode as Enum).name}',
108 'offset': analysisError.offset, 120 'offset': analysisError.offset,
109 'length': analysisError.length, 121 'length': analysisError.length,
110 'message': analysisError.message 122 'message': analysisError.message
111 }; 123 };
112 if (analysisError.correction != null) { 124 if (analysisError.correction != null) {
113 result['correction'] = analysisError.correction; 125 result['correction'] = analysisError.correction;
114 } 126 }
115 return result; 127 return result;
116 } 128 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/computers.dart ('k') | pkg/analysis_server/test/analysis_abstract_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698