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

Side by Side Diff: pkg/analyzer/test/src/context/context_test.dart

Issue 2092673002: Fix recomputing LibraryElement.exportNamespace. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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/analyzer/lib/src/task/dart.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) 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 analyzer.test.src.context.context_test; 5 library analyzer.test.src.context.context_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 } 294 }
295 // Adding the source as a changedSource should have no effect since 295 // Adding the source as a changedSource should have no effect since
296 // it is already overridden in the content cache. 296 // it is already overridden in the content cache.
297 ChangeSet changeSet = new ChangeSet(); 297 ChangeSet changeSet = new ChangeSet();
298 changeSet.changedSource(source); 298 changeSet.changedSource(source);
299 ApplyChangesStatus changesStatus = context.applyChanges(changeSet); 299 ApplyChangesStatus changesStatus = context.applyChanges(changeSet);
300 expect(changesStatus.hasChanges, isFalse); 300 expect(changesStatus.hasChanges, isFalse);
301 expect(context.sourcesNeedingProcessing, hasLength(0)); 301 expect(context.sourcesNeedingProcessing, hasLength(0));
302 } 302 }
303 303
304 void test_applyChanges_recompute_exportNamespace() {
305 Source libSource = addSource(
306 "/lib.dart",
307 r'''
308 class A {}
309 ''');
310 Source exporterSource = addSource(
311 "/exporter.dart",
312 r'''
313 export 'lib.dart';
314 ''');
315 _performPendingAnalysisTasks();
316 // initially: A
317 {
318 LibraryElement libraryElement =
319 context.getResult(exporterSource, LIBRARY_ELEMENT1) as LibraryElement;
320 expect(libraryElement.exportNamespace.definedNames.keys,
321 unorderedEquals(['A']));
322 }
323 // after update: B
324 context.setContents(
325 libSource,
326 r'''
327 class B {}''');
328 _performPendingAnalysisTasks();
329 {
330 LibraryElement libraryElement =
331 context.getResult(exporterSource, LIBRARY_ELEMENT1) as LibraryElement;
332 expect(libraryElement.exportNamespace.definedNames.keys,
333 unorderedEquals(['B']));
334 }
335 }
336
304 Future test_applyChanges_remove() { 337 Future test_applyChanges_remove() {
305 SourcesChangedListener listener = new SourcesChangedListener(); 338 SourcesChangedListener listener = new SourcesChangedListener();
306 context.onSourcesChanged.listen(listener.onData); 339 context.onSourcesChanged.listen(listener.onData);
307 String libAContents = r''' 340 String libAContents = r'''
308 library libA; 341 library libA;
309 import 'libB.dart';'''; 342 import 'libB.dart';''';
310 Source libA = addSource("/libA.dart", libAContents); 343 Source libA = addSource("/libA.dart", libAContents);
311 String libBContents = "library libB;"; 344 String libBContents = "library libB;";
312 Source libB = addSource("/libB.dart", libBContents); 345 Source libB = addSource("/libB.dart", libBContents);
313 LibraryElement libAElement = context.computeLibraryElement(libA); 346 LibraryElement libAElement = context.computeLibraryElement(libA);
(...skipping 2880 matching lines...) Expand 10 before | Expand all | Expand 10 after
3194 * Initialize the visitor. 3227 * Initialize the visitor.
3195 */ 3228 */
3196 _ElementGatherer(); 3229 _ElementGatherer();
3197 3230
3198 @override 3231 @override
3199 void visitElement(Element element) { 3232 void visitElement(Element element) {
3200 elements[element] = element; 3233 elements[element] = element;
3201 super.visitElement(element); 3234 super.visitElement(element);
3202 } 3235 }
3203 } 3236 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698