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 1836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1847 if (actual != expected) { | 1847 if (actual != expected) { |
1848 fail('$name\nExpected: $expected\n Actual: $actual'); | 1848 fail('$name\nExpected: $expected\n Actual: $actual'); |
1849 } | 1849 } |
1850 } | 1850 } |
1851 } | 1851 } |
1852 | 1852 |
1853 class _ClassDeltaHelper { | 1853 class _ClassDeltaHelper { |
1854 final String name; | 1854 final String name; |
1855 | 1855 |
1856 ClassElementDelta delta; | 1856 ClassElementDelta delta; |
1857 ClassElement element; | 1857 ClassElementImpl element; |
| 1858 int oldVersion; |
1858 List<ClassMember> oldMembers; | 1859 List<ClassMember> oldMembers; |
1859 List<ClassMember> newMembers; | 1860 List<ClassMember> newMembers; |
1860 | 1861 |
1861 _ClassDeltaHelper(this.name); | 1862 _ClassDeltaHelper(this.name); |
1862 | 1863 |
1863 void initNew(CompilationUnit newUnit, CompilationUnitElementDelta unitDelta) { | 1864 void initNew(CompilationUnit newUnit, CompilationUnitElementDelta unitDelta) { |
| 1865 expect(element.version, isNot(oldVersion)); |
1864 ClassDeclaration newClass = _findClassNode(newUnit, name); | 1866 ClassDeclaration newClass = _findClassNode(newUnit, name); |
1865 expect(newClass, isNotNull); | 1867 expect(newClass, isNotNull); |
1866 newMembers = newClass.members.toList(); | 1868 newMembers = newClass.members.toList(); |
1867 delta = unitDelta.classDeltas[name]; | 1869 delta = unitDelta.classDeltas[name]; |
1868 expect(delta, isNotNull, reason: 'No delta for class: $name'); | 1870 expect(delta, isNotNull, reason: 'No delta for class: $name'); |
1869 } | 1871 } |
1870 | 1872 |
1871 void initOld(CompilationUnit oldUnit) { | 1873 void initOld(CompilationUnit oldUnit) { |
1872 ClassDeclaration oldClass = _findClassNode(oldUnit, name); | 1874 ClassDeclaration oldClass = _findClassNode(oldUnit, name); |
1873 expect(oldClass, isNotNull); | 1875 expect(oldClass, isNotNull); |
1874 element = oldClass.element; | 1876 element = oldClass.element; |
| 1877 oldVersion = element.version; |
1875 oldMembers = oldClass.members.toList(); | 1878 oldMembers = oldClass.members.toList(); |
1876 } | 1879 } |
1877 | 1880 |
1878 ClassDeclaration _findClassNode(CompilationUnit unit, String name) => | 1881 ClassDeclaration _findClassNode(CompilationUnit unit, String name) => |
1879 unit.declarations.singleWhere((unitMember) => | 1882 unit.declarations.singleWhere((unitMember) => |
1880 unitMember is ClassDeclaration && unitMember.name.name == name); | 1883 unitMember is ClassDeclaration && unitMember.name.name == name); |
1881 } | 1884 } |
OLD | NEW |