use of org.sonar.api.batch.fs.internal.DefaultIndexedFile in project sonarqube by SonarSource.
the class DefaultInputFileTest method prepare.
@Before
public void prepare() throws IOException {
baseDir = temp.newFolder().toPath();
sensorStrategy = new SensorStrategy();
indexedFile = new DefaultIndexedFile(baseDir.resolve(PROJECT_RELATIVE_PATH), "ABCDE", PROJECT_RELATIVE_PATH, MODULE_RELATIVE_PATH, InputFile.Type.TEST, "php", 0, sensorStrategy);
}
use of org.sonar.api.batch.fs.internal.DefaultIndexedFile in project sonarqube by SonarSource.
the class DefaultInputFileTest method test_toString.
@Test
public void test_toString() {
DefaultInputFile file = new DefaultInputFile(new DefaultIndexedFile("ABCDE", Paths.get("module"), MODULE_RELATIVE_PATH, null), (f) -> mock(Metadata.class));
assertThat(file.toString()).isEqualTo(MODULE_RELATIVE_PATH);
}
use of org.sonar.api.batch.fs.internal.DefaultIndexedFile in project sonarqube by SonarSource.
the class DefaultInputFileTest method checkValidRangeUsingGlobalOffset.
@Test
public void checkValidRangeUsingGlobalOffset() {
Metadata metadata = new Metadata(2, 2, "", new int[] { 0, 10 }, new int[] { 9, 15 }, 16);
DefaultInputFile file = new DefaultInputFile(new DefaultIndexedFile("ABCDE", Paths.get("module"), MODULE_RELATIVE_PATH, null), f -> f.setMetadata(metadata));
TextRange newRange = file.newRange(10, 13);
assertThat(newRange.start().line()).isEqualTo(2);
assertThat(newRange.start().lineOffset()).isZero();
assertThat(newRange.end().line()).isEqualTo(2);
assertThat(newRange.end().lineOffset()).isEqualTo(3);
}
use of org.sonar.api.batch.fs.internal.DefaultIndexedFile in project sonarqube by SonarSource.
the class DefaultInputFileTest method testRangeOverlap.
@Test
public void testRangeOverlap() {
Metadata metadata = new Metadata(2, 2, "", new int[] { 0, 10 }, new int[] { 9, 15 }, 16);
DefaultInputFile file = new DefaultInputFile(new DefaultIndexedFile("ABCDE", Paths.get("module"), MODULE_RELATIVE_PATH, null), f -> f.setMetadata(metadata));
// Don't fail
assertThat(file.newRange(file.newPointer(1, 0), file.newPointer(1, 1)).overlap(file.newRange(file.newPointer(1, 0), file.newPointer(1, 1)))).isTrue();
assertThat(file.newRange(file.newPointer(1, 0), file.newPointer(1, 1)).overlap(file.newRange(file.newPointer(1, 0), file.newPointer(1, 2)))).isTrue();
assertThat(file.newRange(file.newPointer(1, 0), file.newPointer(1, 1)).overlap(file.newRange(file.newPointer(1, 1), file.newPointer(1, 2)))).isFalse();
assertThat(file.newRange(file.newPointer(1, 2), file.newPointer(1, 3)).overlap(file.newRange(file.newPointer(1, 0), file.newPointer(1, 2)))).isFalse();
}
use of org.sonar.api.batch.fs.internal.DefaultIndexedFile in project sonarqube by SonarSource.
the class ExclusionFiltersTest method no_inclusions_nor_exclusions.
@Test
public void no_inclusions_nor_exclusions() throws IOException {
ExclusionFilters filter = new ExclusionFilters(new FileExclusions(new MapSettings()));
filter.prepare();
IndexedFile indexedFile = new DefaultIndexedFile("foo", moduleBaseDir, "src/main/java/com/mycompany/FooDao.java");
assertThat(filter.accept(indexedFile, InputFile.Type.MAIN)).isTrue();
assertThat(filter.accept(indexedFile, InputFile.Type.TEST)).isTrue();
}
Aggregations