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:core'; | 9 import 'dart:core'; |
10 import 'dart:io' as io; | 10 import 'dart:io' as io; |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 nd.AnalysisDriver getAnalysisDriver(String path) { | 578 nd.AnalysisDriver getAnalysisDriver(String path) { |
579 Iterable<nd.AnalysisDriver> drivers = driverMap.values; | 579 Iterable<nd.AnalysisDriver> drivers = driverMap.values; |
580 if (drivers.isNotEmpty) { | 580 if (drivers.isNotEmpty) { |
581 return drivers.firstWhere((driver) => driver.isAddedFile(path), | 581 return drivers.firstWhere((driver) => driver.isAddedFile(path), |
582 orElse: () => drivers.first); | 582 orElse: () => drivers.first); |
583 } | 583 } |
584 return null; | 584 return null; |
585 } | 585 } |
586 | 586 |
587 /** | 587 /** |
588 * Return the analysis result for the file with the given [path]. | 588 * Return the analysis result for the file with the given [path]. The file is |
| 589 * analyzed in one of the analysis drivers to which the file was added, |
| 590 * otherwise in the first driver, otherwise `null` is returned. |
589 */ | 591 */ |
590 Future<nd.AnalysisResult> getAnalysisResult(String path) async { | 592 Future<nd.AnalysisResult> getAnalysisResult(String path) async { |
591 nd.AnalysisResult result = priorityFileResults[path]; | 593 nd.AnalysisResult result = priorityFileResults[path]; |
592 if (result != null) { | 594 if (result != null) { |
593 return result; | 595 return result; |
594 } | 596 } |
595 nd.AnalysisDriver driver = getAnalysisDriver(path); | 597 nd.AnalysisDriver driver = getAnalysisDriver(path); |
596 return driver.getResult(path); | 598 return driver?.getResult(path); |
597 } | 599 } |
598 | 600 |
599 CompilationUnitElement getCompilationUnitElement(String file) { | 601 CompilationUnitElement getCompilationUnitElement(String file) { |
600 ContextSourcePair pair = getContextSourcePair(file); | 602 ContextSourcePair pair = getContextSourcePair(file); |
601 if (pair == null) { | 603 if (pair == null) { |
602 return null; | 604 return null; |
603 } | 605 } |
604 // prepare AnalysisContext and Source | 606 // prepare AnalysisContext and Source |
605 AnalysisContext context = pair.context; | 607 AnalysisContext context = pair.context; |
606 Source unitSource = pair.source; | 608 Source unitSource = pair.source; |
(...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 /** | 1992 /** |
1991 * The [PerformanceTag] for time spent in server request handlers. | 1993 * The [PerformanceTag] for time spent in server request handlers. |
1992 */ | 1994 */ |
1993 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); | 1995 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); |
1994 | 1996 |
1995 /** | 1997 /** |
1996 * The [PerformanceTag] for time spent in split store microtasks. | 1998 * The [PerformanceTag] for time spent in split store microtasks. |
1997 */ | 1999 */ |
1998 static PerformanceTag splitStore = new PerformanceTag('splitStore'); | 2000 static PerformanceTag splitStore = new PerformanceTag('splitStore'); |
1999 } | 2001 } |
OLD | NEW |