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

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

Issue 2158973003: Fixes for updating synthetic element offsets. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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/incremental_element_builder_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/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;
- }
}
« no previous file with comments | « no previous file | pkg/analyzer/test/src/task/incremental_element_builder_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698