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

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

Issue 969113002: Reformat (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 /** 87 /**
88 * Implement the 'execution.mapUri' request. 88 * Implement the 'execution.mapUri' request.
89 */ 89 */
90 Response mapUri(Request request) { 90 Response mapUri(Request request) {
91 ExecutionMapUriParams params = 91 ExecutionMapUriParams params =
92 new ExecutionMapUriParams.fromRequest(request); 92 new ExecutionMapUriParams.fromRequest(request);
93 String contextId = params.id; 93 String contextId = params.id;
94 String path = contextMap[contextId]; 94 String path = contextMap[contextId];
95 if (path == null) { 95 if (path == null) {
96 return new Response.invalidParameter( 96 return new Response.invalidParameter(request, 'id',
97 request,
98 'id',
99 'There is no execution context with an id of $contextId'); 97 'There is no execution context with an id of $contextId');
100 } 98 }
101 AnalysisContext context = server.getAnalysisContext(path); 99 AnalysisContext context = server.getAnalysisContext(path);
102 if (context == null) { 100 if (context == null) {
103 return new Response.invalidExecutionContext(request, contextId); 101 return new Response.invalidExecutionContext(request, contextId);
104 } 102 }
105 String file = params.file; 103 String file = params.file;
106 String uri = params.uri; 104 String uri = params.uri;
107 if (file != null) { 105 if (file != null) {
108 if (uri != null) { 106 if (uri != null) {
109 return new Response.invalidParameter( 107 return new Response.invalidParameter(request, 'file',
110 request,
111 'file',
112 'Either file or uri must be provided, but not both'); 108 'Either file or uri must be provided, but not both');
113 } 109 }
114 Resource resource = server.resourceProvider.getResource(file); 110 Resource resource = server.resourceProvider.getResource(file);
115 if (!resource.exists) { 111 if (!resource.exists) {
116 return new Response.invalidParameter(request, 'file', 'Must exist'); 112 return new Response.invalidParameter(request, 'file', 'Must exist');
117 } else if (resource is! File) { 113 } else if (resource is! File) {
118 return new Response.invalidParameter( 114 return new Response.invalidParameter(
119 request, 115 request, 'file', 'Must not refer to a directory');
120 'file',
121 'Must not refer to a directory');
122 } 116 }
123 Source source = server.getSource(file); 117 Source source = server.getSource(file);
124 uri = context.sourceFactory.restoreUri(source).toString(); 118 uri = context.sourceFactory.restoreUri(source).toString();
125 return new ExecutionMapUriResult(uri: uri).toResponse(request.id); 119 return new ExecutionMapUriResult(uri: uri).toResponse(request.id);
126 } else if (uri != null) { 120 } else if (uri != null) {
127 Source source = context.sourceFactory.forUri(uri); 121 Source source = context.sourceFactory.forUri(uri);
128 if (source == null) { 122 if (source == null) {
129 return new Response.invalidParameter(request, 'uri', 'Invalid URI'); 123 return new Response.invalidParameter(request, 'uri', 'Invalid URI');
130 } 124 }
131 file = source.fullName; 125 file = source.fullName;
132 return new ExecutionMapUriResult(file: file).toResponse(request.id); 126 return new ExecutionMapUriResult(file: file).toResponse(request.id);
133 } 127 }
134 return new Response.invalidParameter( 128 return new Response.invalidParameter(
135 request, 129 request, 'file', 'Either file or uri must be provided');
136 'file',
137 'Either file or uri must be provided');
138 } 130 }
139 131
140 /** 132 /**
141 * Implement the 'execution.setSubscriptions' request. 133 * Implement the 'execution.setSubscriptions' request.
142 */ 134 */
143 Response setSubscriptions(Request request) { 135 Response setSubscriptions(Request request) {
144 List<ExecutionService> subscriptions = 136 List<ExecutionService> subscriptions =
145 new ExecutionSetSubscriptionsParams.fromRequest(request).subscriptions; 137 new ExecutionSetSubscriptionsParams.fromRequest(request).subscriptions;
146 if (subscriptions.contains(ExecutionService.LAUNCH_DATA)) { 138 if (subscriptions.contains(ExecutionService.LAUNCH_DATA)) {
147 if (onFileAnalyzed == null) { 139 if (onFileAnalyzed == null) {
(...skipping 21 matching lines...) Expand all
169 ExecutableKind kind = ExecutableKind.NOT_EXECUTABLE; 161 ExecutableKind kind = ExecutableKind.NOT_EXECUTABLE;
170 if (context.isClientLibrary(source)) { 162 if (context.isClientLibrary(source)) {
171 kind = ExecutableKind.CLIENT; 163 kind = ExecutableKind.CLIENT;
172 if (context.isServerLibrary(source)) { 164 if (context.isServerLibrary(source)) {
173 kind = ExecutableKind.EITHER; 165 kind = ExecutableKind.EITHER;
174 } 166 }
175 } else if (context.isServerLibrary(source)) { 167 } else if (context.isServerLibrary(source)) {
176 kind = ExecutableKind.SERVER; 168 kind = ExecutableKind.SERVER;
177 } 169 }
178 server.sendNotification( 170 server.sendNotification(
179 new ExecutionLaunchDataParams(filePath, kind: kind).toNotification() ); 171 new ExecutionLaunchDataParams(filePath, kind: kind)
172 .toNotification());
180 } else if (AnalysisEngine.isHtmlFileName(filePath)) { 173 } else if (AnalysisEngine.isHtmlFileName(filePath)) {
181 List<Source> libraries = context.getLibrariesReferencedFromHtml(source); 174 List<Source> libraries = context.getLibrariesReferencedFromHtml(source);
182 server.sendNotification( 175 server.sendNotification(new ExecutionLaunchDataParams(filePath,
183 new ExecutionLaunchDataParams( 176 referencedFiles: _getFullNames(libraries)).toNotification());
184 filePath,
185 referencedFiles: _getFullNames(libraries)).toNotification());
186 } 177 }
187 }); 178 });
188 } 179 }
189 180
190 /** 181 /**
191 * Return `true` if the given [filePath] represents a file that is in an 182 * Return `true` if the given [filePath] represents a file that is in an
192 * analysis root. 183 * analysis root.
193 */ 184 */
194 bool _isInAnalysisRoot(String filePath) => 185 bool _isInAnalysisRoot(String filePath) =>
195 server.contextDirectoryManager.isInAnalysisRoot(filePath); 186 server.contextDirectoryManager.isInAnalysisRoot(filePath);
(...skipping 16 matching lines...) Expand all
212 librarySources.remove(source); 203 librarySources.remove(source);
213 } 204 }
214 for (Source source in librarySources) { 205 for (Source source in librarySources) {
215 _sendKindNotification(source.fullName, ExecutableKind.NOT_EXECUTABLE); 206 _sendKindNotification(source.fullName, ExecutableKind.NOT_EXECUTABLE);
216 } 207 }
217 for (Source source in context.htmlSources) { 208 for (Source source in context.htmlSources) {
218 String filePath = source.fullName; 209 String filePath = source.fullName;
219 if (_isInAnalysisRoot(filePath)) { 210 if (_isInAnalysisRoot(filePath)) {
220 List<Source> libraries = 211 List<Source> libraries =
221 context.getLibrariesReferencedFromHtml(source); 212 context.getLibrariesReferencedFromHtml(source);
222 server.sendNotification( 213 server.sendNotification(new ExecutionLaunchDataParams(filePath,
223 new ExecutionLaunchDataParams( 214 referencedFiles: _getFullNames(libraries)).toNotification());
224 filePath,
225 referencedFiles: _getFullNames(libraries)).toNotification());
226 } 215 }
227 } 216 }
228 } 217 }
229 } 218 }
230 219
231 /** 220 /**
232 * Send a notification indicating the [kind] of the file with the given 221 * Send a notification indicating the [kind] of the file with the given
233 * [filePath], but only if the file is in an analysis root. 222 * [filePath], but only if the file is in an analysis root.
234 */ 223 */
235 void _sendKindNotification(String filePath, ExecutableKind kind) { 224 void _sendKindNotification(String filePath, ExecutableKind kind) {
236 if (_isInAnalysisRoot(filePath)) { 225 if (_isInAnalysisRoot(filePath)) {
237 server.sendNotification( 226 server.sendNotification(
238 new ExecutionLaunchDataParams(filePath, kind: kind).toNotification()); 227 new ExecutionLaunchDataParams(filePath, kind: kind).toNotification());
239 } 228 }
240 } 229 }
241 230
242 static List<String> _getFullNames(List<Source> sources) { 231 static List<String> _getFullNames(List<Source> sources) {
243 return sources.map((Source source) => source.fullName).toList(); 232 return sources.map((Source source) => source.fullName).toList();
244 } 233 }
245 } 234 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/domain_completion.dart ('k') | pkg/analysis_server/lib/src/domain_server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698