Skip to content

Commit

Permalink
Update package
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools authored and BuildTools committed Dec 9, 2022
1 parent 6da3b4e commit 30a57e6
Show file tree
Hide file tree
Showing 16 changed files with 93 additions and 90 deletions.
43 changes: 0 additions & 43 deletions src/main/kotlin/dsl/test/DslTesting.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package dsl
package me.deotime.kpoetdsl

import com.squareup.kotlinpoet.AnnotationSpec
import com.squareup.kotlinpoet.ClassName
import com.squareup.kotlinpoet.asClassName
import dsl.utils.Assembler
import dsl.utils.buildWith
import dsl.utils.required
import dsl.utils.withRequired
import me.deotime.kpoetdsl.utils.Assembler
import me.deotime.kpoetdsl.utils.buildWith
import me.deotime.kpoetdsl.utils.required
import me.deotime.kpoetdsl.utils.withRequired

class AnnotationBuilder private constructor(private val cozy: Cozy<AnnotationBuilder>) :
Attributes.Sourced<AnnotationSpec.Builder>,
Expand All @@ -20,10 +20,13 @@ class AnnotationBuilder private constructor(private val cozy: Cozy<AnnotationBui
}

fun target(selector: Target.Companion.() -> Target) {
source.useSiteTarget(selector(Target.Companion).source)
source.useSiteTarget(selector(Target).source)
}

fun type(type: ClassName) {
this.type = type
}

fun type(type: ClassName) { this.type = type }
inline fun <reified T> type() = type(T::class.asClassName())

@JvmInline
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dsl
package me.deotime.kpoetdsl

import com.squareup.kotlinpoet.AnnotationSpec
import com.squareup.kotlinpoet.ClassName
Expand All @@ -10,12 +10,12 @@ import com.squareup.kotlinpoet.PropertySpec
import com.squareup.kotlinpoet.TypeName
import com.squareup.kotlinpoet.TypeVariableName
import com.squareup.kotlinpoet.asTypeName
import dsl.utils.Assembler
import dsl.utils.CollectionAssembler
import dsl.utils.Uses
import dsl.utils.buildCollectionTo
import dsl.utils.buildWith
import dsl.utils.requiredByCozy
import me.deotime.kpoetdsl.utils.Assembler
import me.deotime.kpoetdsl.utils.CollectionAssembler
import me.deotime.kpoetdsl.utils.Uses
import me.deotime.kpoetdsl.utils.buildCollectionTo
import me.deotime.kpoetdsl.utils.buildWith
import me.deotime.kpoetdsl.utils.requiredByCozy
import kotlin.reflect.KClass

interface Attributes {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dsl
package me.deotime.kpoetdsl

import com.squareup.kotlinpoet.CodeBlock

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dsl
package me.deotime.kpoetdsl

import kotlin.reflect.KProperty

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package dsl
package me.deotime.kpoetdsl

import com.squareup.kotlinpoet.FileSpec
import dsl.utils.Assembler
import dsl.utils.Uses
import dsl.utils.buildWith
import dsl.utils.required
import dsl.utils.withRequired
import me.deotime.kpoetdsl.utils.Assembler
import me.deotime.kpoetdsl.utils.Uses
import me.deotime.kpoetdsl.utils.buildWith
import me.deotime.kpoetdsl.utils.required
import me.deotime.kpoetdsl.utils.withRequired
import kotlin.reflect.KClass

class FileBuilder private constructor(private val cozy: Cozy<FileBuilder>) :
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package dsl
package me.deotime.kpoetdsl

import com.squareup.kotlinpoet.FunSpec
import com.squareup.kotlinpoet.KModifier
import com.squareup.kotlinpoet.TypeName
import com.squareup.kotlinpoet.TypeVariableName
import com.squareup.kotlinpoet.asTypeName
import com.squareup.kotlinpoet.jvm.jvmStatic
import dsl.utils.Assembler
import dsl.utils.buildWith
import dsl.utils.withRequired
import me.deotime.kpoetdsl.utils.Assembler
import me.deotime.kpoetdsl.utils.buildWith
import me.deotime.kpoetdsl.utils.withRequired
import java.lang.reflect.Modifier
import kotlin.reflect.KClass

Expand Down Expand Up @@ -63,7 +63,7 @@ class FunctionBuilder private constructor(private val cozy: Cozy<FunctionBuilder


fun operator(op: Operator.Companion.() -> Operator) {
name(op(Operator.Companion).name)
name(op(Operator).name)
modifiers { +KModifier.OPERATOR }
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package dsl
package me.deotime.kpoetdsl

import com.squareup.kotlinpoet.ParameterSpec
import dsl.utils.Assembler
import dsl.utils.buildWith
import dsl.utils.withRequired
import me.deotime.kpoetdsl.utils.Assembler
import me.deotime.kpoetdsl.utils.buildWith
import me.deotime.kpoetdsl.utils.withRequired

class ParameterBuilder private constructor(private val cozy: Cozy<ParameterBuilder>) :
Attributes.Sourced<ParameterSpec.Builder>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package dsl
package me.deotime.kpoetdsl

import com.squareup.kotlinpoet.PropertySpec
import com.squareup.kotlinpoet.jvm.transient
import com.squareup.kotlinpoet.jvm.volatile
import dsl.utils.Assembler
import dsl.utils.buildWith
import dsl.utils.withRequired
import me.deotime.kpoetdsl.utils.Assembler
import me.deotime.kpoetdsl.utils.buildWith
import me.deotime.kpoetdsl.utils.withRequired

class PropertyBuilder private constructor(private val cozy: Cozy<PropertyBuilder>) :
Attributes.Sourced<PropertySpec.Builder>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package dsl
package me.deotime.kpoetdsl

import com.squareup.kotlinpoet.TypeSpec
import dsl.utils.Assembler
import dsl.utils.buildWith
import dsl.utils.required
import dsl.utils.withRequired
import me.deotime.kpoetdsl.utils.Assembler
import me.deotime.kpoetdsl.utils.buildWith
import me.deotime.kpoetdsl.utils.required
import me.deotime.kpoetdsl.utils.withRequired
import kotlin.contracts.contract
import kotlin.reflect.KClass

class TypeBuilder private constructor(private val cozy: Cozy<TypeBuilder>) :
Expand Down
42 changes: 42 additions & 0 deletions src/main/kotlin/me/deotime/kpoetdsl/test/DslTesting.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package me.deotime.kpoetdsl.test

import me.deotime.kpoetdsl.invoke
import me.deotime.kpoetdsl.kotlin
import me.deotime.kpoetdsl.type
import me.deotime.kpoetdsl.utils.typeParameter

fun main() {

val dsl = kotlin {
name("Calculator") packaged "idk"

val typeParam = typeParameter<Number>("T")
type("Calculator") {
kind { Class }
property {
name("glitch")
type<String>()
initializer {
+"%T().toString()"(Any::class)
}
}
typeParameters {
+typeParam
}
function {
operator { Plus }
receiver(typeParam)
returns(typeParam)
parameter("other") { type(typeParam) }
comment("This function will add two numbers")
comment("together, and then return that value.")
code {
+"return this + other"
}


}
}
}
dsl.writeTo(System.out)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dsl.utils
package me.deotime.kpoetdsl.utils

interface CollectionBuilder<T> {
operator fun T.unaryPlus()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dsl.utils
package me.deotime.kpoetdsl.utils

import dsl.Cozy
import me.deotime.kpoetdsl.Cozy
import java.util.IdentityHashMap
import kotlin.properties.Delegates
import kotlin.reflect.KProperty
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dsl.utils
package me.deotime.kpoetdsl.utils

sealed interface Uses {
object Name : Uses
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dsl.utils
package me.deotime.kpoetdsl.utils

import com.squareup.kotlinpoet.TypeVariableName
import com.squareup.kotlinpoet.asTypeName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dsl.utils
package me.deotime.kpoetdsl.utils

import dsl.Attributes
import me.deotime.kpoetdsl.Attributes

typealias Assembler<T> = T.() -> Unit

Expand Down

0 comments on commit 30a57e6

Please sign in to comment.