| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'dart:typed_data'; | 7 import 'dart:typed_data'; |
| 8 | 8 |
| 9 import 'package:analyzer/context/declared_variables.dart'; | 9 import 'package:analyzer/context/declared_variables.dart'; |
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 return task.completer.future; | 498 return task.completer.future; |
| 499 } | 499 } |
| 500 | 500 |
| 501 /** | 501 /** |
| 502 * Return a [Future] that completes with the [AnalysisDriverUnitIndex] for | 502 * Return a [Future] that completes with the [AnalysisDriverUnitIndex] for |
| 503 * the file with the given [path], or with `null` if the file cannot be | 503 * the file with the given [path], or with `null` if the file cannot be |
| 504 * analyzed. | 504 * analyzed. |
| 505 */ | 505 */ |
| 506 Future<AnalysisDriverUnitIndex> getIndex(String path) { | 506 Future<AnalysisDriverUnitIndex> getIndex(String path) { |
| 507 if (!_fsState.hasUri(path)) { | 507 if (!_fsState.hasUri(path)) { |
| 508 return null; | 508 return new Future.value(); |
| 509 } | 509 } |
| 510 var completer = new Completer<AnalysisDriverUnitIndex>(); | 510 var completer = new Completer<AnalysisDriverUnitIndex>(); |
| 511 _indexRequestedFiles | 511 _indexRequestedFiles |
| 512 .putIfAbsent(path, () => <Completer<AnalysisDriverUnitIndex>>[]) | 512 .putIfAbsent(path, () => <Completer<AnalysisDriverUnitIndex>>[]) |
| 513 .add(completer); | 513 .add(completer); |
| 514 _statusSupport.transitionToAnalyzing(); | 514 _statusSupport.transitionToAnalyzing(); |
| 515 _scheduler._notify(this); | 515 _scheduler._notify(this); |
| 516 return completer.future; | 516 return completer.future; |
| 517 } | 517 } |
| 518 | 518 |
| 519 /** | 519 /** |
| 520 * Return a [Future] that completes with a [AnalysisResult] for the Dart | 520 * Return a [Future] that completes with a [AnalysisResult] for the Dart |
| 521 * file with the given [path]. If the file is not a Dart file or cannot | 521 * file with the given [path]. If the file is not a Dart file or cannot |
| 522 * be analyzed, the [Future] completes with `null`. | 522 * be analyzed, the [Future] completes with `null`. |
| 523 * | 523 * |
| 524 * The [path] must be absolute and normalized. | 524 * The [path] must be absolute and normalized. |
| 525 * | 525 * |
| 526 * The [path] can be any file - explicitly or implicitly analyzed, or neither. | 526 * The [path] can be any file - explicitly or implicitly analyzed, or neither. |
| 527 * | 527 * |
| 528 * If the driver has the cached analysis result for the file, it is returned. | 528 * If the driver has the cached analysis result for the file, it is returned. |
| 529 * | 529 * |
| 530 * Otherwise causes the analysis state to transition to "analyzing" (if it is | 530 * Otherwise causes the analysis state to transition to "analyzing" (if it is |
| 531 * not in that state already), the driver will read the file and produce the | 531 * not in that state already), the driver will read the file and produce the |
| 532 * analysis result for it, which is consistent with the current file state | 532 * analysis result for it, which is consistent with the current file state |
| 533 * (including the new state of the file), prior to the next time the analysis | 533 * (including the new state of the file), prior to the next time the analysis |
| 534 * state transitions to "idle". | 534 * state transitions to "idle". |
| 535 */ | 535 */ |
| 536 Future<AnalysisResult> getResult(String path) { | 536 Future<AnalysisResult> getResult(String path) { |
| 537 if (!_fsState.hasUri(path)) { | 537 if (!_fsState.hasUri(path)) { |
| 538 return null; | 538 return new Future.value(); |
| 539 } | 539 } |
| 540 | 540 |
| 541 // Return the cached result. | 541 // Return the cached result. |
| 542 { | 542 { |
| 543 AnalysisResult result = _priorityResults[path]; | 543 AnalysisResult result = _priorityResults[path]; |
| 544 if (result != null) { | 544 if (result != null) { |
| 545 return new Future.value(result); | 545 return new Future.value(result); |
| 546 } | 546 } |
| 547 } | 547 } |
| 548 | 548 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 568 _scheduler._notify(this); | 568 _scheduler._notify(this); |
| 569 return task.completer.future; | 569 return task.completer.future; |
| 570 } | 570 } |
| 571 | 571 |
| 572 /** | 572 /** |
| 573 * Return a [Future] that completes with the [CompilationUnitElement] for the | 573 * Return a [Future] that completes with the [CompilationUnitElement] for the |
| 574 * file with the given [path], or with `null` if the file cannot be analyzed. | 574 * file with the given [path], or with `null` if the file cannot be analyzed. |
| 575 */ | 575 */ |
| 576 Future<CompilationUnitElement> getUnitElement(String path) { | 576 Future<CompilationUnitElement> getUnitElement(String path) { |
| 577 if (!_fsState.hasUri(path)) { | 577 if (!_fsState.hasUri(path)) { |
| 578 return null; | 578 return new Future.value(); |
| 579 } | 579 } |
| 580 var completer = new Completer<CompilationUnitElement>(); | 580 var completer = new Completer<CompilationUnitElement>(); |
| 581 _unitElementRequestedFiles | 581 _unitElementRequestedFiles |
| 582 .putIfAbsent(path, () => <Completer<CompilationUnitElement>>[]) | 582 .putIfAbsent(path, () => <Completer<CompilationUnitElement>>[]) |
| 583 .add(completer); | 583 .add(completer); |
| 584 _statusSupport.transitionToAnalyzing(); | 584 _statusSupport.transitionToAnalyzing(); |
| 585 _scheduler._notify(this); | 585 _scheduler._notify(this); |
| 586 return completer.future; | 586 return completer.future; |
| 587 } | 587 } |
| 588 | 588 |
| (...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1695 libraryDeclarations.add(new TopLevelDeclarationInSource( | 1695 libraryDeclarations.add(new TopLevelDeclarationInSource( |
| 1696 file.source, declaration, isExported)); | 1696 file.source, declaration, isExported)); |
| 1697 } | 1697 } |
| 1698 } | 1698 } |
| 1699 } | 1699 } |
| 1700 | 1700 |
| 1701 // We're not done yet. | 1701 // We're not done yet. |
| 1702 return false; | 1702 return false; |
| 1703 } | 1703 } |
| 1704 } | 1704 } |
| OLD | NEW |