summaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2014-02-23 22:39:43 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2014-02-23 22:39:43 +0100
commit1715a09211e7adef88a99952d3a0265c485cb68a (patch)
tree7a4a56eac5c9857b129cfacf05fc04af6afda1b2 /sonar-plugin-api/src
parentebf7643e81af44e8fd06ac0d7a8cf1175946dba7 (diff)
downloadsonarqube-1715a09211e7adef88a99952d3a0265c485cb68a.tar.gz
sonarqube-1715a09211e7adef88a99952d3a0265c485cb68a.zip
SONAR-926 Preload files in DefaultModuleFileSystem
Diffstat (limited to 'sonar-plugin-api/src')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFileSystem.java12
1 files changed, 12 insertions, 0 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 e5c201e211c..ad5486a21e3 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
@@ -109,6 +109,7 @@ public class DefaultFileSystem implements FileSystem {
@Override
public InputFile inputFile(FilePredicate predicate) {
+ doPreloadFiles();
if (predicate instanceof UniqueIndexPredicate) {
return cache.inputFile((UniqueIndexPredicate) predicate);
}
@@ -122,16 +123,19 @@ public class DefaultFileSystem implements FileSystem {
@Override
public Iterable<InputFile> inputFiles(FilePredicate predicate) {
+ doPreloadFiles();
return Iterables.filter(cache.inputFiles(), new GuavaPredicate(predicate));
}
@Override
public boolean hasFiles(FilePredicate predicate) {
+ doPreloadFiles();
return Iterables.indexOf(cache.inputFiles(), new GuavaPredicate(predicate)) >= 0;
}
@Override
public Iterable<File> files(FilePredicate predicate) {
+ doPreloadFiles();
return Iterables.transform(inputFiles(predicate), new Function<InputFile, File>() {
@Override
public File apply(@Nullable InputFile input) {
@@ -149,9 +153,17 @@ public class DefaultFileSystem implements FileSystem {
@Override
public Set<String> languages() {
+ doPreloadFiles();
return languages;
}
+ /**
+ * This method is called before each search of files.
+ */
+ protected void doPreloadFiles() {
+
+ }
+
public static abstract class Cache {
protected abstract Iterable<InputFile> inputFiles();