Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(811)

Side by Side Diff: pkg/analysis_server/test/services/search/search_engine2_test.dart

Issue 1779233002: Fix for indexing synthetic elements. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 library test.services.src.search.search_engine2; 5 library test.services.src.search.search_engine2;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/services/index2/index2.dart'; 9 import 'package:analysis_server/src/services/index2/index2.dart';
10 import 'package:analysis_server/src/services/search/search_engine.dart'; 10 import 'package:analysis_server/src/services/search/search_engine.dart';
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 195 }
196 '''); 196 ''');
197 ConstructorElement element = findElement('named'); 197 ConstructorElement element = findElement('named');
198 Element mainElement = findElement('main'); 198 Element mainElement = findElement('main');
199 var expected = [ 199 var expected = [
200 _expectIdQ(mainElement, MatchKind.REFERENCE, '.named();', length: 6) 200 _expectIdQ(mainElement, MatchKind.REFERENCE, '.named();', length: 6)
201 ]; 201 ];
202 await _verifyReferences(element, expected); 202 await _verifyReferences(element, expected);
203 } 203 }
204 204
205 test_searchReferences_ConstructorElement_synthetic() async {
206 _indexTestUnit('''
207 class A {
208 }
209 main() {
210 new A();
211 }
212 ''');
213 ClassElement classElement = findElement('A');
214 ConstructorElement element = classElement.unnamedConstructor;
215 Element mainElement = findElement('main');
216 var expected = [
217 _expectIdQ(mainElement, MatchKind.REFERENCE, '();', length: 0)
218 ];
219 await _verifyReferences(element, expected);
220 }
221
205 test_searchReferences_Element_unknown() async { 222 test_searchReferences_Element_unknown() async {
206 await _verifyReferences(DynamicElementImpl.instance, []); 223 await _verifyReferences(DynamicElementImpl.instance, []);
207 } 224 }
208 225
209 test_searchReferences_FieldElement() async { 226 test_searchReferences_FieldElement() async {
210 _indexTestUnit(''' 227 _indexTestUnit('''
211 class A { 228 class A {
212 var field; 229 var field;
213 A({this.field}); 230 A({this.field});
214 main() { 231 main() {
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 var expected = [ 553 var expected = [
537 _expectId(elementA, MatchKind.REFERENCE, 'ppp.Future'), 554 _expectId(elementA, MatchKind.REFERENCE, 'ppp.Future'),
538 _expectId(elementB, MatchKind.REFERENCE, 'ppp.Stream') 555 _expectId(elementB, MatchKind.REFERENCE, 'ppp.Stream')
539 ]; 556 ];
540 await _verifyReferences(element, expected); 557 await _verifyReferences(element, expected);
541 } 558 }
542 559
543 test_searchReferences_PropertyAccessorElement_getter() async { 560 test_searchReferences_PropertyAccessorElement_getter() async {
544 _indexTestUnit(''' 561 _indexTestUnit('''
545 class A { 562 class A {
546 get g => null; 563 get ggg => null;
547 main() { 564 main() {
548 g; // 1 565 print(ggg); // ref-nq
549 this.g; // 2 566 print(this.ggg); // ref-q
567 ggg(); // inv-nq
568 this.ggg(); // inv-q
550 } 569 }
551 } 570 }
552 '''); 571 ''');
553 PropertyAccessorElement element = findElement('g', ElementKind.GETTER); 572 PropertyAccessorElement element = findElement('ggg', ElementKind.GETTER);
554 Element mainElement = findElement('main'); 573 Element main = findElement('main');
555 var expected = [ 574 var expected = [
556 _expectId(mainElement, MatchKind.REFERENCE, 'g; // 1'), 575 _expectId(main, MatchKind.REFERENCE, 'ggg); // ref-nq'),
557 _expectIdQ(mainElement, MatchKind.REFERENCE, 'g; // 2') 576 _expectIdQ(main, MatchKind.REFERENCE, 'ggg); // ref-q'),
577 _expectId(main, MatchKind.INVOCATION, 'ggg(); // inv-nq'),
578 _expectIdQ(main, MatchKind.INVOCATION, 'ggg(); // inv-q'),
558 ]; 579 ];
559 await _verifyReferences(element, expected); 580 await _verifyReferences(element, expected);
560 } 581 }
561 582
562 test_searchReferences_PropertyAccessorElement_setter() async { 583 test_searchReferences_PropertyAccessorElement_setter() async {
563 _indexTestUnit(''' 584 _indexTestUnit('''
564 class A { 585 class A {
565 set s(x) {} 586 set s(x) {}
566 main() { 587 main() {
567 s = 1; 588 s = 1;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 Element element, List<ExpectedMatch> expectedMatches) async { 726 Element element, List<ExpectedMatch> expectedMatches) async {
706 List<SearchMatch> matches = await searchEngine.searchReferences(element); 727 List<SearchMatch> matches = await searchEngine.searchReferences(element);
707 _assertMatches(matches, expectedMatches); 728 _assertMatches(matches, expectedMatches);
708 } 729 }
709 730
710 static void _assertMatches( 731 static void _assertMatches(
711 List<SearchMatch> matches, List<ExpectedMatch> expectedMatches) { 732 List<SearchMatch> matches, List<ExpectedMatch> expectedMatches) {
712 expect(matches, unorderedEquals(expectedMatches)); 733 expect(matches, unorderedEquals(expectedMatches));
713 } 734 }
714 } 735 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/search/search_engine_internal2.dart ('k') | pkg/analyzer/lib/src/summary/index_unit.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698