Skip to content

Commit

Permalink
Merge pull request #1571 from jarlehansen
Browse files Browse the repository at this point in the history
* pr/1571:
  Polish "Add beans for Java, Kotlin and Groovy SourceCodeWriters"
  Add beans for Java, Kotlin and Groovy SourceCodeWriters

Closes gh-1571
  • Loading branch information
mhalbritter committed Sep 25, 2024
2 parents 1f1ba4e + 80f374f commit ab18264
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,32 @@ public class GroovyProjectGenerationConfiguration {

private final ProjectDescription description;

private final IndentingWriterFactory indentingWriterFactory;

public GroovyProjectGenerationConfiguration(ProjectDescription description,
IndentingWriterFactory indentingWriterFactory) {
public GroovyProjectGenerationConfiguration(ProjectDescription description) {
this.description = description;
this.indentingWriterFactory = indentingWriterFactory;
}

@Bean
public MainSourceCodeProjectContributor<GroovyTypeDeclaration, GroovyCompilationUnit, GroovySourceCode> mainGroovySourceCodeProjectContributor(
GroovySourceCodeWriter groovySourceCodeWriter(IndentingWriterFactory indentingWriterFactory) {
return new GroovySourceCodeWriter(indentingWriterFactory);
}

@Bean
MainSourceCodeProjectContributor<GroovyTypeDeclaration, GroovyCompilationUnit, GroovySourceCode> mainGroovySourceCodeProjectContributor(
ObjectProvider<MainApplicationTypeCustomizer<?>> mainApplicationTypeCustomizers,
ObjectProvider<MainCompilationUnitCustomizer<?, ?>> mainCompilationUnitCustomizers,
ObjectProvider<MainSourceCodeCustomizer<?, ?, ?>> mainSourceCodeCustomizers) {
return new MainSourceCodeProjectContributor<>(this.description, GroovySourceCode::new,
new GroovySourceCodeWriter(this.indentingWriterFactory), mainApplicationTypeCustomizers,
mainCompilationUnitCustomizers, mainSourceCodeCustomizers);
ObjectProvider<MainSourceCodeCustomizer<?, ?, ?>> mainSourceCodeCustomizers,
GroovySourceCodeWriter groovySourceCodeWriter) {
return new MainSourceCodeProjectContributor<>(this.description, GroovySourceCode::new, groovySourceCodeWriter,
mainApplicationTypeCustomizers, mainCompilationUnitCustomizers, mainSourceCodeCustomizers);
}

@Bean
public TestSourceCodeProjectContributor<GroovyTypeDeclaration, GroovyCompilationUnit, GroovySourceCode> testGroovySourceCodeProjectContributor(
TestSourceCodeProjectContributor<GroovyTypeDeclaration, GroovyCompilationUnit, GroovySourceCode> testGroovySourceCodeProjectContributor(
ObjectProvider<TestApplicationTypeCustomizer<?>> testApplicationTypeCustomizers,
ObjectProvider<TestSourceCodeCustomizer<?, ?, ?>> testSourceCodeCustomizers) {
return new TestSourceCodeProjectContributor<>(this.description, GroovySourceCode::new,
new GroovySourceCodeWriter(this.indentingWriterFactory), testApplicationTypeCustomizers,
testSourceCodeCustomizers);
ObjectProvider<TestSourceCodeCustomizer<?, ?, ?>> testSourceCodeCustomizers,
GroovySourceCodeWriter groovySourceCodeWriter) {
return new TestSourceCodeProjectContributor<>(this.description, GroovySourceCode::new, groovySourceCodeWriter,
testApplicationTypeCustomizers, testSourceCodeCustomizers);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,32 @@ public class JavaProjectGenerationConfiguration {

private final ProjectDescription description;

private final IndentingWriterFactory indentingWriterFactory;

public JavaProjectGenerationConfiguration(ProjectDescription description,
IndentingWriterFactory indentingWriterFactory) {
public JavaProjectGenerationConfiguration(ProjectDescription description) {
this.description = description;
this.indentingWriterFactory = indentingWriterFactory;
}

@Bean
public MainSourceCodeProjectContributor<JavaTypeDeclaration, JavaCompilationUnit, JavaSourceCode> mainJavaSourceCodeProjectContributor(
JavaSourceCodeWriter javaSourceCodeWriter(IndentingWriterFactory indentingWriterFactory) {
return new JavaSourceCodeWriter(indentingWriterFactory);
}

@Bean
MainSourceCodeProjectContributor<JavaTypeDeclaration, JavaCompilationUnit, JavaSourceCode> mainJavaSourceCodeProjectContributor(
ObjectProvider<MainApplicationTypeCustomizer<?>> mainApplicationTypeCustomizers,
ObjectProvider<MainCompilationUnitCustomizer<?, ?>> mainCompilationUnitCustomizers,
ObjectProvider<MainSourceCodeCustomizer<?, ?, ?>> mainSourceCodeCustomizers) {
return new MainSourceCodeProjectContributor<>(this.description, JavaSourceCode::new,
new JavaSourceCodeWriter(this.indentingWriterFactory), mainApplicationTypeCustomizers,
mainCompilationUnitCustomizers, mainSourceCodeCustomizers);
ObjectProvider<MainSourceCodeCustomizer<?, ?, ?>> mainSourceCodeCustomizers,
JavaSourceCodeWriter javaSourceCodeWriter) {
return new MainSourceCodeProjectContributor<>(this.description, JavaSourceCode::new, javaSourceCodeWriter,
mainApplicationTypeCustomizers, mainCompilationUnitCustomizers, mainSourceCodeCustomizers);
}

@Bean
public TestSourceCodeProjectContributor<JavaTypeDeclaration, JavaCompilationUnit, JavaSourceCode> testJavaSourceCodeProjectContributor(
TestSourceCodeProjectContributor<JavaTypeDeclaration, JavaCompilationUnit, JavaSourceCode> testJavaSourceCodeProjectContributor(
ObjectProvider<TestApplicationTypeCustomizer<?>> testApplicationTypeCustomizers,
ObjectProvider<TestSourceCodeCustomizer<?, ?, ?>> testSourceCodeCustomizers) {
return new TestSourceCodeProjectContributor<>(this.description, JavaSourceCode::new,
new JavaSourceCodeWriter(this.indentingWriterFactory), testApplicationTypeCustomizers,
testSourceCodeCustomizers);
ObjectProvider<TestSourceCodeCustomizer<?, ?, ?>> testSourceCodeCustomizers,
JavaSourceCodeWriter javaSourceCodeWriter) {
return new TestSourceCodeProjectContributor<>(this.description, JavaSourceCode::new, javaSourceCodeWriter,
testApplicationTypeCustomizers, testSourceCodeCustomizers);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,31 @@ public class KotlinProjectGenerationConfiguration {

private final ProjectDescription description;

private final IndentingWriterFactory indentingWriterFactory;

public KotlinProjectGenerationConfiguration(ProjectDescription description,
IndentingWriterFactory indentingWriterFactory) {
public KotlinProjectGenerationConfiguration(ProjectDescription description) {
this.description = description;
this.indentingWriterFactory = indentingWriterFactory;
}

@Bean
public MainSourceCodeProjectContributor<KotlinTypeDeclaration, KotlinCompilationUnit, KotlinSourceCode> mainKotlinSourceCodeProjectContributor(
KotlinSourceCodeWriter kotlinSourceCodeWriter(IndentingWriterFactory indentingWriterFactory) {
return new KotlinSourceCodeWriter(this.description.getLanguage(), indentingWriterFactory);
}

@Bean
MainSourceCodeProjectContributor<KotlinTypeDeclaration, KotlinCompilationUnit, KotlinSourceCode> mainKotlinSourceCodeProjectContributor(
ObjectProvider<MainApplicationTypeCustomizer<?>> mainApplicationTypeCustomizers,
ObjectProvider<MainCompilationUnitCustomizer<?, ?>> mainCompilationUnitCustomizers,
ObjectProvider<MainSourceCodeCustomizer<?, ?, ?>> mainSourceCodeCustomizers) {
return new MainSourceCodeProjectContributor<>(this.description, KotlinSourceCode::new,
new KotlinSourceCodeWriter(this.description.getLanguage(), this.indentingWriterFactory),
ObjectProvider<MainSourceCodeCustomizer<?, ?, ?>> mainSourceCodeCustomizers,
KotlinSourceCodeWriter kotlinSourceCodeWriter) {
return new MainSourceCodeProjectContributor<>(this.description, KotlinSourceCode::new, kotlinSourceCodeWriter,
mainApplicationTypeCustomizers, mainCompilationUnitCustomizers, mainSourceCodeCustomizers);
}

@Bean
public TestSourceCodeProjectContributor<KotlinTypeDeclaration, KotlinCompilationUnit, KotlinSourceCode> testKotlinSourceCodeProjectContributor(
TestSourceCodeProjectContributor<KotlinTypeDeclaration, KotlinCompilationUnit, KotlinSourceCode> testKotlinSourceCodeProjectContributor(
ObjectProvider<TestApplicationTypeCustomizer<?>> testApplicationTypeCustomizers,
ObjectProvider<TestSourceCodeCustomizer<?, ?, ?>> testSourceCodeCustomizers) {
return new TestSourceCodeProjectContributor<>(this.description, KotlinSourceCode::new,
new KotlinSourceCodeWriter(this.description.getLanguage(), this.indentingWriterFactory),
ObjectProvider<TestSourceCodeCustomizer<?, ?, ?>> testSourceCodeCustomizers,
KotlinSourceCodeWriter kotlinSourceCodeWriter) {
return new TestSourceCodeProjectContributor<>(this.description, KotlinSourceCode::new, kotlinSourceCodeWriter,
testApplicationTypeCustomizers, testSourceCodeCustomizers);
}

Expand Down

0 comments on commit ab18264

Please sign in to comment.