From 87b925a5dd02dfdd11dc1f6be885d52cbe6422de Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Wed, 11 Feb 2015 14:02:50 +0100 Subject: [PATCH] SONAR-6048 Fix views --- .../scan/filesystem/DefaultModuleFileSystem.java | 2 +- .../api/batch/fs/internal/DefaultFileSystem.java | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java index 5f16313e853..c45dd646495 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java @@ -62,7 +62,7 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module public DefaultModuleFileSystem(ModuleInputFileCache moduleInputFileCache, Project project, Settings settings, FileIndexer indexer, ModuleFileSystemInitializer initializer, ComponentIndexer componentIndexer) { - super(initializer.baseDir().toPath(), moduleInputFileCache); + super(initializer.baseDir(), moduleInputFileCache); this.componentIndexer = componentIndexer; this.moduleKey = project.getKey(); this.settings = settings; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFileSystem.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFileSystem.java index e727b3b578f..ef1b62e9d14 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFileSystem.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFileSystem.java @@ -20,7 +20,6 @@ package org.sonar.api.batch.fs.internal; import com.google.common.base.Function; -import com.google.common.base.Preconditions; import com.google.common.collect.Iterables; import org.sonar.api.batch.fs.FilePredicate; import org.sonar.api.batch.fs.FilePredicates; @@ -61,14 +60,21 @@ public class DefaultFileSystem implements FileSystem { * Only for testing */ public DefaultFileSystem(Path baseDir) { + this(baseDir.toFile(), new MapCache()); + } + + /** + * Only for testing + */ + public DefaultFileSystem(File baseDir) { this(baseDir, new MapCache()); } - protected DefaultFileSystem(Path baseDir, Cache cache) { - Preconditions.checkNotNull(baseDir, "Base directory can't be null"); - this.baseDir = baseDir.toAbsolutePath().normalize(); + protected DefaultFileSystem(@Nullable File baseDir, Cache cache) { + // Basedir can be null with views + this.baseDir = baseDir != null ? baseDir.toPath().toAbsolutePath().normalize() : new File(".").toPath(); this.cache = cache; - this.predicates = new DefaultFilePredicates(baseDir); + this.predicates = new DefaultFilePredicates(this.baseDir); } public Path baseDirPath() { -- 2.39.5