| OLD | NEW |
| 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 library test.analysis_server.src.single_context_manager; | 5 library test.analysis_server.src.single_context_manager; |
| 6 | 6 |
| 7 import 'dart:core' hide Resource; | 7 import 'dart:core' hide Resource; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/single_context_manager.dart'; | 9 import 'package:analysis_server/src/single_context_manager.dart'; |
| 10 import 'package:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 DartSdkManager sdkManager = new DartSdkManager((_) { | 76 DartSdkManager sdkManager = new DartSdkManager((_) { |
| 77 return new MockSdk(); | 77 return new MockSdk(); |
| 78 }); | 78 }); |
| 79 manager = new SingleContextManager(resourceProvider, sdkManager, | 79 manager = new SingleContextManager(resourceProvider, sdkManager, |
| 80 () => packageResolver, analysisFilesGlobs); | 80 () => packageResolver, analysisFilesGlobs); |
| 81 callbacks = new TestContextManagerCallbacks(resourceProvider); | 81 callbacks = new TestContextManagerCallbacks(resourceProvider); |
| 82 manager.callbacks = callbacks; | 82 manager.callbacks = callbacks; |
| 83 resourceProvider.newFolder(projPath); | 83 resourceProvider.newFolder(projPath); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void test_isIgnored_false() { |
| 87 String project = '/project'; |
| 88 manager.setRoots(<String>[project], <String>[], <String, String>{}); |
| 89 expect(manager.isIgnored('$project/file.dart'), isFalse); |
| 90 } |
| 91 |
| 92 void test_isIgnored_true_inDotFolder() { |
| 93 String project = '/project'; |
| 94 manager.setRoots(<String>[project], <String>[], <String, String>{}); |
| 95 expect(manager.isIgnored('$project/foo/.bar/file.dart'), isTrue); |
| 96 } |
| 97 |
| 98 void test_isIgnored_true_inExcludedPath() { |
| 99 String project = '/project'; |
| 100 String excludedPath = '/project/excluded'; |
| 101 manager.setRoots( |
| 102 <String>[project], <String>[excludedPath], <String, String>{}); |
| 103 expect(manager.isIgnored('$excludedPath/file.dart'), isTrue); |
| 104 } |
| 105 |
| 106 void test_isIgnored_true_notInRoot() { |
| 107 String root1 = '/context/root1'; |
| 108 String root2 = '/context/root2'; |
| 109 manager.setRoots(<String>[root1, root2], <String>[], <String, String>{}); |
| 110 expect(manager.isIgnored('$context/root3/file.dart'), isTrue); |
| 111 } |
| 112 |
| 113 void test_isInAnalysisRoot_false_inExcludedPath() { |
| 114 String project = '/project'; |
| 115 String excludedPath = '/project/excluded'; |
| 116 manager.setRoots( |
| 117 <String>[project], <String>[excludedPath], <String, String>{}); |
| 118 expect(manager.isInAnalysisRoot('$excludedPath/file.dart'), isFalse); |
| 119 } |
| 120 |
| 121 void test_isInAnalysisRoot_false_notInRoot() { |
| 122 String root1 = '/context/root1'; |
| 123 String root2 = '/context/root2'; |
| 124 manager.setRoots(<String>[root1, root2], <String>[], <String, String>{}); |
| 125 expect(manager.isInAnalysisRoot('$context/root3/file.dart'), isFalse); |
| 126 } |
| 127 |
| 128 void test_isInAnalysisRoot_true() { |
| 129 String project = '/project'; |
| 130 manager.setRoots(<String>[project], <String>[], <String, String>{}); |
| 131 expect(manager.isInAnalysisRoot('$project/file.dart'), isTrue); |
| 132 } |
| 133 |
| 86 void test_setRoots_addFolderWithDartFile() { | 134 void test_setRoots_addFolderWithDartFile() { |
| 87 String filePath = posix.join(projPath, 'lib', 'foo.dart'); | 135 String filePath = posix.join(projPath, 'lib', 'foo.dart'); |
| 88 resourceProvider.newFile(filePath, 'contents'); | 136 resourceProvider.newFile(filePath, 'contents'); |
| 89 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | 137 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
| 90 // verify | 138 // verify |
| 91 callbacks.assertContextFiles(projPath, [filePath]); | 139 callbacks.assertContextFiles(projPath, [filePath]); |
| 92 // There is an analysis context. | 140 // There is an analysis context. |
| 93 List<AnalysisContext> contextsInAnalysisRoot = | 141 List<AnalysisContext> contextsInAnalysisRoot = |
| 94 manager.contextsInAnalysisRoot(rootFolder); | 142 manager.contextsInAnalysisRoot(rootFolder); |
| 95 expect(contextsInAnalysisRoot, hasLength(1)); | 143 expect(contextsInAnalysisRoot, hasLength(1)); |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 String relPath = resourceProvider.pathContext.joinAll(relSegments); | 517 String relPath = resourceProvider.pathContext.joinAll(relSegments); |
| 470 Resource file = rootFolder.getChild(relPath); | 518 Resource file = rootFolder.getChild(relPath); |
| 471 if (file is File && file.exists) { | 519 if (file is File && file.exists) { |
| 472 return file.createSource(uri); | 520 return file.createSource(uri); |
| 473 } | 521 } |
| 474 } | 522 } |
| 475 } | 523 } |
| 476 return null; | 524 return null; |
| 477 } | 525 } |
| 478 } | 526 } |
| OLD | NEW |