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

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

Issue 839913002: Validate incremental resolutions results if requested. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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
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 aaf09f286003ac1cde8981fb5ab8f62da5779744..49ff6a010ee141c769457111c157c0158a150a8f 100644
--- a/pkg/analyzer/lib/src/generated/engine.dart
+++ b/pkg/analyzer/lib/src/generated/engine.dart
@@ -33,6 +33,7 @@ import 'sdk.dart' show DartSdk;
import 'source.dart';
import 'utilities_collection.dart';
import 'utilities_general.dart';
+import 'package:analyzer/src/generated/incremental_resolution_validator.dart';
/**
* Type of callback functions used by PendingFuture. Functions of this type
@@ -1041,6 +1042,26 @@ class AnalysisContextImpl implements InternalAnalysisContext {
List<AnalysisListener> _listeners = new List<AnalysisListener>();
/**
+ * The most recently incrementally resolved [Source].
+ * Is null when it was already validated, or the most recent change was
+ * not incrementally resolved.
+ */
+ Source incrementalResolutionValidation_lastUnitSource;
+
+ /**
+ * The most recently incrementally resolved library [Source].
+ * Is null when it was already validated, or the most recent change was
+ * not incrementally resolved.
+ */
+ Source incrementalResolutionValidation_lastLibrarySource;
+
+ /**
+ * The result of incremental resolution result of
+ * [incrementalResolutionValidation_lastSource].
+ */
+ CompilationUnit incrementalResolutionValidation_lastUnit;
+
+ /**
* Initialize a newly created analysis context.
*/
AnalysisContextImpl() {
@@ -2160,6 +2181,7 @@ class AnalysisContextImpl implements InternalAnalysisContext {
task = nextAnalysisTask;
}
if (task == null) {
+ _validateLastIncrementalResolutionResult();
return new AnalysisResult(
_getChangeNotices(true),
getEnd - getStart,
@@ -2209,6 +2231,29 @@ class AnalysisContextImpl implements InternalAnalysisContext {
performEnd - performStart);
}
+ void _validateLastIncrementalResolutionResult() {
+ if (incrementalResolutionValidation_lastUnitSource == null ||
+ incrementalResolutionValidation_lastLibrarySource == null ||
+ incrementalResolutionValidation_lastUnit == null) {
+ return;
+ }
+ CompilationUnit fullUnit = getResolvedCompilationUnit2(
+ incrementalResolutionValidation_lastUnitSource,
+ incrementalResolutionValidation_lastLibrarySource);
+ if (fullUnit != null) {
+ try {
+ assertSameResolution(incrementalResolutionValidation_lastUnit, fullUnit);
danrubel 2015/01/07 22:32:48 Should this be asserting valid types?
scheglov 2015/01/07 23:24:11 We should, but we cannot. See my message about Ele
+ } on IncrementalResolutionMismatch catch (mismatch, stack) {
+ String failure = mismatch.message;
+ String message = 'Incremental resolution mismatch:\n$failure\nat\n$stack';
+ AnalysisEngine.instance.instrumentationService.logError(message);
+ }
+ }
+ incrementalResolutionValidation_lastUnitSource = null;
+ incrementalResolutionValidation_lastLibrarySource = null;
+ incrementalResolutionValidation_lastUnit = null;
+ }
+
@override
void recordLibraryElements(Map<Source, LibraryElement> elementMap) {
Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML);
@@ -5083,6 +5128,10 @@ class AnalysisContextImpl implements InternalAnalysisContext {
* TODO(scheglov) A hackish, limited incremental resolution implementation.
*/
bool _tryPoorMansIncrementalResolution(Source unitSource, String newCode) {
+ incrementalResolutionValidation_lastUnitSource = null;
+ incrementalResolutionValidation_lastLibrarySource = null;
+ incrementalResolutionValidation_lastUnit = null;
+ // prepare the entry
DartEntry dartEntry = _cache.get(unitSource);
if (dartEntry == null) {
return false;
@@ -5109,6 +5158,13 @@ class AnalysisContextImpl implements InternalAnalysisContext {
if (!success) {
return false;
}
+ // if validation, remember the result, but throw it away
danrubel 2015/01/07 22:32:48 Can we switch this around so that it remembers the
scheglov 2015/01/07 23:24:11 Unfortunately I don't see how to make it work. If
+ if (analysisOptions.incrementalValidation) {
+ incrementalResolutionValidation_lastUnitSource = oldUnit.element.source;
+ incrementalResolutionValidation_lastLibrarySource = oldUnit.element.library.source;
+ incrementalResolutionValidation_lastUnit = oldUnit;
+ return false;
+ }
// prepare notice
ChangeNoticeImpl notice = _getNotice(unitSource);
notice.compilationUnit = oldUnit;
@@ -5117,6 +5173,7 @@ class AnalysisContextImpl implements InternalAnalysisContext {
LineInfo lineInfo = getLineInfo(unitSource);
notice.setErrors(dartEntry.allErrors, lineInfo);
}
+ // OK
return true;
}

Powered by Google App Engine
This is Rietveld 408576698