All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.protostuff.compiler.parser.ImportsPostProcessor Maven / Gradle / Ivy

There is a newer version: 3.1.40
Show newest version
package io.protostuff.compiler.parser;

import javax.inject.Inject;

import io.protostuff.compiler.model.Import;

/**
 * @author Kostiantyn Shchepanovskyi
 */
public class ImportsPostProcessor implements ProtoContextPostProcessor {

    private final Importer importer;

    @Inject
    public ImportsPostProcessor(Importer importer) {
        this.importer = importer;
    }

    @Override
    public void process(ProtoContext context) {
        resolveImports(context);
    }

    private void resolveImports(ProtoContext context) {
        for (Import anImport : context.getProto().getImports()) {
            FileReader reader = context.getFileReader();
            String file = anImport.getValue();
            ProtoContext importedContext = importer.importFile(reader, file);
            if (anImport.isPublic()) {
                context.addPublicImport(importedContext);
            } else {
                context.addImport(importedContext);
            }
            anImport.setProto(importedContext.getProto());
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy