diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-10-16 17:57:54 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-10-16 17:57:54 +0200 |
commit | b7a6509ebe171c78132c1b6c8739743088dd86ca (patch) | |
tree | 3e058320303f17af3846323fcecbf8d85b983f8b /sonar-plugin-api | |
parent | 8aa56b454c0b126baba39be04e60541a98d3f532 (diff) | |
download | sonarqube-b7a6509ebe171c78132c1b6c8739743088dd86ca.tar.gz sonarqube-b7a6509ebe171c78132c1b6c8739743088dd86ca.zip |
Remove file system refactoring from API
Diffstat (limited to 'sonar-plugin-api')
13 files changed, 68 insertions, 32 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/InputFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/InputFile.java index d33cd146ea4..8584e22b07b 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/InputFile.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/InputFile.java @@ -25,9 +25,7 @@ import java.io.InputStream; /** * @since 2.6 - * @deprecated in 4.0. Replaced by {@link org.sonar.api.scan.filesystem.InputFile} */ -@Deprecated public interface InputFile { /** * The source base directory, different than the project basedir. diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/InputFileUtils.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/InputFileUtils.java index 9e018844b19..576d2c18cec 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/InputFileUtils.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/InputFileUtils.java @@ -34,9 +34,7 @@ import java.util.List; /** * @since 2.8 - * @deprecated in 4.0. Replaced by {@link org.sonar.api.scan.filesystem.InputFile}. */ -@Deprecated public final class InputFileUtils { private InputFileUtils() { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileQuery.java index 6e858ee2511..256a2f9aa95 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileQuery.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileQuery.java @@ -24,6 +24,7 @@ import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Collections2; import com.google.common.collect.ListMultimap; import com.google.common.collect.Sets; +import org.sonar.api.scan.filesystem.internal.InputFile; import javax.annotation.Nullable; import java.io.FileFilter; @@ -37,8 +38,6 @@ import java.util.Set; */ public class FileQuery { - // TODO REFACTOR - better builders, for example FileQuery.ALL - public static FileQuery on(FileType... types) { FileQuery query = new FileQuery(); for (FileType type : types) { @@ -73,7 +72,6 @@ public class FileQuery { return attributes.asMap(); } - @Deprecated public Collection<FileType> types() { return Collections2.transform(attributes.get(InputFile.ATTRIBUTE_TYPE), new Function<String, FileType>() { @Override @@ -109,12 +107,10 @@ public class FileQuery { return this; } - // TODO deprecate public Collection<FileFilter> filters() { throw new UnsupportedOperationException("TODO"); } - // TODO deprecate ? public FileQuery withFilters(FileFilter... filters) { throw new UnsupportedOperationException("TODO"); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileSystemFilter.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileSystemFilter.java new file mode 100644 index 00000000000..599b7db8595 --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileSystemFilter.java @@ -0,0 +1,59 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.api.scan.filesystem; + +import org.sonar.api.BatchExtension; + +import java.io.File; + +/** + * Extension point to exclude some files from project scan. Some use-cases : + * <ul> + * <li>exclude the files that are older than x days</li> + * <li>exclude the files which names start with Generated</li> + * </ul> + * + * @since 3.5 + */ +public interface FileSystemFilter extends BatchExtension { + + /** + * Plugins must not implement this interface. It is provided at runtime. + */ + public interface Context { + ModuleFileSystem fileSystem(); + + FileType type(); + + File relativeDir(); + + /** + * File path relative to source directory. Never return null. + */ + String relativePath(); + + /** + * Absolute file path. Directory separator is slash, even on windows. Never return null. + */ + String canonicalPath(); + } + + boolean accept(File file, Context context); +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileType.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileType.java index 8100c473f09..6600ae2099a 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileType.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileType.java @@ -21,9 +21,7 @@ package org.sonar.api.scan.filesystem; /** * @since 3.5 - * @deprecated in 4.0. Replaced by more flexible {@link org.sonar.api.scan.filesystem.InputFile} attributes. */ -@Deprecated public enum FileType { SOURCE, TEST } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/ModuleFileSystem.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/ModuleFileSystem.java index 7a1921cea13..3a055f15112 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/ModuleFileSystem.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/ModuleFileSystem.java @@ -19,7 +19,6 @@ */ package org.sonar.api.scan.filesystem; -import com.google.common.annotations.Beta; import org.sonar.api.BatchComponent; import javax.annotation.CheckForNull; @@ -33,13 +32,6 @@ import java.util.List; public interface ModuleFileSystem extends BatchComponent { /** - * Unique module key - * - * @since 4.0 - */ - String moduleKey(); - - /** * Base directory. */ File baseDir(); @@ -80,12 +72,6 @@ public interface ModuleFileSystem extends BatchComponent { List<File> files(FileQuery query); /** - * @since 4.0 - */ - @Beta - Iterable<InputFile> inputFiles(FileQuery query); - - /** * Charset of source and test files. If it's not defined, then * return the platform default charset. */ diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputFile.java index 7e901cd89da..b7f2848da2b 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputFile.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputFile.java @@ -21,7 +21,6 @@ package org.sonar.api.scan.filesystem.internal; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang.StringUtils; -import org.sonar.api.scan.filesystem.InputFile; import org.sonar.api.utils.PathUtils; import javax.annotation.CheckForNull; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFile.java index 98761950914..b8484fb7fc6 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputFile.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFile.java @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.api.scan.filesystem; +package org.sonar.api.scan.filesystem.internal; import javax.annotation.CheckForNull; import java.io.File; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFileBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFileBuilder.java index 2a081efe312..042958fb8f4 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFileBuilder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFileBuilder.java @@ -19,7 +19,6 @@ */ package org.sonar.api.scan.filesystem.internal; -import org.sonar.api.scan.filesystem.InputFile; import org.sonar.api.utils.PathUtils; import javax.annotation.Nullable; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputFileFilter.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFileFilter.java index a09f5df6c17..e48880d58d5 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputFileFilter.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFileFilter.java @@ -17,9 +17,10 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.api.scan.filesystem; +package org.sonar.api.scan.filesystem.internal; import org.sonar.api.BatchExtension; +import org.sonar.api.scan.filesystem.internal.InputFile; /** * TODO document lifecycle -> executed when initializing project diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputFiles.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFiles.java index a6e2fc8bd6d..f6272e24a99 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputFiles.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFiles.java @@ -17,9 +17,10 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.api.scan.filesystem; +package org.sonar.api.scan.filesystem.internal; import com.google.common.collect.Lists; +import org.sonar.api.scan.filesystem.internal.InputFile; import java.io.File; import java.util.List; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/internal/DefaultInputFileTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/internal/DefaultInputFileTest.java index afeb907394c..166d5660e3e 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/internal/DefaultInputFileTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/internal/DefaultInputFileTest.java @@ -23,7 +23,6 @@ import org.apache.commons.io.FilenameUtils; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.sonar.api.scan.filesystem.InputFile; import org.sonar.api.utils.PathUtils; import java.io.File; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/InputFilesTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/internal/InputFilesTest.java index cb1f210b454..ba1c25eb1fb 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/InputFilesTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/internal/InputFilesTest.java @@ -17,13 +17,15 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.api.scan.filesystem; +package org.sonar.api.scan.filesystem.internal; import com.google.common.collect.Lists; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; +import org.sonar.api.scan.filesystem.internal.InputFile; import org.sonar.api.scan.filesystem.internal.InputFileBuilder; +import org.sonar.api.scan.filesystem.internal.InputFiles; import java.io.File; |