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

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

Issue 319523004: Outline notification implementation in server. (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/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';
11 import 'package:analysis_server/src/computer/computer_outline.dart';
11 import 'package:analysis_server/src/constants.dart'; 12 import 'package:analysis_server/src/constants.dart';
12 import 'package:analysis_server/src/protocol.dart'; 13 import 'package:analysis_server/src/protocol.dart';
13 import 'package:analyzer/src/generated/ast.dart'; 14 import 'package:analyzer/src/generated/ast.dart';
14 import 'package:analyzer/src/generated/engine.dart'; 15 import 'package:analyzer/src/generated/engine.dart';
15 import 'package:analyzer/src/generated/error.dart'; 16 import 'package:analyzer/src/generated/error.dart';
16 import 'package:analyzer/src/generated/java_core.dart'; 17 import 'package:analyzer/src/generated/java_core.dart';
17 import 'package:analyzer/src/generated/source.dart'; 18 import 'package:analyzer/src/generated/source.dart';
18 19
19 20
20 /** 21 /**
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 CompilationUnit dartUnit = notice.compilationUnit; 70 CompilationUnit dartUnit = notice.compilationUnit;
70 // TODO(scheglov) use default subscriptions 71 // TODO(scheglov) use default subscriptions
71 String file = source.fullName; 72 String file = source.fullName;
72 if (dartUnit != null) { 73 if (dartUnit != null) {
73 if (server.hasAnalysisSubscription(AnalysisService.HIGHLIGHTS, file)) { 74 if (server.hasAnalysisSubscription(AnalysisService.HIGHLIGHTS, file)) {
74 sendAnalysisNotificationHighlights(server, file, dartUnit); 75 sendAnalysisNotificationHighlights(server, file, dartUnit);
75 } 76 }
76 if (server.hasAnalysisSubscription(AnalysisService.NAVIGATION, file)) { 77 if (server.hasAnalysisSubscription(AnalysisService.NAVIGATION, file)) {
77 sendAnalysisNotificationNavigation(server, file, dartUnit); 78 sendAnalysisNotificationNavigation(server, file, dartUnit);
78 } 79 }
80 if (server.hasAnalysisSubscription(AnalysisService.OUTLINE, file)) {
81 sendAnalysisNotificationOutline(server, file, dartUnit);
82 }
79 } 83 }
80 if (!source.isInSystemLibrary) { 84 if (!source.isInSystemLibrary) {
81 sendAnalysisNotificationErrors(server, file, notice.errors); 85 sendAnalysisNotificationErrors(server, file, notice.errors);
82 } 86 }
83 } 87 }
84 } 88 }
85 } 89 }
86 90
91
Brian Wilkerson 2014/06/04 23:54:00 I don't actually like having two blank lines betwe
scheglov 2014/06/05 01:37:51 Why not both? Two lines help to distinguish visua
87 void sendAnalysisNotificationErrors(AnalysisServer server, 92 void sendAnalysisNotificationErrors(AnalysisServer server,
88 String file, List<AnalysisError> errors) { 93 String file, List<AnalysisError> errors) {
89 Notification notification = new Notification(NOTIFICATION_ERRORS); 94 Notification notification = new Notification(NOTIFICATION_ERRORS);
90 notification.setParameter(FILE, file); 95 notification.setParameter(FILE, file);
91 notification.setParameter(ERRORS, errors.map(errorToJson).toList()); 96 notification.setParameter(ERRORS, errors.map(errorToJson).toList());
92 server.sendNotification(notification); 97 server.sendNotification(notification);
93 } 98 }
94 99
100
95 void sendAnalysisNotificationHighlights(AnalysisServer server, 101 void sendAnalysisNotificationHighlights(AnalysisServer server,
96 String file, CompilationUnit dartUnit) { 102 String file, CompilationUnit dartUnit) {
97 Notification notification = new Notification(NOTIFICATION_HIGHLIGHTS); 103 Notification notification = new Notification(NOTIFICATION_HIGHLIGHTS);
98 notification.setParameter(FILE, file); 104 notification.setParameter(FILE, file);
99 notification.setParameter( 105 notification.setParameter(
100 REGIONS, 106 REGIONS,
101 new DartUnitHighlightsComputer(dartUnit).compute()); 107 new DartUnitHighlightsComputer(dartUnit).compute());
102 server.sendNotification(notification); 108 server.sendNotification(notification);
103 } 109 }
104 110
111
105 void sendAnalysisNotificationNavigation(AnalysisServer server, 112 void sendAnalysisNotificationNavigation(AnalysisServer server,
106 String file, CompilationUnit dartUnit) { 113 String file, CompilationUnit dartUnit) {
107 Notification notification = new Notification(NOTIFICATION_NAVIGATION); 114 Notification notification = new Notification(NOTIFICATION_NAVIGATION);
108 notification.setParameter(FILE, file); 115 notification.setParameter(FILE, file);
109 notification.setParameter( 116 notification.setParameter(
110 REGIONS, 117 REGIONS,
111 new DartUnitNavigationComputer(dartUnit).compute()); 118 new DartUnitNavigationComputer(dartUnit).compute());
112 server.sendNotification(notification); 119 server.sendNotification(notification);
113 } 120 }
114 121
122
123 void sendAnalysisNotificationOutline(AnalysisServer server,
124 String file, CompilationUnit dartUnit) {
125 Notification notification = new Notification(NOTIFICATION_OUTLINE);
126 notification.setParameter(FILE, file);
127 notification.setParameter(
128 OUTLINE,
129 new DartUnitOutlineComputer(dartUnit).compute());
130 server.sendNotification(notification);
131 }
132
133
115 Map<String, Object> errorToJson(AnalysisError analysisError) { 134 Map<String, Object> errorToJson(AnalysisError analysisError) {
116 // TODO(paulberry): move this function into the AnalysisError class. 135 // TODO(paulberry): move this function into the AnalysisError class.
117 ErrorCode errorCode = analysisError.errorCode; 136 ErrorCode errorCode = analysisError.errorCode;
118 Map<String, Object> result = { 137 Map<String, Object> result = {
119 'file': analysisError.source.fullName, 138 'file': analysisError.source.fullName,
120 // TODO(scheglov) add Enum.fullName ? 139 // TODO(scheglov) add Enum.fullName ?
121 'errorCode': '${errorCode.runtimeType}.${(errorCode as Enum).name}', 140 'errorCode': '${errorCode.runtimeType}.${(errorCode as Enum).name}',
122 'offset': analysisError.offset, 141 'offset': analysisError.offset,
123 'length': analysisError.length, 142 'length': analysisError.length,
124 'message': analysisError.message 143 'message': analysisError.message
125 }; 144 };
126 if (analysisError.correction != null) { 145 if (analysisError.correction != null) {
127 result['correction'] = analysisError.correction; 146 result['correction'] = analysisError.correction;
128 } 147 }
129 return result; 148 return result;
130 } 149 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/constants.dart ('k') | pkg/analysis_server/test/analysis_notification_outline_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698