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

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

Issue 630863003: Stop sending launchData for non-analyzed files (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments Created 6 years, 2 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
« no previous file with comments | « no previous file | pkg/analysis_server/test/domain_execution_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 onFileAnalyzed.cancel(); 135 onFileAnalyzed.cancel();
136 onFileAnalyzed = null; 136 onFileAnalyzed = null;
137 } 137 }
138 } 138 }
139 return new ExecutionSetSubscriptionsResult().toResponse(request.id); 139 return new ExecutionSetSubscriptionsResult().toResponse(request.id);
140 } 140 }
141 141
142 void _fileAnalyzed(ChangeNotice notice) { 142 void _fileAnalyzed(ChangeNotice notice) {
143 Source source = notice.source; 143 Source source = notice.source;
144 String filePath = source.fullName; 144 String filePath = source.fullName;
145 if (!_isInAnalysisRoot(filePath)) {
146 return;
147 }
145 AnalysisContext context = server.getAnalysisContext(filePath); 148 AnalysisContext context = server.getAnalysisContext(filePath);
146 if (AnalysisEngine.isDartFileName(filePath)) { 149 if (AnalysisEngine.isDartFileName(filePath)) {
147 ExecutableKind kind = ExecutableKind.NOT_EXECUTABLE; 150 ExecutableKind kind = ExecutableKind.NOT_EXECUTABLE;
148 if (context.isClientLibrary(source)) { 151 if (context.isClientLibrary(source)) {
149 kind = ExecutableKind.CLIENT; 152 kind = ExecutableKind.CLIENT;
150 if (context.isServerLibrary(source)) { 153 if (context.isServerLibrary(source)) {
151 kind = ExecutableKind.EITHER; 154 kind = ExecutableKind.EITHER;
152 } 155 }
153 } else if (context.isServerLibrary(source)) { 156 } else if (context.isServerLibrary(source)) {
154 kind = ExecutableKind.SERVER; 157 kind = ExecutableKind.SERVER;
155 } 158 }
156 server.sendNotification( 159 server.sendNotification(
157 new ExecutionLaunchDataParams( 160 new ExecutionLaunchDataParams(
158 filePath, 161 filePath,
159 kind: kind).toNotification()); 162 kind: kind).toNotification());
160 } else if (AnalysisEngine.isHtmlFileName(filePath)) { 163 } else if (AnalysisEngine.isHtmlFileName(filePath)) {
161 List<Source> libraries = context.getLibrariesReferencedFromHtml(source); 164 List<Source> libraries = context.getLibrariesReferencedFromHtml(source);
162 server.sendNotification( 165 server.sendNotification(
163 new ExecutionLaunchDataParams( 166 new ExecutionLaunchDataParams(
164 filePath, 167 filePath,
165 referencedFiles: _getFullNames(libraries)).toNotification()); 168 referencedFiles: _getFullNames(libraries)).toNotification());
166 } 169 }
167 } 170 }
168 171
172 /**
173 * Return `true` if the given [filePath] represents a file that is in an
174 * analysis root.
175 */
176 bool _isInAnalysisRoot(String filePath)
177 => server.contextDirectoryManager.isInAnalysisRoot(filePath);
178
169 void _reportCurrentFileStatus() { 179 void _reportCurrentFileStatus() {
170 Map<String, List<String>> dartToHtml = new HashMap<String, List<String>>(); 180 Map<String, List<String>> dartToHtml = new HashMap<String, List<String>>();
171 Map<String, List<String>> htmlToDart = new HashMap<String, List<String>>(); 181 Map<String, List<String>> htmlToDart = new HashMap<String, List<String>>();
172 for (AnalysisContext context in server.getAnalysisContexts()) { 182 for (AnalysisContext context in server.getAnalysisContexts()) {
173 List<Source> librarySources = context.librarySources; 183 List<Source> librarySources = context.librarySources;
174 List<Source> clientSources = context.launchableClientLibrarySources; 184 List<Source> clientSources = context.launchableClientLibrarySources;
175 List<Source> serverSources = context.launchableServerLibrarySources; 185 List<Source> serverSources = context.launchableServerLibrarySources;
176 for (Source source in clientSources) { 186 for (Source source in clientSources) {
177 if (serverSources.remove(source)) { 187 if (serverSources.remove(source)) {
178 server.sendNotification( 188 _sendKindNotification(source.fullName, ExecutableKind.EITHER);
179 new ExecutionLaunchDataParams(
180 source.fullName,
181 kind: ExecutableKind.EITHER).toNotification());
182 } else { 189 } else {
183 server.sendNotification( 190 _sendKindNotification(source.fullName, ExecutableKind.CLIENT);
184 new ExecutionLaunchDataParams(
185 source.fullName,
186 kind: ExecutableKind.CLIENT).toNotification());
187 } 191 }
188 librarySources.remove(source); 192 librarySources.remove(source);
189 } 193 }
190 for (Source source in serverSources) { 194 for (Source source in serverSources) {
191 server.sendNotification( 195 _sendKindNotification(source.fullName, ExecutableKind.SERVER);
192 new ExecutionLaunchDataParams(
193 source.fullName,
194 kind: ExecutableKind.SERVER).toNotification());
195 librarySources.remove(source); 196 librarySources.remove(source);
196 } 197 }
197 for (Source source in librarySources) { 198 for (Source source in librarySources) {
198 server.sendNotification( 199 _sendKindNotification(source.fullName, ExecutableKind.NOT_EXECUTABLE);
199 new ExecutionLaunchDataParams(
200 source.fullName,
201 kind: ExecutableKind.NOT_EXECUTABLE).toNotification());
202 } 200 }
203 for (Source source in context.htmlSources) { 201 for (Source source in context.htmlSources) {
204 List<Source> libraries = context.getLibrariesReferencedFromHtml(source); 202 String filePath = source.fullName;
205 server.sendNotification( 203 if (_isInAnalysisRoot(filePath)) {
206 new ExecutionLaunchDataParams( 204 List<Source> libraries = context.getLibrariesReferencedFromHtml(source );
207 source.fullName, 205 server.sendNotification(
208 referencedFiles: _getFullNames(libraries)).toNotification()); 206 new ExecutionLaunchDataParams(
207 filePath,
208 referencedFiles: _getFullNames(libraries)).toNotification());
209 }
209 } 210 }
210 } 211 }
211 } 212 }
212 213
214 /**
215 * Send a notification indicating the [kind] of the file with the given
216 * [filePath], but only if the file is in an analysis root.
217 */
218 void _sendKindNotification(String filePath, ExecutableKind kind) {
219 if (_isInAnalysisRoot(filePath)) {
220 server.sendNotification(
221 new ExecutionLaunchDataParams(filePath, kind: kind).toNotification());
222 }
223 }
224
213 static List<String> _getFullNames(List<Source> sources) { 225 static List<String> _getFullNames(List<Source> sources) {
214 return sources.map((Source source) => source.fullName).toList(); 226 return sources.map((Source source) => source.fullName).toList();
215 } 227 }
216 } 228 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/domain_execution_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698