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

Side by Side Diff: pkg/analysis_server/test/context_directory_manager_test.dart

Issue 315183004: Remove unused analysis contexts (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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
« no previous file with comments | « pkg/analysis_server/lib/src/context_directory_manager.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 test.context.directory.manager; 5 library test.context.directory.manager;
6 6
7 import 'mocks.dart'; 7 import 'mocks.dart';
8 import 'package:analysis_server/src/context_directory_manager.dart'; 8 import 'package:analysis_server/src/context_directory_manager.dart';
9 import 'package:analysis_server/src/resource.dart'; 9 import 'package:analysis_server/src/resource.dart';
10 import 'package:path/path.dart'; 10 import 'package:path/path.dart';
11 import 'package:unittest/unittest.dart'; 11 import 'package:unittest/unittest.dart';
12 import 'package:analyzer/src/generated/engine.dart'; 12 import 'package:analyzer/src/generated/engine.dart';
13 import 'package:analyzer/src/generated/source.dart'; 13 import 'package:analyzer/src/generated/source.dart';
14 14
15 class TestContextDirectoryManager extends ContextDirectoryManager { 15 class TestContextDirectoryManager extends ContextDirectoryManager {
16 TestContextDirectoryManager(MemoryResourceProvider provider) : super(provider) ; 16 TestContextDirectoryManager(MemoryResourceProvider provider) : super(provider) ;
17 17
18 final Set<String> currentContextPaths = new Set<String>(); 18 final Set<String> currentContextPaths = new Set<String>();
19 final Map<String, String> currentContextPubspecPaths = <String, String>{}; 19 final Map<String, String> currentContextPubspecPaths = <String, String>{};
20 final Map<String, Set<String>> currentContextFilePaths = <String, Set<String>> {}; 20 final Map<String, Set<String>> currentContextFilePaths = <String, Set<String>> {};
21 21
22 @override 22 @override
23 void addContext(Folder folder, File pubspecFile) { 23 void addContext(Folder folder, File pubspecFile) {
24 currentContextPaths.add(folder.path); 24 String path = folder.path;
25 currentContextPubspecPaths[folder.path] = pubspecFile != null ? pubspecFile. path : null; 25 currentContextPaths.add(path);
26 currentContextFilePaths[folder.path] = new Set<String>(); 26 currentContextPubspecPaths[path] = pubspecFile != null ? pubspecFile.path : null;
27 currentContextFilePaths[path] = new Set<String>();
27 } 28 }
28 29
29 @override 30 @override
30 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { 31 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) {
31 Set<String> filePaths = currentContextFilePaths[contextFolder.path]; 32 Set<String> filePaths = currentContextFilePaths[contextFolder.path];
32 for (Source source in changeSet.addedSources) { 33 for (Source source in changeSet.addedSources) {
33 expect(filePaths, isNot(contains(source.fullName))); 34 expect(filePaths, isNot(contains(source.fullName)));
34 filePaths.add(source.fullName); 35 filePaths.add(source.fullName);
35 } 36 }
36 for (Source source in changeSet.removedSources) { 37 for (Source source in changeSet.removedSources) {
37 expect(filePaths, contains(source.fullName)); 38 expect(filePaths, contains(source.fullName));
38 filePaths.remove(source.fullName); 39 filePaths.remove(source.fullName);
39 } 40 }
40 // TODO(paulberry): handle source.changedSources. 41 // TODO(paulberry): handle source.changedSources.
41 } 42 }
43
44 @override
45 void removeContext(Folder folder) {
46 String path = folder.path;
47 currentContextPaths.remove(path);
48 currentContextPubspecPaths.remove(path);
49 currentContextFilePaths.remove(path);
50 }
42 } 51 }
43 52
44 main() { 53 main() {
45 groupSep = ' | '; 54 groupSep = ' | ';
46 55
47 group('ContextDirectoryManager', () { 56 group('ContextDirectoryManager', () {
48 TestContextDirectoryManager manager; 57 TestContextDirectoryManager manager;
49 MemoryResourceProvider provider; 58 MemoryResourceProvider provider;
50 59
51 setUp(() { 60 setUp(() {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 manager.setRoots(<String>[projPath], <String>[]); 161 manager.setRoots(<String>[projPath], <String>[]);
153 Set<String> filePaths = manager.currentContextFilePaths[projPath]; 162 Set<String> filePaths = manager.currentContextFilePaths[projPath];
154 expect(filePaths, hasLength(1)); 163 expect(filePaths, hasLength(1));
155 expect(filePaths, contains(filePath)); 164 expect(filePaths, contains(filePath));
156 provider.deleteFile(filePath); 165 provider.deleteFile(filePath);
157 return pumpEventQueue().then((_) => expect(filePaths, hasLength(0))); 166 return pumpEventQueue().then((_) => expect(filePaths, hasLength(0)));
158 }); 167 });
159 }); 168 });
160 }); 169 });
161 } 170 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/context_directory_manager.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698