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

Unified Diff: pkg/analyzer/lib/src/task/dart.dart

Issue 1113103003: Use memento in ScanDartTask. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 | « no previous file | pkg/analyzer/test/src/task/dart_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/task/dart.dart
diff --git a/pkg/analyzer/lib/src/task/dart.dart b/pkg/analyzer/lib/src/task/dart.dart
index b09c6808cea65c332835d5d20f087a12bfec83c2..5b443255a1e5f5e953e30c5b534a2f4d350ab536 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -2383,6 +2383,17 @@ class ResolveVariableReferencesTask extends SourceBasedAnalysisTask {
}
/**
+ * The memento for [ScanDartTask].
+ */
+class ScanDartMemento {
+ final String content;
+ final Token tokenStream;
+ final LineInfo lineInfo;
+ final List<AnalysisError> errors;
+ ScanDartMemento(this.content, this.tokenStream, this.lineInfo, this.errors);
+}
+
+/**
* A task that scans the content of a file, producing a set of Dart tokens.
*/
class ScanDartTask extends SourceBasedAnalysisTask {
@@ -2416,15 +2427,31 @@ class ScanDartTask extends SourceBasedAnalysisTask {
Source source = getRequiredSource();
String content = getRequiredInput(CONTENT_INPUT_NAME);
+ if (inputMemento is ScanDartMemento) {
+ ScanDartMemento memento = inputMemento;
+ if (memento.content == content) {
+ outputMemento = memento;
+ outputs[TOKEN_STREAM] = memento.tokenStream;
+ outputs[LINE_INFO] = memento.lineInfo;
+ outputs[SCAN_ERRORS] = memento.errors;
+ return;
+ }
+ }
+
RecordingErrorListener errorListener = new RecordingErrorListener();
Scanner scanner =
new Scanner(source, new CharSequenceReader(content), errorListener);
scanner.preserveComments = context.analysisOptions.preserveComments;
scanner.enableNullAwareOperators =
context.analysisOptions.enableNullAwareOperators;
- outputs[TOKEN_STREAM] = scanner.tokenize();
- outputs[LINE_INFO] = new LineInfo(scanner.lineStarts);
- outputs[SCAN_ERRORS] = errorListener.getErrorsForSource(source);
+
+ Token tokenStream = scanner.tokenize();
+ LineInfo lineInfo = new LineInfo(scanner.lineStarts);
+ List<AnalysisError> errors = errorListener.errors;
+ outputs[TOKEN_STREAM] = tokenStream;
+ outputs[LINE_INFO] = lineInfo;
+ outputs[SCAN_ERRORS] = errors;
+ outputMemento = new ScanDartMemento(content, tokenStream, lineInfo, errors);
}
/**
« no previous file with comments | « no previous file | pkg/analyzer/test/src/task/dart_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698