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 analysis.server; | 5 library analysis.server; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:math' show max; | 9 import 'dart:math' show max; |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 /** | 61 /** |
62 * Instances of the class [AnalysisServer] implement a server that listens on a | 62 * Instances of the class [AnalysisServer] implement a server that listens on a |
63 * [CommunicationChannel] for analysis requests and process them. | 63 * [CommunicationChannel] for analysis requests and process them. |
64 */ | 64 */ |
65 class AnalysisServer { | 65 class AnalysisServer { |
66 /** | 66 /** |
67 * The version of the analysis server. The value should be replaced | 67 * The version of the analysis server. The value should be replaced |
68 * automatically during the build. | 68 * automatically during the build. |
69 */ | 69 */ |
70 static final String VERSION = '1.0.0'; | 70 static final String VERSION = '1.1.0'; |
71 | 71 |
72 /** | 72 /** |
73 * The number of milliseconds to perform operations before inserting | 73 * The number of milliseconds to perform operations before inserting |
74 * a 1 millisecond delay so that the VM and dart:io can deliver content | 74 * a 1 millisecond delay so that the VM and dart:io can deliver content |
75 * to stdin. This should be removed once the underlying problem is fixed. | 75 * to stdin. This should be removed once the underlying problem is fixed. |
76 */ | 76 */ |
77 static int performOperationDelayFreqency = 25; | 77 static int performOperationDelayFreqency = 25; |
78 | 78 |
79 /** | 79 /** |
80 * The channel from which requests are received and to which responses should | 80 * The channel from which requests are received and to which responses should |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 /** | 347 /** |
348 * Return the preferred [AnalysisContext] for analyzing the given [path]. | 348 * Return the preferred [AnalysisContext] for analyzing the given [path]. |
349 * This will be the context that explicitly contains the path, if any such | 349 * This will be the context that explicitly contains the path, if any such |
350 * context exists, otherwise it will be the first analysis context that | 350 * context exists, otherwise it will be the first analysis context that |
351 * implicitly analyzes it. Return `null` if no context is analyzing the | 351 * implicitly analyzes it. Return `null` if no context is analyzing the |
352 * path. | 352 * path. |
353 */ | 353 */ |
354 AnalysisContext getAnalysisContext(String path) { | 354 AnalysisContext getAnalysisContext(String path) { |
355 // try to find a containing context | 355 // try to find a containing context |
356 for (Folder folder in folderMap.keys) { | 356 for (Folder folder in folderMap.keys) { |
357 if (folder.contains(path)) { | 357 if (folder.path == path || folder.contains(path)) { |
358 return folderMap[folder]; | 358 return folderMap[folder]; |
359 } | 359 } |
360 } | 360 } |
| 361 Resource resource = resourceProvider.getResource(path); |
| 362 if (resource is Folder) { |
| 363 return null; |
| 364 } |
361 // check if there is a context that analyzed this source | 365 // check if there is a context that analyzed this source |
362 return getAnalysisContextForSource(getSource(path)); | 366 return getAnalysisContextForSource(getSource(path)); |
363 } | 367 } |
364 | 368 |
365 /** | 369 /** |
366 * Return any [AnalysisContext] that is analyzing the given [source], either | 370 * Return any [AnalysisContext] that is analyzing the given [source], either |
367 * explicitly or implicitly. Return `null` if there is no such context. | 371 * explicitly or implicitly. Return `null` if there is no such context. |
368 */ | 372 */ |
369 AnalysisContext getAnalysisContextForSource(Source source) { | 373 AnalysisContext getAnalysisContextForSource(Source source) { |
370 for (AnalysisContext context in folderMap.values) { | 374 for (AnalysisContext context in folderMap.values) { |
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1257 new DateTime.now().millisecondsSinceEpoch - | 1261 new DateTime.now().millisecondsSinceEpoch - |
1258 request.clientRequestTime; | 1262 request.clientRequestTime; |
1259 requestLatency += latency; | 1263 requestLatency += latency; |
1260 maxLatency = max(maxLatency, latency); | 1264 maxLatency = max(maxLatency, latency); |
1261 if (latency > 150) { | 1265 if (latency > 150) { |
1262 ++slowRequestCount; | 1266 ++slowRequestCount; |
1263 } | 1267 } |
1264 } | 1268 } |
1265 } | 1269 } |
1266 } | 1270 } |
OLD | NEW |