diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2015-11-02 15:34:12 +0100 |
---|---|---|
committer | Duarte Meneses <duarte.meneses@sonarsource.com> | 2015-11-04 11:07:44 +0100 |
commit | 7f652d4d5eae1098e92522e9f9bb024fec000075 (patch) | |
tree | b29dc410b74344ca5f4614f0332e6323aebc1db5 /sonar-plugin-api/src | |
parent | 7c8ad8ca233cfa6f24a8822f9a4487fa9461a539 (diff) | |
download | sonarqube-7f652d4d5eae1098e92522e9f9bb024fec000075.tar.gz sonarqube-7f652d4d5eae1098e92522e9f9bb024fec000075.zip |
SONAR-6931 Speed up issues mode by scanning only changed files
Diffstat (limited to 'sonar-plugin-api/src')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFileSystem.java | 25 |
1 files changed, 22 insertions, 3 deletions
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 2876fdfa9ba..b53c2d6bdbd 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 @@ -54,7 +54,8 @@ public class DefaultFileSystem implements FileSystem { private final Path baseDir; private Path workDir; private Charset encoding; - private final FilePredicates predicates; + protected final FilePredicates predicates; + private FilePredicate defaultPredicate; /** * Only for testing @@ -104,7 +105,12 @@ public class DefaultFileSystem implements FileSystem { this.workDir = d.getAbsoluteFile().toPath().normalize(); return this; } - + + public DefaultFileSystem setDefaultPredicate(@Nullable FilePredicate predicate) { + this.defaultPredicate = predicate; + return this; + } + @Override public File workDir() { return workDir.toFile(); @@ -135,11 +141,24 @@ public class DefaultFileSystem implements FileSystem { throw new IllegalArgumentException(sb.toString()); } + + /** + * Bypass default predicate to get all files/dirs indexed. + * Default predicate is used when some files/dirs should not be processed by sensors. + */ + public Iterable<InputFile> inputFiles() { + doPreloadFiles(); + return OptimizedFilePredicateAdapter.create(predicates.all()).get(cache); + } @Override public Iterable<InputFile> inputFiles(FilePredicate predicate) { doPreloadFiles(); - return OptimizedFilePredicateAdapter.create(predicate).get(cache); + FilePredicate combinedPredicate = predicate; + if(defaultPredicate != null) { + combinedPredicate = predicates().and(defaultPredicate, predicate); + } + return OptimizedFilePredicateAdapter.create(combinedPredicate).get(cache); } @Override |