| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:convert'; | 6 import 'dart:convert'; |
| 7 | 7 |
| 8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/src/dart/analysis/driver.dart'; | 10 import 'package:analyzer/src/dart/analysis/driver.dart'; |
| (...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 A.foo({this.field}); | 909 A.foo({this.field}); |
| 910 A.bar() : field = 5; | 910 A.bar() : field = 5; |
| 911 } | 911 } |
| 912 '''); | 912 '''); |
| 913 FieldElement element = findElement('field', ElementKind.FIELD); | 913 FieldElement element = findElement('field', ElementKind.FIELD); |
| 914 assertThat(element) | 914 assertThat(element) |
| 915 ..isWrittenAt('field})', true) | 915 ..isWrittenAt('field})', true) |
| 916 ..isWrittenAt('field = 5', true); | 916 ..isWrittenAt('field = 5', true); |
| 917 } | 917 } |
| 918 | 918 |
| 919 test_subtypes() async { |
| 920 String libP = 'package:test/lib.dart;package:test/lib.dart'; |
| 921 provider.newFile( |
| 922 _p('$testProject/lib.dart'), |
| 923 ''' |
| 924 class A {} |
| 925 class B {} |
| 926 class C {} |
| 927 class D {} |
| 928 class E {} |
| 929 '''); |
| 930 await _indexTestUnit(''' |
| 931 import 'lib.dart'; |
| 932 |
| 933 class X extends A { |
| 934 int field1, field2; |
| 935 int get getter1 => null; |
| 936 void set setter1(_) {} |
| 937 void method1() {} |
| 938 } |
| 939 |
| 940 class Y extends Object with B, C { |
| 941 void methodY() {} |
| 942 } |
| 943 |
| 944 class Z implements E, D { |
| 945 void methodZ() {} |
| 946 } |
| 947 '''); |
| 948 |
| 949 { |
| 950 AnalysisDriverSubtype X = |
| 951 index.subtypes.singleWhere((t) => t.name == 'X'); |
| 952 expect(X.supertypes, ['$libP;A']); |
| 953 expect(X.members, ['field1', 'field2', 'getter1', 'method1', 'setter1']); |
| 954 } |
| 955 |
| 956 { |
| 957 AnalysisDriverSubtype Y = |
| 958 index.subtypes.singleWhere((t) => t.name == 'Y'); |
| 959 expect( |
| 960 Y.supertypes, ['dart:core;dart:core;Object', '$libP;B', '$libP;C']); |
| 961 expect(Y.members, ['methodY']); |
| 962 } |
| 963 |
| 964 { |
| 965 AnalysisDriverSubtype Z = |
| 966 index.subtypes.singleWhere((t) => t.name == 'Z'); |
| 967 expect(Z.supertypes, ['$libP;D', '$libP;E']); |
| 968 expect(Z.members, ['methodZ']); |
| 969 } |
| 970 } |
| 971 |
| 919 test_usedName_inLibraryIdentifier() async { | 972 test_usedName_inLibraryIdentifier() async { |
| 920 await _indexTestUnit(''' | 973 await _indexTestUnit(''' |
| 921 library aaa.bbb.ccc; | 974 library aaa.bbb.ccc; |
| 922 class C { | 975 class C { |
| 923 var bbb; | 976 var bbb; |
| 924 } | 977 } |
| 925 main(p) { | 978 main(p) { |
| 926 p.bbb = 1; | 979 p.bbb = 1; |
| 927 } | 980 } |
| 928 '''); | 981 '''); |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 final bool isQualified; | 1310 final bool isQualified; |
| 1258 | 1311 |
| 1259 _Relation(this.kind, this.offset, this.length, this.isQualified); | 1312 _Relation(this.kind, this.offset, this.length, this.isQualified); |
| 1260 | 1313 |
| 1261 @override | 1314 @override |
| 1262 String toString() { | 1315 String toString() { |
| 1263 return '_Relation{kind: $kind, offset: $offset, length: $length, ' | 1316 return '_Relation{kind: $kind, offset: $offset, length: $length, ' |
| 1264 'isQualified: $isQualified}lified)'; | 1317 'isQualified: $isQualified}lified)'; |
| 1265 } | 1318 } |
| 1266 } | 1319 } |
| OLD | NEW |