OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 'package:unittest/unittest.dart'; | 5 import 'package:unittest/unittest.dart'; |
6 import 'package:analyzer/file_system/memory_file_system.dart'; | 6 import 'package:analyzer/file_system/memory_file_system.dart'; |
7 import 'mock_sdk.dart'; | 7 import 'mock_sdk.dart'; |
8 import 'package:analyzer/src/generated/sdk.dart'; | 8 import 'package:analyzer/src/generated/sdk.dart'; |
9 import 'package:analyzer/file_system/file_system.dart'; | 9 import 'package:analyzer/file_system/file_system.dart'; |
10 import 'package:analyzer/src/generated/source.dart'; | 10 import 'package:analyzer/src/generated/source.dart'; |
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 } | 1090 } |
1091 '''); | 1091 '''); |
1092 helper.checkDynamic('h().x', 'h()', 'x', isRead: true); | 1092 helper.checkDynamic('h().x', 'h()', 'x', isRead: true); |
1093 }); | 1093 }); |
1094 | 1094 |
1095 test('Get class defined at top level', () { | 1095 test('Get class defined at top level', () { |
1096 Helper helper = new Helper(''' | 1096 Helper helper = new Helper(''' |
1097 class A {} | 1097 class A {} |
1098 var t = A; | 1098 var t = A; |
1099 '''); | 1099 '''); |
1100 helper.checkTypeReference('A', 'A', AccessKind.TOPLEVEL_CLASS); | 1100 helper.checkTypeReference('A', 'A', AccessKind.TOPLEVEL_TYPE); |
1101 }); | 1101 }); |
1102 | 1102 |
1103 test('Get class defined at top level via prefix', () { | 1103 test('Get class defined at top level via prefix', () { |
1104 Helper helper = new Helper(''' | 1104 Helper helper = new Helper(''' |
1105 import 'lib.dart' as l; | 1105 import 'lib.dart' as l; |
1106 | 1106 |
1107 var t = l.A; | 1107 var t = l.A; |
1108 '''); | 1108 '''); |
1109 helper.addFile('/lib.dart', ''' | 1109 helper.addFile('/lib.dart', ''' |
1110 library lib; | 1110 library lib; |
1111 | 1111 |
1112 class A; | 1112 class A; |
1113 '''); | 1113 '''); |
1114 helper.checkTypeReference('l.A', 'A', AccessKind.TOPLEVEL_CLASS); | 1114 helper.checkTypeReference('l.A', 'A', AccessKind.TOPLEVEL_TYPE); |
| 1115 }); |
| 1116 |
| 1117 test('Get dynamic type', () { |
| 1118 Helper helper = new Helper(''' |
| 1119 var t = dynamic; |
| 1120 '''); |
| 1121 helper.checkTypeReference('dynamic', 'dynamic', AccessKind.TOPLEVEL_TYPE); |
| 1122 }); |
| 1123 |
| 1124 test('Get function typedef defined at top level', () { |
| 1125 Helper helper = new Helper(''' |
| 1126 typedef F(); |
| 1127 var t = F; |
| 1128 '''); |
| 1129 helper.checkTypeReference('F', 'F', AccessKind.TOPLEVEL_TYPE); |
| 1130 }); |
| 1131 |
| 1132 test('Get function typedef defined at top level via prefix', () { |
| 1133 Helper helper = new Helper(''' |
| 1134 import 'lib.dart' as l; |
| 1135 |
| 1136 var t = l.F; |
| 1137 '''); |
| 1138 helper.addFile('/lib.dart', ''' |
| 1139 library lib; |
| 1140 |
| 1141 typedef F(); |
| 1142 '''); |
| 1143 helper.checkTypeReference('l.F', 'F', AccessKind.TOPLEVEL_TYPE); |
| 1144 }); |
| 1145 |
| 1146 test('Get mixin application defined at top level', () { |
| 1147 Helper helper = new Helper(''' |
| 1148 class A {} |
| 1149 class B {} |
| 1150 class C = A with B; |
| 1151 var t = C; |
| 1152 '''); |
| 1153 helper.checkTypeReference('C', 'C', AccessKind.TOPLEVEL_TYPE); |
| 1154 }); |
| 1155 |
| 1156 test('Get mixin application defined at top level via prefix', () { |
| 1157 Helper helper = new Helper(''' |
| 1158 import 'lib.dart' as l; |
| 1159 |
| 1160 var t = l.C; |
| 1161 '''); |
| 1162 helper.addFile('/lib.dart', ''' |
| 1163 library lib; |
| 1164 |
| 1165 class A; |
| 1166 class B; |
| 1167 class C = A with B; |
| 1168 '''); |
| 1169 helper.checkTypeReference('l.C', 'C', AccessKind.TOPLEVEL_TYPE); |
1115 }); | 1170 }); |
1116 | 1171 |
1117 test('Get type parameter of enclosing class', () { | 1172 test('Get type parameter of enclosing class', () { |
1118 Helper helper = new Helper(''' | 1173 Helper helper = new Helper(''' |
1119 class A<T, U> { | 1174 class A<T, U> { |
1120 f() { | 1175 f() { |
1121 var t = U; | 1176 var t = U; |
1122 } | 1177 } |
1123 } | 1178 } |
1124 '''); | 1179 '''); |
(...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2307 } | 2362 } |
2308 | 2363 |
2309 @override | 2364 @override |
2310 visitSimpleIdentifier(SimpleIdentifier node) { | 2365 visitSimpleIdentifier(SimpleIdentifier node) { |
2311 AccessSemantics semantics = node.accept(ACCESS_SEMANTICS_VISITOR); | 2366 AccessSemantics semantics = node.accept(ACCESS_SEMANTICS_VISITOR); |
2312 if (semantics != null) { | 2367 if (semantics != null) { |
2313 onAccess(node, semantics); | 2368 onAccess(node, semantics); |
2314 } | 2369 } |
2315 } | 2370 } |
2316 } | 2371 } |
OLD | NEW |