| 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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 .add(completer); | 624 .add(completer); |
| 625 _scheduler.notify(this); | 625 _scheduler.notify(this); |
| 626 return completer.future; | 626 return completer.future; |
| 627 } | 627 } |
| 628 | 628 |
| 629 /** | 629 /** |
| 630 * Return a [Future] that completes with the signature for the | 630 * Return a [Future] that completes with the signature for the |
| 631 * [UnitElementResult] for the file with the given [path], or with `null` if | 631 * [UnitElementResult] for the file with the given [path], or with `null` if |
| 632 * the file cannot be analyzed. | 632 * the file cannot be analyzed. |
| 633 * | 633 * |
| 634 * The signature is based on the content of the file, and the transitive | 634 * The signature is based the APIs of the files of the library (including |
| 635 * closure of files imported and exported by the the library of the requested | 635 * the file itself) of the requested file and the transitive closure of files |
| 636 * file. | 636 * imported and exported by the the library. |
| 637 */ | 637 */ |
| 638 Future<String> getUnitElementSignature(String path) { | 638 Future<String> getUnitElementSignature(String path) { |
| 639 if (!_fileTracker.fsState.hasUri(path)) { | 639 if (!_fileTracker.fsState.hasUri(path)) { |
| 640 return new Future.value(); | 640 return new Future.value(); |
| 641 } | 641 } |
| 642 var completer = new Completer<String>(); | 642 var completer = new Completer<String>(); |
| 643 _unitElementSignatureRequests | 643 _unitElementSignatureRequests |
| 644 .putIfAbsent(path, () => <Completer<String>>[]) | 644 .putIfAbsent(path, () => <Completer<String>>[]) |
| 645 .add(completer); | 645 .add(completer); |
| 646 _scheduler.notify(this); | 646 _scheduler.notify(this); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 FileState file = _fileTracker.fsState.getFileForPath(path); | 813 FileState file = _fileTracker.fsState.getFileForPath(path); |
| 814 FileState library = file.library ?? file; | 814 FileState library = file.library ?? file; |
| 815 | 815 |
| 816 // Create the AnalysisContext to resynthesize elements in. | 816 // Create the AnalysisContext to resynthesize elements in. |
| 817 LibraryContext libraryContext = _createLibraryContext(library); | 817 LibraryContext libraryContext = _createLibraryContext(library); |
| 818 | 818 |
| 819 // Resynthesize the CompilationUnitElement in the context. | 819 // Resynthesize the CompilationUnitElement in the context. |
| 820 try { | 820 try { |
| 821 CompilationUnitElement element = | 821 CompilationUnitElement element = |
| 822 libraryContext.computeUnitElement(library.source, file.source); | 822 libraryContext.computeUnitElement(library.source, file.source); |
| 823 String signature = _getResolvedUnitSignature(library, file); | 823 String signature = library.transitiveSignature; |
| 824 return new UnitElementResult(path, file.contentHash, signature, element); | 824 return new UnitElementResult(path, file.contentHash, signature, element); |
| 825 } finally { | 825 } finally { |
| 826 libraryContext.dispose(); | 826 libraryContext.dispose(); |
| 827 } | 827 } |
| 828 } | 828 } |
| 829 | 829 |
| 830 String _computeUnitElementSignature(String path) { | 830 String _computeUnitElementSignature(String path) { |
| 831 FileState file = _fileTracker.fsState.getFileForPath(path); | 831 FileState file = _fileTracker.fsState.getFileForPath(path); |
| 832 FileState library = file.library ?? file; | 832 FileState library = file.library ?? file; |
| 833 return _getResolvedUnitSignature(library, file); | 833 return library.transitiveSignature; |
| 834 } | 834 } |
| 835 | 835 |
| 836 /** | 836 /** |
| 837 * Creates a new [FileTracker] object and stores it in [_fileTracker]. | 837 * Creates a new [FileTracker] object and stores it in [_fileTracker]. |
| 838 * | 838 * |
| 839 * This is used both on initial construction and whenever the configuration | 839 * This is used both on initial construction and whenever the configuration |
| 840 * changes. | 840 * changes. |
| 841 */ | 841 */ |
| 842 void _createFileTracker(PerformanceLog logger) { | 842 void _createFileTracker(PerformanceLog logger) { |
| 843 _fillSalt(); | 843 _fillSalt(); |
| (...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1698 * The path of the file, absolute and normalized. | 1698 * The path of the file, absolute and normalized. |
| 1699 */ | 1699 */ |
| 1700 final String path; | 1700 final String path; |
| 1701 | 1701 |
| 1702 /** | 1702 /** |
| 1703 * The MD5 hash of the file content. | 1703 * The MD5 hash of the file content. |
| 1704 */ | 1704 */ |
| 1705 final String contentHash; | 1705 final String contentHash; |
| 1706 | 1706 |
| 1707 /** | 1707 /** |
| 1708 * The signature of the [element] based on the content of the file, and the | 1708 * The signature of the [element] is based the APIs of the files of the |
| 1709 * transitive closure of files imported and exported by the the library of | 1709 * library (including the file itself) of the requested file and the |
| 1710 * the requested file. | 1710 * transitive closure of files imported and exported by the the library. |
| 1711 */ | 1711 */ |
| 1712 final String signature; | 1712 final String signature; |
| 1713 | 1713 |
| 1714 /** | 1714 /** |
| 1715 * The element of the file. | 1715 * The element of the file. |
| 1716 */ | 1716 */ |
| 1717 final CompilationUnitElement element; | 1717 final CompilationUnitElement element; |
| 1718 | 1718 |
| 1719 UnitElementResult(this.path, this.contentHash, this.signature, this.element); | 1719 UnitElementResult(this.path, this.contentHash, this.signature, this.element); |
| 1720 } | 1720 } |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1904 libraryDeclarations.add(new TopLevelDeclarationInSource( | 1904 libraryDeclarations.add(new TopLevelDeclarationInSource( |
| 1905 file.source, declaration, isExported)); | 1905 file.source, declaration, isExported)); |
| 1906 } | 1906 } |
| 1907 } | 1907 } |
| 1908 } | 1908 } |
| 1909 | 1909 |
| 1910 // We're not done yet. | 1910 // We're not done yet. |
| 1911 return false; | 1911 return false; |
| 1912 } | 1912 } |
| 1913 } | 1913 } |
| OLD | NEW |