| 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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 * file with the given [path]. If the file is not a Dart file or cannot | 535 * file with the given [path]. If the file is not a Dart file or cannot |
| 536 * be analyzed, the [Future] completes with `null`. | 536 * be analyzed, the [Future] completes with `null`. |
| 537 * | 537 * |
| 538 * The [path] must be absolute and normalized. | 538 * The [path] must be absolute and normalized. |
| 539 * | 539 * |
| 540 * The [path] can be any file - explicitly or implicitly analyzed, or neither. | 540 * The [path] can be any file - explicitly or implicitly analyzed, or neither. |
| 541 * | 541 * |
| 542 * If the driver has the cached analysis result for the file, it is returned. | 542 * If the driver has the cached analysis result for the file, it is returned. |
| 543 * | 543 * |
| 544 * Otherwise causes the analysis state to transition to "analyzing" (if it is | 544 * Otherwise causes the analysis state to transition to "analyzing" (if it is |
| 545 * not in that state already), the driver will read the file and produce the | 545 * not in that state already), the driver will produce the analysis result for |
| 546 * analysis result for it, which is consistent with the current file state | 546 * it, which is consistent with the current file state (including new states |
| 547 * (including the new state of the file), prior to the next time the analysis | 547 * of the files previously reported using [changeFile]), prior to the next |
| 548 * state transitions to "idle". | 548 * time the analysis state transitions to "idle". |
| 549 */ | 549 */ |
| 550 Future<AnalysisResult> getResult(String path) { | 550 Future<AnalysisResult> getResult(String path) { |
| 551 if (!_fileTracker.fsState.hasUri(path)) { | 551 if (!_fileTracker.fsState.hasUri(path)) { |
| 552 return new Future.value(); | 552 return new Future.value(); |
| 553 } | 553 } |
| 554 | 554 |
| 555 // Return the cached result. | 555 // Return the cached result. |
| 556 { | 556 { |
| 557 AnalysisResult result = _priorityResults[path]; | 557 AnalysisResult result = _priorityResults[path]; |
| 558 if (result != null) { | 558 if (result != null) { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 // Check for the cached result. | 694 // Check for the cached result. |
| 695 String key = _getResolvedUnitKey(libraryFile, file); | 695 String key = _getResolvedUnitKey(libraryFile, file); |
| 696 List<int> bytes = _byteStore.get(key); | 696 List<int> bytes = _byteStore.get(key); |
| 697 if (bytes != null) { | 697 if (bytes != null) { |
| 698 return _getAnalysisResultFromBytes(file, bytes); | 698 return _getAnalysisResultFromBytes(file, bytes); |
| 699 } | 699 } |
| 700 } | 700 } |
| 701 | 701 |
| 702 // We need the fully resolved unit, or the result is not cached. | 702 // We need the fully resolved unit, or the result is not cached. |
| 703 return _logger.run('Compute analysis result for $path', () { | 703 return _logger.run('Compute analysis result for $path', () { |
| 704 FileState file = _fileTracker.verifyApiSignature(path); | 704 FileState file = fsState.getFileForPath(path); |
| 705 | 705 |
| 706 // Prepare the library file - the file itself, or the known library. | 706 // Prepare the library file - the file itself, or the known library. |
| 707 FileState library = getLibraryFile(file); | 707 FileState library = getLibraryFile(file); |
| 708 if (library == null) { | 708 if (library == null) { |
| 709 return null; | 709 return null; |
| 710 } | 710 } |
| 711 | 711 |
| 712 try { | 712 try { |
| 713 LibraryContext libraryContext = _createLibraryContext(library); | 713 LibraryContext libraryContext = _createLibraryContext(library); |
| 714 try { | 714 try { |
| (...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1786 libraryDeclarations.add(new TopLevelDeclarationInSource( | 1786 libraryDeclarations.add(new TopLevelDeclarationInSource( |
| 1787 file.source, declaration, isExported)); | 1787 file.source, declaration, isExported)); |
| 1788 } | 1788 } |
| 1789 } | 1789 } |
| 1790 } | 1790 } |
| 1791 | 1791 |
| 1792 // We're not done yet. | 1792 // We're not done yet. |
| 1793 return false; | 1793 return false; |
| 1794 } | 1794 } |
| 1795 } | 1795 } |
| OLD | NEW |