use of org.sonar.api.batch.fs.InputFile in project sonarqube by SonarSource.
the class SymbolReferencesSensorTest method testNoExecutionIfNoSymbolFile.
@Test
public void testNoExecutionIfNoSymbolFile() {
InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").setModuleBaseDir(baseDir.toPath()).build();
fileSystem.add(inputFile);
sensor.execute(context);
}
use of org.sonar.api.batch.fs.InputFile in project sonarqube by SonarSource.
the class AbsolutePathPredicate method get.
@Override
public Iterable<InputFile> get(Index index) {
String relative = PathUtils.sanitize(new PathResolver().relativePath(baseDir.toFile(), new File(path)));
if (relative == null) {
return Collections.emptyList();
}
InputFile f = index.inputFile(relative);
return f != null ? Arrays.asList(f) : Collections.<InputFile>emptyList();
}
use of org.sonar.api.batch.fs.InputFile in project sonarqube by SonarSource.
the class DefaultFileSystem method inputFile.
@Override
public InputFile inputFile(FilePredicate predicate) {
Iterable<InputFile> files = inputFiles(predicate);
Iterator<InputFile> iterator = files.iterator();
if (!iterator.hasNext()) {
return null;
}
InputFile first = iterator.next();
if (!iterator.hasNext()) {
return first;
}
StringBuilder sb = new StringBuilder();
sb.append("expected one element but was: <" + first);
for (int i = 0; i < 4 && iterator.hasNext(); i++) {
sb.append(", " + iterator.next());
}
if (iterator.hasNext()) {
sb.append(", ...");
}
sb.append('>');
throw new IllegalArgumentException(sb.toString());
}
use of org.sonar.api.batch.fs.InputFile in project sonarqube by SonarSource.
the class File method create.
/**
* Internal use only.
* @deprecated since 5.1 use {@link FileSystem#inputFile(org.sonar.api.batch.fs.FilePredicate)}
*/
@Deprecated
public static File create(String relativePathFromBasedir) {
File file = new File();
String normalizedPath = normalize(relativePathFromBasedir);
file.setKey(normalizedPath);
file.setPath(normalizedPath);
String directoryPath;
if (normalizedPath != null && normalizedPath.contains(Directory.SEPARATOR)) {
directoryPath = StringUtils.substringBeforeLast(normalizedPath, Directory.SEPARATOR);
file.filename = StringUtils.substringAfterLast(normalizedPath, Directory.SEPARATOR);
} else {
directoryPath = Directory.SEPARATOR;
file.filename = normalizedPath;
}
file.parent = Directory.create(directoryPath);
return file;
}
use of org.sonar.api.batch.fs.InputFile in project sonarqube by SonarSource.
the class File method create.
/**
* Internal use only.
* @deprecated since 5.1 use {@link FileSystem#inputFile(org.sonar.api.batch.fs.FilePredicate)}
*/
@Deprecated
public static File create(String relativePathFromBasedir, Language language, boolean unitTest) {
File file = create(relativePathFromBasedir);
file.setLanguage(language);
if (unitTest) {
file.setQualifier(Qualifiers.UNIT_TEST_FILE);
}
return file;
}
Aggregations