-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from ty1824/references
New reference handling for node builders
- Loading branch information
Showing
13 changed files
with
361 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 66 additions & 46 deletions
112
dialector-kt-processor/src/main/kotlin/dev/dialector/processor/DialectorSymbolProcessor.kt
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...ctor-kt-processor/src/test/kotlin/dev/dialector/processor/DialectorSymbolProcessorTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package dev.dialector.processor | ||
|
||
import dev.dialector.processor.ast.childNode | ||
import dev.dialector.processor.ast.simpleNode | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
/** | ||
* These tests are designed to validate the generated code, both its API and its functionality. | ||
*/ | ||
class DialectorSymbolProcessorTest { | ||
|
||
@Test | ||
fun processorApi() { | ||
val singleChildValue = childNode() | ||
val optionalChildValue = childNode() | ||
val pluralFirstChildValue = childNode() | ||
val pluralSecondChildValue = childNode() | ||
val pluralThirdChildValue = childNode() | ||
val node = simpleNode { | ||
property = "hello" | ||
optionalProperty = "provided" | ||
singleChild = singleChildValue | ||
optionalChild = optionalChildValue | ||
pluralChildren += pluralFirstChildValue | ||
pluralChildren += listOf(pluralSecondChildValue, pluralThirdChildValue) | ||
reference = "target.id" | ||
optionalReference = "target.otherId" | ||
} | ||
|
||
// Verify raw values | ||
assertEquals("hello", node.property) | ||
assertEquals("provided", node.optionalProperty) | ||
assertEquals(singleChildValue, node.singleChild) | ||
assertEquals(optionalChildValue, node.optionalChild) | ||
assertEquals(listOf(pluralFirstChildValue, pluralSecondChildValue, pluralThirdChildValue), node.pluralChildren) | ||
assertEquals("target.id", node.reference.targetIdentifier) | ||
assertEquals("target.otherId", node.optionalReference?.targetIdentifier) | ||
|
||
// Verify parent assignment | ||
assertEquals(node, singleChildValue.parent) | ||
|
||
// Verify reference property assignment | ||
assertEquals(node, node.reference.sourceNode) | ||
assertEquals(SimpleNode::reference, node.reference.relation) | ||
assertEquals(SimpleNode::optionalReference, node.optionalReference?.relation) | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
dialector-kt-processor/src/test/kotlin/dev/dialector/processor/SampleModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package dev.dialector.processor | ||
|
||
import dev.dialector.syntax.Child | ||
import dev.dialector.syntax.Node | ||
import dev.dialector.syntax.NodeDefinition | ||
import dev.dialector.syntax.NodeReference | ||
import dev.dialector.syntax.Property | ||
import dev.dialector.syntax.Reference | ||
|
||
@NodeDefinition | ||
interface SimpleNode : Node { | ||
@Property | ||
val property: String | ||
|
||
@Property | ||
val optionalProperty: String? | ||
|
||
@Child | ||
val singleChild: ChildNode | ||
|
||
@Child | ||
val optionalChild: ChildNode | ||
|
||
@Child | ||
val pluralChildren: List<ChildNode> | ||
|
||
@Reference | ||
val reference: NodeReference<ReferenceTargetNode> | ||
|
||
@Reference | ||
val optionalReference: NodeReference<ReferenceTargetNode>? | ||
} | ||
|
||
@NodeDefinition | ||
interface ChildNode : Node | ||
|
||
@NodeDefinition | ||
interface ReferenceTargetNode : Node { | ||
@Property | ||
val name: String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 0 additions & 119 deletions
119
dialector-kt/src/main/kotlin/dev/dialector/server/DialectorServer.kt
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
dialector-kt/src/main/kotlin/dev/dialector/server/EventBus.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.