* <p>The unit tests needing an instance of FileSystem can use the implementation
* {@link org.sonar.api.batch.fs.internal.DefaultFileSystem} and the related {@link org.sonar.api.scan.filesystem.internal.DefaultInputFile}:</p>
* <pre>
- * FileSystem fs = new DefaultFileSystem();
+ * DefaultFileSystem fs = new DefaultFileSystem();
* fs.add(new DefaultInputFile("src/foo/bar.php"));
* </pre>
*
File workDir();
/**
+ * Returns the single element matching the predicate. If more than one elements match
+ * the predicate, then {@link IllegalArgumentException} is thrown. Returns {@code null}
+ * if no files match.
* @see org.sonar.api.batch.fs.FilePredicates
*/
@CheckForNull
/**
* Input files matching the given attributes. Return all the files if the parameter
* <code>attributes</code> is empty.
+ * <p/>
+ * Important - result is an {@link java.lang.Iterable} to benefit from streaming and decreasing
+ * memory consumption. It should be iterated only once, else copy it into a list :
+ * {@code com.google.common.collect.Lists.newArrayList(inputFiles(predicate))}
* @see org.sonar.api.batch.fs.FilePredicates
*/
Iterable<InputFile> inputFiles(FilePredicate predicate);
/**
* Returns true if at least one {@link org.sonar.api.batch.fs.InputFile} matches
- * the given attributes. This method can be faster than checking if {@link #inputFiles(org.sonar.api.batch.fs.FilePredicate...)}
- * has elements. If the parameter <code>attributes</code> is empty, then returns true
- * if at least one input file exists.
+ * the given predicate. This method can be faster than checking if {@link #inputFiles(org.sonar.api.batch.fs.FilePredicate...)}
+ * has elements.
* @see org.sonar.api.batch.fs.FilePredicates
*/
boolean hasFiles(FilePredicate predicate);
/**
- * Files matching the given attributes.
+ * Files matching the given predicate.
* @see org.sonar.api.batch.fs.FilePredicates
*/
Iterable<File> files(FilePredicate predicate);
/**
- * Languages detected in all the files, whatever their type (main code or test)
+ * Languages detected in all files, whatever their type (main or test)
*/
Set<String> languages();
}
import java.io.Serializable;
/**
- * This layer over {@link java.io.File} adds information useful for code analyzers.
+ * This layer over {@link java.io.File} adds information for code analyzers.
*
* @since 4.2
*/
/**
* Path relative to module base directory. Path is unique and identifies file
- * within given <code>{@link FileSystem}</code>.
- * File separator is the forward slash ('/'), even on Microsoft Windows.
+ * within given <code>{@link FileSystem}</code>. File separator is the forward
+ * slash ('/'), even on Microsoft Windows.
* <p/>
* Returns <code>src/main/java/com/Foo.java</code> if module base dir is
- * <code>/absolute/path/to/module</code> and if file is
- * <code>/absolute/path/to/module/src/main/java/com/Foo.java</code>.
+ * <code>/path/to/module</code> and if file is
+ * <code>/path/to/module/src/main/java/com/Foo.java</code>.
* <p/>
* Relative path is not null and is normalized ('foo/../foo' is replaced by 'foo').
*/
File file();
/**
- * Language, for example "java" or "php". It's automatically guessed when it is not
- * set by project configuration.
+ * Language, for example "java" or "php". It's automatically guessed if it is not
+ * set in project settings.
*/
String language();
*/
Status status();
+ /**
+ * Number of physical lines. This method supports all end-of-line characters. Returns
+ * zero if the file is empty.
+ */
int lines();
}
import org.sonar.api.BatchExtension;
/**
- * Extension point to complete the list of files to ignore during inspection
+ * Extension point to exclude some files from inspection
* @since 4.2
*/
public interface InputFileFilter extends BatchExtension {
import javax.annotation.Nullable;
import java.io.File;
import java.nio.charset.Charset;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
+import java.util.*;
/**
* @since 4.2
}
/**
- * Marked as nullable just for the unit tests that do not previously call
- * {@link #setHash(String)}
+ * Digest hash of the file. Marked as nullable just for the unit tests
+ * that do not previously call {@link #setHash(String)}
*/
@CheckForNull
public String hash() {
}
/**
- * Marked as nullable just for the unit tests that do not previously call
- * {@link #setKey(String)}.
+ * Component key. It's marked as nullable just for the unit tests that
+ * do not previously call {@link #setKey(String)}.
*/
@CheckForNull
public String key() {
}
/**
- * Key used before version 4.2. It's different than {@link #key} on Java files.
+ * Key used before version 4.2. It can be different than {@link #key} on Java files.
*/
public String deprecatedKey() {
return deprecatedKey;
}
/**
- * @deprecated in 4.2. Use {@link org.sonar.api.batch.fs.FileSystem#baseDir()}
+ * @deprecated in 4.2. Replaced by {@link org.sonar.api.batch.fs.FileSystem#baseDir()}
*/
@Deprecated
@Override