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

Unified Diff: pkg/analyzer_cli/lib/src/driver.dart

Issue 2967883002: Make analyzer respect exclusions from the analysis options file (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_cli/lib/src/driver.dart
diff --git a/pkg/analyzer_cli/lib/src/driver.dart b/pkg/analyzer_cli/lib/src/driver.dart
index d8aacada4fbe24c7b9aa927a07db9906ae6e2511..f11bd821a393361267e1d8c83f2a21448930caac 100644
--- a/pkg/analyzer_cli/lib/src/driver.dart
+++ b/pkg/analyzer_cli/lib/src/driver.dart
@@ -211,7 +211,8 @@ class Driver implements CommandLineStarter {
// Note that these files will all be analyzed in the same context.
// This should be updated when the ContextManager re-work is complete
// (See: https://github.com/dart-lang/sdk/issues/24133)
- Iterable<io.File> files = _collectFiles(sourcePath);
+ Iterable<io.File> files =
+ _collectFiles(sourcePath, context.analysisOptions);
if (files.isEmpty) {
errorSink.writeln('No dart files found at: $sourcePath');
io.exitCode = ErrorSeverity.ERROR.ordinal;
@@ -446,11 +447,24 @@ class Driver implements CommandLineStarter {
/// Collect all analyzable files at [filePath], recursively if it's a
/// directory, ignoring links.
- Iterable<io.File> _collectFiles(String filePath) {
- // TODO(devoncarew): This needs to respect analysis_options excludes.
+ Iterable<io.File> _collectFiles(String filePath, AnalysisOptions options) {
+ List<String> excludedPaths = options.excludePatterns;
+
+ /**
+ * Returns `true` if the given [path] is excluded by [excludedPaths].
+ */
+ bool _isExcluded(String path) {
+ return excludedPaths.any((excludedPath) {
+ if (resourceProvider.absolutePathContext.isWithin(excludedPath, path)) {
+ return true;
+ }
+ return path == excludedPath;
+ });
+ }
+
List<io.File> files = <io.File>[];
io.File file = new io.File(filePath);
- if (file.existsSync()) {
+ if (file.existsSync() && !_isExcluded(filePath)) {
files.add(file);
} else {
io.Directory directory = new io.Directory(filePath);
@@ -459,6 +473,7 @@ class Driver implements CommandLineStarter {
in directory.listSync(recursive: true, followLinks: false)) {
String relative = path.relative(entry.path, from: directory.path);
if (AnalysisEngine.isDartFileName(entry.path) &&
+ !_isExcluded(relative) &&
!_isInHiddenDir(relative)) {
files.add(entry);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698