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

Side by Side Diff: pkg/analysis_server/test/services/index2/index2_test.dart

Issue 1778113002: Separate index objects for each analysis context. (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 | « pkg/analysis_server/lib/src/services/index2/index2.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 'package:analysis_server/src/services/index2/index2.dart'; 5 import 'package:analysis_server/src/services/index2/index2.dart';
6 import 'package:analyzer/dart/ast/ast.dart'; 6 import 'package:analyzer/dart/ast/ast.dart';
7 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/src/generated/source.dart'; 8 import 'package:analyzer/src/generated/source.dart';
9 import 'package:analyzer/src/summary/idl.dart'; 9 import 'package:analyzer/src/summary/idl.dart';
10 import 'package:test_reflective_loader/test_reflective_loader.dart'; 10 import 'package:test_reflective_loader/test_reflective_loader.dart';
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 '''); 173 ''');
174 List<Location> locations = 174 List<Location> locations =
175 await index.getUnresolvedMemberReferences('test'); 175 await index.getUnresolvedMemberReferences('test');
176 expect(locations, hasLength(4)); 176 expect(locations, hasLength(4));
177 findLocationTest(locations, 'test(); // p-inv-ur-q'); 177 findLocationTest(locations, 'test(); // p-inv-ur-q');
178 findLocationTest(locations, 'test = 1; // p-ref-ur-q'); 178 findLocationTest(locations, 'test = 1; // p-ref-ur-q');
179 findLocationTest(locations, 'test += 2; // p-ref-ur-q'); 179 findLocationTest(locations, 'test += 2; // p-ref-ur-q');
180 findLocationTest(locations, 'test); // p-ref-ur-q'); 180 findLocationTest(locations, 'test); // p-ref-ur-q');
181 } 181 }
182 182
183 test_indexUnit_nullUnit() async {
184 index.indexUnit(null);
185 }
186
187 test_indexUnit_nullUnitElement() async {
188 resolveTestUnit('');
189 testUnit.element = null;
190 index.indexUnit(testUnit);
191 }
192
193 test_removeContext() async {
194 _indexTestUnit('''
195 class A {}
196 ''');
197 RegExp regExp = new RegExp(r'^A$');
198 expect(await index.getDefinedNames(regExp, IndexNameKind.topLevel),
199 hasLength(1));
200 // remove the context - no
201 index.removeContext(context);
202 expect(
203 await index.getDefinedNames(regExp, IndexNameKind.topLevel), isEmpty);
204 }
205
183 /** 206 /**
184 * Assert that the given list of [locations] has a [Location] corresponding 207 * Assert that the given list of [locations] has a [Location] corresponding
185 * to the [element]. 208 * to the [element].
186 */ 209 */
187 void _assertHasDefinedName(List<Location> locations, Element element) { 210 void _assertHasDefinedName(List<Location> locations, Element element) {
188 String libraryUri = element.library.source.uri.toString(); 211 String libraryUri = element.library.source.uri.toString();
189 String unitUri = element.source.uri.toString(); 212 String unitUri = element.source.uri.toString();
190 for (Location location in locations) { 213 for (Location location in locations) {
191 if (location.libraryUri == libraryUri && 214 if (location.libraryUri == libraryUri &&
192 location.unitUri == unitUri && 215 location.unitUri == unitUri &&
(...skipping 11 matching lines...) Expand all
204 index.indexUnit(testUnit); 227 index.indexUnit(testUnit);
205 } 228 }
206 229
207 Source _indexUnit(String path, String code) { 230 Source _indexUnit(String path, String code) {
208 Source source = addSource(path, code); 231 Source source = addSource(path, code);
209 CompilationUnit unit = resolveLibraryUnit(source); 232 CompilationUnit unit = resolveLibraryUnit(source);
210 index.indexUnit(unit); 233 index.indexUnit(unit);
211 return source; 234 return source;
212 } 235 }
213 } 236 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/index2/index2.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698