| 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.test.src.task.incremental_element_builder_test; | 5 library analyzer.test.src.task.incremental_element_builder_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/element/element.dart'; | 8 import 'package:analyzer/dart/element/element.dart'; |
| 9 import 'package:analyzer/src/dart/ast/utilities.dart'; | 9 import 'package:analyzer/src/dart/ast/utilities.dart'; |
| 10 import 'package:analyzer/src/dart/element/element.dart'; | 10 import 'package:analyzer/src/dart/element/element.dart'; |
| (...skipping 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1593 | 1593 |
| 1594 main() { | 1594 main() { |
| 1595 new A(); | 1595 new A(); |
| 1596 new A.named(); | 1596 new A.named(); |
| 1597 } | 1597 } |
| 1598 '''); | 1598 '''); |
| 1599 } | 1599 } |
| 1600 | 1600 |
| 1601 void _buildNewUnit(String newCode) { | 1601 void _buildNewUnit(String newCode) { |
| 1602 this.newCode = newCode; | 1602 this.newCode = newCode; |
| 1603 AnalysisEngine.instance.limitInvalidationInTaskModel = false; | 1603 AnalysisOptionsImpl analysisOptions = context.analysisOptions; |
| 1604 analysisOptions.finerGrainedInvalidation = false; |
| 1604 try { | 1605 try { |
| 1605 context.setContents(source, newCode); | 1606 context.setContents(source, newCode); |
| 1606 newUnit = context.parseCompilationUnit(source); | 1607 newUnit = context.parseCompilationUnit(source); |
| 1607 IncrementalCompilationUnitElementBuilder builder = | 1608 IncrementalCompilationUnitElementBuilder builder = |
| 1608 new IncrementalCompilationUnitElementBuilder(oldUnit, newUnit); | 1609 new IncrementalCompilationUnitElementBuilder(oldUnit, newUnit); |
| 1609 builder.build(); | 1610 builder.build(); |
| 1610 unitDelta = builder.unitDelta; | 1611 unitDelta = builder.unitDelta; |
| 1611 expect(newUnit.element, unitElement); | 1612 expect(newUnit.element, unitElement); |
| 1612 // Flush all tokens, ASTs and elements. | 1613 // Flush all tokens, ASTs and elements. |
| 1613 context.analysisCache.flush((target, result) { | 1614 context.analysisCache.flush((target, result) { |
| 1614 return result == TOKEN_STREAM || | 1615 return result == TOKEN_STREAM || |
| 1615 result == PARSED_UNIT || | 1616 result == PARSED_UNIT || |
| 1616 RESOLVED_UNIT_RESULTS.contains(result) || | 1617 RESOLVED_UNIT_RESULTS.contains(result) || |
| 1617 LIBRARY_ELEMENT_RESULTS.contains(result); | 1618 LIBRARY_ELEMENT_RESULTS.contains(result); |
| 1618 }); | 1619 }); |
| 1619 // Compute a new AST with built elements. | 1620 // Compute a new AST with built elements. |
| 1620 CompilationUnit newUnitFull = context.computeResult( | 1621 CompilationUnit newUnitFull = context.computeResult( |
| 1621 new LibrarySpecificUnit(source, source), RESOLVED_UNIT1); | 1622 new LibrarySpecificUnit(source, source), RESOLVED_UNIT1); |
| 1622 expect(newUnitFull, isNot(same(newUnit))); | 1623 expect(newUnitFull, isNot(same(newUnit))); |
| 1623 new _BuiltElementsValidator().isEqualNodes(newUnitFull, newUnit); | 1624 new _BuiltElementsValidator().isEqualNodes(newUnitFull, newUnit); |
| 1624 } finally { | 1625 } finally { |
| 1625 AnalysisEngine.instance.limitInvalidationInTaskModel = true; | 1626 analysisOptions.finerGrainedInvalidation = true; |
| 1626 } | 1627 } |
| 1627 } | 1628 } |
| 1628 | 1629 |
| 1629 void _buildOldUnit(String oldCode, [Source libSource]) { | 1630 void _buildOldUnit(String oldCode, [Source libSource]) { |
| 1630 this.oldCode = oldCode; | 1631 this.oldCode = oldCode; |
| 1631 source = newSource('/test.dart', oldCode); | 1632 source = newSource('/test.dart', oldCode); |
| 1632 if (libSource == null) { | 1633 if (libSource == null) { |
| 1633 libSource = source; | 1634 libSource = source; |
| 1634 } | 1635 } |
| 1635 oldUnit = context.resolveCompilationUnit2(source, libSource); | 1636 oldUnit = context.resolveCompilationUnit2(source, libSource); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1768 ClassDeclaration oldClass = _findClassNode(oldUnit, name); | 1769 ClassDeclaration oldClass = _findClassNode(oldUnit, name); |
| 1769 expect(oldClass, isNotNull); | 1770 expect(oldClass, isNotNull); |
| 1770 element = oldClass.element; | 1771 element = oldClass.element; |
| 1771 oldMembers = oldClass.members.toList(); | 1772 oldMembers = oldClass.members.toList(); |
| 1772 } | 1773 } |
| 1773 | 1774 |
| 1774 ClassDeclaration _findClassNode(CompilationUnit unit, String name) => | 1775 ClassDeclaration _findClassNode(CompilationUnit unit, String name) => |
| 1775 unit.declarations.singleWhere((unitMember) => | 1776 unit.declarations.singleWhere((unitMember) => |
| 1776 unitMember is ClassDeclaration && unitMember.name.name == name); | 1777 unitMember is ClassDeclaration && unitMember.name.name == name); |
| 1777 } | 1778 } |
| OLD | NEW |