| 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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 361 |
| 362 /** | 362 /** |
| 363 * Return the preferred [AnalysisContext] for analyzing the given [path]. | 363 * Return the preferred [AnalysisContext] for analyzing the given [path]. |
| 364 * This will be the context that explicitly contains the path, if any such | 364 * This will be the context that explicitly contains the path, if any such |
| 365 * context exists, otherwise it will be the first analysis context that | 365 * context exists, otherwise it will be the first analysis context that |
| 366 * implicitly analyzes it. Return `null` if no context is analyzing the | 366 * implicitly analyzes it. Return `null` if no context is analyzing the |
| 367 * path. | 367 * path. |
| 368 */ | 368 */ |
| 369 AnalysisContext getAnalysisContext(String path) { | 369 AnalysisContext getAnalysisContext(String path) { |
| 370 // try to find a containing context | 370 // try to find a containing context |
| 371 Folder containingFolder = null; |
| 371 for (Folder folder in folderMap.keys) { | 372 for (Folder folder in folderMap.keys) { |
| 372 if (folder.path == path || folder.contains(path)) { | 373 if (folder.path == path || folder.contains(path)) { |
| 373 return folderMap[folder]; | 374 if (containingFolder == null) { |
| 375 containingFolder = folder; |
| 376 } else if (containingFolder.path.length < folder.path.length) { |
| 377 containingFolder = folder; |
| 378 } |
| 374 } | 379 } |
| 375 } | 380 } |
| 381 if (containingFolder != null) { |
| 382 return folderMap[containingFolder]; |
| 383 } |
| 376 Resource resource = resourceProvider.getResource(path); | 384 Resource resource = resourceProvider.getResource(path); |
| 377 if (resource is Folder) { | 385 if (resource is Folder) { |
| 378 return null; | 386 return null; |
| 379 } | 387 } |
| 380 // check if there is a context that analyzed this source | 388 // check if there is a context that analyzed this source |
| 381 return getAnalysisContextForSource(getSource(path)); | 389 return getAnalysisContextForSource(getSource(path)); |
| 382 } | 390 } |
| 383 | 391 |
| 384 /** | 392 /** |
| 385 * Return any [AnalysisContext] that is analyzing the given [source], either | 393 * Return any [AnalysisContext] that is analyzing the given [source], either |
| (...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1278 new DateTime.now().millisecondsSinceEpoch - | 1286 new DateTime.now().millisecondsSinceEpoch - |
| 1279 request.clientRequestTime; | 1287 request.clientRequestTime; |
| 1280 requestLatency += latency; | 1288 requestLatency += latency; |
| 1281 maxLatency = max(maxLatency, latency); | 1289 maxLatency = max(maxLatency, latency); |
| 1282 if (latency > 150) { | 1290 if (latency > 150) { |
| 1283 ++slowRequestCount; | 1291 ++slowRequestCount; |
| 1284 } | 1292 } |
| 1285 } | 1293 } |
| 1286 } | 1294 } |
| 1287 } | 1295 } |
| OLD | NEW |