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

Side by Side Diff: pkg/analyzer/test/src/dart/analysis/search_test.dart

Issue 2566393003: Implement SearchEngine.searchMemberDeclarations() for the new driver. (Closed)
Patch Set: Created 4 years 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/analyzer/lib/src/dart/analysis/search.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) 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/ast/standard_resolution_map.dart'; 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/src/dart/analysis/driver.dart'; 10 import 'package:analyzer/src/dart/analysis/driver.dart';
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 64 }
65 65
66 @reflectiveTest 66 @reflectiveTest
67 class SearchTest extends BaseAnalysisDriverTest { 67 class SearchTest extends BaseAnalysisDriverTest {
68 static const testUri = 'package:test/test.dart'; 68 static const testUri = 'package:test/test.dart';
69 69
70 CompilationUnit testUnit; 70 CompilationUnit testUnit;
71 CompilationUnitElement testUnitElement; 71 CompilationUnitElement testUnitElement;
72 LibraryElement testLibraryElement; 72 LibraryElement testLibraryElement;
73 73
74 test_classMembers() async {
75 await _resolveTestUnit('''
76 class A {
77 test() {}
78 }
79 class B {
80 int test = 1;
81 int testTwo = 2;
82 main() {
83 int test = 3;
84 }
85 }
86 ''');
87 ClassElement a = _findElement('A');
88 ClassElement b = _findElement('B');
89 RegExp regExp = new RegExp(r'^test$');
90 expect(await driver.search.classMembers(regExp),
91 unorderedEquals([a.methods[0], b.fields[0]]));
92 }
93
74 test_searchReferences_ClassElement_definedInside() async { 94 test_searchReferences_ClassElement_definedInside() async {
75 await _resolveTestUnit(''' 95 await _resolveTestUnit('''
76 class A {}; 96 class A {};
77 main(A p) { 97 main(A p) {
78 A v; 98 A v;
79 } 99 }
80 class B1 extends A {} // extends 100 class B1 extends A {} // extends
81 class B2 implements A {} // implements 101 class B2 implements A {} // implements
82 class B3 extends Object with A {} // with 102 class B3 extends Object with A {} // with
83 List<A> v2 = null; 103 List<A> v2 = null;
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 List<SearchResult> results = await driver.search.references(element); 1010 List<SearchResult> results = await driver.search.references(element);
991 _assertResults(results, expectedMatches); 1011 _assertResults(results, expectedMatches);
992 expect(results, hasLength(expectedMatches.length)); 1012 expect(results, hasLength(expectedMatches.length));
993 } 1013 }
994 1014
995 static void _assertResults( 1015 static void _assertResults(
996 List<SearchResult> matches, List<ExpectedResult> expectedMatches) { 1016 List<SearchResult> matches, List<ExpectedResult> expectedMatches) {
997 expect(matches, unorderedEquals(expectedMatches)); 1017 expect(matches, unorderedEquals(expectedMatches));
998 } 1018 }
999 } 1019 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/analysis/search.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698