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

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

Issue 1791493003: Fix for indexing synthetic enum fields. (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 | « no previous file | pkg/analyzer/lib/src/summary/format.fbs » ('j') | 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_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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 _expectId(main, MatchKind.READ, 'field); // ref-nq'), 250 _expectId(main, MatchKind.READ, 'field); // ref-nq'),
251 _expectIdQ(main, MatchKind.READ, 'field); // ref-q'), 251 _expectIdQ(main, MatchKind.READ, 'field); // ref-q'),
252 _expectId(main, MatchKind.INVOCATION, 'field(); // inv-nq'), 252 _expectId(main, MatchKind.INVOCATION, 'field(); // inv-nq'),
253 _expectIdQ(main, MatchKind.INVOCATION, 'field(); // inv-q'), 253 _expectIdQ(main, MatchKind.INVOCATION, 'field(); // inv-q'),
254 _expectId(main, MatchKind.WRITE, 'field = 2; // ref-nq'), 254 _expectId(main, MatchKind.WRITE, 'field = 2; // ref-nq'),
255 _expectIdQ(main, MatchKind.WRITE, 'field = 3; // ref-q'), 255 _expectIdQ(main, MatchKind.WRITE, 'field = 3; // ref-q'),
256 ]; 256 ];
257 await _verifyReferences(element, expected); 257 await _verifyReferences(element, expected);
258 } 258 }
259 259
260 test_searchReferences_FieldElement_ofEnum() async {
261 _indexTestUnit('''
262 enum MyEnum {
263 A, B, C
264 }
265 main() {
266 print(MyEnum.A.index);
267 print(MyEnum.values);
268 print(MyEnum.A);
269 print(MyEnum.B);
270 }
271 ''');
272 ClassElement enumElement = findElement('MyEnum');
273 Element mainElement = findElement('main');
274 await _verifyReferences(enumElement.getField('index'),
275 [_expectIdQ(mainElement, MatchKind.READ, 'index);')]);
276 await _verifyReferences(enumElement.getField('values'),
277 [_expectIdQ(mainElement, MatchKind.READ, 'values);')]);
278 await _verifyReferences(enumElement.getField('A'), [
279 _expectIdQ(mainElement, MatchKind.READ, 'A.index);'),
280 _expectIdQ(mainElement, MatchKind.READ, 'A);')
281 ]);
282 await _verifyReferences(enumElement.getField('B'),
283 [_expectIdQ(mainElement, MatchKind.READ, 'B);')]);
284 }
285
260 test_searchReferences_FieldElement_synthetic() async { 286 test_searchReferences_FieldElement_synthetic() async {
261 _indexTestUnit(''' 287 _indexTestUnit('''
262 class A { 288 class A {
263 get field => null; 289 get field => null;
264 set field(x) {} 290 set field(x) {}
265 main() { 291 main() {
266 // getter 292 // getter
267 print(field); // ref-nq 293 print(field); // ref-nq
268 print(this.field); // ref-q 294 print(this.field); // ref-q
269 field(); // inv-nq 295 field(); // inv-nq
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 List<SearchMatch> matches = await searchEngine.searchReferences(element); 792 List<SearchMatch> matches = await searchEngine.searchReferences(element);
767 _assertMatches(matches, expectedMatches); 793 _assertMatches(matches, expectedMatches);
768 expect(matches, hasLength(expectedMatches.length)); 794 expect(matches, hasLength(expectedMatches.length));
769 } 795 }
770 796
771 static void _assertMatches( 797 static void _assertMatches(
772 List<SearchMatch> matches, List<ExpectedMatch> expectedMatches) { 798 List<SearchMatch> matches, List<ExpectedMatch> expectedMatches) {
773 expect(matches, unorderedEquals(expectedMatches)); 799 expect(matches, unorderedEquals(expectedMatches));
774 } 800 }
775 } 801 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/format.fbs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698