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

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

Issue 1802023002: Fix for searching parameters of constructors. (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
« no previous file with comments | « pkg/analysis_server/lib/src/services/search/search_engine_internal.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_engine_internal; 5 library test.services.src.search.search_engine_internal;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/services/index/index.dart'; 9 import 'package:analysis_server/src/services/index/index.dart';
10 import 'package:analysis_server/src/services/search/search_engine.dart'; 10 import 'package:analysis_server/src/services/search/search_engine.dart';
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 } 558 }
559 '''); 559 ''');
560 MethodMember method = findNodeElementAtString('m(); // ref'); 560 MethodMember method = findNodeElementAtString('m(); // ref');
561 Element mainElement = findElement('main'); 561 Element mainElement = findElement('main');
562 var expected = [ 562 var expected = [
563 _expectIdQ(mainElement, MatchKind.INVOCATION, 'm(); // ref') 563 _expectIdQ(mainElement, MatchKind.INVOCATION, 'm(); // ref')
564 ]; 564 ];
565 await _verifyReferences(method, expected); 565 await _verifyReferences(method, expected);
566 } 566 }
567 567
568 test_searchReferences_ParameterElement_ofConstructor() async {
569 _indexTestUnit('''
570 class C {
571 var f;
572 C({p}) : f = p + 1 {
573 p = 2;
574 p += 3;
575 print(p);
576 p();
577 }
578 }
579 main() {
580 new C(p: 42);
581 }
582 ''');
583 ParameterElement element = findElement('p');
584 ClassElement classC = findElement('C');
585 ConstructorElement constructorA = classC.unnamedConstructor;
586 Element mainElement = findElement('main');
587 var expected = [
588 _expectId(constructorA, MatchKind.READ, 'p + 1 {'),
589 _expectId(constructorA, MatchKind.WRITE, 'p = 2;'),
590 _expectId(constructorA, MatchKind.READ_WRITE, 'p += 3;'),
591 _expectId(constructorA, MatchKind.READ, 'p);'),
592 _expectId(constructorA, MatchKind.INVOCATION, 'p();'),
593 _expectIdQ(mainElement, MatchKind.REFERENCE, 'p: 42')
594 ];
595 await _verifyReferences(element, expected);
596 }
597
568 test_searchReferences_ParameterElement_ofLocalFunction() async { 598 test_searchReferences_ParameterElement_ofLocalFunction() async {
569 _indexTestUnit(''' 599 _indexTestUnit('''
570 main() { 600 main() {
571 foo({p}) { 601 foo({p}) {
572 p = 1; 602 p = 1;
573 p += 2; 603 p += 2;
574 print(p); 604 print(p);
575 p(); 605 p();
576 } 606 }
577 foo(p: 42); 607 foo(p: 42);
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 List<SearchMatch> matches = await searchEngine.searchReferences(element); 876 List<SearchMatch> matches = await searchEngine.searchReferences(element);
847 _assertMatches(matches, expectedMatches); 877 _assertMatches(matches, expectedMatches);
848 expect(matches, hasLength(expectedMatches.length)); 878 expect(matches, hasLength(expectedMatches.length));
849 } 879 }
850 880
851 static void _assertMatches( 881 static void _assertMatches(
852 List<SearchMatch> matches, List<ExpectedMatch> expectedMatches) { 882 List<SearchMatch> matches, List<ExpectedMatch> expectedMatches) {
853 expect(matches, unorderedEquals(expectedMatches)); 883 expect(matches, unorderedEquals(expectedMatches));
854 } 884 }
855 } 885 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/search/search_engine_internal.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698