Skip to content

Commit

Permalink
Merge branch 'release/0.0.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
jangalinski committed Sep 27, 2024
2 parents 5b57711 + 61dfa61 commit e54c37f
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 12 deletions.
2 changes: 1 addition & 1 deletion _build/parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.toolisticon.kotlin.generation._</groupId>
<artifactId>kotlin-code-generation-root</artifactId>
<version>0.0.9</version>
<version>0.0.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion _build/report-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.toolisticon.kotlin.generation._</groupId>
<artifactId>kotlin-code-generation-parent</artifactId>
<version>0.0.9</version>
<version>0.0.10</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion _itest/builder-itest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.toolisticon.kotlin.generation._</groupId>
<artifactId>kotlin-code-generation-itest-root</artifactId>
<version>0.0.9</version>
<version>0.0.10</version>
</parent>

<groupId>io.toolisticon.kotlin.generation.itest</groupId>
Expand Down
2 changes: 1 addition & 1 deletion _itest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.toolisticon.kotlin.generation._</groupId>
<artifactId>kotlin-code-generation-parent</artifactId>
<version>0.0.9</version>
<version>0.0.10</version>
<relativePath>../_build/parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion _itest/spi-itest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.toolisticon.kotlin.generation._</groupId>
<artifactId>kotlin-code-generation-itest-root</artifactId>
<version>0.0.9</version>
<version>0.0.10</version>
</parent>

<groupId>io.toolisticon.kotlin.generation.itest</groupId>
Expand Down
2 changes: 1 addition & 1 deletion kotlin-code-generation-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.toolisticon.kotlin.generation._</groupId>
<artifactId>kotlin-code-generation-root</artifactId>
<version>0.0.9</version>
<version>0.0.10</version>
</parent>

<groupId>io.toolisticon.kotlin.generation</groupId>
Expand Down
2 changes: 1 addition & 1 deletion kotlin-code-generation-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.toolisticon.kotlin.generation._</groupId>
<artifactId>kotlin-code-generation-parent</artifactId>
<version>0.0.9</version>
<version>0.0.10</version>
<relativePath>../_build/parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion kotlin-code-generation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.toolisticon.kotlin.generation._</groupId>
<artifactId>kotlin-code-generation-parent</artifactId>
<version>0.0.9</version>
<version>0.0.10</version>
<relativePath>../_build/parent/pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,15 @@ abstract class KotlinFileSpecProcessor<CONTEXT : KotlinCodeGenerationContext<CON

/**
* Used to implement a [io.toolisticon.kotlin.generation.spi.KotlinCodeGenerationProcessor]
* that will visit/modify a [KotlinFileSpecBuilder] but do not work on a loop variable.
* that will visit/modify a [KotlinFileSpecBuilder] but do not work on a loop variable/input type.
*/
@ExperimentalKotlinPoetApi
abstract class KotlinFileSpecEmptyInputProcessor<CONTEXT : KotlinCodeGenerationContext<CONTEXT>>(
contextType: KClass<CONTEXT>,
order: Int = KotlinCodeGenerationSpi.DEFAULT_ORDER
) : KotlinCodeGenerationProcessorBase<CONTEXT, EmptyInput, KotlinFileSpecBuilder>(
) : KotlinFileSpecProcessor<CONTEXT, EmptyInput>(
contextType = contextType,
inputType = EmptyInput::class,
builderType = KotlinFileSpecBuilder::class,
order = order
) {
/**
Expand All @@ -54,4 +53,10 @@ abstract class KotlinFileSpecEmptyInputProcessor<CONTEXT : KotlinCodeGenerationC
fun test(context: CONTEXT): Boolean = context::class.isSubclassOf(contextType)

override fun test(context: CONTEXT, input: Any): Boolean = super.test(context, input) && test(context)

/**
* Execute only based on context.
*/
fun execute(context: CONTEXT, builder: KotlinFileSpecBuilder): KotlinFileSpecBuilder = super.execute(context, EmptyInput, builder)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.toolisticon.kotlin.generation.spi.processor

import com.squareup.kotlinpoet.ExperimentalKotlinPoetApi
import io.toolisticon.kotlin.generation.KotlinCodeGeneration
import io.toolisticon.kotlin.generation.KotlinCodeGeneration.builder.fileBuilder
import io.toolisticon.kotlin.generation.KotlinCodeGeneration.className
import io.toolisticon.kotlin.generation._test.MutableSpiRegistry
import io.toolisticon.kotlin.generation._test.TestContext
import io.toolisticon.kotlin.generation.builder.KotlinFileSpecBuilder
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test

@OptIn(ExperimentalKotlinPoetApi::class)
internal class KotlinFileSpecEmptyInputProcessorTest {

@Test
fun `add doc to file via processor`() {
val file = fileBuilder("foo", "bar")

class AddDocProcessor : KotlinFileSpecEmptyInputProcessor<TestContext>(TestContext::class) {
override fun invoke(context: TestContext, builder: KotlinFileSpecBuilder): KotlinFileSpecBuilder {
return builder.addFileComment(KotlinCodeGeneration.format.FORMAT_STRING, "Hello World")
}
}

AddDocProcessor().execute(TestContext(className("foo", "bar"), MutableSpiRegistry()), file)

assertThat(file.spec().code).isEqualToIgnoringWhitespace("""
// "Hello World"
package foo
""".trimIndent())
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>io.toolisticon.kotlin.generation._</groupId>
<artifactId>kotlin-code-generation-root</artifactId>
<version>0.0.9</version>
<version>0.0.10</version>

<name>pom: ${project.artifactId}</name>
<description>Root of kotlin-code-generation</description>
Expand Down

0 comments on commit e54c37f

Please sign in to comment.