Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: pkg/analyzer/lib/src/dart/element/element.dart

Issue 2335843003: Remove LibraryElement.isUpToDate(). (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 analyzer.src.dart.element.element; 5 library analyzer.src.dart.element.element;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:math' show min; 8 import 'dart:math' show min;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 5804 matching lines...) Expand 10 before | Expand all | Expand 10 after
5815 library._libraryCycle = null; 5815 library._libraryCycle = null;
5816 } 5816 }
5817 library.exportedLibraries.forEach(invalidate); 5817 library.exportedLibraries.forEach(invalidate);
5818 library.importedLibraries.forEach(invalidate); 5818 library.importedLibraries.forEach(invalidate);
5819 } 5819 }
5820 } 5820 }
5821 5821
5822 invalidate(this); 5822 invalidate(this);
5823 } 5823 }
5824 5824
5825 @override
5826 bool isUpToDate(int timeStamp) {
5827 Set<LibraryElement> visitedLibraries = new Set();
5828 return _safeIsUpToDate(this, timeStamp, visitedLibraries);
5829 }
5830
5831 /** 5825 /**
5832 * Set whether the library has the given [capability] to 5826 * Set whether the library has the given [capability] to
5833 * correspond to the given [value]. 5827 * correspond to the given [value].
5834 */ 5828 */
5835 void setResolutionCapability( 5829 void setResolutionCapability(
5836 LibraryResolutionCapability capability, bool value) { 5830 LibraryResolutionCapability capability, bool value) {
5837 _resolutionCapabilities = 5831 _resolutionCapabilities =
5838 BooleanArray.set(_resolutionCapabilities, capability.index, value); 5832 BooleanArray.set(_resolutionCapabilities, capability.index, value);
5839 } 5833 }
5840 5834
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
5878 } 5872 }
5879 5873
5880 /** 5874 /**
5881 * Return `true` if the [library] has the given [capability]. 5875 * Return `true` if the [library] has the given [capability].
5882 */ 5876 */
5883 static bool hasResolutionCapability( 5877 static bool hasResolutionCapability(
5884 LibraryElement library, LibraryResolutionCapability capability) { 5878 LibraryElement library, LibraryResolutionCapability capability) {
5885 return library is LibraryElementImpl && 5879 return library is LibraryElementImpl &&
5886 BooleanArray.get(library._resolutionCapabilities, capability.index); 5880 BooleanArray.get(library._resolutionCapabilities, capability.index);
5887 } 5881 }
5888
5889 /**
5890 * Return `true` if the given [library] is up to date with respect to the
5891 * given [timeStamp]. The set of [visitedLibraries] is used to prevent
5892 * infinite recursion in the case of mutually dependent libraries.
5893 */
5894 static bool _safeIsUpToDate(LibraryElement library, int timeStamp,
5895 Set<LibraryElement> visitedLibraries) {
5896 if (!visitedLibraries.contains(library)) {
5897 visitedLibraries.add(library);
5898 AnalysisContext context = library.context;
5899 // Check the defining compilation unit.
5900 if (timeStamp <
5901 context
5902 .getModificationStamp(library.definingCompilationUnit.source)) {
5903 return false;
5904 }
5905 // Check the parted compilation units.
5906 for (CompilationUnitElement element in library.parts) {
5907 if (timeStamp < context.getModificationStamp(element.source)) {
5908 return false;
5909 }
5910 }
5911 // Check the imported libraries.
5912 for (LibraryElement importedLibrary in library.importedLibraries) {
5913 if (!_safeIsUpToDate(importedLibrary, timeStamp, visitedLibraries)) {
5914 return false;
5915 }
5916 }
5917 // Check the exported libraries.
5918 for (LibraryElement exportedLibrary in library.exportedLibraries) {
5919 if (!_safeIsUpToDate(exportedLibrary, timeStamp, visitedLibraries)) {
5920 return false;
5921 }
5922 }
5923 }
5924 return true;
5925 }
5926 } 5882 }
5927 5883
5928 /** 5884 /**
5929 * Enum of possible resolution capabilities that a [LibraryElementImpl] has. 5885 * Enum of possible resolution capabilities that a [LibraryElementImpl] has.
5930 */ 5886 */
5931 enum LibraryResolutionCapability { 5887 enum LibraryResolutionCapability {
5932 /** 5888 /**
5933 * All elements have their types resolved. 5889 * All elements have their types resolved.
5934 */ 5890 */
5935 resolvedTypeNames, 5891 resolvedTypeNames,
(...skipping 2461 matching lines...) Expand 10 before | Expand all | Expand 10 after
8397 8353
8398 @override 8354 @override
8399 void visitElement(Element element) { 8355 void visitElement(Element element) {
8400 int offset = element.nameOffset; 8356 int offset = element.nameOffset;
8401 if (offset != -1) { 8357 if (offset != -1) {
8402 map[offset] = element; 8358 map[offset] = element;
8403 } 8359 }
8404 super.visitElement(element); 8360 super.visitElement(element);
8405 } 8361 }
8406 } 8362 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/dart/element/element.dart ('k') | pkg/analyzer/lib/src/dart/element/handle.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698