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

Side by Side Diff: pkg/analysis_server/test/search/element_references_test.dart

Issue 949623005: Field references in field format parameter declarations and initializers mean writing. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | 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.search.element_references; 5 library test.search.element_references;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol.dart'; 9 import 'package:analysis_server/src/protocol.dart';
10 import 'package:analysis_server/src/services/index/index.dart'; 10 import 'package:analysis_server/src/services/index/index.dart';
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 expect(searchElement.kind, ElementKind.CONSTRUCTOR); 131 expect(searchElement.kind, ElementKind.CONSTRUCTOR);
132 expect(results, hasLength(1)); 132 expect(results, hasLength(1));
133 assertHasResult(SearchResultKind.REFERENCE, '(1)', 0); 133 assertHasResult(SearchResultKind.REFERENCE, '(1)', 0);
134 } 134 }
135 135
136 test_field_explicit() async { 136 test_field_explicit() async {
137 addTestFile(''' 137 addTestFile('''
138 class A { 138 class A {
139 var fff; // declaration 139 var fff; // declaration
140 A(this.fff); // in constructor 140 A(this.fff); // in constructor
141 A.named() : fff = 1;
141 m() { 142 m() {
142 fff = 2; 143 fff = 2;
143 fff += 3; 144 fff += 3;
144 print(fff); // in m() 145 print(fff); // in m()
145 fff(); // in m() 146 fff(); // in m()
146 } 147 }
147 } 148 }
148 main(A a) { 149 main(A a) {
149 a.fff = 20; 150 a.fff = 20;
150 a.fff += 30; 151 a.fff += 30;
151 print(a.fff); // in main() 152 print(a.fff); // in main()
152 a.fff(); // in main() 153 a.fff(); // in main()
153 } 154 }
154 '''); 155 ''');
155 await findElementReferences('fff; // declaration', false); 156 await findElementReferences('fff; // declaration', false);
156 expect(searchElement.kind, ElementKind.FIELD); 157 expect(searchElement.kind, ElementKind.FIELD);
157 expect(results, hasLength(10)); 158 expect(results, hasLength(11));
158 assertHasResult(SearchResultKind.DECLARATION, 'fff; // declaration'); 159 assertHasResult(SearchResultKind.DECLARATION, 'fff; // declaration');
159 assertHasResult(SearchResultKind.REFERENCE, 'fff); // in constructor'); 160 assertHasResult(SearchResultKind.WRITE, 'fff); // in constructor');
161 assertHasResult(SearchResultKind.WRITE, 'fff = 1;');
160 // m() 162 // m()
161 assertHasResult(SearchResultKind.WRITE, 'fff = 2;'); 163 assertHasResult(SearchResultKind.WRITE, 'fff = 2;');
162 assertHasResult(SearchResultKind.WRITE, 'fff += 3;'); 164 assertHasResult(SearchResultKind.WRITE, 'fff += 3;');
163 assertHasResult(SearchResultKind.READ, 'fff); // in m()'); 165 assertHasResult(SearchResultKind.READ, 'fff); // in m()');
164 assertHasResult(SearchResultKind.INVOCATION, 'fff(); // in m()'); 166 assertHasResult(SearchResultKind.INVOCATION, 'fff(); // in m()');
165 // main() 167 // main()
166 assertHasResult(SearchResultKind.WRITE, 'fff = 20;'); 168 assertHasResult(SearchResultKind.WRITE, 'fff = 20;');
167 assertHasResult(SearchResultKind.WRITE, 'fff += 30;'); 169 assertHasResult(SearchResultKind.WRITE, 'fff += 30;');
168 assertHasResult(SearchResultKind.READ, 'fff); // in main()'); 170 assertHasResult(SearchResultKind.READ, 'fff); // in main()');
169 assertHasResult(SearchResultKind.INVOCATION, 'fff(); // in main()'); 171 assertHasResult(SearchResultKind.INVOCATION, 'fff(); // in main()');
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 m() { 213 m() {
212 fff = 2; 214 fff = 2;
213 print(fff); // in m() 215 print(fff); // in m()
214 } 216 }
215 } 217 }
216 '''); 218 ''');
217 await findElementReferences('fff); // in constructor', false); 219 await findElementReferences('fff); // in constructor', false);
218 expect(searchElement.kind, ElementKind.FIELD); 220 expect(searchElement.kind, ElementKind.FIELD);
219 expect(results, hasLength(4)); 221 expect(results, hasLength(4));
220 assertHasResult(SearchResultKind.DECLARATION, 'fff; // declaration'); 222 assertHasResult(SearchResultKind.DECLARATION, 'fff; // declaration');
221 assertHasResult(SearchResultKind.REFERENCE, 'fff); // in constructor'); 223 assertHasResult(SearchResultKind.WRITE, 'fff); // in constructor');
222 assertHasResult(SearchResultKind.WRITE, 'fff = 2;'); 224 assertHasResult(SearchResultKind.WRITE, 'fff = 2;');
223 assertHasResult(SearchResultKind.READ, 'fff); // in m()'); 225 assertHasResult(SearchResultKind.READ, 'fff); // in m()');
224 } 226 }
225 227
226 test_function() async { 228 test_function() async {
227 addTestFile(''' 229 addTestFile('''
228 fff(p) {} 230 fff(p) {}
229 main() { 231 main() {
230 fff(1); 232 fff(1);
231 print(fff); 233 print(fff);
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 print(vvv); 724 print(vvv);
723 } 725 }
724 '''); 726 ''');
725 Request request = 727 Request request =
726 new SearchFindElementReferencesParams(testFile, 0, false).toRequest('0') ; 728 new SearchFindElementReferencesParams(testFile, 0, false).toRequest('0') ;
727 Response response = await waitResponse(request); 729 Response response = await waitResponse(request);
728 expect(response.error, isNotNull); 730 expect(response.error, isNotNull);
729 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); 731 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED);
730 } 732 }
731 } 733 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698