Chromium Code Reviews| 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'; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 onFileAnalyzed = null; | 147 onFileAnalyzed = null; |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 return new ExecutionSetSubscriptionsResult().toResponse(request.id); | 150 return new ExecutionSetSubscriptionsResult().toResponse(request.id); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void _fileAnalyzed(ChangeNotice notice) { | 153 void _fileAnalyzed(ChangeNotice notice) { |
| 154 ServerPerformanceStatistics.executionNotifications.makeCurrentWhile(() { | 154 ServerPerformanceStatistics.executionNotifications.makeCurrentWhile(() { |
| 155 Source source = notice.source; | 155 Source source = notice.source; |
| 156 String filePath = source.fullName; | 156 String filePath = source.fullName; |
| 157 // check files | |
| 158 bool isDartFile = notice.resolvedDartUnit != null; | |
| 159 bool isHtmlFile = AnalysisEngine.isHtmlFileName(filePath); | |
|
Brian Wilkerson
2015/05/24 15:53:31
Why not "notice.resolvedHtmlUnit != null"?
| |
| 160 if (!isDartFile && !isHtmlFile) { | |
| 161 return; | |
| 162 } | |
| 163 // prepare context | |
| 157 AnalysisContext context = server.getContainingContext(filePath); | 164 AnalysisContext context = server.getContainingContext(filePath); |
| 158 if (context == null) { | 165 if (context == null) { |
| 159 return; | 166 return; |
| 160 } | 167 } |
| 161 if (AnalysisEngine.isDartFileName(filePath)) { | 168 // analyze the file |
| 169 if (isDartFile) { | |
| 162 ExecutableKind kind = ExecutableKind.NOT_EXECUTABLE; | 170 ExecutableKind kind = ExecutableKind.NOT_EXECUTABLE; |
| 163 if (context.isClientLibrary(source)) { | 171 if (context.isClientLibrary(source)) { |
| 164 kind = ExecutableKind.CLIENT; | 172 kind = ExecutableKind.CLIENT; |
| 165 if (context.isServerLibrary(source)) { | 173 if (context.isServerLibrary(source)) { |
| 166 kind = ExecutableKind.EITHER; | 174 kind = ExecutableKind.EITHER; |
| 167 } | 175 } |
| 168 } else if (context.isServerLibrary(source)) { | 176 } else if (context.isServerLibrary(source)) { |
| 169 kind = ExecutableKind.SERVER; | 177 kind = ExecutableKind.SERVER; |
| 170 } | 178 } |
| 171 server.sendNotification( | 179 server.sendNotification( |
| 172 new ExecutionLaunchDataParams(filePath, kind: kind) | 180 new ExecutionLaunchDataParams(filePath, kind: kind) |
| 173 .toNotification()); | 181 .toNotification()); |
| 174 } else if (AnalysisEngine.isHtmlFileName(filePath)) { | 182 } else if (isHtmlFile) { |
| 175 List<Source> libraries = context.getLibrariesReferencedFromHtml(source); | 183 List<Source> libraries = context.getLibrariesReferencedFromHtml(source); |
| 176 server.sendNotification(new ExecutionLaunchDataParams(filePath, | 184 server.sendNotification(new ExecutionLaunchDataParams(filePath, |
| 177 referencedFiles: _getFullNames(libraries)).toNotification()); | 185 referencedFiles: _getFullNames(libraries)).toNotification()); |
| 178 } | 186 } |
| 179 }); | 187 }); |
| 180 } | 188 } |
| 181 | 189 |
| 182 /** | 190 /** |
| 183 * 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 |
| 184 * analysis root. | 192 * analysis root. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 if (_isInAnalysisRoot(filePath)) { | 234 if (_isInAnalysisRoot(filePath)) { |
| 227 server.sendNotification( | 235 server.sendNotification( |
| 228 new ExecutionLaunchDataParams(filePath, kind: kind).toNotification()); | 236 new ExecutionLaunchDataParams(filePath, kind: kind).toNotification()); |
| 229 } | 237 } |
| 230 } | 238 } |
| 231 | 239 |
| 232 static List<String> _getFullNames(List<Source> sources) { | 240 static List<String> _getFullNames(List<Source> sources) { |
| 233 return sources.map((Source source) => source.fullName).toList(); | 241 return sources.map((Source source) => source.fullName).toList(); |
| 234 } | 242 } |
| 235 } | 243 } |
| OLD | NEW |