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

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

Issue 709493002: Fix 'Unused local variable' hints in analyzer and analysis_server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
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; 5 library test.services.src.search.search_engine;
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/index/local_memory_index.dart'; 10 import 'package:analysis_server/src/services/index/local_memory_index.dart';
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 a.test(); // a-inv-r-q 162 a.test(); // a-inv-r-q
163 a.test = 1; // a-write-r-q 163 a.test = 1; // a-write-r-q
164 a.test += 2; // a-read-write-r-q 164 a.test += 2; // a-read-write-r-q
165 print(a.test); // a-read-r-q 165 print(a.test); // a-read-r-q
166 p.test(); // p-inv-ur-q 166 p.test(); // p-inv-ur-q
167 p.test = 1; // p-write-ur-q 167 p.test = 1; // p-write-ur-q
168 p.test += 2; // p-read-write-ur-q 168 p.test += 2; // p-read-write-ur-q
169 print(p.test); // p-read-ur-q 169 print(p.test); // p-read-ur-q
170 } 170 }
171 '''); 171 ''');
172 ClassElement elementA = findElement('A');
173 ClassElement elementB = findElement('B');
174 Element mainA = findElement('mainA'); 172 Element mainA = findElement('mainA');
175 Element main = findElement('main'); 173 Element main = findElement('main');
176 var expected = [ 174 var expected = [
177 _expectId(mainA, MatchKind.INVOCATION, 'test(); // a-inv-r-nq'), 175 _expectId(mainA, MatchKind.INVOCATION, 'test(); // a-inv-r-nq'),
178 _expectId(mainA, MatchKind.WRITE, 'test = 1; // a-write-r-nq'), 176 _expectId(mainA, MatchKind.WRITE, 'test = 1; // a-write-r-nq'),
179 _expectId(mainA, MatchKind.READ_WRITE, 'test += 2; // a-read-write-r-nq' ), 177 _expectId(mainA, MatchKind.READ_WRITE, 'test += 2; // a-read-write-r-nq' ),
180 _expectId(mainA, MatchKind.READ, 'test); // a-read-r-nq'), 178 _expectId(mainA, MatchKind.READ, 'test); // a-read-r-nq'),
181 _expectIdQ(main, MatchKind.INVOCATION, 'test(); // a-inv-r-q'), 179 _expectIdQ(main, MatchKind.INVOCATION, 'test(); // a-inv-r-q'),
182 _expectIdQ(main, MatchKind.WRITE, 'test = 1; // a-write-r-q'), 180 _expectIdQ(main, MatchKind.WRITE, 'test = 1; // a-write-r-q'),
183 _expectIdQ(main, MatchKind.READ_WRITE, 'test += 2; // a-read-write-r-q') , 181 _expectIdQ(main, MatchKind.READ_WRITE, 'test += 2; // a-read-write-r-q') ,
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 Element mainElement = findElement('main'); 363 Element mainElement = findElement('main');
366 var kind = MatchKind.REFERENCE; 364 var kind = MatchKind.REFERENCE;
367 var expected = [ 365 var expected = [
368 _expectId(mainElement, kind, 'math.PI);', length: 'math.'.length)]; 366 _expectId(mainElement, kind, 'math.PI);', length: 'math.'.length)];
369 return _verifyReferences(element, expected); 367 return _verifyReferences(element, expected);
370 } 368 }
371 369
372 Future test_searchReferences_LibraryElement() { 370 Future test_searchReferences_LibraryElement() {
373 var codeA = 'part of lib; // A'; 371 var codeA = 'part of lib; // A';
374 var codeB = 'part of lib; // B'; 372 var codeB = 'part of lib; // B';
375 var sourceA = addSource('/unitA.dart', codeA); 373 addSource('/unitA.dart', codeA);
376 var sourceB = addSource('/unitB.dart', codeB); 374 addSource('/unitB.dart', codeB);
377 _indexTestUnit(''' 375 _indexTestUnit('''
378 library lib; 376 library lib;
379 part 'unitA.dart'; 377 part 'unitA.dart';
380 part 'unitB.dart'; 378 part 'unitB.dart';
381 '''); 379 ''');
382 LibraryElement element = testLibraryElement; 380 LibraryElement element = testLibraryElement;
383 CompilationUnitElement elementA = element.parts[0]; 381 CompilationUnitElement elementA = element.parts[0];
384 CompilationUnitElement elementB = element.parts[1]; 382 CompilationUnitElement elementB = element.parts[1];
385 index.indexUnit(context, elementA.node); 383 index.indexUnit(context, elementA.node);
386 index.indexUnit(context, elementB.node); 384 index.indexUnit(context, elementB.node);
387 Element mainElement = findElement('main');
388 var expected = [ 385 var expected = [
389 new ExpectedMatch( 386 new ExpectedMatch(
390 elementA, 387 elementA,
391 MatchKind.REFERENCE, 388 MatchKind.REFERENCE,
392 codeA.indexOf('lib; // A'), 389 codeA.indexOf('lib; // A'),
393 'lib'.length), 390 'lib'.length),
394 new ExpectedMatch( 391 new ExpectedMatch(
395 elementB, 392 elementB,
396 MatchKind.REFERENCE, 393 MatchKind.REFERENCE,
397 codeB.indexOf('lib; // B'), 394 codeB.indexOf('lib; // B'),
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 621
625 Future test_searchTopLevelDeclarations() { 622 Future test_searchTopLevelDeclarations() {
626 _indexTestUnit(''' 623 _indexTestUnit('''
627 class A {} // A 624 class A {} // A
628 class B = Object with A; 625 class B = Object with A;
629 typedef C(); 626 typedef C();
630 D() {} 627 D() {}
631 var E = null; 628 var E = null;
632 class NoMatchABCDE {} 629 class NoMatchABCDE {}
633 '''); 630 ''');
634 NameElement element = new NameElement('test');
635 Element topA = findElement('A'); 631 Element topA = findElement('A');
636 Element topB = findElement('B'); 632 Element topB = findElement('B');
637 Element topC = findElement('C'); 633 Element topC = findElement('C');
638 Element topD = findElement('D'); 634 Element topD = findElement('D');
639 Element topE = findElement('E'); 635 Element topE = findElement('E');
640 Element topNoMatch = new MockElement('NoMatchABCDE');
641 var expected = [ 636 var expected = [
642 _expectId(topA, MatchKind.DECLARATION, 'A {} // A'), 637 _expectId(topA, MatchKind.DECLARATION, 'A {} // A'),
643 _expectId(topB, MatchKind.DECLARATION, 'B ='), 638 _expectId(topB, MatchKind.DECLARATION, 'B ='),
644 _expectId(topC, MatchKind.DECLARATION, 'C()'), 639 _expectId(topC, MatchKind.DECLARATION, 'C()'),
645 _expectId(topD, MatchKind.DECLARATION, 'D() {}'), 640 _expectId(topD, MatchKind.DECLARATION, 'D() {}'),
646 _expectId(topE, MatchKind.DECLARATION, 'E = null')]; 641 _expectId(topE, MatchKind.DECLARATION, 'E = null')];
647 return _verifyTopLevelDeclarations('^[A-E]\$', expected); 642 return _verifyTopLevelDeclarations('^[A-E]\$', expected);
648 } 643 }
649 644
650 ExpectedMatch _expectId(Element element, MatchKind kind, String search, 645 ExpectedMatch _expectId(Element element, MatchKind kind, String search,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 pattern).then((List<SearchMatch> matches) { 689 pattern).then((List<SearchMatch> matches) {
695 _assertMatches(matches, expectedMatches); 690 _assertMatches(matches, expectedMatches);
696 }); 691 });
697 } 692 }
698 693
699 static void _assertMatches(List<SearchMatch> matches, 694 static void _assertMatches(List<SearchMatch> matches,
700 List<ExpectedMatch> expectedMatches) { 695 List<ExpectedMatch> expectedMatches) {
701 expect(matches, unorderedEquals(expectedMatches)); 696 expect(matches, unorderedEquals(expectedMatches));
702 } 697 }
703 } 698 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/services/search/hierarchy_test.dart ('k') | pkg/analysis_server/test/timing/timing_framework.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698