| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer.src.task.incremental_element_builder; | 5 library analyzer.src.task.incremental_element_builder; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
| 10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| 11 import 'package:analyzer/src/generated/resolver.dart'; | 11 import 'package:analyzer/src/generated/resolver.dart'; |
| 12 import 'package:analyzer/src/generated/scanner.dart'; | 12 import 'package:analyzer/src/generated/scanner.dart'; |
| 13 import 'package:analyzer/src/generated/source.dart'; | 13 import 'package:analyzer/src/generated/source.dart'; |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * Incrementally updates the existing [unitElement] and builds elements for | 16 * Incrementally updates the existing [unitElement] and builds elements for |
| 17 * the [newUnit]. | 17 * the [newUnit]. |
| 18 */ | 18 */ |
| 19 class IncrementalCompilationUnitElementBuilder { | 19 class IncrementalCompilationUnitElementBuilder { |
| 20 final Source source; | 20 final Source source; |
| 21 final Source librarySource; |
| 21 final CompilationUnit oldUnit; | 22 final CompilationUnit oldUnit; |
| 22 final CompilationUnitElementImpl unitElement; | 23 final CompilationUnitElementImpl unitElement; |
| 23 final CompilationUnit newUnit; | 24 final CompilationUnit newUnit; |
| 24 final ElementHolder holder = new ElementHolder(); | 25 final ElementHolder holder = new ElementHolder(); |
| 25 | 26 |
| 26 IncrementalCompilationUnitElementBuilder( | 27 IncrementalCompilationUnitElementBuilder( |
| 27 CompilationUnit oldUnit, this.newUnit) | 28 CompilationUnit oldUnit, this.newUnit) |
| 28 : oldUnit = oldUnit, | 29 : oldUnit = oldUnit, |
| 29 unitElement = oldUnit.element, | 30 unitElement = oldUnit.element, |
| 30 source = oldUnit.element.source; | 31 source = oldUnit.element.source, |
| 32 librarySource = (oldUnit.element as CompilationUnitElementImpl).libraryS
ource; |
| 31 | 33 |
| 32 void build() { | 34 void build() { |
| 33 new CompilationUnitBuilder().buildCompilationUnit(source, newUnit); | 35 new CompilationUnitBuilder().buildCompilationUnit( |
| 36 source, newUnit, librarySource); |
| 34 _processDirectives(); | 37 _processDirectives(); |
| 35 _processUnitMembers(); | 38 _processUnitMembers(); |
| 36 newUnit.element = unitElement; | 39 newUnit.element = unitElement; |
| 37 } | 40 } |
| 38 | 41 |
| 39 void _addElementsToHolder(CompilationUnitMember node) { | 42 void _addElementsToHolder(CompilationUnitMember node) { |
| 40 List<Element> elements = _getElements(node); | 43 List<Element> elements = _getElements(node); |
| 41 elements.forEach(_addElementToHolder); | 44 elements.forEach(_addElementToHolder); |
| 42 } | 45 } |
| 43 | 46 |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 } | 286 } |
| 284 int oldOffset = element.nameOffset; | 287 int oldOffset = element.nameOffset; |
| 285 int newOffset = map[oldOffset]; | 288 int newOffset = map[oldOffset]; |
| 286 assert(newOffset != null); | 289 assert(newOffset != null); |
| 287 (element as ElementImpl).nameOffset = newOffset; | 290 (element as ElementImpl).nameOffset = newOffset; |
| 288 if (element is! LibraryElement) { | 291 if (element is! LibraryElement) { |
| 289 super.visitElement(element); | 292 super.visitElement(element); |
| 290 } | 293 } |
| 291 } | 294 } |
| 292 } | 295 } |
| OLD | NEW |