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

Unified Diff: bin/edit_files.dart

Issue 1141013002: Fixes #179 -- compile error if editing files during server mode (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 7 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 | lib/devc.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bin/edit_files.dart
diff --git a/bin/edit_files.dart b/bin/edit_files.dart
index cf9d82aa78cb636193d7be2e0a2733c582bed207..b526feece955dd59310f26fdc86cf7d3caebbd16 100644
--- a/bin/edit_files.dart
+++ b/bin/edit_files.dart
@@ -13,6 +13,7 @@ library dev_compiler.bin.edit_files;
import 'dart:io';
import 'dart:convert';
+import 'package:analyzer/src/generated/source.dart' show Source;
import 'package:args/args.dart';
import 'package:cli_util/cli_util.dart' show getSdkDir;
import 'package:source_maps/refactor.dart';
@@ -63,6 +64,8 @@ class EditFileSummaryVisitor extends RecursiveSummaryVisitor {
RegExp includePattern;
RegExp excludePattern;
+ final Map<Uri, Source> _sources = <Uri, Source>{};
+
EditFileSummaryVisitor(this.typeResolver, this.level,
this.checkoutFilesExecutable, this.checkoutFilesArg, this.includePattern,
this.excludePattern);
@@ -72,6 +75,13 @@ class EditFileSummaryVisitor extends RecursiveSummaryVisitor {
return new TextEditTransaction(fileContents, new SourceFile(fileContents));
});
+ /// Find the corresponding [Source] for [uri].
+ Source findSource(Uri uri) {
+ var source = _sources[uri];
+ if (source != null) return source;
+ return _sources[uri] = typeResolver.context.sourceFactory.forUri('$uri');
+ }
+
@override
void visitMessage(MessageSummary message) {
var uri = message.span.sourceUrl;
@@ -88,7 +98,7 @@ class EditFileSummaryVisitor extends RecursiveSummaryVisitor {
break;
}
}
- var fullName = typeResolver.findSource(uri).fullName;
+ var fullName = findSource(uri).fullName;
if (includePattern != null && !includePattern.hasMatch(fullName)) return;
if (excludePattern != null && excludePattern.hasMatch(fullName)) return;
var edits = getEdits(fullName);
« no previous file with comments | « no previous file | lib/devc.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698