| 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 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 8 import 'package:analyzer/dart/ast/standard_resolution_map.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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 _expectId(main, SearchResultKind.REFERENCE, 'A v'), | 231 _expectId(main, SearchResultKind.REFERENCE, 'A v'), |
| 232 _expectId(b1, SearchResultKind.REFERENCE, 'A {} // extends'), | 232 _expectId(b1, SearchResultKind.REFERENCE, 'A {} // extends'), |
| 233 _expectId(b2, SearchResultKind.REFERENCE, 'A {} // implements'), | 233 _expectId(b2, SearchResultKind.REFERENCE, 'A {} // implements'), |
| 234 _expectId(b3, SearchResultKind.REFERENCE, 'A {} // with'), | 234 _expectId(b3, SearchResultKind.REFERENCE, 'A {} // with'), |
| 235 _expectId(v2, SearchResultKind.REFERENCE, 'A> v2'), | 235 _expectId(v2, SearchResultKind.REFERENCE, 'A> v2'), |
| 236 ]; | 236 ]; |
| 237 await _verifyReferences(element, expected); | 237 await _verifyReferences(element, expected); |
| 238 } | 238 } |
| 239 | 239 |
| 240 test_searchReferences_ClassElement_definedOutside() async { | 240 test_searchReferences_ClassElement_definedOutside() async { |
| 241 provider.newFile( | 241 provider.newFile(_p('$testProject/lib.dart'), r''' |
| 242 _p('$testProject/lib.dart'), | |
| 243 r''' | |
| 244 class A {}; | 242 class A {}; |
| 245 '''); | 243 '''); |
| 246 await _resolveTestUnit(''' | 244 await _resolveTestUnit(''' |
| 247 import 'lib.dart'; | 245 import 'lib.dart'; |
| 248 main(A p) { | 246 main(A p) { |
| 249 A v; | 247 A v; |
| 250 } | 248 } |
| 251 '''); | 249 '''); |
| 252 ClassElement element = _findElementAtString('A p'); | 250 ClassElement element = _findElementAtString('A p'); |
| 253 Element p = _findElement('p'); | 251 Element p = _findElement('p'); |
| (...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 PropertyAccessorElement element = _findElement('s='); | 955 PropertyAccessorElement element = _findElement('s='); |
| 958 Element mainElement = _findElement('main'); | 956 Element mainElement = _findElement('main'); |
| 959 var expected = [ | 957 var expected = [ |
| 960 _expectId(mainElement, SearchResultKind.REFERENCE, 's = 1'), | 958 _expectId(mainElement, SearchResultKind.REFERENCE, 's = 1'), |
| 961 _expectIdQ(mainElement, SearchResultKind.REFERENCE, 's = 2') | 959 _expectIdQ(mainElement, SearchResultKind.REFERENCE, 's = 2') |
| 962 ]; | 960 ]; |
| 963 await _verifyReferences(element, expected); | 961 await _verifyReferences(element, expected); |
| 964 } | 962 } |
| 965 | 963 |
| 966 test_searchReferences_TopLevelVariableElement() async { | 964 test_searchReferences_TopLevelVariableElement() async { |
| 967 provider.newFile( | 965 provider.newFile(_p('$testProject/lib.dart'), ''' |
| 968 _p('$testProject/lib.dart'), | |
| 969 ''' | |
| 970 library lib; | 966 library lib; |
| 971 var V; | 967 var V; |
| 972 '''); | 968 '''); |
| 973 await _resolveTestUnit(''' | 969 await _resolveTestUnit(''' |
| 974 import 'lib.dart' show V; // imp | 970 import 'lib.dart' show V; // imp |
| 975 import 'lib.dart' as pref; | 971 import 'lib.dart' as pref; |
| 976 main() { | 972 main() { |
| 977 pref.V = 1; // q | 973 pref.V = 1; // q |
| 978 print(pref.V); // q | 974 print(pref.V); // q |
| 979 pref.V(); // q | 975 pref.V(); // q |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1132 List<SubtypeResult> subtypes = await driver.search.subtypes(subtype: b); | 1128 List<SubtypeResult> subtypes = await driver.search.subtypes(subtype: b); |
| 1133 expect(subtypes, hasLength(1)); | 1129 expect(subtypes, hasLength(1)); |
| 1134 SubtypeResult e = subtypes.singleWhere((r) => r.name == 'E'); | 1130 SubtypeResult e = subtypes.singleWhere((r) => r.name == 'E'); |
| 1135 expect(e.members, ['methodE']); | 1131 expect(e.members, ['methodE']); |
| 1136 } | 1132 } |
| 1137 } | 1133 } |
| 1138 | 1134 |
| 1139 test_subtypes_files() async { | 1135 test_subtypes_files() async { |
| 1140 String pathB = _p('$testProject/b.dart'); | 1136 String pathB = _p('$testProject/b.dart'); |
| 1141 String pathC = _p('$testProject/c.dart'); | 1137 String pathC = _p('$testProject/c.dart'); |
| 1142 provider.newFile( | 1138 provider.newFile(pathB, r''' |
| 1143 pathB, | |
| 1144 r''' | |
| 1145 import 'test.dart'; | 1139 import 'test.dart'; |
| 1146 class B extends A {} | 1140 class B extends A {} |
| 1147 '''); | 1141 '''); |
| 1148 provider.newFile( | 1142 provider.newFile(pathC, r''' |
| 1149 pathC, | |
| 1150 r''' | |
| 1151 import 'test.dart'; | 1143 import 'test.dart'; |
| 1152 class C extends A {} | 1144 class C extends A {} |
| 1153 class D {} | 1145 class D {} |
| 1154 '''); | 1146 '''); |
| 1155 | 1147 |
| 1156 await _resolveTestUnit(''' | 1148 await _resolveTestUnit(''' |
| 1157 class A {} | 1149 class A {} |
| 1158 '''); | 1150 '''); |
| 1159 ClassElement a = _findElement('A'); | 1151 ClassElement a = _findElement('A'); |
| 1160 | 1152 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 List<SearchResult> results = await driver.search.references(element); | 1258 List<SearchResult> results = await driver.search.references(element); |
| 1267 _assertResults(results, expectedMatches); | 1259 _assertResults(results, expectedMatches); |
| 1268 expect(results, hasLength(expectedMatches.length)); | 1260 expect(results, hasLength(expectedMatches.length)); |
| 1269 } | 1261 } |
| 1270 | 1262 |
| 1271 static void _assertResults( | 1263 static void _assertResults( |
| 1272 List<SearchResult> matches, List<ExpectedResult> expectedMatches) { | 1264 List<SearchResult> matches, List<ExpectedResult> expectedMatches) { |
| 1273 expect(matches, unorderedEquals(expectedMatches)); | 1265 expect(matches, unorderedEquals(expectedMatches)); |
| 1274 } | 1266 } |
| 1275 } | 1267 } |
| OLD | NEW |