| 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 analysis_server.src.single_context_manager; | 5 library analysis_server.src.single_context_manager; |
| 6 | 6 |
| 7 import 'dart:core' hide Resource; | 7 import 'dart:core' hide Resource; |
| 8 import 'dart:math' as math; | 8 import 'dart:math' as math; |
| 9 | 9 |
| 10 import 'package:analysis_server/src/context_manager.dart'; | 10 import 'package:analysis_server/src/context_manager.dart'; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 178 |
| 179 /** | 179 /** |
| 180 * Recursively add the given [resource] (if it's a file) or its children (if | 180 * Recursively add the given [resource] (if it's a file) or its children (if |
| 181 * it's a folder) to the [addedFiles]. | 181 * it's a folder) to the [addedFiles]. |
| 182 */ | 182 */ |
| 183 void _addFilesInResource( | 183 void _addFilesInResource( |
| 184 List<File> addedFiles, Resource resource, List<String> excludedPaths) { | 184 List<File> addedFiles, Resource resource, List<String> excludedPaths) { |
| 185 if (_isImplicitlyExcludedResource(resource)) { | 185 if (_isImplicitlyExcludedResource(resource)) { |
| 186 return; | 186 return; |
| 187 } | 187 } |
| 188 // TODO(scheglov) apply pathFilter | 188 String path = resource.path; |
| 189 if (_isEqualOrWithinAny(excludedPaths, resource.path)) { | 189 if (_isEqualOrWithinAny(excludedPaths, path)) { |
| 190 return; | 190 return; |
| 191 } | 191 } |
| 192 if (resource is File && resource.exists) { | 192 if (resource is File) { |
| 193 addedFiles.add(resource); | 193 if (_matchesAnyAnalyzedFilesGlob(path) && resource.exists) { |
| 194 addedFiles.add(resource); |
| 195 } |
| 194 } else if (resource is Folder) { | 196 } else if (resource is Folder) { |
| 195 for (Resource child in _getChildrenSafe(resource)) { | 197 for (Resource child in _getChildrenSafe(resource)) { |
| 196 _addFilesInResource(addedFiles, child, excludedPaths); | 198 _addFilesInResource(addedFiles, child, excludedPaths); |
| 197 } | 199 } |
| 198 } | 200 } |
| 199 } | 201 } |
| 200 | 202 |
| 201 List<Resource> _existingResources(List<String> pathList) { | 203 List<Resource> _existingResources(List<String> pathList) { |
| 202 List<Resource> resources = <Resource>[]; | 204 List<Resource> resources = <Resource>[]; |
| 203 for (String path in pathList) { | 205 for (String path in pathList) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 234 */ | 236 */ |
| 235 bool _isImplicitlyExcludedResource(Resource resource) { | 237 bool _isImplicitlyExcludedResource(Resource resource) { |
| 236 String shortName = resource.shortName; | 238 String shortName = resource.shortName; |
| 237 if (shortName.startsWith('.')) { | 239 if (shortName.startsWith('.')) { |
| 238 return true; | 240 return true; |
| 239 } | 241 } |
| 240 return false; | 242 return false; |
| 241 } | 243 } |
| 242 | 244 |
| 243 /** | 245 /** |
| 246 * Return `true` if the given [path] matches one of the [analyzedFilesGlobs]. |
| 247 */ |
| 248 bool _matchesAnyAnalyzedFilesGlob(String path) { |
| 249 for (Glob glob in analyzedFilesGlobs) { |
| 250 if (glob.matches(path)) { |
| 251 return true; |
| 252 } |
| 253 } |
| 254 return false; |
| 255 } |
| 256 |
| 257 /** |
| 244 * Normalize all package root sources by mapping them to folders on the | 258 * Normalize all package root sources by mapping them to folders on the |
| 245 * filesystem. Ignore any package root sources that aren't folders. | 259 * filesystem. Ignore any package root sources that aren't folders. |
| 246 */ | 260 */ |
| 247 void _updateNormalizedPackageRoots() { | 261 void _updateNormalizedPackageRoots() { |
| 248 normalizedPackageRoots = <String, String>{}; | 262 normalizedPackageRoots = <String, String>{}; |
| 249 packageRoots.forEach((String sourcePath, String targetPath) { | 263 packageRoots.forEach((String sourcePath, String targetPath) { |
| 250 Resource resource = resourceProvider.getResource(sourcePath); | 264 Resource resource = resourceProvider.getResource(sourcePath); |
| 251 if (resource is Folder) { | 265 if (resource is Folder) { |
| 252 normalizedPackageRoots[resource.path] = targetPath; | 266 normalizedPackageRoots[resource.path] = targetPath; |
| 253 } | 267 } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 for (int j = 0; j < i; j++) { | 371 for (int j = 0; j < i; j++) { |
| 358 if (_isEqualOrWithin(path, sortedPaths[j])) { | 372 if (_isEqualOrWithin(path, sortedPaths[j])) { |
| 359 sortedPaths.removeAt(i); | 373 sortedPaths.removeAt(i); |
| 360 break; | 374 break; |
| 361 } | 375 } |
| 362 } | 376 } |
| 363 } | 377 } |
| 364 return sortedPaths; | 378 return sortedPaths; |
| 365 } | 379 } |
| 366 } | 380 } |
| OLD | NEW |