| OLD | NEW |
| 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'; |
| 11 import 'package:analysis_server/src/constants.dart'; | 11 import 'package:analysis_server/src/constants.dart'; |
| 12 import 'package:analysis_server/src/protocol.dart'; | 12 import 'package:analysis_server/src/protocol.dart'; |
| 13 import 'package:analyzer/file_system/file_system.dart'; | 13 import 'package:analyzer/file_system/file_system.dart'; |
| 14 import 'package:analyzer/src/generated/engine.dart'; | 14 import 'package:analyzer/src/generated/engine.dart'; |
| 15 import 'package:analyzer/src/generated/source.dart'; | 15 import 'package:analyzer/src/generated/source.dart'; |
| 16 import 'package:analyzer/src/generated/utilities_general.dart'; | |
| 17 | 16 |
| 18 /** | 17 /** |
| 19 * Instances of the class [ExecutionDomainHandler] implement a [RequestHandler] | 18 * Instances of the class [ExecutionDomainHandler] implement a [RequestHandler] |
| 20 * that handles requests in the `execution` domain. | 19 * that handles requests in the `execution` domain. |
| 21 */ | 20 */ |
| 22 class ExecutionDomainHandler implements RequestHandler { | 21 class ExecutionDomainHandler implements RequestHandler { |
| 23 /** | 22 /** |
| 24 * The analysis server that is using this handler to process requests. | 23 * The analysis server that is using this handler to process requests. |
| 25 */ | 24 */ |
| 26 final AnalysisServer server; | 25 final AnalysisServer server; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 } else { | 151 } else { |
| 153 if (onFileAnalyzed != null) { | 152 if (onFileAnalyzed != null) { |
| 154 onFileAnalyzed.cancel(); | 153 onFileAnalyzed.cancel(); |
| 155 onFileAnalyzed = null; | 154 onFileAnalyzed = null; |
| 156 } | 155 } |
| 157 } | 156 } |
| 158 return new ExecutionSetSubscriptionsResult().toResponse(request.id); | 157 return new ExecutionSetSubscriptionsResult().toResponse(request.id); |
| 159 } | 158 } |
| 160 | 159 |
| 161 void _fileAnalyzed(ChangeNotice notice) { | 160 void _fileAnalyzed(ChangeNotice notice) { |
| 162 PerformanceTag prevTag = | 161 ServerPerformanceStatistics.executionNotifications.makeCurrentWhile(() { |
| 163 ServerPerformanceStatistics.executionNotifications.makeCurrent(); | |
| 164 try { | |
| 165 Source source = notice.source; | 162 Source source = notice.source; |
| 166 String filePath = source.fullName; | 163 String filePath = source.fullName; |
| 167 if (!_isInAnalysisRoot(filePath)) { | 164 if (!_isInAnalysisRoot(filePath)) { |
| 168 return; | 165 return; |
| 169 } | 166 } |
| 170 AnalysisContext context = server.getAnalysisContext(filePath); | 167 AnalysisContext context = server.getAnalysisContext(filePath); |
| 171 if (AnalysisEngine.isDartFileName(filePath)) { | 168 if (AnalysisEngine.isDartFileName(filePath)) { |
| 172 ExecutableKind kind = ExecutableKind.NOT_EXECUTABLE; | 169 ExecutableKind kind = ExecutableKind.NOT_EXECUTABLE; |
| 173 if (context.isClientLibrary(source)) { | 170 if (context.isClientLibrary(source)) { |
| 174 kind = ExecutableKind.CLIENT; | 171 kind = ExecutableKind.CLIENT; |
| 175 if (context.isServerLibrary(source)) { | 172 if (context.isServerLibrary(source)) { |
| 176 kind = ExecutableKind.EITHER; | 173 kind = ExecutableKind.EITHER; |
| 177 } | 174 } |
| 178 } else if (context.isServerLibrary(source)) { | 175 } else if (context.isServerLibrary(source)) { |
| 179 kind = ExecutableKind.SERVER; | 176 kind = ExecutableKind.SERVER; |
| 180 } | 177 } |
| 181 server.sendNotification( | 178 server.sendNotification( |
| 182 new ExecutionLaunchDataParams(filePath, kind: kind).toNotification()
); | 179 new ExecutionLaunchDataParams(filePath, kind: kind).toNotification()
); |
| 183 } else if (AnalysisEngine.isHtmlFileName(filePath)) { | 180 } else if (AnalysisEngine.isHtmlFileName(filePath)) { |
| 184 List<Source> libraries = context.getLibrariesReferencedFromHtml(source); | 181 List<Source> libraries = context.getLibrariesReferencedFromHtml(source); |
| 185 server.sendNotification( | 182 server.sendNotification( |
| 186 new ExecutionLaunchDataParams( | 183 new ExecutionLaunchDataParams( |
| 187 filePath, | 184 filePath, |
| 188 referencedFiles: _getFullNames(libraries)).toNotification()); | 185 referencedFiles: _getFullNames(libraries)).toNotification()); |
| 189 } | 186 } |
| 190 } finally { | 187 }); |
| 191 prevTag.makeCurrent(); | |
| 192 } | |
| 193 } | 188 } |
| 194 | 189 |
| 195 /** | 190 /** |
| 196 * Return `true` if the given [filePath] represents a file that is in an | 191 * Return `true` if the given [filePath] represents a file that is in an |
| 197 * analysis root. | 192 * analysis root. |
| 198 */ | 193 */ |
| 199 bool _isInAnalysisRoot(String filePath) => | 194 bool _isInAnalysisRoot(String filePath) => |
| 200 server.contextDirectoryManager.isInAnalysisRoot(filePath); | 195 server.contextDirectoryManager.isInAnalysisRoot(filePath); |
| 201 | 196 |
| 202 void _reportCurrentFileStatus() { | 197 void _reportCurrentFileStatus() { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 if (_isInAnalysisRoot(filePath)) { | 236 if (_isInAnalysisRoot(filePath)) { |
| 242 server.sendNotification( | 237 server.sendNotification( |
| 243 new ExecutionLaunchDataParams(filePath, kind: kind).toNotification()); | 238 new ExecutionLaunchDataParams(filePath, kind: kind).toNotification()); |
| 244 } | 239 } |
| 245 } | 240 } |
| 246 | 241 |
| 247 static List<String> _getFullNames(List<Source> sources) { | 242 static List<String> _getFullNames(List<Source> sources) { |
| 248 return sources.map((Source source) => source.fullName).toList(); | 243 return sources.map((Source source) => source.fullName).toList(); |
| 249 } | 244 } |
| 250 } | 245 } |
| OLD | NEW |