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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 AnalysisContext getAnalysisContextForSource(Source source) { | 554 AnalysisContext getAnalysisContextForSource(Source source) { |
555 for (AnalysisContext context in analysisContexts) { | 555 for (AnalysisContext context in analysisContexts) { |
556 SourceKind kind = context.getKindOf(source); | 556 SourceKind kind = context.getKindOf(source); |
557 if (kind != SourceKind.UNKNOWN) { | 557 if (kind != SourceKind.UNKNOWN) { |
558 return context; | 558 return context; |
559 } | 559 } |
560 } | 560 } |
561 return null; | 561 return null; |
562 } | 562 } |
563 | 563 |
| 564 /** |
| 565 * Return the analysis driver to which the file with the given [path] is |
| 566 * added if exists, otherwise the first driver, otherwise `null`. |
| 567 */ |
| 568 nd.AnalysisDriver getAnalysisDriver(String path) { |
| 569 Iterable<nd.AnalysisDriver> drivers = driverMap.values; |
| 570 if (drivers.isNotEmpty) { |
| 571 return drivers.firstWhere((driver) => driver.isAddedFile(path), |
| 572 orElse: () => drivers.first); |
| 573 } |
| 574 return null; |
| 575 } |
| 576 |
564 CompilationUnitElement getCompilationUnitElement(String file) { | 577 CompilationUnitElement getCompilationUnitElement(String file) { |
565 ContextSourcePair pair = getContextSourcePair(file); | 578 ContextSourcePair pair = getContextSourcePair(file); |
566 if (pair == null) { | 579 if (pair == null) { |
567 return null; | 580 return null; |
568 } | 581 } |
569 // prepare AnalysisContext and Source | 582 // prepare AnalysisContext and Source |
570 AnalysisContext context = pair.context; | 583 AnalysisContext context = pair.context; |
571 Source unitSource = pair.source; | 584 Source unitSource = pair.source; |
572 if (context == null || unitSource == null) { | 585 if (context == null || unitSource == null) { |
573 return null; | 586 return null; |
(...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1943 /** | 1956 /** |
1944 * The [PerformanceTag] for time spent in server request handlers. | 1957 * The [PerformanceTag] for time spent in server request handlers. |
1945 */ | 1958 */ |
1946 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); | 1959 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); |
1947 | 1960 |
1948 /** | 1961 /** |
1949 * The [PerformanceTag] for time spent in split store microtasks. | 1962 * The [PerformanceTag] for time spent in split store microtasks. |
1950 */ | 1963 */ |
1951 static PerformanceTag splitStore = new PerformanceTag('splitStore'); | 1964 static PerformanceTag splitStore = new PerformanceTag('splitStore'); |
1952 } | 1965 } |
OLD | NEW |