Index: pkg/analyzer/lib/src/task/incremental_element_builder.dart |
diff --git a/pkg/analyzer/lib/src/task/incremental_element_builder.dart b/pkg/analyzer/lib/src/task/incremental_element_builder.dart |
index e1f8c5ed49116cf209c1cb8126f6c4b5ad858c5e..54d0ac5252fd56a887594554c21a6103a0582953 100644 |
--- a/pkg/analyzer/lib/src/task/incremental_element_builder.dart |
+++ b/pkg/analyzer/lib/src/task/incremental_element_builder.dart |
@@ -130,6 +130,7 @@ class IncrementalCompilationUnitElementBuilder { |
* Fills [unitDelta] with added/remove elements. |
*/ |
void build() { |
+ _materializeLazyElements(); |
new CompilationUnitBuilder() |
.buildCompilationUnit(unitSource, newUnit, librarySource); |
_processDirectives(); |
@@ -170,6 +171,10 @@ class IncrementalCompilationUnitElementBuilder { |
} |
} |
+ void _materializeLazyElements() { |
+ unitElement.accept(new RecursiveElementVisitor()); |
+ } |
+ |
ClassElementDelta _processClassMembers( |
ClassDeclaration oldClass, ClassDeclaration newClass) { |
// If the class hierarchy or type parameters are changed, |
@@ -683,15 +688,18 @@ class _UpdateElementOffsetsVisitor extends GeneralizingElementVisitor { |
if (element is LibraryElement) { |
return; |
} |
- if (element.isSynthetic && !_isVariableInitializer(element)) { |
- return; |
- } |
if (element is ElementImpl) { |
// name offset |
{ |
int oldOffset = element.nameOffset; |
int newOffset = map[oldOffset]; |
- assert(newOffset != null); |
+ // Some synthetic elements have new offsets, e.g. synthetic accessors |
+ // of property inducing elements. But some are purely synthetic, e.g. |
+ // synthetic enum fields and their accessors. |
+ if (newOffset == null) { |
+ assert(element.isSynthetic); |
+ return; |
+ } |
element.nameOffset = newOffset; |
} |
// code range |
@@ -733,9 +741,4 @@ class _UpdateElementOffsetsVisitor extends GeneralizingElementVisitor { |
} |
super.visitElement(element); |
} |
- |
- static bool _isVariableInitializer(Element element) { |
- return element is FunctionElement && |
- element.enclosingElement is VariableElement; |
- } |
} |