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

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

Issue 753803002: Use a poor man's incremental parser to perform incremental resolution. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 3195e89e3de68b893c1daac28fc31b0de6660afd..9b6a277da0e1ba8404a776922cf715b93deb4550 100644
--- a/pkg/analyzer/lib/src/generated/engine.dart
+++ b/pkg/analyzer/lib/src/generated/engine.dart
@@ -20,7 +20,8 @@ import 'error.dart';
import 'error_verifier.dart';
import 'html.dart' as ht;
import 'incremental_scanner.dart';
-import 'incremental_resolver.dart' show IncrementalResolver;
+import 'incremental_resolver.dart' show IncrementalResolver,
+ poorMansIncrementalResolution;
import 'instrumentation.dart';
import 'java_core.dart';
import 'java_engine.dart';
@@ -2918,7 +2919,10 @@ class AnalysisContextImpl implements InternalAnalysisContext {
if (contents != originalContents) {
_incrementalAnalysisCache =
IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source);
- _sourceChanged(source);
+ if (!analysisOptions.incremental ||
+ !_tryPoorMansIncrementalResolution(source, contents)) {
Brian Wilkerson 2014/11/24 15:09:13 I have concerns about doing this much work while h
scheglov 2014/11/24 18:59:05 As discussed, file size in target applications are
+ _sourceChanged(source);
+ }
changed = true;
SourceEntry sourceEntry = _cache.get(source);
if (sourceEntry != null) {
@@ -4922,6 +4926,31 @@ class AnalysisContextImpl implements InternalAnalysisContext {
}
/**
+ * TODO(scheglov) A hackish, limited incremental resolution implementation.
+ */
+ bool _tryPoorMansIncrementalResolution(Source unitSource, String newCode) {
+ List<Source> librarySources = getLibrariesContaining(unitSource);
+ if (librarySources.length != 1) {
+ return false;
+ }
+ CompilationUnit oldUnit =
+ getResolvedCompilationUnit2(unitSource, librarySources[0]);
+ bool success = poorMansIncrementalResolution(typeProvider, oldUnit, newCode);
+ if (!success) {
+ return false;
+ }
+ ChangeNoticeImpl notice = _getNotice(unitSource);
+ notice.compilationUnit = oldUnit;
+ // TODO(scheglov) apply updated errors
+ {
+ LineInfo lineInfo = getLineInfo(unitSource);
+ DartEntry dartEntry = _cache.get(unitSource);
+ notice.setErrors(dartEntry.allErrors, lineInfo);
+ }
+ return true;
+ }
+
+ /**
* <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
*
* @param source the source that has been removed

Powered by Google App Engine
This is Rietveld 408576698