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

Unified Diff: pkg/analyzer/lib/src/generated/engine.dart

Issue 360393003: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/ast.dart ('k') | pkg/analyzer/lib/src/generated/index.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/engine.dart
diff --git a/pkg/analyzer/lib/src/generated/engine.dart b/pkg/analyzer/lib/src/generated/engine.dart
index e5db6ec42b4a7eacfcb3269c58863592e2e76ded..79abf8c44292c6566f13960e4f826d1db036d4ab 100644
--- a/pkg/analyzer/lib/src/generated/engine.dart
+++ b/pkg/analyzer/lib/src/generated/engine.dart
@@ -35,6 +35,12 @@ class AnalysisCache {
final List<CachePartition> _partitions;
/**
+ * A flag used to control whether trace information should be produced when the content of the
+ * cache is modified.
+ */
+ static bool _TRACE_CHANGES = false;
+
+ /**
* Initialize a newly created cache to have the given partitions. The partitions will be searched
* in the order in which they appear in the array, so the most specific partition (usually an
* [SdkCachePartition]) should be first and the most general (usually a
@@ -122,6 +128,19 @@ class AnalysisCache {
int count = _partitions.length;
for (int i = 0; i < count; i++) {
if (_partitions[i].contains(source)) {
+ if (_TRACE_CHANGES) {
+ try {
+ SourceEntry oldEntry = _partitions[i].get(source);
+ if (oldEntry == null) {
+ AnalysisEngine.instance.logger.logInformation("Added a cache entry for '${source.fullName}'.");
+ } else {
+ AnalysisEngine.instance.logger.logInformation("Modified the cache entry for ${source.fullName}'. Diff = ${(entry as SourceEntryImpl).getDiff(oldEntry)}");
+ }
+ } catch (exception) {
+ // Ignored
+ JavaSystem.currentTimeMillis();
+ }
+ }
_partitions[i].put(source, entry);
return;
}
@@ -137,6 +156,14 @@ class AnalysisCache {
int count = _partitions.length;
for (int i = 0; i < count; i++) {
if (_partitions[i].contains(source)) {
+ if (_TRACE_CHANGES) {
+ try {
+ AnalysisEngine.instance.logger.logInformation("Removed the cache entry for ${source.fullName}'.");
+ } catch (exception) {
+ // Ignored
+ JavaSystem.currentTimeMillis();
+ }
+ }
_partitions[i].remove(source);
return;
}
@@ -9907,6 +9934,83 @@ class DartEntryImpl extends SourceEntryImpl implements DartEntry {
bool get hasErrorState => super.hasErrorState || _scanErrorsState == CacheState.ERROR || _tokenStreamState == CacheState.ERROR || _sourceKindState == CacheState.ERROR || _parsedUnitState == CacheState.ERROR || _parseErrorsState == CacheState.ERROR || _importedLibrariesState == CacheState.ERROR || _exportedLibrariesState == CacheState.ERROR || _includedPartsState == CacheState.ERROR || _elementState == CacheState.ERROR || _publicNamespaceState == CacheState.ERROR || _clientServerState == CacheState.ERROR || _launchableState == CacheState.ERROR || _resolutionState.hasErrorState;
@override
+ bool writeDiffOn(JavaStringBuilder builder, SourceEntry oldEntry) {
+ bool needsSeparator = super.writeDiffOn(builder, oldEntry);
+ if (oldEntry is! DartEntryImpl) {
+ if (needsSeparator) {
+ builder.append("; ");
+ }
+ builder.append("entry type changed; was ${oldEntry.runtimeType.toString()}");
+ return true;
+ }
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEntry.TOKEN_STREAM, "tokenStream");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEntry.SCAN_ERRORS, "scanErrors");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEntry.SOURCE_KIND, "sourceKind");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEntry.PARSED_UNIT, "parsedUnit");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEntry.PARSE_ERRORS, "parseErrors");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEntry.IMPORTED_LIBRARIES, "importedLibraries");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEntry.EXPORTED_LIBRARIES, "exportedLibraries");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEntry.INCLUDED_PARTS, "includedParts");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEntry.ELEMENT, "element");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEntry.PUBLIC_NAMESPACE, "publicNamespace");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEntry.IS_CLIENT, "clientServer");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEntry.IS_LAUNCHABLE, "launchable");
+ // TODO(brianwilkerson) Add better support for containingLibraries. It would be nice to be able
+ // to report on size-preserving changes.
+ int oldLibraryCount = (oldEntry as DartEntryImpl)._containingLibraries.length;
+ int libraryCount = _containingLibraries.length;
+ if (oldLibraryCount != libraryCount) {
+ if (needsSeparator) {
+ builder.append("; ");
+ }
+ builder.append("containingLibraryCount = ");
+ builder.append(oldLibraryCount);
+ builder.append(" -> ");
+ builder.append(libraryCount);
+ needsSeparator = true;
+ }
+ //
+ // Report change to the per-library state.
+ //
+ HashMap<Source, DartEntryImpl_ResolutionState> oldStateMap = new HashMap<Source, DartEntryImpl_ResolutionState>();
+ DartEntryImpl_ResolutionState state = (oldEntry as DartEntryImpl)._resolutionState;
+ while (state != null) {
+ Source librarySource = state._librarySource;
+ if (librarySource != null) {
+ oldStateMap[librarySource] = state;
+ }
+ state = state._nextState;
+ }
+ state = _resolutionState;
+ while (state != null) {
+ Source librarySource = state._librarySource;
+ if (librarySource != null) {
+ DartEntryImpl_ResolutionState oldState = oldStateMap.remove(librarySource);
+ if (oldState == null) {
+ if (needsSeparator) {
+ builder.append("; ");
+ }
+ builder.append("added resolution for ");
+ builder.append(librarySource.fullName);
+ needsSeparator = true;
+ } else {
+ needsSeparator = oldState.writeDiffOn(builder, needsSeparator, oldEntry as DartEntry);
+ }
+ }
+ state = state._nextState;
+ }
+ for (Source librarySource in oldStateMap.keys.toSet()) {
+ if (needsSeparator) {
+ builder.append("; ");
+ }
+ builder.append("removed resolution for ");
+ builder.append(librarySource.fullName);
+ needsSeparator = true;
+ }
+ return needsSeparator;
+ }
+
+ @override
void writeOn(JavaStringBuilder builder) {
builder.append("Dart: ");
super.writeOn(builder);
@@ -10244,6 +10348,24 @@ class DartEntryImpl_ResolutionState {
}
/**
+ * Write a textual representation of the difference between the old entry and this entry to the
+ * given string builder.
+ *
+ * @param builder the string builder to which the difference is to be written
+ * @param oldEntry the entry that was replaced by this entry
+ * @return `true` if some difference was written
+ */
+ bool writeDiffOn(JavaStringBuilder builder, bool needsSeparator, DartEntry oldEntry) {
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEntry.BUILT_UNIT, _builtUnitState, "builtUnit");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEntry.BUILD_ELEMENT_ERRORS, _buildElementErrorsState, "buildElementErrors");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEntry.RESOLVED_UNIT, _resolvedUnitState, "resolvedUnit");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEntry.RESOLUTION_ERRORS, _resolutionErrorsState, "resolutionErrors");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEntry.VERIFICATION_ERRORS, _verificationErrorsState, "verificationErrors");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEntry.HINTS, _hintsState, "hints");
+ return needsSeparator;
+ }
+
+ /**
* Write a textual representation of this state to the given builder. The result will only be
* used for debugging purposes.
*
@@ -10268,6 +10390,33 @@ class DartEntryImpl_ResolutionState {
}
}
}
+
+ /**
+ * Write a textual representation of the difference between the state of the specified data
+ * between the old entry and this entry to the given string builder.
+ *
+ * @param builder the string builder to which the difference is to be written
+ * @param needsSeparator `true` if any data that is written
+ * @param oldEntry the entry that was replaced by this entry
+ * @param descriptor the descriptor defining the data whose state is being compared
+ * @param label the label used to describe the state
+ * @return `true` if some difference was written
+ */
+ bool writeStateDiffOn(JavaStringBuilder builder, bool needsSeparator, SourceEntry oldEntry, DataDescriptor descriptor, CacheState newState, String label) {
+ CacheState oldState = (oldEntry as DartEntryImpl).getStateInLibrary(descriptor, _librarySource);
+ if (oldState != newState) {
+ if (needsSeparator) {
+ builder.append("; ");
+ }
+ builder.append(label);
+ builder.append(" = ");
+ builder.append(oldState);
+ builder.append(" -> ");
+ builder.append(newState);
+ return true;
+ }
+ return needsSeparator;
+ }
}
/**
@@ -10650,7 +10799,7 @@ class GetContentTask extends AnalysisTask {
TimestampedData<String> data = context.getContents(source);
_content = data.data;
_modificationTime = data.modificationTime;
- } on JavaException catch (exception, stackTrace) {
+ } catch (exception, stackTrace) {
throw new AnalysisException("Could not get contents of ${source}", new CaughtException(exception, stackTrace));
}
}
@@ -11250,6 +11399,31 @@ class HtmlEntryImpl extends SourceEntryImpl implements HtmlEntry {
bool get hasErrorState => super.hasErrorState || _parsedUnitState == CacheState.ERROR || _resolvedUnitState == CacheState.ERROR || _parseErrorsState == CacheState.ERROR || _resolutionErrorsState == CacheState.ERROR || _referencedLibrariesState == CacheState.ERROR || _elementState == CacheState.ERROR || _angularErrorsState == CacheState.ERROR || _hintsState == CacheState.ERROR || _polymerBuildErrorsState == CacheState.ERROR || _polymerResolutionErrorsState == CacheState.ERROR;
@override
+ bool writeDiffOn(JavaStringBuilder builder, SourceEntry oldEntry) {
+ bool needsSeparator = super.writeDiffOn(builder, oldEntry);
+ if (oldEntry is! HtmlEntryImpl) {
+ if (needsSeparator) {
+ builder.append("; ");
+ }
+ builder.append("entry type changed; was ${oldEntry.runtimeType.toString()}");
+ return true;
+ }
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEntry.PARSE_ERRORS, "parseErrors");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEntry.PARSED_UNIT, "parsedUnit");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEntry.RESOLVED_UNIT, "resolvedUnit");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEntry.RESOLUTION_ERRORS, "resolutionErrors");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEntry.REFERENCED_LIBRARIES, "referencedLibraries");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEntry.ELEMENT, "element");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEntry.ANGULAR_APPLICATION, "angularApplicationState");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEntry.ANGULAR_COMPONENT, "angularComponent");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEntry.ANGULAR_ENTRY, "angularEntry");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEntry.ANGULAR_ERRORS, "angularErrors");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEntry.POLYMER_BUILD_ERRORS, "polymerBuildErrors");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEntry.POLYMER_RESOLUTION_ERRORS, "polymerResolutionErrors");
+ return needsSeparator;
+ }
+
+ @override
void writeOn(JavaStringBuilder builder) {
builder.append("Html: ");
super.writeOn(builder);
@@ -14876,6 +15050,20 @@ abstract class SourceEntryImpl implements SourceEntry {
}
/**
+ * Return a textual representation of the difference between the old entry and this entry. The
+ * difference is represented as a sequence of fields whose value would change if the old entry
+ * were converted into the new entry.
+ *
+ * @param oldEntry the entry being diff'd with this entry
+ * @return a textual representation of the difference
+ */
+ String getDiff(SourceEntry oldEntry) {
+ JavaStringBuilder builder = new JavaStringBuilder();
+ writeDiffOn(builder, oldEntry);
+ return builder.toString();
+ }
+
+ /**
* Return the exception that caused one or more values to have a state of [CacheState#ERROR]
* .
*
@@ -15102,6 +15290,40 @@ abstract class SourceEntryImpl implements SourceEntry {
}
/**
+ * Write a textual representation of the difference between the old entry and this entry to the
+ * given string builder.
+ *
+ * @param builder the string builder to which the difference is to be written
+ * @param oldEntry the entry that was replaced by this entry
+ * @return `true` if some difference was written
+ */
+ bool writeDiffOn(JavaStringBuilder builder, SourceEntry oldEntry) {
+ bool needsSeparator = false;
+ CaughtException oldException = oldEntry.exception;
+ if (!identical(oldException, _exception)) {
+ builder.append("exception = ");
+ builder.append(oldException.runtimeType);
+ builder.append(" -> ");
+ builder.append(_exception.runtimeType);
+ needsSeparator = true;
+ }
+ int oldModificationTime = oldEntry.modificationTime;
+ if (oldModificationTime != _modificationTime) {
+ if (needsSeparator) {
+ builder.append("; ");
+ }
+ builder.append("time = ");
+ builder.append(oldModificationTime);
+ builder.append(" -> ");
+ builder.append(_modificationTime);
+ needsSeparator = true;
+ }
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, SourceEntry.CONTENT, "content");
+ needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, SourceEntry.LINE_INFO, "lineInfo");
+ return needsSeparator;
+ }
+
+ /**
* Write a textual representation of this entry to the given builder. The result will only be used
* for debugging purposes.
*
@@ -15117,6 +15339,34 @@ abstract class SourceEntryImpl implements SourceEntry {
}
/**
+ * Write a textual representation of the difference between the state of the specified data
+ * between the old entry and this entry to the given string builder.
+ *
+ * @param builder the string builder to which the difference is to be written
+ * @param needsSeparator `true` if any data that is written
+ * @param oldEntry the entry that was replaced by this entry
+ * @param descriptor the descriptor defining the data whose state is being compared
+ * @param label the label used to describe the state
+ * @return `true` if some difference was written
+ */
+ bool writeStateDiffOn(JavaStringBuilder builder, bool needsSeparator, SourceEntry oldEntry, DataDescriptor descriptor, String label) {
+ CacheState oldState = oldEntry.getState(descriptor);
+ CacheState newState = getState(descriptor);
+ if (oldState != newState) {
+ if (needsSeparator) {
+ builder.append("; ");
+ }
+ builder.append(label);
+ builder.append(" = ");
+ builder.append(oldState);
+ builder.append(" -> ");
+ builder.append(newState);
+ return true;
+ }
+ return needsSeparator;
+ }
+
+ /**
* If the state is changing from ERROR to anything else, capture the information. This is an
* attempt to discover the underlying cause of a long-standing bug.
*
« no previous file with comments | « pkg/analyzer/lib/src/generated/ast.dart ('k') | pkg/analyzer/lib/src/generated/index.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698