use of org.sonar.api.batch.fs.internal.DefaultInputModule in project sonarqube by SonarSource.
the class LocalIssueTracking method loadSourceHashes.
@CheckForNull
private SourceHashHolder loadSourceHashes(InputComponent component) {
SourceHashHolder sourceHashHolder = null;
if (component.isFile()) {
DefaultInputModule module = (DefaultInputModule) componentTree.getParent(componentTree.getParent(component));
DefaultInputFile file = (DefaultInputFile) component;
sourceHashHolder = new SourceHashHolder(module, file, lastLineHashes);
}
return sourceHashHolder;
}
use of org.sonar.api.batch.fs.internal.DefaultInputModule in project sonarqube by SonarSource.
the class DefaultInputModuleHierarchy method relativePath.
@Override
@CheckForNull
public String relativePath(InputModule module) {
DefaultInputModule parent = parent(module);
if (parent == null) {
return null;
}
DefaultInputModule inputModule = (DefaultInputModule) module;
ProjectDefinition parentDefinition = parent.definition();
Path parentBaseDir = parentDefinition.getBaseDir().toPath();
ProjectDefinition moduleDefinition = inputModule.definition();
Path moduleBaseDir = moduleDefinition.getBaseDir().toPath();
return pathResolver.relativePath(parentBaseDir, moduleBaseDir);
}
use of org.sonar.api.batch.fs.internal.DefaultInputModule in project sonarqube by SonarSource.
the class ModuleIndexer method createChildren.
private void createChildren(DefaultInputModule parent) {
for (ProjectDefinition def : parent.definition().getSubProjects()) {
DefaultInputModule child = new DefaultInputModule(def, batchIdGenerator.get());
moduleHierarchy.index(child, parent);
componentTree.index(child, parent);
componentStore.put(child);
createChildren(child);
}
}
use of org.sonar.api.batch.fs.internal.DefaultInputModule in project sonarqube by SonarSource.
the class DefaultIndexTest method shouldGetHierarchy.
@Test
public void shouldGetHierarchy() {
InputComponent component = new DefaultInputModule("module1");
InputFile file1 = new TestInputFileBuilder("module1", "src/org/foo/Bar.java").build();
when(componentStore.getByKey("module1")).thenReturn(component);
when(componentStore.getByKey("module1:src/org/foo/Bar.java")).thenReturn(file1);
when(componentTree.getParent(file1)).thenReturn(component);
when(componentTree.getChildren(component)).thenReturn(Collections.singleton(file1));
assertThat(index.getParent("module1:src/org/foo/Bar.java").getKey()).isEqualTo("module1");
assertThat(index.getParent("module1")).isNull();
assertThat(index.getChildren("module1")).containsOnly(File.create("src/org/foo/Bar.java"));
assertThat(index.getChildren("module1:src/org/foo/Bar.java")).isEmpty();
}
use of org.sonar.api.batch.fs.internal.DefaultInputModule in project sonarqube by SonarSource.
the class DefaultIndexTest method shouldTransformToResource.
@Test
public void shouldTransformToResource() {
DefaultInputModule component = new DefaultInputModule(ProjectDefinition.create().setKey("module1").setProperty(CoreProperties.PROJECT_BRANCH_PROPERTY, "branch1"), 1);
InputFile file1 = new TestInputFileBuilder("module1", "src/org/foo/Bar.java").build();
InputDir dir = new DefaultInputDir("module1", "src");
assertThat(index.toResource(component)).isInstanceOf(Project.class);
assertThat(index.toResource(component).getKey()).isEqualTo("module1");
assertThat(index.toResource(component).getEffectiveKey()).isEqualTo("module1:branch1");
assertThat(index.toResource(file1)).isInstanceOf(File.class);
assertThat(index.toResource(file1).getKey()).isEqualTo("src/org/foo/Bar.java");
assertThat(index.toResource(file1).getPath()).isEqualTo("src/org/foo/Bar.java");
assertThat(index.toResource(dir)).isInstanceOf(Directory.class);
assertThat(index.toResource(dir).getKey()).isEqualTo("src");
assertThat(index.toResource(dir).getPath()).isEqualTo("src");
}
Aggregations