public class ComputationContext implements org.sonar.server.computation.context.ComputationContext {
private final DbClient dbClient;
private final Component component;
- private final LanguageRepository languageRepository;
public ComputationContext(BatchReportReader reportReader, String projectKey, Settings projectSettings, DbClient dbClient,
ComponentTreeBuilder componentTreeBuilder, LanguageRepository languageRepository) {
this.dbClient = dbClient;
this.component = componentTreeBuilder.build(this);
- this.languageRepository = languageRepository;
}
@Override
return dbClient;
}
- @Override
- public LanguageRepository getLanguageRepository() {
- return languageRepository;
- }
}
import org.sonar.server.computation.component.DepthTraversalTypeAwareVisitor;
import org.sonar.server.computation.event.Event;
import org.sonar.server.computation.event.EventRepository;
+import org.sonar.server.computation.language.LanguageRepository;
import org.sonar.server.computation.measure.MeasureRepository;
import org.sonar.server.computation.qualityprofile.QPMeasureData;
import org.sonar.server.computation.qualityprofile.QualityProfile;
public class QualityProfileEventsStep implements ComputationStep {
private final MeasureRepository measureRepository;
private final EventRepository eventRepository;
+ private final LanguageRepository languageRepository;
- public QualityProfileEventsStep(MeasureRepository measureRepository, EventRepository eventRepository) {
+ public QualityProfileEventsStep(MeasureRepository measureRepository, EventRepository eventRepository, LanguageRepository languageRepository) {
this.measureRepository = measureRepository;
this.eventRepository = eventRepository;
+ this.languageRepository = languageRepository;
}
@Override
eventRepository.add(component, createQProfileEvent(component, profile, "Use %s"));
}
- private static Event createQProfileEvent(Component component, QualityProfile profile, String namePattern) {
+ private Event createQProfileEvent(Component component, QualityProfile profile, String namePattern) {
return createQProfileEvent(component, profile, namePattern, null);
}
- private static Event createQProfileEvent(Component component, QualityProfile profile, String namePattern, @Nullable String data) {
+ private Event createQProfileEvent(Component component, QualityProfile profile, String namePattern, @Nullable String data) {
return Event.createProfile(String.format(namePattern, profileLabel(component, profile)), data, null);
}
- private static String profileLabel(Component component, QualityProfile profile) {
- Optional<Language> language = component.getContext().getLanguageRepository().find(profile.getLanguageKey());
+ private String profileLabel(Component component, QualityProfile profile) {
+ Optional<Language> language = languageRepository.find(profile.getLanguageKey());
String languageName = language.isPresent() ? language.get().getName() : profile.getLanguageKey();
return String.format("'%s' (%s)", profile.getQpName(), languageName);
}