| 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/element/element.dart'; | 8 import 'package:analyzer/dart/element/element.dart'; |
| 9 import 'package:analyzer/src/dart/analysis/driver.dart'; | 9 import 'package:analyzer/src/dart/analysis/driver.dart'; |
| 10 import 'package:analyzer/src/dart/analysis/search.dart'; | 10 import 'package:analyzer/src/dart/analysis/search.dart'; |
| (...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 TypeParameterElement element = _findElement('T'); | 879 TypeParameterElement element = _findElement('T'); |
| 880 Element a = _findElement('a'); | 880 Element a = _findElement('a'); |
| 881 Element b = _findElement('b'); | 881 Element b = _findElement('b'); |
| 882 var expected = [ | 882 var expected = [ |
| 883 _expectId(a, SearchResultKind.REFERENCE, 'T a'), | 883 _expectId(a, SearchResultKind.REFERENCE, 'T a'), |
| 884 _expectId(b, SearchResultKind.REFERENCE, 'T b'), | 884 _expectId(b, SearchResultKind.REFERENCE, 'T b'), |
| 885 ]; | 885 ]; |
| 886 await _verifyReferences(element, expected); | 886 await _verifyReferences(element, expected); |
| 887 } | 887 } |
| 888 | 888 |
| 889 test_searchSubtypes() async { |
| 890 await _resolveTestUnit(''' |
| 891 class T {} |
| 892 class A extends T {} // A |
| 893 class B = Object with T; // B |
| 894 class C implements T {} // C |
| 895 '''); |
| 896 ClassElement element = _findElement('T'); |
| 897 ClassElement a = _findElement('A'); |
| 898 ClassElement b = _findElement('B'); |
| 899 ClassElement c = _findElement('C'); |
| 900 var expected = [ |
| 901 _expectId(a, SearchResultKind.REFERENCE, 'T {} // A'), |
| 902 _expectId(b, SearchResultKind.REFERENCE, 'T; // B'), |
| 903 _expectId(c, SearchResultKind.REFERENCE, 'T {} // C'), |
| 904 ]; |
| 905 await _verifyReferences(element, expected); |
| 906 } |
| 907 |
| 889 ExpectedResult _expectId( | 908 ExpectedResult _expectId( |
| 890 Element enclosingElement, SearchResultKind kind, String search, | 909 Element enclosingElement, SearchResultKind kind, String search, |
| 891 {int length, bool isResolved: true, bool isQualified: false}) { | 910 {int length, bool isResolved: true, bool isQualified: false}) { |
| 892 int offset = findOffset(search); | 911 int offset = findOffset(search); |
| 893 if (length == null) { | 912 if (length == null) { |
| 894 length = getLeadingIdentifierLength(search); | 913 length = getLeadingIdentifierLength(search); |
| 895 } | 914 } |
| 896 return new ExpectedResult(enclosingElement, kind, offset, length, | 915 return new ExpectedResult(enclosingElement, kind, offset, length, |
| 897 isResolved: isResolved, isQualified: isQualified); | 916 isResolved: isResolved, isQualified: isQualified); |
| 898 } | 917 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 List<SearchResult> results = await driver.search.references(element); | 952 List<SearchResult> results = await driver.search.references(element); |
| 934 _assertResults(results, expectedMatches); | 953 _assertResults(results, expectedMatches); |
| 935 expect(results, hasLength(expectedMatches.length)); | 954 expect(results, hasLength(expectedMatches.length)); |
| 936 } | 955 } |
| 937 | 956 |
| 938 static void _assertResults( | 957 static void _assertResults( |
| 939 List<SearchResult> matches, List<ExpectedResult> expectedMatches) { | 958 List<SearchResult> matches, List<ExpectedResult> expectedMatches) { |
| 940 expect(matches, unorderedEquals(expectedMatches)); | 959 expect(matches, unorderedEquals(expectedMatches)); |
| 941 } | 960 } |
| 942 } | 961 } |
| OLD | NEW |