import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.BatchComponent;
+import org.sonar.api.batch.fs.FilePredicates;
+import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.database.DatabaseSession;
}
}
- public void migrateIfNeeded(Project module, Iterable<InputFile> inputFiles) {
+ public void migrateIfNeeded(Project module, FileSystem fs) {
+ migrateIfNeeded(module, fs.inputFiles(FilePredicates.all()));
+ }
+
+ void migrateIfNeeded(Project module, Iterable<InputFile> inputFiles) {
if (migrationNeeded) {
logger.info("Starting migration of resource keys");
Map<String, InputFile> deprecatedFileKeyMapper = new HashMap<String, InputFile>();
}
public void execute(FileSystem fs) {
+ migration.migrateIfNeeded(module, fs);
+
boolean shouldImportSource = settings.getBoolean(CoreProperties.CORE_IMPORT_SOURCES_PROPERTY);
- Iterable<InputFile> inputFiles = fs.inputFiles(FilePredicates.all());
- migration.migrateIfNeeded(module, inputFiles);
- for (InputFile inputFile : inputFiles) {
+ for (InputFile inputFile : fs.inputFiles(FilePredicates.all())) {
String languageKey = inputFile.language();
boolean unitTest = InputFile.Type.TEST == inputFile.type();
String pathFromSourceDir = ((DefaultInputFile) inputFile).pathRelativeToSourceDir();
import com.google.common.collect.ImmutableSet;
import org.sonar.api.component.Component;
import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.Scopes;
import org.sonar.api.source.Highlightable;
import org.sonar.batch.index.ComponentDataCache;
import org.sonar.core.component.PerspectiveBuilder;
protected Highlightable loadPerspective(Class<Highlightable> perspectiveClass, Component component) {
boolean supported = SUPPORTED_QUALIFIERS.contains(component.qualifier());
if (supported && component instanceof ResourceComponent) {
- // temporary hack waiting for the removal of JavaClass.
- // JavaClass has the same qualifier than JavaFile, so they have to distinguished by their scope
- supported = Scopes.FILE.equals(((ResourceComponent) component).scope());
- }
- if (supported) {
return new DefaultHighlightable(component, cache);
}
return null;
import org.sonar.jpa.test.AbstractDbUnitTestCase;
import java.io.File;
-import java.io.IOException;
-import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
@Rule
public ExpectedException thrown = ExpectedException.none();
+
@Rule
public TemporaryFolder temp = new TemporaryFolder();
File baseDir;
@Before
- public void before() throws ParseException, IOException {
+ public void before() throws Exception {
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
multiModuleProject = newProject("root", "java");
import org.sonar.api.source.Highlightable;
import org.sonar.batch.index.ComponentDataCache;
import org.sonar.core.component.ResourceComponent;
-import org.sonar.java.api.JavaClass;
import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Mockito.mock;
assertThat(perspective).isNull();
}
-
- @Test
- public void java_class_should_not_be_highlightable() {
- Component component = new ResourceComponent(JavaClass.create("org.struts.Action").setEffectiveKey("struts:org.struts.Action"));
-
- HighlightableBuilder builder = new HighlightableBuilder(cache);
- Highlightable perspective = builder.loadPerspective(Highlightable.class, component);
-
- assertThat(perspective).isNull();
- }
}