private <T> List<T> getFilteredExtensions(Class<T> type, @Nullable Project project, @Nullable ExtensionMatcher matcher) {
List<T> result = Lists.newArrayList();
for (Object extension : getExtensions(type)) {
if (org.sonar.api.batch.Sensor.class.equals(type) && extension instanceof Sensor) {
extension = new SensorWrapper((Sensor) extension, context, analyzerOptimizer);
}
if (shouldKeep(type, extension, project, matcher)) {
result.add((T) extension);
}
}
if (org.sonar.api.batch.Sensor.class.equals(type)) {
// Retrieve new Sensors and wrap then in SensorWrapper
for (Object extension : getExtensions(Sensor.class)) {
extension = new SensorWrapper((Sensor) extension, context, analyzerOptimizer);
if (shouldKeep(type, extension, project, matcher)) {
result.add((T) extension);
}
}
}