| 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 { | 919 test_subtypes_classDeclaration() async { |
| 920 String libP = 'package:test/lib.dart;package:test/lib.dart'; | 920 String libP = 'package:test/lib.dart;package:test/lib.dart'; |
| 921 provider.newFile( | 921 provider.newFile( |
| 922 _p('$testProject/lib.dart'), | 922 _p('$testProject/lib.dart'), |
| 923 ''' | 923 ''' |
| 924 class A {} | 924 class A {} |
| 925 class B {} | 925 class B {} |
| 926 class C {} | 926 class C {} |
| 927 class D {} | 927 class D {} |
| 928 class E {} | 928 class E {} |
| 929 '''); | 929 '''); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 } | 968 } |
| 969 | 969 |
| 970 { | 970 { |
| 971 AnalysisDriverSubtype Z = | 971 AnalysisDriverSubtype Z = |
| 972 index.subtypes.singleWhere((t) => t.name == 'Z'); | 972 index.subtypes.singleWhere((t) => t.name == 'Z'); |
| 973 expect(Z.supertypes, ['$libP;D', '$libP;E']); | 973 expect(Z.supertypes, ['$libP;D', '$libP;E']); |
| 974 expect(Z.members, ['methodZ']); | 974 expect(Z.members, ['methodZ']); |
| 975 } | 975 } |
| 976 } | 976 } |
| 977 | 977 |
| 978 test_subtypes_classTypeAlias() async { |
| 979 String libP = 'package:test/lib.dart;package:test/lib.dart'; |
| 980 provider.newFile( |
| 981 _p('$testProject/lib.dart'), |
| 982 ''' |
| 983 class A {} |
| 984 class B {} |
| 985 class C {} |
| 986 class D {} |
| 987 '''); |
| 988 await _indexTestUnit(''' |
| 989 import 'lib.dart'; |
| 990 |
| 991 class X = A with B, C; |
| 992 class Y = A with B implements C, D; |
| 993 '''); |
| 994 |
| 995 { |
| 996 AnalysisDriverSubtype X = |
| 997 index.subtypes.singleWhere((t) => t.name == 'X'); |
| 998 expect(X.supertypes, ['$libP;A', '$libP;B', '$libP;C']); |
| 999 expect(X.members, isEmpty); |
| 1000 } |
| 1001 |
| 1002 { |
| 1003 AnalysisDriverSubtype Y = |
| 1004 index.subtypes.singleWhere((t) => t.name == 'Y'); |
| 1005 expect(Y.supertypes, ['$libP;A', '$libP;B', '$libP;C', '$libP;D']); |
| 1006 expect(Y.members, isEmpty); |
| 1007 } |
| 1008 } |
| 1009 |
| 978 test_subtypes_dynamic() async { | 1010 test_subtypes_dynamic() async { |
| 979 await _indexTestUnit(''' | 1011 await _indexTestUnit(''' |
| 980 class X extends dynamic { | 1012 class X extends dynamic { |
| 981 void foo() {} | 1013 void foo() {} |
| 982 } | 1014 } |
| 983 '''); | 1015 '''); |
| 984 | 1016 |
| 985 AnalysisDriverSubtype X = index.subtypes.singleWhere((t) => t.name == 'X'); | 1017 AnalysisDriverSubtype X = index.subtypes.singleWhere((t) => t.name == 'X'); |
| 986 expect(X.supertypes, isEmpty); | 1018 expect(X.supertypes, isEmpty); |
| 987 expect(X.members, ['foo']); | 1019 expect(X.members, ['foo']); |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1328 final bool isQualified; | 1360 final bool isQualified; |
| 1329 | 1361 |
| 1330 _Relation(this.kind, this.offset, this.length, this.isQualified); | 1362 _Relation(this.kind, this.offset, this.length, this.isQualified); |
| 1331 | 1363 |
| 1332 @override | 1364 @override |
| 1333 String toString() { | 1365 String toString() { |
| 1334 return '_Relation{kind: $kind, offset: $offset, length: $length, ' | 1366 return '_Relation{kind: $kind, offset: $offset, length: $length, ' |
| 1335 'isQualified: $isQualified}lified)'; | 1367 'isQualified: $isQualified}lified)'; |
| 1336 } | 1368 } |
| 1337 } | 1369 } |
| OLD | NEW |