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

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

Issue 2996383002: Remove support for watching changes to the set of files known to a driver (Closed)
Patch Set: Created 3 years, 4 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/dart/analysis/file_state.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';
6 import 'dart:convert'; 5 import 'dart:convert';
7 import 'dart:typed_data'; 6 import 'dart:typed_data';
8 7
9 import 'package:analyzer/file_system/file_system.dart'; 8 import 'package:analyzer/file_system/file_system.dart';
10 import 'package:analyzer/file_system/memory_file_system.dart'; 9 import 'package:analyzer/file_system/memory_file_system.dart';
11 import 'package:analyzer/source/package_map_resolver.dart'; 10 import 'package:analyzer/source/package_map_resolver.dart';
12 import 'package:analyzer/src/dart/analysis/file_state.dart'; 11 import 'package:analyzer/src/dart/analysis/file_state.dart';
13 import 'package:analyzer/src/dart/analysis/top_level_declaration.dart'; 12 import 'package:analyzer/src/dart/analysis/top_level_declaration.dart';
14 import 'package:analyzer/src/generated/engine.dart' 13 import 'package:analyzer/src/generated/engine.dart'
15 show AnalysisOptions, AnalysisOptionsImpl; 14 show AnalysisOptions, AnalysisOptionsImpl;
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 when(generatedSource.fullName).thenReturn(generatedPath); 497 when(generatedSource.fullName).thenReturn(generatedPath);
499 when(generatedSource.uri).thenReturn(uri); 498 when(generatedSource.uri).thenReturn(uri);
500 499
501 when(generatedUriResolver.resolveAbsolute(uri, uri)) 500 when(generatedUriResolver.resolveAbsolute(uri, uri))
502 .thenReturn(generatedSource); 501 .thenReturn(generatedSource);
503 502
504 expect(fileSystemState.hasUri(templatePath), isFalse); 503 expect(fileSystemState.hasUri(templatePath), isFalse);
505 expect(fileSystemState.hasUri(generatedPath), isTrue); 504 expect(fileSystemState.hasUri(generatedPath), isTrue);
506 } 505 }
507 506
508 test_knownFilesSetChanges() async {
509 fileSystemState.test.knownFilesDelay = new Duration(milliseconds: 5);
510
511 String a = _p('/test/lib/a.dart');
512 String b = _p('/test/lib/b.dart');
513 String c = _p('/test/lib/c.dart');
514 provider.newFile(a, r'''
515 import 'b.dart';
516 ''');
517 provider.newFile(b, '');
518 provider.newFile(c, '');
519
520 Stream<KnownFilesSetChange> broadcastEvents =
521 fileSystemState.knownFilesSetChanges.asBroadcastStream();
522
523 FileState file = fileSystemState.getFileForPath(a);
524 {
525 KnownFilesSetChange event = await broadcastEvents.first;
526 expect(event.added, contains(a));
527 expect(event.added, contains(b));
528 expect(event.removed, isEmpty);
529 }
530
531 // Update a.dart to import c.dart and refresh.
532 // So, c.dart should be reported as added in the next change event.
533 provider.newFile(a, r'''
534 import 'b.dart';
535 import 'c.dart';
536 ''');
537 file.refresh();
538 {
539 KnownFilesSetChange event = await broadcastEvents.first;
540 expect(event.added, contains(c));
541 expect(event.removed, isEmpty);
542 }
543 }
544
545 test_referencedNames() { 507 test_referencedNames() {
546 String path = _p('/aaa/lib/a.dart'); 508 String path = _p('/aaa/lib/a.dart');
547 provider.newFile(path, r''' 509 provider.newFile(path, r'''
548 A foo(B p) { 510 A foo(B p) {
549 foo(null); 511 foo(null);
550 C c = new C(p); 512 C c = new C(p);
551 return c; 513 return c;
552 } 514 }
553 '''); 515 ''');
554 FileState file = fileSystemState.getFileForPath(path); 516 FileState file = fileSystemState.getFileForPath(path);
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 String _p(String path) => provider.convertPath(path); 788 String _p(String path) => provider.convertPath(path);
827 789
828 static String _md5(String content) { 790 static String _md5(String content) {
829 return hex.encode(md5.convert(UTF8.encode(content)).bytes); 791 return hex.encode(md5.convert(UTF8.encode(content)).bytes);
830 } 792 }
831 } 793 }
832 794
833 class _GeneratedUriResolverMock extends Mock implements UriResolver {} 795 class _GeneratedUriResolverMock extends Mock implements UriResolver {}
834 796
835 class _SourceMock extends Mock implements Source {} 797 class _SourceMock extends Mock implements Source {}
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/analysis/file_state.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698