| // Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file | |
| // for details. All rights reserved. Use of this source code is governed by a | |
| // BSD-style license that can be found in the LICENSE file. | |
| package com.android.tools.r8; | |
| import com.android.tools.r8.naming.ClassNameMapper; | |
| import com.android.tools.r8.naming.InternalMapConsumer; | |
| import com.android.tools.r8.retrace.ProguardMapPartitioner; | |
| import com.android.tools.r8.retrace.internal.ProguardMapProducerInternal; | |
| import com.android.tools.r8.utils.internal.exceptions.Unreachable; | |
| import java.io.IOException; | |
| public class MapConsumerToPartitionMapConsumer implements InternalMapConsumer { | |
| protected final PartitionMapConsumer partitionMapConsumer; | |
| protected MapConsumerToPartitionMapConsumer(PartitionMapConsumer partitionMapConsumer) { | |
| assert partitionMapConsumer != null; | |
| this.partitionMapConsumer = partitionMapConsumer; | |
| } | |
| @Override | |
| public void accept( | |
| DiagnosticsHandler diagnosticsHandler, | |
| ClassNameMapper classNameMapper) { | |
| try { | |
| partitionMapConsumer.acceptMappingPartitionMetadata( | |
| ProguardMapPartitioner.builder(diagnosticsHandler) | |
| .setProguardMapProducer(new ProguardMapProducerInternal(classNameMapper)) | |
| .setPartitionConsumer(partitionMapConsumer::acceptMappingPartition) | |
| // Modifying these do not actually do anything currently since there is no parsing. | |
| .setAllowEmptyMappedRanges(false) | |
| .setAllowExperimentalMapping(false) | |
| .build() | |
| .run()); | |
| } catch (IOException exception) { | |
| throw new Unreachable("IOExceptions should only occur when parsing"); | |
| } | |
| } | |
| @Override | |
| public void finished(DiagnosticsHandler handler) { | |
| partitionMapConsumer.finished(handler); | |
| } | |
| } |