|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface FileSystem
The FileSystem
manages all the source files to be analyzed.
public class MySensor implements Sensor { private final FileSystem fs; public MySensor(FileSystem fs) { this.fs = fs; } }
DefaultFileSystem
and the related DefaultInputFile
,
for example :
DefaultFileSystem fs = new DefaultFileSystem(); fs.add(new DefaultInputFile("src/foo/bar.php"));
Nested Class Summary | |
---|---|
static interface |
FileSystem.Index
Interface of the underlying file index. |
Method Summary | |
---|---|
File |
baseDir()
Absolute base directory of module |
Charset |
encoding()
Default encoding of input files. |
Iterable<File> |
files(FilePredicate predicate)
Files matching the given predicate. |
boolean |
hasFiles(FilePredicate predicate)
Returns true if at least one InputFile matches
the given predicate. |
InputDir |
inputDir(File dir)
Returns InputDir matching the current File . |
InputFile |
inputFile(FilePredicate predicate)
Returns the single element matching the predicate. |
Iterable<InputFile> |
inputFiles(FilePredicate predicate)
Input files matching the given attributes. |
SortedSet<String> |
languages()
Languages detected in all files, whatever their type (main or test) |
FilePredicates |
predicates()
Factory of FilePredicate |
File |
workDir()
Absolute work directory. |
Method Detail |
---|
File baseDir()
Charset encoding()
File workDir()
baseDir()
.
FilePredicates predicates()
FilePredicate
@CheckForNull InputFile inputFile(FilePredicate predicate)
IllegalArgumentException
is thrown. Returns null
if no files match.
How to use :
InputFile file = fs.inputFile(fs.predicates().hasRelativePath("src/Foo.php"));
predicates()
@CheckForNull InputDir inputDir(File dir)
InputDir
matching the current File
.
Iterable<InputFile> inputFiles(FilePredicate predicate)
attributes
is empty.
Important - result is an Iterable
to benefit from streaming and decreasing
memory consumption. It should be iterated only once, else copy it into a list :
com.google.common.collect.Lists.newArrayList(inputFiles(predicate))
How to use :
FilePredicates p = fs.predicates(); Iterablefiles = fs.inputFiles(p.and(p.hasLanguage("java"), p.hasType(InputFile.Type.MAIN)));
predicates()
boolean hasFiles(FilePredicate predicate)
InputFile
matches
the given predicate. This method can be faster than checking if inputFiles(org.sonar.api.batch.fs.FilePredicate)
has elements.
predicates()
Iterable<File> files(FilePredicate predicate)
predicates()
SortedSet<String> languages()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |