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

Unified Diff: pkg/analyzer/lib/src/summary/resynthesize.dart

Issue 2615903003: Fix for resynthesizing libraries with invalid part URIs. (Closed)
Patch Set: Un-fail other tests. Created 3 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/summary/resynthesize.dart
diff --git a/pkg/analyzer/lib/src/summary/resynthesize.dart b/pkg/analyzer/lib/src/summary/resynthesize.dart
index c3734e8ca268e6ae231921aa63ec9cc8dcddfcbf..69298a5fd0a1274d0a073f01f3e4e76dd5ec06f0 100644
--- a/pkg/analyzer/lib/src/summary/resynthesize.dart
+++ b/pkg/analyzer/lib/src/summary/resynthesize.dart
@@ -230,9 +230,13 @@ abstract class SummaryResynthesizer extends ElementResynthesizer {
List<UnlinkedUnit> serializedUnits = <UnlinkedUnit>[unlinkedSummary];
for (String part in serializedUnits[0].publicNamespace.parts) {
Source partSource = sourceFactory.resolveUri(librarySource, part);
- String partAbsUri = partSource.uri.toString();
- serializedUnits.add(_getUnlinkedSummaryOrNull(partAbsUri) ??
- new UnlinkedUnitBuilder(codeRange: new CodeRangeBuilder()));
+ if (partSource == null) {
+ serializedUnits.add(null);
+ } else {
+ String partAbsUri = partSource.uri.toString();
+ serializedUnits.add(_getUnlinkedSummaryOrNull(partAbsUri) ??
+ new UnlinkedUnitBuilder(codeRange: new CodeRangeBuilder()));
+ }
}
_LibraryResynthesizer libraryResynthesizer = new _LibraryResynthesizer(
this, serializedLibrary, serializedUnits, librarySource);
@@ -1034,7 +1038,9 @@ class _LibraryResynthesizer {
unlinkedDefiningUnit.publicNamespace.parts[i - 1],
unlinkedDefiningUnit.parts[i - 1],
i);
- partResynthesizers.add(partResynthesizer);
+ if (partResynthesizer != null) {
+ partResynthesizers.add(partResynthesizer);
+ }
}
library.parts = partResynthesizers.map((r) => r.unit).toList();
// Populate units.
@@ -1055,13 +1061,16 @@ class _LibraryResynthesizer {
}
/**
- * Create, but do not populate, the [CompilationUnitElement] for a part other
- * than the defining compilation unit.
+ * Create a [_UnitResynthesizer] that will resynthesize the part with the
+ * given [uri]. Return `null` if the [uri] is invalid.
*/
_UnitResynthesizer buildPart(_UnitResynthesizer definingUnitResynthesizer,
String uri, UnlinkedPart partDecl, int unitNum) {
Source unitSource =
summaryResynthesizer.sourceFactory.resolveUri(librarySource, uri);
+ if (unitSource == null) {
+ return null;
+ }
_UnitResynthesizer partResynthesizer =
createUnitResynthesizer(unitNum, unitSource, partDecl);
CompilationUnitElementImpl partUnit = partResynthesizer.unit;

Powered by Google App Engine
This is Rietveld 408576698