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

Unified Diff: pkg/analyzer/test/src/dart/analysis/search_test.dart

Issue 2572603003: Implement SearchEngine.searchTopLevelDeclarations() 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/dart/analysis/search.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/dart/analysis/search_test.dart
diff --git a/pkg/analyzer/test/src/dart/analysis/search_test.dart b/pkg/analyzer/test/src/dart/analysis/search_test.dart
index fd8373f47c7f3af90c0b6a40b9ce8d286f7a7023..293c1dcd18fc961994390e3901841910f6113085 100644
--- a/pkg/analyzer/test/src/dart/analysis/search_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/search_test.dart
@@ -528,6 +528,31 @@ main(A<int> a) {
await _verifyReferences(method, expected);
}
+ test_searchReferences_ParameterElement_named() async {
+ await _resolveTestUnit('''
+foo({p}) {
+ p = 1;
+ p += 2;
+ print(p);
+ p();
+}
+main() {
+ foo(p: 42);
+}
+''');
+ ParameterElement element = _findElement('p');
+ Element fooElement = _findElement('foo');
+ Element mainElement = _findElement('main');
+ var expected = [
+ _expectId(fooElement, SearchResultKind.WRITE, 'p = 1;'),
+ _expectId(fooElement, SearchResultKind.READ_WRITE, 'p += 2;'),
+ _expectId(fooElement, SearchResultKind.READ, 'p);'),
+ _expectId(fooElement, SearchResultKind.INVOCATION, 'p();'),
+ _expectIdQ(mainElement, SearchResultKind.REFERENCE, 'p: 42')
+ ];
+ await _verifyReferences(element, expected);
+ }
+
test_searchReferences_ParameterElement_ofConstructor() async {
await _resolveTestUnit('''
class C {
@@ -627,31 +652,6 @@ main() {
await _verifyReferences(element, expected);
}
- test_searchReferences_ParameterElement_named() async {
- await _resolveTestUnit('''
-foo({p}) {
- p = 1;
- p += 2;
- print(p);
- p();
-}
-main() {
- foo(p: 42);
-}
-''');
- ParameterElement element = _findElement('p');
- Element fooElement = _findElement('foo');
- Element mainElement = _findElement('main');
- var expected = [
- _expectId(fooElement, SearchResultKind.WRITE, 'p = 1;'),
- _expectId(fooElement, SearchResultKind.READ_WRITE, 'p += 2;'),
- _expectId(fooElement, SearchResultKind.READ, 'p);'),
- _expectId(fooElement, SearchResultKind.INVOCATION, 'p();'),
- _expectIdQ(mainElement, SearchResultKind.REFERENCE, 'p: 42')
- ];
- await _verifyReferences(element, expected);
- }
-
test_searchReferences_PrefixElement() async {
String partCode = r'''
part of my_lib;
@@ -924,6 +924,25 @@ class C implements T {} // C
await _verifyReferences(element, expected);
}
+ test_topLevelElements() async {
+ await _resolveTestUnit('''
+class A {} // A
+class B = Object with A;
+typedef C();
+D() {}
+var E = null;
+class NoMatchABCDE {}
+''');
+ Element a = _findElement('A');
+ Element b = _findElement('B');
+ Element c = _findElement('C');
+ Element d = _findElement('D');
+ Element e = _findElement('E');
+ RegExp regExp = new RegExp(r'^[A-E]$');
+ expect(await driver.search.topLevelElements(regExp),
+ unorderedEquals([a, b, c, d, e]));
+ }
+
ExpectedResult _expectId(
Element enclosingElement, SearchResultKind kind, String search,
{int length, bool isResolved: true, bool isQualified: false}) {
« 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