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

Side by Side Diff: pkg/analysis_server/lib/src/domain_execution.dart

Issue 596893002: Rework launch data (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated Java side Created 6 years, 3 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 domain.execution; 5 library domain.execution;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analysis_server/src/analysis_server.dart'; 10 import 'package:analysis_server/src/analysis_server.dart';
(...skipping 19 matching lines...) Expand all
30 30
31 /** 31 /**
32 * A table mapping execution context id's to the root of the context. 32 * A table mapping execution context id's to the root of the context.
33 */ 33 */
34 Map<String, String> contextMap = new HashMap<String, String>(); 34 Map<String, String> contextMap = new HashMap<String, String>();
35 35
36 /** 36 /**
37 * The subscription to the 'onAnalysisComplete' events, 37 * The subscription to the 'onAnalysisComplete' events,
38 * used to send notifications when 38 * used to send notifications when
39 */ 39 */
40 StreamSubscription onAnalysisSubscription; 40 StreamSubscription onFileAnalyzed;
41 41
42 /** 42 /**
43 * Initialize a newly created handler to handle requests for the given [server ]. 43 * Initialize a newly created handler to handle requests for the given [server ].
44 */ 44 */
45 ExecutionDomainHandler(this.server); 45 ExecutionDomainHandler(this.server);
46 46
47 /** 47 /**
48 * Implement the `execution.createContext` request. 48 * Implement the `execution.createContext` request.
49 */ 49 */
50 Response createContext(Request request) { 50 Response createContext(Request request) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 'Either file or uri must be provided'); 119 'Either file or uri must be provided');
120 } 120 }
121 121
122 /** 122 /**
123 * Implement the 'execution.setSubscriptions' request. 123 * Implement the 'execution.setSubscriptions' request.
124 */ 124 */
125 Response setSubscriptions(Request request) { 125 Response setSubscriptions(Request request) {
126 List<ExecutionService> subscriptions = 126 List<ExecutionService> subscriptions =
127 new ExecutionSetSubscriptionsParams.fromRequest(request).subscriptions; 127 new ExecutionSetSubscriptionsParams.fromRequest(request).subscriptions;
128 if (subscriptions.contains(ExecutionService.LAUNCH_DATA)) { 128 if (subscriptions.contains(ExecutionService.LAUNCH_DATA)) {
129 if (onAnalysisSubscription == null) { 129 if (onFileAnalyzed == null) {
130 onAnalysisSubscription = 130 onFileAnalyzed = server.onFileAnalyzed.listen(_fileAnalyzed);
131 server.onAnalysisComplete.listen(_analysisComplete); 131 _reportCurrentFileStatus();
132 if (server.isAnalysisComplete()) {
133 _analysisComplete(null);
134 }
135 } 132 }
136 } else { 133 } else {
137 if (onAnalysisSubscription != null) { 134 if (onFileAnalyzed != null) {
138 onAnalysisSubscription.cancel(); 135 onFileAnalyzed.cancel();
139 onAnalysisSubscription = null; 136 onFileAnalyzed = null;
140 } 137 }
141 } 138 }
142 return new ExecutionSetSubscriptionsResult().toResponse(request.id); 139 return new ExecutionSetSubscriptionsResult().toResponse(request.id);
143 } 140 }
144 141
145 void _analysisComplete(_) { 142 void _fileAnalyzed(ChangeNotice notice) {
146 List<ExecutableFile> executables = []; 143 Source source = notice.source;
144 String filePath = source.fullName;
145 AnalysisContext context = server.getAnalysisContext(filePath);
146 if (AnalysisEngine.isDartFileName(filePath)) {
147 ExecutableKind kind;
148 if (context.isClientLibrary(source)) {
149 kind = ExecutableKind.CLIENT;
150 if (context.isServerLibrary(source)) {
151 kind = ExecutableKind.EITHER;
152 }
153 } else if (context.isServerLibrary(source)) {
154 kind = ExecutableKind.SERVER;
155 }
Paul Berry 2014/09/23 20:34:12 Needs an else block that sets kind to ExecutableKi
Brian Wilkerson 2014/09/23 22:01:24 Good catch! Done.
156 server.sendNotification(
157 new ExecutionLaunchDataParams(
158 filePath,
159 kind: kind).toNotification());
160 } else if (AnalysisEngine.isHtmlFileName(filePath)) {
161 List<Source> libraries = context.getLibrariesReferencedFromHtml(source);
162 server.sendNotification(
163 new ExecutionLaunchDataParams(
164 filePath,
165 referencedFiles: _getFullNames(libraries)).toNotification());
166 }
167 }
168
169 void _reportCurrentFileStatus() {
147 Map<String, List<String>> dartToHtml = new HashMap<String, List<String>>(); 170 Map<String, List<String>> dartToHtml = new HashMap<String, List<String>>();
148 Map<String, List<String>> htmlToDart = new HashMap<String, List<String>>(); 171 Map<String, List<String>> htmlToDart = new HashMap<String, List<String>>();
149 for (AnalysisContext context in server.getAnalysisContexts()) { 172 for (AnalysisContext context in server.getAnalysisContexts()) {
173 List<Source> librarySources = context.librarySources;
150 List<Source> clientSources = context.launchableClientLibrarySources; 174 List<Source> clientSources = context.launchableClientLibrarySources;
151 List<Source> serverSources = context.launchableServerLibrarySources; 175 List<Source> serverSources = context.launchableServerLibrarySources;
152 for (Source source in clientSources) { 176 for (Source source in clientSources) {
153 ExecutableKind kind = ExecutableKind.CLIENT;
154 if (serverSources.remove(source)) { 177 if (serverSources.remove(source)) {
155 kind = ExecutableKind.EITHER; 178 server.sendNotification(
179 new ExecutionLaunchDataParams(
180 source.fullName,
181 kind: ExecutableKind.EITHER).toNotification());
182 } else {
183 server.sendNotification(
184 new ExecutionLaunchDataParams(
185 source.fullName,
186 kind: ExecutableKind.CLIENT).toNotification());
156 } 187 }
157 executables.add(new ExecutableFile(source.fullName, kind)); 188 librarySources.remove(source);
158 } 189 }
159 for (Source source in serverSources) { 190 for (Source source in serverSources) {
160 executables.add( 191 server.sendNotification(
161 new ExecutableFile(source.fullName, ExecutableKind.SERVER)); 192 new ExecutionLaunchDataParams(
193 source.fullName,
194 kind: ExecutableKind.SERVER).toNotification());
195 librarySources.remove(source);
162 } 196 }
163 197 for (Source source in librarySources) {
164 for (Source librarySource in context.librarySources) { 198 server.sendNotification(
165 List<Source> files = context.getHtmlFilesReferencing(librarySource); 199 new ExecutionLaunchDataParams(
166 if (files.isNotEmpty) { 200 source.fullName,
167 // TODO(brianwilkerson) Handle the case where the same library is 201 kind: ExecutableKind.NOT_EXECUTABLE).toNotification());
168 // being analyzed in multiple contexts.
169 dartToHtml[librarySource.fullName] = _getFullNames(files);
170 }
171 } 202 }
172 203 for (Source source in context.htmlSources) {
173 for (Source htmlSource in context.htmlSources) { 204 List<Source> libraries = context.getLibrariesReferencedFromHtml(source);
174 List<Source> libraries = 205 server.sendNotification(
175 context.getLibrariesReferencedFromHtml(htmlSource); 206 new ExecutionLaunchDataParams(
176 if (libraries.isNotEmpty) { 207 source.fullName,
177 // TODO(brianwilkerson) Handle the case where the same HTML file is 208 referencedFiles: _getFullNames(libraries)).toNotification());
178 // being analyzed in multiple contexts.
179 htmlToDart[htmlSource.fullName] = _getFullNames(libraries);
180 }
181 } 209 }
182 } 210 }
183 server.sendNotification(
184 new ExecutionLaunchDataParams(
185 executables,
186 dartToHtml,
187 htmlToDart).toNotification());
188 } 211 }
189 212
190 static List<String> _getFullNames(List<Source> sources) { 213 static List<String> _getFullNames(List<Source> sources) {
191 return sources.map((Source source) => source.fullName).toList(); 214 return sources.map((Source source) => source.fullName).toList();
192 } 215 }
193 } 216 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | pkg/analysis_server/lib/src/generated_protocol.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698