use of com.palantir.conjure.python.processors.typename.TypeNameProcessor in project conjure-python by palantir.
the class ConjurePythonGenerator method generate.
private List<PythonFile> generate(ConjureDefinition conjureDefinition) {
DealiasingTypeVisitor dealiasingTypeVisitor = new DealiasingTypeVisitor(conjureDefinition.getTypes().stream().collect(Collectors.toMap(type -> type.accept(TypeDefinitionVisitor.TYPE_NAME), Function.identity())));
PackageNameProcessor implPackageNameProcessor = new ConstantPackageNameProcessor(config.pythonicPackageName().orElse(""));
List<PackageNameProcessor> packageNameProcessors = new ArrayList<>();
packageNameProcessors.add(new TwoComponentStrippingPackageNameProcessor());
packageNameProcessors.add(FlatteningPackageNameProcessor.INSTANCE);
packageNameProcessors.addAll(config.pythonicPackageName().map(pythonPackageName -> ImmutableSet.of(new PrefixingPackageNameProcessor(pythonPackageName))).orElseGet(ImmutableSet::of));
PackageNameProcessor definitionPackageNameProcessor = new CompoundPackageNameProcessor(packageNameProcessors);
TypeNameProcessor implTypeNameProcessor = new PackagePrependingTypeNameProcessor(new CompoundPackageNameProcessor(ImmutableList.of(new TwoComponentStrippingPackageNameProcessor(), FlatteningPackageNameProcessor.INSTANCE)));
TypeNameProcessor definitionTypeNameProcessor = NameOnlyTypeNameProcessor.INSTANCE;
List<PythonFile> pythonFiles = new ArrayList<>();
pythonFiles.add(getImplPythonFile(conjureDefinition, dealiasingTypeVisitor, implPackageNameProcessor, implTypeNameProcessor, definitionPackageNameProcessor, definitionTypeNameProcessor));
List<PythonFile> initFiles = getInitFiles(conjureDefinition, implTypeNameProcessor, definitionPackageNameProcessor, definitionTypeNameProcessor);
pythonFiles.addAll(initFiles);
PythonPackage rootPackage = PythonPackage.of(buildPackageNameProcessor().process("."));
pythonFiles.add(getRootInit(initFiles.stream().map(PythonFile::pythonPackage).collect(Collectors.toSet()), rootPackage));
return pythonFiles;
}
Aggregations