amanda.hinchman-dominguez
11/07/2019, 8:41 PMquoteOutputMatches
? Why are there repetitive code in the source strings between both the code snippet and whatever is in quoteOutputMatches(...)
? i.e. HigherTestPlugins.ktImran/Malic
11/07/2019, 8:49 PMquoteOutputMatches
is agnostic to what we think of the QuoteSystem. Input
Output
. Thus the Test does exactly this.
It checks what the user writes and test the output of compilation. You can see it here https://github.com/arrow-kt/arrow-meta/blob/b1ed3bdcff0fe2056fe9f58a233c6a9533e2cd27/testing-plugin/src/main/kotlin/arrow/meta/plugin/testing/CompilationAssertions.kt#L83amanda.hinchman-dominguez
11/07/2019, 8:59 PMamanda.hinchman-dominguez
11/07/2019, 9:01 PMamanda.hinchman-dominguez
11/07/2019, 9:01 PMassertThis(CompilerTest(
config = { metaDependencies },
code = {
"""
| import arrow.higherkind
|
| //metadebug
|
| @higherkind
| class Id2<out A>(val value: A)
|
| val x: Id2Of<Int> = Id2(1)
|
""".source
},
assert = {
allOf(quoteOutputMatches(
"""
| import arrow.higherkind
|
| //meta: <date>
|
| @arrow.synthetic class ForId2 private constructor() { companion object }
| @arrow.synthetic typealias Id2Of<A> = arrow.Kind<ForId2, A>
| @arrow.synthetic typealias Id2KindedJ<A> = arrow.HkJ<ForId2, A>
| @arrow.synthetic fun <A> Id2Of<A>.fix(): Id2<A> =
| this as Id2<A>
| @arrow.synthetic @higherkind /* empty? */class Id2 <out A> public constructor (val value: A) : Id2Of<A> {}
|
| val x: Id2Of<Int> = Id2(1)
|
""".source))
amanda.hinchman-dominguez
11/07/2019, 9:01 PM@arrow.synthetic
stuff?amanda.hinchman-dominguez
11/07/2019, 9:02 PMImran/Malic
11/07/2019, 9:40 PMf:(Code) -> Code
Imran/Malic
11/07/2019, 9:41 PM@arrow.synthetic
is part of the implementation details within the HigherkindedPlugin
.Imran/Malic
11/07/2019, 9:46 PMfunc
or type Aliases with typeAlias
. These are just instances, plugin developers can always extend it to other areas, too. Interestingly enough, this gives you the power to drop code generation frameworks like kapt entirely with the advantage to have the newly constructed code at compile time. The Ide plugin also supports those synthetic members to be in scope, so your not getting redlines.raulraja
11/07/2019, 9:48 PMraulraja
11/07/2019, 9:51 PMquoteOutputMatches
is an assert where you can assert the output you expect the quote system to generate in text form.raulraja
11/07/2019, 9:51 PMamanda.hinchman-dominguez
11/07/2019, 9:53 PMraulraja
11/07/2019, 9:53 PM.synthetic
in ElementScope annotates anything you generate in the quote system as @arrow.synthetic
and that makes it automatically discoverable by the IDE when you compile the project and Arrow Meta can extract the synth descriptors from the class files disregarding anything that is not annotated by @arrow.synthetic
amanda.hinchman-dominguez
11/07/2019, 9:53 PMraulraja
11/07/2019, 9:53 PMraulraja
11/07/2019, 9:53 PMraulraja
11/07/2019, 9:54 PMamanda.hinchman-dominguez
11/07/2019, 10:11 PM