├── .github └── workflows │ └── gradle.yml ├── .gitignore ├── Contact.md ├── LICENSE ├── Readme.md ├── annotations ├── build.gradle └── src │ └── commonMain │ └── kotlin │ └── de │ └── jensklingenberg │ └── testAnnotations │ └── Annotations.kt ├── build.gradle ├── buildSrc ├── build.gradle └── src │ └── main │ └── kotlin │ └── de │ └── jensklingenberg │ └── mpapt │ └── MpAptGradleSubPlugin.kt ├── demoProject ├── .gitignore ├── Contact.md ├── README.md ├── build.gradle ├── buildSrc │ ├── build.gradle │ └── src │ │ └── main │ │ └── kotlin │ │ └── de │ │ └── jensklingenberg │ │ └── mpapt │ │ ├── MpAptGradlePlugin.kt │ │ └── MpAptGradleSubplugin.kt ├── example │ ├── build.gradle │ └── src │ │ └── jsMain │ │ └── kotlin │ │ └── de │ │ └── jensklingenberg │ │ └── ktorfit │ │ ├── Api.kt │ │ └── Start.kt ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── ktorfit-annotations │ ├── build.gradle │ └── src │ │ └── commonMain │ │ └── kotlin │ │ └── de │ │ └── jensklingenberg │ │ └── ktofitAnnotations │ │ └── Annotations.kt ├── ktorfit-compiler │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── de │ │ └── jensklingenberg │ │ └── CommonComponentRegistrar.kt ├── ktorfit-shared │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── de │ │ └── jensklingenberg │ │ └── MpAptTestProcessor.kt └── settings.gradle ├── docs ├── 404.html ├── CHANGELOG.md ├── CHANGELOG │ └── index.html ├── assets │ ├── fonts │ │ ├── font-awesome.css │ │ ├── material-icons.css │ │ └── specimen │ │ │ ├── FontAwesome.ttf │ │ │ ├── FontAwesome.woff │ │ │ ├── FontAwesome.woff2 │ │ │ ├── MaterialIcons-Regular.ttf │ │ │ ├── MaterialIcons-Regular.woff │ │ │ └── MaterialIcons-Regular.woff2 │ ├── images │ │ ├── favicon.png │ │ └── icons │ │ │ ├── bitbucket.1b09e088.svg │ │ │ ├── github.f0b8504a.svg │ │ │ └── gitlab.6dd19c00.svg │ ├── javascripts │ │ ├── application.c648116f.js │ │ ├── lunr │ │ │ ├── lunr.da.js │ │ │ ├── lunr.de.js │ │ │ ├── lunr.du.js │ │ │ ├── lunr.es.js │ │ │ ├── lunr.fi.js │ │ │ ├── lunr.fr.js │ │ │ ├── lunr.hu.js │ │ │ ├── lunr.it.js │ │ │ ├── lunr.ja.js │ │ │ ├── lunr.jp.js │ │ │ ├── lunr.multi.js │ │ │ ├── lunr.nl.js │ │ │ ├── lunr.no.js │ │ │ ├── lunr.pt.js │ │ │ ├── lunr.ro.js │ │ │ ├── lunr.ru.js │ │ │ ├── lunr.stemmer.support.js │ │ │ ├── lunr.sv.js │ │ │ ├── lunr.th.js │ │ │ ├── lunr.tr.js │ │ │ ├── tinyseg.js │ │ │ └── wordcut.js │ │ └── modernizr.74668098.js │ └── stylesheets │ │ ├── application-palette.a8b3c06d.css │ │ └── application.30686662.css ├── images │ ├── KonanDebug.png │ ├── kotlincompilerdebug.png │ ├── logJs.png │ ├── logJvm.png │ ├── logNative.png │ └── terminaldebugnative.png ├── index.html ├── index.md ├── search │ └── search_index.json ├── sitemap.xml ├── sitemap.xml.gz ├── test.md └── test │ └── index.html ├── example ├── build.gradle └── src │ ├── commonMain │ └── kotlin │ │ └── CommonAnnotated.kt │ ├── jsMain │ └── kotlin │ │ └── de │ │ └── jensklingenberg │ │ └── mpapt │ │ ├── Generated.kt │ │ ├── JSAnnotated.kt │ │ ├── JsSecondAnnotated.kt │ │ └── TestAbstract.kt │ ├── jvmMain │ └── kotlin │ │ └── de │ │ └── jensklingenberg │ │ ├── JVMSecondAnnotated.kt │ │ └── mpapt │ │ ├── Generated.kt │ │ └── JVMAnnotated.kt │ └── linuxMain │ └── kotlin │ └── sample │ ├── LinuxAnnotated.kt │ └── LinuxSecondAnnotated.kt ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── kotlin-compiler-native-plugin ├── build.gradle └── src │ └── main │ └── java │ └── de │ └── jensklingenberg │ └── common │ └── NativeTestComponentRegistrar.kt ├── kotlin-plugin-shared ├── build.gradle └── src │ ├── main │ └── java │ │ └── de │ │ └── jensklingenberg │ │ └── MpAptTestProcessor.kt │ └── test │ └── kotlin │ └── de │ └── jensklingenberg │ └── CompileTest.kt ├── kotlin-plugin ├── build.gradle └── src │ └── main │ └── java │ └── de │ └── jensklingenberg │ └── CommonComponentRegistrar.kt ├── mkdocs.yml ├── mpapt-runtime ├── build.gradle └── src │ └── main │ └── java │ └── de │ └── jensklingenberg │ └── mpapt │ ├── common │ ├── AnnotationDescriptorExt.kt │ ├── ClassDescriptorExt.kt │ ├── Ext.kt │ ├── FunctionDescriptorExt.kt │ ├── ModuleDescriptorExt.kt │ └── MpAptProject.kt │ ├── extension │ ├── DeclarationCheckerImpl.kt │ ├── NativeIrGenerationExtension.kt │ ├── ProcessorFinishedDetector.kt │ ├── ProcessorFinishedDetectorImpl.kt │ └── StorageComponentContainerContributorImpl.kt │ ├── model │ ├── AbstractProcessor.kt │ ├── Element.kt │ ├── FunctionParameter.kt │ ├── ProcessingEnvironment.kt │ ├── Processor.kt │ ├── RoundEnvironment.kt │ └── SourceVersion.kt │ └── utils │ ├── ElementUtils.kt │ ├── KaptUtils.kt │ ├── KonanTargetValues.kt │ └── KotlinPlatformValues.kt ├── nativeDemo ├── .gitignore ├── Contact.md ├── Readme.md ├── build.gradle ├── buildSrc │ ├── build.gradle │ └── src │ │ └── main │ │ └── kotlin │ │ └── de │ │ └── jensklingenberg │ │ └── mpapt │ │ ├── MpAptGradlePlugin.kt │ │ └── MpAptGradleSubplugin.kt ├── example │ ├── build.gradle │ └── src │ │ └── linuxMain │ │ └── kotlin │ │ └── sample │ │ └── LinuxAnnotated.kt ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── native-plugin │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── de │ │ └── jensklingenberg │ │ ├── MpAptTestProcessor.kt │ │ └── NativeComponentRegistrar.kt ├── nativedemo-annotations │ ├── build.gradle │ └── src │ │ └── commonMain │ │ └── kotlin │ │ └── de │ │ └── jensklingenberg │ │ └── nativedemo │ │ └── Annotations.kt ├── nativedemo.png └── settings.gradle └── settings.gradle /.github/workflows/gradle.yml: -------------------------------------------------------------------------------- 1 | name: Java CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v1 12 | - name: Set up JDK 1.8 13 | uses: actions/setup-java@v1 14 | with: 15 | java-version: 1.8 16 | - name: Build with Gradle 17 | run: ./gradlew :annotations:publishToMavenLocal 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /mpapt/build/ 2 | /kotlin-plugin/build/ 3 | /gradle-plugin/build/ 4 | /example/build/ 5 | /.idea/ 6 | /annotations/build/ 7 | /kotlin-compiler-native-plugin/build/ 8 | /.gradle/ 9 | /build/ 10 | /mpapt-runtime/build/* 11 | /kotlin-plugin-shared/build/ 12 | /buildSrc/build/ 13 | /buildSrc/.gradle/ 14 | -------------------------------------------------------------------------------- /Contact.md: -------------------------------------------------------------------------------- 1 | Created by Jens Klingenberg 2 | * www.jensklingenberg.de 3 | 4 | 5 | Contact: 6 | * Mail: mail@jensklingenberg.de 7 | * Twitter: [@jklingenberg_](https://twitter.com/jklingenberg_) -------------------------------------------------------------------------------- /annotations/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | 3 | ext.buildMaven = { p -> repositories { maven { url p } } } 4 | 5 | 6 | repositories { 7 | mavenLocal() 8 | google() 9 | jcenter() 10 | mavenCentral() 11 | } 12 | 13 | dependencies { 14 | } 15 | 16 | } 17 | 18 | plugins { 19 | id 'org.jetbrains.kotlin.multiplatform' version '1.5.10' 20 | id "maven" 21 | id("maven-publish") 22 | 23 | } 24 | 25 | group = "de.jensklingenberg.mpapt.testAnnotations" 26 | 27 | version = "0.0.1" 28 | 29 | 30 | repositories { 31 | mavenCentral() 32 | } 33 | 34 | kotlin { 35 | jvm() 36 | js() 37 | linuxX64("linux") 38 | 39 | sourceSets { 40 | commonMain { 41 | dependencies { 42 | implementation kotlin('stdlib-common') 43 | 44 | } 45 | } 46 | commonTest { 47 | dependencies { 48 | implementation kotlin('test-common') 49 | implementation kotlin('test-annotations-common') 50 | } 51 | } 52 | 53 | jsMain { 54 | dependencies { 55 | implementation kotlin('stdlib-js') 56 | 57 | } 58 | } 59 | jsTest { 60 | dependencies { 61 | implementation kotlin('test-js') 62 | } 63 | } 64 | 65 | jvmMain { 66 | dependencies { 67 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" 68 | } 69 | } 70 | jsTest { 71 | dependencies { 72 | implementation kotlin('test-js') 73 | } 74 | } 75 | 76 | } 77 | } 78 | 79 | 80 | 81 | 82 | build.finalizedBy(publishToMavenLocal) -------------------------------------------------------------------------------- /annotations/src/commonMain/kotlin/de/jensklingenberg/testAnnotations/Annotations.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.testAnnotations 2 | 3 | 4 | @Target(AnnotationTarget.CLASS) 5 | annotation class TestClass() 6 | 7 | @Target(AnnotationTarget.FUNCTION) 8 | annotation class TestFunction() 9 | 10 | @Target(AnnotationTarget.PROPERTY) 11 | annotation class TestProperty() 12 | 13 | @Target(AnnotationTarget.VALUE_PARAMETER) 14 | annotation class TestValueParameter() 15 | 16 | @Target(AnnotationTarget.TYPE_PARAMETER) 17 | annotation class TestTypeParameter() 18 | 19 | @Target(AnnotationTarget.TYPEALIAS) 20 | annotation class TestTypeAlias() 21 | 22 | 23 | @Target(AnnotationTarget.PROPERTY_GETTER) 24 | annotation class TestPropertyGetter 25 | 26 | @Target(AnnotationTarget.PROPERTY_SETTER) 27 | annotation class TestPropertySetter() 28 | 29 | @Target(AnnotationTarget.TYPE) 30 | annotation class TestType() 31 | 32 | @Target(AnnotationTarget.FILE) 33 | annotation class TestFile(val file: String = "HELLO") 34 | 35 | @Retention(AnnotationRetention.SOURCE) 36 | @Target(AnnotationTarget.EXPRESSION) 37 | annotation class TestExpression(val value: String = "") 38 | 39 | @Target(AnnotationTarget.ANNOTATION_CLASS) 40 | annotation class TestAnnotationClass 41 | 42 | @Target(AnnotationTarget.CONSTRUCTOR) 43 | annotation class TestConstructor 44 | 45 | @Target(AnnotationTarget.FIELD) 46 | annotation class TestField 47 | 48 | @Target(AnnotationTarget.LOCAL_VARIABLE) 49 | annotation class TestLocalVariable 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | //./gradlew :example:clean :example:build --no-daemon -Dorg.gradle.debug=true -Dkotlin.compiler.execution.strategy="in-process" -Dkotlin.daemon.jvm.options="-Xdebug,-Xrunjdwp:transport=dt_socket\,address=5005\,server=y\,suspend=n" -------------------------------------------------------------------------------- /buildSrc/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.5.10' 3 | 4 | 5 | repositories { 6 | mavenCentral() 7 | 8 | jcenter() 9 | } 10 | dependencies { 11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 12 | classpath 'com.github.jengelman.gradle.plugins:shadow:5.0.0' 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | mavenCentral() 18 | mavenLocal() 19 | jcenter() 20 | } 21 | } 22 | } 23 | 24 | 25 | plugins { 26 | id 'org.jetbrains.kotlin.jvm' version '1.5.10' 27 | id 'com.gradle.plugin-publish' version '0.10.1' 28 | } 29 | apply plugin: "java-gradle-plugin" 30 | apply plugin: "kotlin-kapt" 31 | apply plugin: "maven" 32 | 33 | 34 | group = "de.jensklingenberg" 35 | archivesBaseName = "mpapt-gradle" 36 | version = "1.0.0" 37 | 38 | 39 | 40 | install { 41 | repositories.mavenInstaller { 42 | pom.artifactId = archivesBaseName 43 | } 44 | } 45 | 46 | gradlePlugin { 47 | plugins { 48 | simplePlugin { 49 | id = "de.jensklingenberg.mpapt" // users will do `apply plugin: "de.jensklingenberg.mpapt"` 50 | implementationClass = "de.jensklingenberg.mpapt.MpAptGradleSubPlugin" // entry-point class 51 | } 52 | } 53 | } 54 | 55 | dependencies { 56 | compile "org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.5.10" 57 | compileOnly "com.google.auto.service:auto-service:1.0" 58 | kapt "com.google.auto.service:auto-service:1.0" 59 | } 60 | 61 | 62 | build { 63 | dependsOn install 64 | } 65 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/de/jensklingenberg/mpapt/MpAptGradleSubPlugin.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt 2 | 3 | import org.gradle.api.provider.Provider 4 | import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation 5 | import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerPluginSupportPlugin 6 | import org.jetbrains.kotlin.gradle.plugin.SubpluginArtifact 7 | import org.jetbrains.kotlin.gradle.plugin.SubpluginOption 8 | 9 | class MpAptGradleSubPlugin : KotlinCompilerPluginSupportPlugin { 10 | 11 | companion object { 12 | const val SERIALIZATION_GROUP_NAME = "de.jensklingenberg" 13 | const val ARTIFACT_NAME = "kotlin-compiler-plugin" 14 | const val NATIVE_ARTIFACT_NAME = "kotlin-compiler-native-plugin" 15 | } 16 | 17 | override fun applyToCompilation(kotlinCompilation: KotlinCompilation<*>): Provider> { 18 | val project = kotlinCompilation.target.project 19 | 20 | return project.provider { 21 | val options = mutableListOf() 22 | options 23 | } 24 | } 25 | 26 | 27 | /** 28 | * Just needs to be consistent with the key for CommandLineProcessor#pluginId 29 | */ 30 | override fun getCompilerPluginId(): String = "MpAptPlugin" 31 | 32 | override fun getPluginArtifact(): SubpluginArtifact = SubpluginArtifact( 33 | groupId = SERIALIZATION_GROUP_NAME, 34 | artifactId =ARTIFACT_NAME, 35 | version = "0.0.1" // remember to bump this version before any release! 36 | ) 37 | 38 | override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean { 39 | return true 40 | } 41 | 42 | override fun getPluginArtifactForNative() = SubpluginArtifact( 43 | groupId = SERIALIZATION_GROUP_NAME, 44 | artifactId = NATIVE_ARTIFACT_NAME, 45 | version = "0.0.1" // remember to bump this version before any release! 46 | ) 47 | } 48 | -------------------------------------------------------------------------------- /demoProject/.gitignore: -------------------------------------------------------------------------------- 1 | /ktorfit-shared/build/ 2 | /example/build/ 3 | /buildSrc/.gradle/ 4 | /.idea/ 5 | /buildSrc/build/ 6 | /ktorfit-compiler/build/ 7 | /.gradle/ 8 | /ktorfit-annotations/build/ 9 | -------------------------------------------------------------------------------- /demoProject/Contact.md: -------------------------------------------------------------------------------- 1 | Created by Jens Klingenberg 2 | * www.jensklingenberg.de 3 | 4 | 5 | Contact: 6 | * Mail: mail@jensklingenberg.de 7 | * Twitter: [@jklingenberg_](https://twitter.com/jklingenberg_) -------------------------------------------------------------------------------- /demoProject/README.md: -------------------------------------------------------------------------------- 1 | This is a (POC) demo project. 2 | It shows how to use MpApt with Kotlin Poet. 3 | 4 | How to build: 5 | Inside the project folder run: 6 | * ./gradlew :ktorfit-annotations:publishToMavenLocal 7 | * ./gradlew :ktorfit-compiler:build 8 | 9 | I haven't added the MacOS targets for the annotations module. You need to add the target in build.gradle if you want to build them. 10 | 11 | In jsMain is a Api interface 12 | ```kotlin 13 | interface Api { 14 | @GET("users/{value}") 15 | suspend fun getName(value: String): String 16 | 17 | @GET("users/Foso/image") 18 | suspend fun loadImage(): String 19 | 20 | @GET("users/Foso/images") 21 | suspend fun loadPictures(): Int 22 | } 23 | 24 | ``` 25 | 26 | If you run build, the compiler plugin will generate a Ktor Client inside KtorfitApi class: 27 | 28 | ```kotlin 29 | class KtorfitApi( 30 | val baseUrl: String 31 | ) : Api { 32 | val client: HttpClient = HttpClient() 33 | 34 | override suspend fun getName(value: String): kotlin.String = client.get(baseUrl+"users/{value}") 35 | 36 | override suspend fun loadImage(): kotlin.String = client.get(baseUrl+"users/Foso/image") 37 | 38 | override suspend fun loadPictures(): kotlin.Int = client.get(baseUrl+"users/Foso/images") 39 | 40 | fun create(): Api = this 41 | } 42 | 43 | 44 | ``` -------------------------------------------------------------------------------- /demoProject/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | //./gradlew :example:clean :example:build --no-daemon -Dorg.gradle.debug=true -Dkotlin.compiler.execution.strategy="in-process" -Dkotlin.daemon.jvm.options="-Xdebug,-Xrunjdwp:transport=dt_socket\,address=5005\,server=y\,suspend=n" -------------------------------------------------------------------------------- /demoProject/buildSrc/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.5.10' 3 | 4 | 5 | repositories { 6 | mavenCentral() 7 | 8 | jcenter() 9 | } 10 | dependencies { 11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 12 | classpath 'com.github.jengelman.gradle.plugins:shadow:5.0.0' 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | mavenCentral() 18 | mavenLocal() 19 | jcenter() 20 | } 21 | } 22 | } 23 | 24 | 25 | plugins { 26 | id 'org.jetbrains.kotlin.jvm' version '1.5.10' 27 | } 28 | apply plugin: "java-gradle-plugin" 29 | apply plugin: "kotlin-kapt" 30 | apply plugin: "maven" 31 | 32 | 33 | group = "de.jensklingenberg" 34 | archivesBaseName = "ktorfit" 35 | version = "1.0.0" 36 | 37 | 38 | 39 | install { 40 | repositories.mavenInstaller { 41 | pom.artifactId = archivesBaseName 42 | } 43 | } 44 | 45 | gradlePlugin { 46 | plugins { 47 | simplePlugin { 48 | id = "de.jensklingenberg.ktorfit" // users will do `apply plugin: "de.jensklingenberg.mpapt"` 49 | implementationClass = "de.jensklingenberg.mpapt.MpAptGradlePlugin" // entry-point class 50 | } 51 | } 52 | } 53 | 54 | dependencies { 55 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" 56 | compile "org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.5.10" 57 | compileOnly "com.google.auto.service:auto-service:1.0-rc7" 58 | kapt "com.google.auto.service:auto-service:1.0" 59 | } 60 | 61 | 62 | build { 63 | dependsOn install 64 | } 65 | -------------------------------------------------------------------------------- /demoProject/buildSrc/src/main/kotlin/de/jensklingenberg/mpapt/MpAptGradlePlugin.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt 2 | 3 | import org.gradle.api.Project 4 | 5 | open class MpAptGradlePlugin : org.gradle.api.Plugin { 6 | override fun apply(project: Project) { 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /demoProject/buildSrc/src/main/kotlin/de/jensklingenberg/mpapt/MpAptGradleSubplugin.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt 2 | 3 | import com.google.auto.service.AutoService 4 | import org.gradle.api.Project 5 | import org.gradle.api.tasks.compile.AbstractCompile 6 | import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions 7 | import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation 8 | import org.jetbrains.kotlin.gradle.plugin.KotlinGradleSubplugin 9 | import org.jetbrains.kotlin.gradle.plugin.SubpluginArtifact 10 | import org.jetbrains.kotlin.gradle.plugin.SubpluginOption 11 | 12 | @AutoService(KotlinGradleSubplugin::class) // don't forget! 13 | class MpAptGradleSubplugin : KotlinGradleSubplugin { 14 | override fun apply( 15 | project: Project, 16 | kotlinCompile: AbstractCompile, 17 | javaCompile: AbstractCompile?, 18 | variantData: Any?, 19 | androidProjectHandler: Any?, 20 | kotlinCompilation: KotlinCompilation? 21 | ): List { 22 | return emptyList() 23 | 24 | } 25 | 26 | override fun isApplicable(project: Project, task: AbstractCompile) = 27 | project.plugins.hasPlugin(MpAptGradlePlugin::class.java) 28 | 29 | 30 | /** 31 | * Just needs to be consistent with the key for CommandLineProcessor#pluginId 32 | */ 33 | override fun getCompilerPluginId(): String = "MpAptPlugin" 34 | 35 | override fun getPluginArtifact(): SubpluginArtifact = SubpluginArtifact( 36 | groupId = "de.jensklingenberg", 37 | artifactId = "ktorfit-compiler", 38 | version = "0.0.1" // remember to bump this version before any release! 39 | ) 40 | 41 | } 42 | -------------------------------------------------------------------------------- /demoProject/example/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | 3 | ext.buildMaven = { p -> repositories { maven { url p } } } 4 | 5 | 6 | repositories { 7 | mavenLocal() 8 | google() 9 | jcenter() 10 | mavenCentral() 11 | } 12 | 13 | dependencies { 14 | classpath "de.jensklingenberg:ktorfit:1.0.0" 15 | 16 | } 17 | 18 | } 19 | plugins { 20 | id 'org.jetbrains.kotlin.multiplatform' version '1.5.10' 21 | } 22 | 23 | 24 | System.setProperty("kotlin.compiler.execution.strategy", "in-process") // For debugging 25 | 26 | allprojects { 27 | repositories { 28 | mavenLocal() 29 | mavenCentral() 30 | google() 31 | 32 | maven { url "https://maven.google.com" } 33 | maven { url "https://plugins.gradle.org/m2/" } 34 | } 35 | } 36 | 37 | 38 | apply plugin: 'de.jensklingenberg.ktorfit' 39 | 40 | 41 | 42 | 43 | allprojects { 44 | ext.buildMaven = { p -> repositories { maven { url p } } } 45 | 46 | repositories { 47 | mavenLocal() 48 | mavenCentral() 49 | maven { url "https://maven.google.com" } 50 | maven { url "https://plugins.gradle.org/m2/" } 51 | google() 52 | jcenter() 53 | 54 | 55 | } 56 | } 57 | 58 | 59 | kotlin { 60 | 61 | js() { 62 | configure([compilations.main]) { 63 | tasks.getByName(compileKotlinTaskName).kotlinOptions { 64 | sourceMap = true 65 | 66 | moduleKind = "commonjs" 67 | metaInfo = true 68 | outputFile = "${project.buildDir.path}/js/${project.name}.js" 69 | main = "call" 70 | } 71 | } 72 | } 73 | sourceSets { 74 | commonMain { 75 | dependencies { 76 | implementation kotlin('stdlib-common') 77 | implementation "io.ktor:ktor-client-core:1.2.3" 78 | implementation project(":ktorfit-annotations") 79 | 80 | } 81 | } 82 | commonTest { 83 | dependencies { 84 | implementation kotlin('test-common') 85 | 86 | } 87 | } 88 | 89 | jsMain { 90 | dependencies { 91 | implementation kotlin('stdlib-js') 92 | implementation "io.ktor:ktor-client-js:1.2.3" 93 | 94 | } 95 | } 96 | jsTest { 97 | dependencies { 98 | implementation kotlin('test-js') 99 | } 100 | } 101 | 102 | 103 | 104 | } 105 | } 106 | 107 | 108 | build{ 109 | dependsOn ':ktorfit-annotations:publishToMavenLocal' 110 | } 111 | 112 | // workaround for https://youtrack.jetbrains.com/issue/KT-27170 113 | configurations { 114 | compileClasspath 115 | } -------------------------------------------------------------------------------- /demoProject/example/src/jsMain/kotlin/de/jensklingenberg/ktorfit/Api.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.ktorfit 2 | 3 | import de.jensklingenberg.ktofitAnnotations.GET 4 | 5 | interface Api { 6 | @GET("users/{value}") 7 | suspend fun getName(value: String): String 8 | 9 | @GET("users/Foso/image") 10 | suspend fun loadImage(): String 11 | 12 | @GET("users/Foso/images") 13 | suspend fun loadPictures(): Int 14 | } -------------------------------------------------------------------------------- /demoProject/example/src/jsMain/kotlin/de/jensklingenberg/ktorfit/Start.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.ktorfit 2 | 3 | import kotlinx.coroutines.GlobalScope 4 | import kotlinx.coroutines.launch 5 | 6 | fun main() { 7 | 8 | } -------------------------------------------------------------------------------- /demoProject/gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.incremental=false 2 | org.gradle.daemon=false 3 | org.gradle.parallel=false 4 | org.gradle.configureondemand=false 5 | kotlin.compiler.execution.strategy=in-process 6 | kotlin.daemon.debug.log=true 7 | org.gradle.jvmargs=-Xmx6g -XX:MaxPermSize=1024m 8 | //kotlin.native.jvmArgs=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5006 9 | gnsp.disableApplyOnlyOnRootProjectEnforcement 10 | 11 | SONATYPE_NEXUS_USERNAME= 12 | SONATYPE_NEXUS_PASSWORD= 13 | nexusUsername= 14 | nexusPassword= 15 | signing.keyId= 16 | signing.password= 17 | signing.secretKeyRingFile= 18 | -------------------------------------------------------------------------------- /demoProject/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Foso/MpApt/f1f3edee8c0ee2c56ea24869c1a66d3ae0854bd0/demoProject/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /demoProject/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Aug 25 15:26:06 CEST 2019 2 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip 3 | distributionBase=GRADLE_USER_HOME 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /demoProject/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin, switch paths to Windows format before running java 129 | if $cygwin ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=$((i+1)) 158 | done 159 | case $i in 160 | (0) set -- ;; 161 | (1) set -- "$args0" ;; 162 | (2) set -- "$args0" "$args1" ;; 163 | (3) set -- "$args0" "$args1" "$args2" ;; 164 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=$(save "$@") 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 184 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 185 | cd "$(dirname "$0")" 186 | fi 187 | 188 | exec "$JAVACMD" "$@" 189 | -------------------------------------------------------------------------------- /demoProject/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 34 | 35 | @rem Find java.exe 36 | if defined JAVA_HOME goto findJavaFromJavaHome 37 | 38 | set JAVA_EXE=java.exe 39 | %JAVA_EXE% -version >NUL 2>&1 40 | if "%ERRORLEVEL%" == "0" goto init 41 | 42 | echo. 43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 44 | echo. 45 | echo Please set the JAVA_HOME variable in your environment to match the 46 | echo location of your Java installation. 47 | 48 | goto fail 49 | 50 | :findJavaFromJavaHome 51 | set JAVA_HOME=%JAVA_HOME:"=% 52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 53 | 54 | if exist "%JAVA_EXE%" goto init 55 | 56 | echo. 57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 58 | echo. 59 | echo Please set the JAVA_HOME variable in your environment to match the 60 | echo location of your Java installation. 61 | 62 | goto fail 63 | 64 | :init 65 | @rem Get command-line arguments, handling Windows variants 66 | 67 | if not "%OS%" == "Windows_NT" goto win9xME_args 68 | 69 | :win9xME_args 70 | @rem Slurp the command line arguments. 71 | set CMD_LINE_ARGS= 72 | set _SKIP=2 73 | 74 | :win9xME_args_slurp 75 | if "x%~1" == "x" goto execute 76 | 77 | set CMD_LINE_ARGS=%* 78 | 79 | :execute 80 | @rem Setup the command line 81 | 82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 83 | 84 | @rem Execute Gradle 85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 86 | 87 | :end 88 | @rem End local scope for the variables with windows NT shell 89 | if "%ERRORLEVEL%"=="0" goto mainEnd 90 | 91 | :fail 92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 93 | rem the _cmd.exe /c_ return code! 94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 95 | exit /b 1 96 | 97 | :mainEnd 98 | if "%OS%"=="Windows_NT" endlocal 99 | 100 | :omega 101 | -------------------------------------------------------------------------------- /demoProject/ktorfit-annotations/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | 3 | ext.buildMaven = { p -> repositories { maven { url p } } } 4 | 5 | 6 | repositories { 7 | mavenLocal() 8 | google() 9 | jcenter() 10 | mavenCentral() 11 | } 12 | 13 | dependencies { 14 | } 15 | 16 | } 17 | 18 | plugins { 19 | id 'org.jetbrains.kotlin.multiplatform' version '1.5.10' 20 | id "maven" 21 | id("maven-publish") 22 | 23 | } 24 | 25 | group = "de.jensklingenberg.ktorfit" 26 | 27 | version = "0.0.1" 28 | 29 | 30 | repositories { 31 | mavenCentral() 32 | } 33 | 34 | kotlin { 35 | jvm() 36 | js() 37 | linuxX64("linux") 38 | 39 | sourceSets { 40 | commonMain { 41 | dependencies { 42 | implementation kotlin('stdlib-common') 43 | 44 | } 45 | } 46 | commonTest { 47 | dependencies { 48 | implementation kotlin('test-common') 49 | implementation kotlin('test-annotations-common') 50 | } 51 | } 52 | 53 | jsMain { 54 | dependencies { 55 | implementation kotlin('stdlib-js') 56 | 57 | } 58 | } 59 | jsTest { 60 | dependencies { 61 | implementation kotlin('test-js') 62 | } 63 | } 64 | 65 | jvmMain { 66 | dependencies { 67 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" 68 | } 69 | } 70 | jsTest { 71 | dependencies { 72 | implementation kotlin('test-js') 73 | } 74 | } 75 | 76 | } 77 | } 78 | 79 | 80 | 81 | 82 | build.finalizedBy(publishToMavenLocal) -------------------------------------------------------------------------------- /demoProject/ktorfit-annotations/src/commonMain/kotlin/de/jensklingenberg/ktofitAnnotations/Annotations.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.ktofitAnnotations 2 | 3 | @Target(AnnotationTarget.FUNCTION) 4 | annotation class GET(val url: String) 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /demoProject/ktorfit-compiler/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.5.10' 3 | 4 | 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 10 | classpath 'com.github.jengelman.gradle.plugins:shadow:5.0.0' 11 | } 12 | 13 | allprojects { 14 | repositories { 15 | mavenLocal() 16 | jcenter() 17 | } 18 | } 19 | } 20 | 21 | 22 | 23 | apply plugin: "org.jetbrains.kotlin.jvm" 24 | apply plugin: "kotlin-kapt" 25 | apply plugin: "maven" 26 | 27 | 28 | group = "de.jensklingenberg" 29 | archivesBaseName = "ktorfit-compiler" 30 | version = "0.0.1" 31 | 32 | install { 33 | repositories.mavenInstaller { 34 | pom.artifactId = archivesBaseName 35 | } 36 | } 37 | 38 | repositories { 39 | mavenCentral() 40 | mavenLocal() 41 | jcenter() 42 | } 43 | 44 | dependencies { 45 | compile project(':ktorfit-shared') 46 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" 47 | compileOnly "org.jetbrains.kotlin:kotlin-compiler-embeddable" 48 | compileOnly "com.google.auto.service:auto-service:1.0" 49 | kapt "com.google.auto.service:auto-service:1.0" 50 | } 51 | 52 | build{ 53 | dependsOn ':ktorfit-shared:install' 54 | 55 | finalizedBy(install) 56 | } 57 | 58 | kapt { 59 | includeCompileClasspath = true 60 | } 61 | -------------------------------------------------------------------------------- /demoProject/ktorfit-compiler/src/main/java/de/jensklingenberg/CommonComponentRegistrar.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg 2 | 3 | import com.google.auto.service.AutoService 4 | import de.jensklingenberg.mpapt.common.MpAptProject 5 | import org.jetbrains.kotlin.codegen.extensions.ClassBuilderInterceptorExtension 6 | import org.jetbrains.kotlin.com.intellij.mock.MockProject 7 | import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar 8 | import org.jetbrains.kotlin.config.CompilerConfiguration 9 | import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor 10 | import org.jetbrains.kotlin.js.translate.extensions.JsSyntheticTranslateExtension 11 | import org.jetbrains.kotlin.resolve.extensions.SyntheticResolveExtension 12 | 13 | /** 14 | * This is the entry class for a compiler plugin 15 | */ 16 | @AutoService(ComponentRegistrar::class) 17 | open class CommonComponentRegistrar : ComponentRegistrar { 18 | 19 | override fun registerProjectComponents( 20 | project: MockProject, 21 | configuration: CompilerConfiguration 22 | ) { 23 | val processor = MpAptTestProcessor() 24 | val mpapt = MpAptProject(processor,configuration) 25 | StorageComponentContainerContributor.registerExtension(project,mpapt) 26 | ClassBuilderInterceptorExtension.registerExtension(project,mpapt) 27 | JsSyntheticTranslateExtension.registerExtension(project,mpapt) 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /demoProject/ktorfit-shared/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.5.10' 3 | 4 | 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 10 | classpath 'com.github.jengelman.gradle.plugins:shadow:5.0.0' 11 | } 12 | 13 | allprojects { 14 | repositories { 15 | 16 | } 17 | } 18 | } 19 | 20 | 21 | 22 | apply plugin: "org.jetbrains.kotlin.jvm" 23 | apply plugin: "kotlin-kapt" 24 | apply plugin: "maven" 25 | 26 | 27 | group = "de.jensklingenberg" 28 | archivesBaseName = "ktorfit-shared" 29 | version = "0.0.1" 30 | 31 | install { 32 | 33 | repositories.mavenInstaller { 34 | pom.artifactId = archivesBaseName 35 | } 36 | } 37 | 38 | repositories { 39 | mavenLocal() 40 | mavenCentral() 41 | } 42 | 43 | dependencies { 44 | implementation 'com.squareup:kotlinpoet:1.3.0' 45 | compile 'de.jensklingenberg:mpapt-runtime:0.8.8' 46 | compile "de.jensklingenberg.ktorfit:ktorfit-annotations-jvm:0.0.1" 47 | compileOnly "org.jetbrains.kotlin:kotlin-compiler-embeddable" 48 | compileOnly "com.google.auto.service:auto-service:1.0" 49 | kapt "com.google.auto.service:auto-service:1.0" 50 | } 51 | 52 | 53 | kapt { 54 | includeCompileClasspath = true 55 | } 56 | -------------------------------------------------------------------------------- /demoProject/ktorfit-shared/src/main/java/de/jensklingenberg/MpAptTestProcessor.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg 2 | 3 | 4 | import com.squareup.kotlinpoet.* 5 | import de.jensklingenberg.ktofitAnnotations.GET 6 | import de.jensklingenberg.mpapt.common.* 7 | import de.jensklingenberg.mpapt.model.AbstractProcessor 8 | import de.jensklingenberg.mpapt.model.Element 9 | import de.jensklingenberg.mpapt.model.RoundEnvironment 10 | import de.jensklingenberg.mpapt.utils.KonanTargetValues 11 | import de.jensklingenberg.mpapt.utils.KotlinPlatformValues 12 | import org.jetbrains.kotlin.config.CompilerConfiguration 13 | import org.jetbrains.kotlin.descriptors.ClassDescriptor 14 | import org.jetbrains.kotlin.descriptors.FunctionDescriptor 15 | import org.jetbrains.kotlin.platform.TargetPlatform 16 | import org.jetbrains.kotlin.resolve.annotations.argumentValue 17 | import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe 18 | import java.io.File 19 | 20 | class MpAptTestProcessor() : AbstractProcessor() { 21 | val TAG = "MyAnnotationProcessor" 22 | 23 | val get = GET::class.java.name 24 | val getFunctions = mutableListOf() 25 | 26 | override fun process(roundEnvironment: RoundEnvironment) { 27 | 28 | roundEnvironment.getElementsAnnotatedWith(get).forEach { element -> 29 | when (element) { 30 | is Element.FunctionElement -> { 31 | getFunctions.add(element.func) 32 | } 33 | } 34 | } 35 | 36 | 37 | } 38 | 39 | override fun isTargetPlatformSupported(platform: TargetPlatform): Boolean { 40 | val targetName = platform.first().platformName 41 | 42 | return when (targetName) { 43 | KotlinPlatformValues.JS -> true 44 | KotlinPlatformValues.JVM -> false 45 | KotlinPlatformValues.NATIVE -> { 46 | return when (configuration.nativeTargetPlatformName()) { 47 | KonanTargetValues.LINUX_X64,KonanTargetValues.MACOS_X64 -> { 48 | false 49 | } 50 | else->{ 51 | false 52 | } 53 | } 54 | } 55 | else -> { 56 | log(targetName) 57 | false 58 | } 59 | } 60 | 61 | } 62 | 63 | override fun getSupportedAnnotationTypes(): Set = setOf(get) 64 | 65 | override fun processingOver() { 66 | log("$TAG***Processor over ***") 67 | 68 | val getFunSpecs = getFunctions 69 | .map { function -> 70 | FunSpec.builder(function.simpleName()).apply { 71 | when (function.isSuspend) { 72 | true -> addModifiers(KModifier.SUSPEND) 73 | } 74 | } 75 | .addModifiers(KModifier.OVERRIDE) 76 | .addParameters( 77 | function.getFunctionParameters().map { 78 | ParameterSpec.builder( 79 | it.parameterName, 80 | ClassName(it.packagee.packagename, it.packagee.classname) 81 | ).build() 82 | } 83 | 84 | ) 85 | .returns(ClassName("", function.getReturnTypeImport().toString())) 86 | .addStatement("return client.get(baseUrl+${function.annotations.first().argumentValue("url")})") 87 | .build() 88 | } 89 | 90 | 91 | val file = FileSpec.builder(getFunctions.first().containingDeclaration.containingDeclaration?.fqNameSafe?.asString() 92 | ?: "", "KtorfitApi") 93 | .addComment("GENERATED by KtorFit") 94 | .apply { 95 | if (getFunctions.isNotEmpty()) { 96 | addImport("io.ktor.client.request.get", "") 97 | } 98 | } 99 | .addType( 100 | TypeSpec.classBuilder(ClassName(getFunctions.first().containingDeclaration.containingDeclaration?.fqNameSafe?.asString() 101 | ?: "", "KtorfitApi")) 102 | .primaryConstructor(FunSpec.constructorBuilder() 103 | .addParameter("baseUrl", String::class) 104 | .build()) 105 | .addProperty(PropertySpec.builder("client", ClassName("io.ktor.client", "HttpClient")).initializer("HttpClient()").build()) 106 | .addProperty(PropertySpec.builder("baseUrl", String::class).initializer("baseUrl").build()) 107 | 108 | .addSuperinterface( 109 | ClassName( 110 | getFunctions.first().containingDeclaration.containingDeclaration?.fqNameSafe?.asString() 111 | ?: "", 112 | "Api" 113 | ) 114 | ) 115 | .addFunctions(getFunSpecs) 116 | 117 | .addFunction( 118 | FunSpec.builder("create") 119 | .addCode( 120 | """ 121 | |return this 122 | |""".trimMargin() 123 | 124 | 125 | ).returns(ClassName("", "Api")).build() 126 | ) 127 | 128 | 129 | // .addFunctions(postFuncs) 130 | .build() 131 | ) 132 | 133 | 134 | .build() 135 | val filepath = (getFunctions.first().containingDeclaration as ClassDescriptor).guessingSourceSetFolder() 136 | file.writeTo(File(filepath)) 137 | 138 | 139 | } 140 | 141 | } 142 | -------------------------------------------------------------------------------- /demoProject/settings.gradle: -------------------------------------------------------------------------------- 1 | include 'example' 2 | include ':ktorfit-compiler' 3 | include ':ktorfit-shared' 4 | include 'ktorfit-annotations' -------------------------------------------------------------------------------- /docs/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | v0.8.8 2 | ======================================== 3 | Update to Kotlin 1.5.10, same api as 0.8.6 4 | 5 | v0.8.7 6 | ======================================== 7 | Update to Kotlin 1.4.0, same api as 0.8.6 8 | 9 | v0.8.6 10 | ======================================== 11 | * Fixed that processing of file annotation on native targets was called too often 12 | 13 | v0.8.5 14 | ======================================== 15 | 16 | Fix method signature of overridden abstract method 17 | 18 | v0.8.4 19 | ======================================== 20 | 21 | * Build with Kotlin 1.3.71 22 | 23 | * Fixed bug that produced a crash when annotating functions with expression body like 24 | "fun functionWithExpressionBody() = 1 + 1" on Native (thx to @chippmann) 25 | 26 | 27 | * Removed SyntheticResolveExtensionImpl, you don't need add: 28 | SyntheticResolveExtension.registerExtension(project, mpapt) anymore 29 | 30 | 31 | v0.8.3 32 | ======================================== 33 | * You can now detect annotated expressions in functions 34 | 35 | * Added util method "printMessage()" 36 | Added an extension function to the MessageCollector that can be used to print text or raise compiler errors. 37 | 38 | Inside your processor, you can use it like that: 39 | ```kotlin 40 | configuration.messager().printMessage(DiagnosticKind.ERROR,"My error message", CompilerMessageLocation.Companion.create("/home/jens/Code/2019/MpApt/kotlin-plugin-shared/src/main/java/de/jensklingenberg/MpAptTestProcessor.kt",42,106)) 41 | ``` 42 | 43 | This will print the message to the log and stop the compiler: 44 | ```kotlin 45 | e: /home/jens/Code/2019/MpApt/kotlin-plugin-shared/src/main/java/de/jensklingenberg/MpAptTestProcessor.kt: (42, 106): My error message 46 | 47 | ``` 48 | 49 | v0.8.2 50 | ======================================== 51 | fixed that processingOver was called to often 52 | You can now detect annotation with Target (ANNOTATION_CLASS,TYPE_PARAMETER,FIELD,FILE,LocalVariable) 53 | 54 | v0.8.1 55 | 56 | ======================================== 57 | 58 | You can now distinguish between which native target platforms you want to support. 59 | Before processing the isTargetPlatformSupported(platform: TargetPlatform) will be called and you can return true if you want to enable your processor for this target or false if you don't. By default this methods returns true 60 | 61 | configuration.nativeTargetPlatformName() will get you the names of the Native Targets(macos_x64,linux_x64,etc) the values are defined in KonanTargetValues. 62 | It needs to be used only on Kotlin Native otherwise it will return an empty string 63 | 64 | Example: 65 | ```kotlin 66 | override fun isTargetPlatformSupported(platform: TargetPlatform): Boolean { 67 | val targetName = platform.first().platformName 68 | 69 | return when (targetName) { 70 | KotlinPlatformValues.JS -> false 71 | KotlinPlatformValues.JVM -> true 72 | KotlinPlatformValues.NATIVE -> { 73 | return when (configuration.nativeTargetPlatformName()) { 74 | KonanTargetValues.LINUX_X64,KonanTargetValues.MACOS_X64 -> { 75 | false 76 | } 77 | else->{ 78 | false 79 | } 80 | } 81 | } 82 | else -> { 83 | log(targetName) 84 | false 85 | } 86 | } 87 | 88 | } 89 | 90 | ``` 91 | 92 | 93 | 94 | ======================================== 95 | 96 | Changed the initialization of the library. 97 | 98 | Now you need to add the compiler configuration to the MpAptProject 99 | 100 | ```kotlin 101 | val processor = MpAptTestProcessor() 102 | val mpapt = MpAptProject(processor,configuration) 103 | ``` 104 | -------------------------------------------------------------------------------- /docs/assets/fonts/material-icons.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 3 | * use this file except in compliance with the License. You may obtain a copy 4 | * of the License at: 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, SOFTWARE 9 | * DISTRIBUTED UNDER THE LICENSE IS DISTRIBUTED ON AN "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 11 | * SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING PERMISSIONS AND 12 | * LIMITATIONS UNDER THE LICENSE. 13 | */@font-face{font-family:"Material Icons";font-style:normal;font-weight:400;src:local("Material Icons"),local("MaterialIcons-Regular"),url("specimen/MaterialIcons-Regular.woff2") format("woff2"),url("specimen/MaterialIcons-Regular.woff") format("woff"),url("specimen/MaterialIcons-Regular.ttf") format("truetype")} -------------------------------------------------------------------------------- /docs/assets/fonts/specimen/FontAwesome.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Foso/MpApt/f1f3edee8c0ee2c56ea24869c1a66d3ae0854bd0/docs/assets/fonts/specimen/FontAwesome.ttf -------------------------------------------------------------------------------- /docs/assets/fonts/specimen/FontAwesome.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Foso/MpApt/f1f3edee8c0ee2c56ea24869c1a66d3ae0854bd0/docs/assets/fonts/specimen/FontAwesome.woff -------------------------------------------------------------------------------- /docs/assets/fonts/specimen/FontAwesome.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Foso/MpApt/f1f3edee8c0ee2c56ea24869c1a66d3ae0854bd0/docs/assets/fonts/specimen/FontAwesome.woff2 -------------------------------------------------------------------------------- /docs/assets/fonts/specimen/MaterialIcons-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Foso/MpApt/f1f3edee8c0ee2c56ea24869c1a66d3ae0854bd0/docs/assets/fonts/specimen/MaterialIcons-Regular.ttf -------------------------------------------------------------------------------- /docs/assets/fonts/specimen/MaterialIcons-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Foso/MpApt/f1f3edee8c0ee2c56ea24869c1a66d3ae0854bd0/docs/assets/fonts/specimen/MaterialIcons-Regular.woff -------------------------------------------------------------------------------- /docs/assets/fonts/specimen/MaterialIcons-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Foso/MpApt/f1f3edee8c0ee2c56ea24869c1a66d3ae0854bd0/docs/assets/fonts/specimen/MaterialIcons-Regular.woff2 -------------------------------------------------------------------------------- /docs/assets/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Foso/MpApt/f1f3edee8c0ee2c56ea24869c1a66d3ae0854bd0/docs/assets/images/favicon.png -------------------------------------------------------------------------------- /docs/assets/images/icons/bitbucket.1b09e088.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/assets/images/icons/github.f0b8504a.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/assets/images/icons/gitlab.6dd19c00.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/assets/javascripts/lunr/lunr.da.js: -------------------------------------------------------------------------------- 1 | !function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var r,m,i;e.da=function(){this.pipeline.reset(),this.pipeline.add(e.da.trimmer,e.da.stopWordFilter,e.da.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.da.stemmer))},e.da.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.da.trimmer=e.trimmerSupport.generateTrimmer(e.da.wordCharacters),e.Pipeline.registerFunction(e.da.trimmer,"trimmer-da"),e.da.stemmer=(r=e.stemmerSupport.Among,m=e.stemmerSupport.SnowballProgram,i=new function(){var i,t,n,s=[new r("hed",-1,1),new r("ethed",0,1),new r("ered",-1,1),new r("e",-1,1),new r("erede",3,1),new r("ende",3,1),new r("erende",5,1),new r("ene",3,1),new r("erne",3,1),new r("ere",3,1),new r("en",-1,1),new r("heden",10,1),new r("eren",10,1),new r("er",-1,1),new r("heder",13,1),new r("erer",13,1),new r("s",-1,2),new r("heds",16,1),new r("es",16,1),new r("endes",18,1),new r("erendes",19,1),new r("enes",18,1),new r("ernes",18,1),new r("eres",18,1),new r("ens",16,1),new r("hedens",24,1),new r("erens",24,1),new r("ers",16,1),new r("ets",16,1),new r("erets",28,1),new r("et",-1,1),new r("eret",30,1)],o=[new r("gd",-1,-1),new r("dt",-1,-1),new r("gt",-1,-1),new r("kt",-1,-1)],a=[new r("ig",-1,1),new r("lig",0,1),new r("elig",1,1),new r("els",-1,1),new r("løst",-1,2)],d=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,48,0,128],u=[239,254,42,3,0,0,0,0,0,0,0,0,0,0,0,0,16],c=new m;function l(){var e,r=c.limit-c.cursor;c.cursor>=t&&(e=c.limit_backward,c.limit_backward=t,c.ket=c.cursor,c.find_among_b(o,4)?(c.bra=c.cursor,c.limit_backward=e,c.cursor=c.limit-r,c.cursor>c.limit_backward&&(c.cursor--,c.bra=c.cursor,c.slice_del())):c.limit_backward=e)}this.setCurrent=function(e){c.setCurrent(e)},this.getCurrent=function(){return c.getCurrent()},this.stem=function(){var e,r=c.cursor;return function(){var e,r=c.cursor+3;if(t=c.limit,0<=r&&r<=c.limit){for(i=r;;){if(e=c.cursor,c.in_grouping(d,97,248)){c.cursor=e;break}if((c.cursor=e)>=c.limit)return;c.cursor++}for(;!c.out_grouping(d,97,248);){if(c.cursor>=c.limit)return;c.cursor++}(t=c.cursor)=t&&(r=c.limit_backward,c.limit_backward=t,c.ket=c.cursor,e=c.find_among_b(s,32),c.limit_backward=r,e))switch(c.bra=c.cursor,e){case 1:c.slice_del();break;case 2:c.in_grouping_b(u,97,229)&&c.slice_del()}}(),c.cursor=c.limit,l(),c.cursor=c.limit,function(){var e,r,i,n=c.limit-c.cursor;if(c.ket=c.cursor,c.eq_s_b(2,"st")&&(c.bra=c.cursor,c.eq_s_b(2,"ig")&&c.slice_del()),c.cursor=c.limit-n,c.cursor>=t&&(r=c.limit_backward,c.limit_backward=t,c.ket=c.cursor,e=c.find_among_b(a,5),c.limit_backward=r,e))switch(c.bra=c.cursor,e){case 1:c.slice_del(),i=c.limit-c.cursor,l(),c.cursor=c.limit-i;break;case 2:c.slice_from("løs")}}(),c.cursor=c.limit,c.cursor>=t&&(e=c.limit_backward,c.limit_backward=t,c.ket=c.cursor,c.out_grouping_b(d,97,248)?(c.bra=c.cursor,n=c.slice_to(n),c.limit_backward=e,c.eq_v_b(n)&&c.slice_del()):c.limit_backward=e),!0}},function(e){return"function"==typeof e.update?e.update(function(e){return i.setCurrent(e),i.stem(),i.getCurrent()}):(i.setCurrent(e),i.stem(),i.getCurrent())}),e.Pipeline.registerFunction(e.da.stemmer,"stemmer-da"),e.da.stopWordFilter=e.generateStopWordFilter("ad af alle alt anden at blev blive bliver da de dem den denne der deres det dette dig din disse dog du efter eller en end er et for fra ham han hans har havde have hende hendes her hos hun hvad hvis hvor i ikke ind jeg jer jo kunne man mange med meget men mig min mine mit mod ned noget nogle nu når og også om op os over på selv sig sin sine sit skal skulle som sådan thi til ud under var vi vil ville vor være været".split(" ")),e.Pipeline.registerFunction(e.da.stopWordFilter,"stopWordFilter-da")}}); -------------------------------------------------------------------------------- /docs/assets/javascripts/lunr/lunr.de.js: -------------------------------------------------------------------------------- 1 | !function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var _,p,r;e.de=function(){this.pipeline.reset(),this.pipeline.add(e.de.trimmer,e.de.stopWordFilter,e.de.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.de.stemmer))},e.de.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.de.trimmer=e.trimmerSupport.generateTrimmer(e.de.wordCharacters),e.Pipeline.registerFunction(e.de.trimmer,"trimmer-de"),e.de.stemmer=(_=e.stemmerSupport.Among,p=e.stemmerSupport.SnowballProgram,r=new function(){var r,n,i,s=[new _("",-1,6),new _("U",0,2),new _("Y",0,1),new _("ä",0,3),new _("ö",0,4),new _("ü",0,5)],o=[new _("e",-1,2),new _("em",-1,1),new _("en",-1,2),new _("ern",-1,1),new _("er",-1,1),new _("s",-1,3),new _("es",5,2)],c=[new _("en",-1,1),new _("er",-1,1),new _("st",-1,2),new _("est",2,1)],u=[new _("ig",-1,1),new _("lich",-1,1)],a=[new _("end",-1,1),new _("ig",-1,2),new _("ung",-1,1),new _("lich",-1,3),new _("isch",-1,2),new _("ik",-1,2),new _("heit",-1,3),new _("keit",-1,4)],t=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,8,0,32,8],d=[117,30,5],l=[117,30,4],m=new p;function h(e,r,n){return!(!m.eq_s(1,e)||(m.ket=m.cursor,!m.in_grouping(t,97,252)))&&(m.slice_from(r),m.cursor=n,!0)}function w(){for(;!m.in_grouping(t,97,252);){if(m.cursor>=m.limit)return!0;m.cursor++}for(;!m.out_grouping(t,97,252);){if(m.cursor>=m.limit)return!0;m.cursor++}return!1}function f(){return i<=m.cursor}function b(){return n<=m.cursor}this.setCurrent=function(e){m.setCurrent(e)},this.getCurrent=function(){return m.getCurrent()},this.stem=function(){var e=m.cursor;return function(){for(var e,r,n,i,s=m.cursor;;)if(e=m.cursor,m.bra=e,m.eq_s(1,"ß"))m.ket=m.cursor,m.slice_from("ss");else{if(e>=m.limit)break;m.cursor=e+1}for(m.cursor=s;;)for(r=m.cursor;;){if(n=m.cursor,m.in_grouping(t,97,252)){if(i=m.cursor,m.bra=i,h("u","U",n))break;if(m.cursor=i,h("y","Y",n))break}if(n>=m.limit)return m.cursor=r;m.cursor=n+1}}(),m.cursor=e,function(){i=m.limit,n=i;var e=m.cursor+3;0<=e&&e<=m.limit&&(r=e,w()||((i=m.cursor)=m.limit)return;m.cursor++}}}(),!0}},function(e){return"function"==typeof e.update?e.update(function(e){return r.setCurrent(e),r.stem(),r.getCurrent()}):(r.setCurrent(e),r.stem(),r.getCurrent())}),e.Pipeline.registerFunction(e.de.stemmer,"stemmer-de"),e.de.stopWordFilter=e.generateStopWordFilter("aber alle allem allen aller alles als also am an ander andere anderem anderen anderer anderes anderm andern anderr anders auch auf aus bei bin bis bist da damit dann das dasselbe dazu daß dein deine deinem deinen deiner deines dem demselben den denn denselben der derer derselbe derselben des desselben dessen dich die dies diese dieselbe dieselben diesem diesen dieser dieses dir doch dort du durch ein eine einem einen einer eines einig einige einigem einigen einiger einiges einmal er es etwas euch euer eure eurem euren eurer eures für gegen gewesen hab habe haben hat hatte hatten hier hin hinter ich ihm ihn ihnen ihr ihre ihrem ihren ihrer ihres im in indem ins ist jede jedem jeden jeder jedes jene jenem jenen jener jenes jetzt kann kein keine keinem keinen keiner keines können könnte machen man manche manchem manchen mancher manches mein meine meinem meinen meiner meines mich mir mit muss musste nach nicht nichts noch nun nur ob oder ohne sehr sein seine seinem seinen seiner seines selbst sich sie sind so solche solchem solchen solcher solches soll sollte sondern sonst um und uns unse unsem unsen unser unses unter viel vom von vor war waren warst was weg weil weiter welche welchem welchen welcher welches wenn werde werden wie wieder will wir wird wirst wo wollen wollte während würde würden zu zum zur zwar zwischen über".split(" ")),e.Pipeline.registerFunction(e.de.stopWordFilter,"stopWordFilter-de")}}); -------------------------------------------------------------------------------- /docs/assets/javascripts/lunr/lunr.du.js: -------------------------------------------------------------------------------- 1 | !function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var v,q,r;console.warn('[Lunr Languages] Please use the "nl" instead of the "du". The "nl" code is the standard code for Dutch language, and "du" will be removed in the next major versions.'),e.du=function(){this.pipeline.reset(),this.pipeline.add(e.du.trimmer,e.du.stopWordFilter,e.du.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.du.stemmer))},e.du.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.du.trimmer=e.trimmerSupport.generateTrimmer(e.du.wordCharacters),e.Pipeline.registerFunction(e.du.trimmer,"trimmer-du"),e.du.stemmer=(v=e.stemmerSupport.Among,q=e.stemmerSupport.SnowballProgram,r=new function(){var r,i,u,o=[new v("",-1,6),new v("á",0,1),new v("ä",0,1),new v("é",0,2),new v("ë",0,2),new v("í",0,3),new v("ï",0,3),new v("ó",0,4),new v("ö",0,4),new v("ú",0,5),new v("ü",0,5)],n=[new v("",-1,3),new v("I",0,2),new v("Y",0,1)],t=[new v("dd",-1,-1),new v("kk",-1,-1),new v("tt",-1,-1)],c=[new v("ene",-1,2),new v("se",-1,3),new v("en",-1,2),new v("heden",2,1),new v("s",-1,3)],a=[new v("end",-1,1),new v("ig",-1,2),new v("ing",-1,1),new v("lijk",-1,3),new v("baar",-1,4),new v("bar",-1,5)],l=[new v("aa",-1,-1),new v("ee",-1,-1),new v("oo",-1,-1),new v("uu",-1,-1)],m=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,128],d=[1,0,0,17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,128],f=[17,67,16,1,0,0,0,0,0,0,0,0,0,0,0,0,128],_=new q;function s(e){return(_.cursor=e)>=_.limit||(_.cursor++,!1)}function w(){for(;!_.in_grouping(m,97,232);){if(_.cursor>=_.limit)return!0;_.cursor++}for(;!_.out_grouping(m,97,232);){if(_.cursor>=_.limit)return!0;_.cursor++}return!1}function b(){return i<=_.cursor}function p(){return r<=_.cursor}function g(){var e=_.limit-_.cursor;_.find_among_b(t,3)&&(_.cursor=_.limit-e,_.ket=_.cursor,_.cursor>_.limit_backward&&(_.cursor--,_.bra=_.cursor,_.slice_del()))}function h(){var e;u=!1,_.ket=_.cursor,_.eq_s_b(1,"e")&&(_.bra=_.cursor,b()&&(e=_.limit-_.cursor,_.out_grouping_b(m,97,232)&&(_.cursor=_.limit-e,_.slice_del(),u=!0,g())))}function k(){var e;b()&&(e=_.limit-_.cursor,_.out_grouping_b(m,97,232)&&(_.cursor=_.limit-e,_.eq_s_b(3,"gem")||(_.cursor=_.limit-e,_.slice_del(),g())))}this.setCurrent=function(e){_.setCurrent(e)},this.getCurrent=function(){return _.getCurrent()},this.stem=function(){var e=_.cursor;return function(){for(var e,r,i,n=_.cursor;;){if(_.bra=_.cursor,e=_.find_among(o,11))switch(_.ket=_.cursor,e){case 1:_.slice_from("a");continue;case 2:_.slice_from("e");continue;case 3:_.slice_from("i");continue;case 4:_.slice_from("o");continue;case 5:_.slice_from("u");continue;case 6:if(_.cursor>=_.limit)break;_.cursor++;continue}break}for(_.cursor=n,_.bra=n,_.eq_s(1,"y")?(_.ket=_.cursor,_.slice_from("Y")):_.cursor=n;;)if(r=_.cursor,_.in_grouping(m,97,232)){if(i=_.cursor,_.bra=i,_.eq_s(1,"i"))_.ket=_.cursor,_.in_grouping(m,97,232)&&(_.slice_from("I"),_.cursor=r);else if(_.cursor=i,_.eq_s(1,"y"))_.ket=_.cursor,_.slice_from("Y"),_.cursor=r;else if(s(r))break}else if(s(r))break}(),_.cursor=e,i=_.limit,r=i,w()||((i=_.cursor)<3&&(i=3),w()||(r=_.cursor)),_.limit_backward=e,_.cursor=_.limit,function(){var e,r,i,n,o,t,s=_.limit-_.cursor;if(_.ket=_.cursor,e=_.find_among_b(c,5))switch(_.bra=_.cursor,e){case 1:b()&&_.slice_from("heid");break;case 2:k();break;case 3:b()&&_.out_grouping_b(f,97,232)&&_.slice_del()}if(_.cursor=_.limit-s,h(),_.cursor=_.limit-s,_.ket=_.cursor,_.eq_s_b(4,"heid")&&(_.bra=_.cursor,p()&&(r=_.limit-_.cursor,_.eq_s_b(1,"c")||(_.cursor=_.limit-r,_.slice_del(),_.ket=_.cursor,_.eq_s_b(2,"en")&&(_.bra=_.cursor,k())))),_.cursor=_.limit-s,_.ket=_.cursor,e=_.find_among_b(a,6))switch(_.bra=_.cursor,e){case 1:if(p()){if(_.slice_del(),i=_.limit-_.cursor,_.ket=_.cursor,_.eq_s_b(2,"ig")&&(_.bra=_.cursor,p()&&(n=_.limit-_.cursor,!_.eq_s_b(1,"e")))){_.cursor=_.limit-n,_.slice_del();break}_.cursor=_.limit-i,g()}break;case 2:p()&&(o=_.limit-_.cursor,_.eq_s_b(1,"e")||(_.cursor=_.limit-o,_.slice_del()));break;case 3:p()&&(_.slice_del(),h());break;case 4:p()&&_.slice_del();break;case 5:p()&&u&&_.slice_del()}_.cursor=_.limit-s,_.out_grouping_b(d,73,232)&&(t=_.limit-_.cursor,_.find_among_b(l,4)&&_.out_grouping_b(m,97,232)&&(_.cursor=_.limit-t,_.ket=_.cursor,_.cursor>_.limit_backward&&(_.cursor--,_.bra=_.cursor,_.slice_del())))}(),_.cursor=_.limit_backward,function(){for(var e;;)if(_.bra=_.cursor,e=_.find_among(n,3))switch(_.ket=_.cursor,e){case 1:_.slice_from("y");break;case 2:_.slice_from("i");break;case 3:if(_.cursor>=_.limit)return;_.cursor++}}(),!0}},function(e){return"function"==typeof e.update?e.update(function(e){return r.setCurrent(e),r.stem(),r.getCurrent()}):(r.setCurrent(e),r.stem(),r.getCurrent())}),e.Pipeline.registerFunction(e.du.stemmer,"stemmer-du"),e.du.stopWordFilter=e.generateStopWordFilter(" aan al alles als altijd andere ben bij daar dan dat de der deze die dit doch doen door dus een eens en er ge geen geweest haar had heb hebben heeft hem het hier hij hoe hun iemand iets ik in is ja je kan kon kunnen maar me meer men met mij mijn moet na naar niet niets nog nu of om omdat onder ons ook op over reeds te tegen toch toen tot u uit uw van veel voor want waren was wat werd wezen wie wil worden wordt zal ze zelf zich zij zijn zo zonder zou".split(" ")),e.Pipeline.registerFunction(e.du.stopWordFilter,"stopWordFilter-du")}}); -------------------------------------------------------------------------------- /docs/assets/javascripts/lunr/lunr.fi.js: -------------------------------------------------------------------------------- 1 | !function(i,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():e()(i.lunr)}(this,function(){return function(i){if(void 0===i)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===i.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var v,C,e;i.fi=function(){this.pipeline.reset(),this.pipeline.add(i.fi.trimmer,i.fi.stopWordFilter,i.fi.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(i.fi.stemmer))},i.fi.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",i.fi.trimmer=i.trimmerSupport.generateTrimmer(i.fi.wordCharacters),i.Pipeline.registerFunction(i.fi.trimmer,"trimmer-fi"),i.fi.stemmer=(v=i.stemmerSupport.Among,C=i.stemmerSupport.SnowballProgram,e=new function(){var n,t,l,o,r=[new v("pa",-1,1),new v("sti",-1,2),new v("kaan",-1,1),new v("han",-1,1),new v("kin",-1,1),new v("hän",-1,1),new v("kään",-1,1),new v("ko",-1,1),new v("pä",-1,1),new v("kö",-1,1)],s=[new v("lla",-1,-1),new v("na",-1,-1),new v("ssa",-1,-1),new v("ta",-1,-1),new v("lta",3,-1),new v("sta",3,-1)],a=[new v("llä",-1,-1),new v("nä",-1,-1),new v("ssä",-1,-1),new v("tä",-1,-1),new v("ltä",3,-1),new v("stä",3,-1)],u=[new v("lle",-1,-1),new v("ine",-1,-1)],c=[new v("nsa",-1,3),new v("mme",-1,3),new v("nne",-1,3),new v("ni",-1,2),new v("si",-1,1),new v("an",-1,4),new v("en",-1,6),new v("än",-1,5),new v("nsä",-1,3)],i=[new v("aa",-1,-1),new v("ee",-1,-1),new v("ii",-1,-1),new v("oo",-1,-1),new v("uu",-1,-1),new v("ää",-1,-1),new v("öö",-1,-1)],m=[new v("a",-1,8),new v("lla",0,-1),new v("na",0,-1),new v("ssa",0,-1),new v("ta",0,-1),new v("lta",4,-1),new v("sta",4,-1),new v("tta",4,9),new v("lle",-1,-1),new v("ine",-1,-1),new v("ksi",-1,-1),new v("n",-1,7),new v("han",11,1),new v("den",11,-1,q),new v("seen",11,-1,j),new v("hen",11,2),new v("tten",11,-1,q),new v("hin",11,3),new v("siin",11,-1,q),new v("hon",11,4),new v("hän",11,5),new v("hön",11,6),new v("ä",-1,8),new v("llä",22,-1),new v("nä",22,-1),new v("ssä",22,-1),new v("tä",22,-1),new v("ltä",26,-1),new v("stä",26,-1),new v("ttä",26,9)],w=[new v("eja",-1,-1),new v("mma",-1,1),new v("imma",1,-1),new v("mpa",-1,1),new v("impa",3,-1),new v("mmi",-1,1),new v("immi",5,-1),new v("mpi",-1,1),new v("impi",7,-1),new v("ejä",-1,-1),new v("mmä",-1,1),new v("immä",10,-1),new v("mpä",-1,1),new v("impä",12,-1)],_=[new v("i",-1,-1),new v("j",-1,-1)],k=[new v("mma",-1,1),new v("imma",0,-1)],b=[17,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8],d=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,8,0,32],e=[17,65,16,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,32],f=[17,97,24,1,0,0,0,0,0,0,0,0,0,0,0,0,8,0,32],h=new C;function p(){for(var i;i=h.cursor,!h.in_grouping(d,97,246);){if((h.cursor=i)>=h.limit)return!0;h.cursor++}for(h.cursor=i;!h.out_grouping(d,97,246);){if(h.cursor>=h.limit)return!0;h.cursor++}return!1}function g(){var i,e;if(h.cursor>=o)if(e=h.limit_backward,h.limit_backward=o,h.ket=h.cursor,i=h.find_among_b(r,10)){switch(h.bra=h.cursor,h.limit_backward=e,i){case 1:if(!h.in_grouping_b(f,97,246))return;break;case 2:if(!(l<=h.cursor))return}h.slice_del()}else h.limit_backward=e}function j(){return h.find_among_b(i,7)}function q(){return h.eq_s_b(1,"i")&&h.in_grouping_b(e,97,246)}this.setCurrent=function(i){h.setCurrent(i)},this.getCurrent=function(){return h.getCurrent()},this.stem=function(){var i,e=h.cursor;return o=h.limit,l=o,p()||(o=h.cursor,p()||(l=h.cursor)),n=!1,h.limit_backward=e,h.cursor=h.limit,g(),h.cursor=h.limit,function(){var i,e,r;if(h.cursor>=o)if(e=h.limit_backward,h.limit_backward=o,h.ket=h.cursor,i=h.find_among_b(c,9))switch(h.bra=h.cursor,h.limit_backward=e,i){case 1:r=h.limit-h.cursor,h.eq_s_b(1,"k")||(h.cursor=h.limit-r,h.slice_del());break;case 2:h.slice_del(),h.ket=h.cursor,h.eq_s_b(3,"kse")&&(h.bra=h.cursor,h.slice_from("ksi"));break;case 3:h.slice_del();break;case 4:h.find_among_b(s,6)&&h.slice_del();break;case 5:h.find_among_b(a,6)&&h.slice_del();break;case 6:h.find_among_b(u,2)&&h.slice_del()}else h.limit_backward=e}(),h.cursor=h.limit,function(){var i,e,r;if(h.cursor>=o)if(e=h.limit_backward,h.limit_backward=o,h.ket=h.cursor,i=h.find_among_b(m,30)){switch(h.bra=h.cursor,h.limit_backward=e,i){case 1:if(!h.eq_s_b(1,"a"))return;break;case 2:case 9:if(!h.eq_s_b(1,"e"))return;break;case 3:if(!h.eq_s_b(1,"i"))return;break;case 4:if(!h.eq_s_b(1,"o"))return;break;case 5:if(!h.eq_s_b(1,"ä"))return;break;case 6:if(!h.eq_s_b(1,"ö"))return;break;case 7:if(r=h.limit-h.cursor,!j()&&(h.cursor=h.limit-r,!h.eq_s_b(2,"ie"))){h.cursor=h.limit-r;break}if(h.cursor=h.limit-r,h.cursor<=h.limit_backward){h.cursor=h.limit-r;break}h.cursor--,h.bra=h.cursor;break;case 8:if(!h.in_grouping_b(d,97,246)||!h.out_grouping_b(d,97,246))return}h.slice_del(),n=!0}else h.limit_backward=e}(),h.cursor=h.limit,function(){var i,e,r;if(h.cursor>=l)if(e=h.limit_backward,h.limit_backward=l,h.ket=h.cursor,i=h.find_among_b(w,14)){if(h.bra=h.cursor,h.limit_backward=e,1==i){if(r=h.limit-h.cursor,h.eq_s_b(2,"po"))return;h.cursor=h.limit-r}h.slice_del()}else h.limit_backward=e}(),h.cursor=h.limit,h.cursor=(n?h.cursor>=o&&(i=h.limit_backward,h.limit_backward=o,h.ket=h.cursor,h.find_among_b(_,2)?(h.bra=h.cursor,h.limit_backward=i,h.slice_del()):h.limit_backward=i):(h.cursor=h.limit,function(){var i,e,r,n,t,s;if(h.cursor>=o){if(e=h.limit_backward,h.limit_backward=o,h.ket=h.cursor,h.eq_s_b(1,"t")&&(h.bra=h.cursor,r=h.limit-h.cursor,h.in_grouping_b(d,97,246)&&(h.cursor=h.limit-r,h.slice_del(),h.limit_backward=e,n=h.limit-h.cursor,h.cursor>=l&&(h.cursor=l,t=h.limit_backward,h.limit_backward=h.cursor,h.cursor=h.limit-n,h.ket=h.cursor,i=h.find_among_b(k,2))))){if(h.bra=h.cursor,h.limit_backward=t,1==i){if(s=h.limit-h.cursor,h.eq_s_b(2,"po"))return;h.cursor=h.limit-s}return h.slice_del()}h.limit_backward=e}}()),h.limit),function(){var i,e,r,n;if(h.cursor>=o){for(i=h.limit_backward,h.limit_backward=o,e=h.limit-h.cursor,j()&&(h.cursor=h.limit-e,h.ket=h.cursor,h.cursor>h.limit_backward&&(h.cursor--,h.bra=h.cursor,h.slice_del())),h.cursor=h.limit-e,h.ket=h.cursor,h.in_grouping_b(b,97,228)&&(h.bra=h.cursor,h.out_grouping_b(d,97,246)&&h.slice_del()),h.cursor=h.limit-e,h.ket=h.cursor,h.eq_s_b(1,"j")&&(h.bra=h.cursor,r=h.limit-h.cursor,h.eq_s_b(1,"o")?h.slice_del():(h.cursor=h.limit-r,h.eq_s_b(1,"u")&&h.slice_del())),h.cursor=h.limit-e,h.ket=h.cursor,h.eq_s_b(1,"o")&&(h.bra=h.cursor,h.eq_s_b(1,"j")&&h.slice_del()),h.cursor=h.limit-e,h.limit_backward=i;;){if(n=h.limit-h.cursor,h.out_grouping_b(d,97,246)){h.cursor=h.limit-n;break}if(h.cursor=h.limit-n,h.cursor<=h.limit_backward)return;h.cursor--}h.ket=h.cursor,h.cursor>h.limit_backward&&(h.cursor--,h.bra=h.cursor,t=h.slice_to(),h.eq_v_b(t)&&h.slice_del())}}(),!0}},function(i){return"function"==typeof i.update?i.update(function(i){return e.setCurrent(i),e.stem(),e.getCurrent()}):(e.setCurrent(i),e.stem(),e.getCurrent())}),i.Pipeline.registerFunction(i.fi.stemmer,"stemmer-fi"),i.fi.stopWordFilter=i.generateStopWordFilter("ei eivät emme en et ette että he heidän heidät heihin heille heillä heiltä heissä heistä heitä hän häneen hänelle hänellä häneltä hänen hänessä hänestä hänet häntä itse ja johon joiden joihin joiksi joilla joille joilta joina joissa joista joita joka joksi jolla jolle jolta jona jonka jos jossa josta jota jotka kanssa keiden keihin keiksi keille keillä keiltä keinä keissä keistä keitä keneen keneksi kenelle kenellä keneltä kenen kenenä kenessä kenestä kenet ketkä ketkä ketä koska kuin kuka kun me meidän meidät meihin meille meillä meiltä meissä meistä meitä mihin miksi mikä mille millä miltä minkä minkä minua minulla minulle minulta minun minussa minusta minut minuun minä minä missä mistä mitkä mitä mukaan mutta ne niiden niihin niiksi niille niillä niiltä niin niin niinä niissä niistä niitä noiden noihin noiksi noilla noille noilta noin noina noissa noista noita nuo nyt näiden näihin näiksi näille näillä näiltä näinä näissä näistä näitä nämä ole olemme olen olet olette oli olimme olin olisi olisimme olisin olisit olisitte olisivat olit olitte olivat olla olleet ollut on ovat poikki se sekä sen siihen siinä siitä siksi sille sillä sillä siltä sinua sinulla sinulle sinulta sinun sinussa sinusta sinut sinuun sinä sinä sitä tai te teidän teidät teihin teille teillä teiltä teissä teistä teitä tuo tuohon tuoksi tuolla tuolle tuolta tuon tuona tuossa tuosta tuota tähän täksi tälle tällä tältä tämä tämän tänä tässä tästä tätä vaan vai vaikka yli".split(" ")),i.Pipeline.registerFunction(i.fi.stopWordFilter,"stopWordFilter-fi")}}); -------------------------------------------------------------------------------- /docs/assets/javascripts/lunr/lunr.ja.js: -------------------------------------------------------------------------------- 1 | !function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(m){if(void 0===m)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===m.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var l="2"==m.version[0];m.ja=function(){this.pipeline.reset(),this.pipeline.add(m.ja.trimmer,m.ja.stopWordFilter,m.ja.stemmer),l?this.tokenizer=m.ja.tokenizer:(m.tokenizer&&(m.tokenizer=m.ja.tokenizer),this.tokenizerFn&&(this.tokenizerFn=m.ja.tokenizer))};var j=new m.TinySegmenter;m.ja.tokenizer=function(e){var r,t,i,n,o,s,p,a,u;if(!arguments.length||null==e||null==e)return[];if(Array.isArray(e))return e.map(function(e){return l?new m.Token(e.toLowerCase()):e.toLowerCase()});for(r=(t=e.toString().toLowerCase().replace(/^\s+/,"")).length-1;0<=r;r--)if(/\S/.test(t.charAt(r))){t=t.substring(0,r+1);break}for(o=[],i=t.length,p=a=0;a<=i;a++)if(s=a-p,t.charAt(a).match(/\s/)||a==i){if(0=_.limit||(_.cursor++,!1)}function w(){for(;!_.in_grouping(m,97,232);){if(_.cursor>=_.limit)return!0;_.cursor++}for(;!_.out_grouping(m,97,232);){if(_.cursor>=_.limit)return!0;_.cursor++}return!1}function b(){return i<=_.cursor}function p(){return e<=_.cursor}function g(){var r=_.limit-_.cursor;_.find_among_b(t,3)&&(_.cursor=_.limit-r,_.ket=_.cursor,_.cursor>_.limit_backward&&(_.cursor--,_.bra=_.cursor,_.slice_del()))}function h(){var r;u=!1,_.ket=_.cursor,_.eq_s_b(1,"e")&&(_.bra=_.cursor,b()&&(r=_.limit-_.cursor,_.out_grouping_b(m,97,232)&&(_.cursor=_.limit-r,_.slice_del(),u=!0,g())))}function k(){var r;b()&&(r=_.limit-_.cursor,_.out_grouping_b(m,97,232)&&(_.cursor=_.limit-r,_.eq_s_b(3,"gem")||(_.cursor=_.limit-r,_.slice_del(),g())))}this.setCurrent=function(r){_.setCurrent(r)},this.getCurrent=function(){return _.getCurrent()},this.stem=function(){var r=_.cursor;return function(){for(var r,e,i,n=_.cursor;;){if(_.bra=_.cursor,r=_.find_among(o,11))switch(_.ket=_.cursor,r){case 1:_.slice_from("a");continue;case 2:_.slice_from("e");continue;case 3:_.slice_from("i");continue;case 4:_.slice_from("o");continue;case 5:_.slice_from("u");continue;case 6:if(_.cursor>=_.limit)break;_.cursor++;continue}break}for(_.cursor=n,_.bra=n,_.eq_s(1,"y")?(_.ket=_.cursor,_.slice_from("Y")):_.cursor=n;;)if(e=_.cursor,_.in_grouping(m,97,232)){if(i=_.cursor,_.bra=i,_.eq_s(1,"i"))_.ket=_.cursor,_.in_grouping(m,97,232)&&(_.slice_from("I"),_.cursor=e);else if(_.cursor=i,_.eq_s(1,"y"))_.ket=_.cursor,_.slice_from("Y"),_.cursor=e;else if(s(e))break}else if(s(e))break}(),_.cursor=r,i=_.limit,e=i,w()||((i=_.cursor)<3&&(i=3),w()||(e=_.cursor)),_.limit_backward=r,_.cursor=_.limit,function(){var r,e,i,n,o,t,s=_.limit-_.cursor;if(_.ket=_.cursor,r=_.find_among_b(c,5))switch(_.bra=_.cursor,r){case 1:b()&&_.slice_from("heid");break;case 2:k();break;case 3:b()&&_.out_grouping_b(f,97,232)&&_.slice_del()}if(_.cursor=_.limit-s,h(),_.cursor=_.limit-s,_.ket=_.cursor,_.eq_s_b(4,"heid")&&(_.bra=_.cursor,p()&&(e=_.limit-_.cursor,_.eq_s_b(1,"c")||(_.cursor=_.limit-e,_.slice_del(),_.ket=_.cursor,_.eq_s_b(2,"en")&&(_.bra=_.cursor,k())))),_.cursor=_.limit-s,_.ket=_.cursor,r=_.find_among_b(a,6))switch(_.bra=_.cursor,r){case 1:if(p()){if(_.slice_del(),i=_.limit-_.cursor,_.ket=_.cursor,_.eq_s_b(2,"ig")&&(_.bra=_.cursor,p()&&(n=_.limit-_.cursor,!_.eq_s_b(1,"e")))){_.cursor=_.limit-n,_.slice_del();break}_.cursor=_.limit-i,g()}break;case 2:p()&&(o=_.limit-_.cursor,_.eq_s_b(1,"e")||(_.cursor=_.limit-o,_.slice_del()));break;case 3:p()&&(_.slice_del(),h());break;case 4:p()&&_.slice_del();break;case 5:p()&&u&&_.slice_del()}_.cursor=_.limit-s,_.out_grouping_b(d,73,232)&&(t=_.limit-_.cursor,_.find_among_b(l,4)&&_.out_grouping_b(m,97,232)&&(_.cursor=_.limit-t,_.ket=_.cursor,_.cursor>_.limit_backward&&(_.cursor--,_.bra=_.cursor,_.slice_del())))}(),_.cursor=_.limit_backward,function(){for(var r;;)if(_.bra=_.cursor,r=_.find_among(n,3))switch(_.ket=_.cursor,r){case 1:_.slice_from("y");break;case 2:_.slice_from("i");break;case 3:if(_.cursor>=_.limit)return;_.cursor++}}(),!0}},function(r){return"function"==typeof r.update?r.update(function(r){return e.setCurrent(r),e.stem(),e.getCurrent()}):(e.setCurrent(r),e.stem(),e.getCurrent())}),r.Pipeline.registerFunction(r.nl.stemmer,"stemmer-nl"),r.nl.stopWordFilter=r.generateStopWordFilter(" aan al alles als altijd andere ben bij daar dan dat de der deze die dit doch doen door dus een eens en er ge geen geweest haar had heb hebben heeft hem het hier hij hoe hun iemand iets ik in is ja je kan kon kunnen maar me meer men met mij mijn moet na naar niet niets nog nu of om omdat onder ons ook op over reeds te tegen toch toen tot u uit uw van veel voor want waren was wat werd wezen wie wil worden wordt zal ze zelf zich zij zijn zo zonder zou".split(" ")),r.Pipeline.registerFunction(r.nl.stopWordFilter,"stopWordFilter-nl")}}); -------------------------------------------------------------------------------- /docs/assets/javascripts/lunr/lunr.no.js: -------------------------------------------------------------------------------- 1 | !function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var r,n,i;e.no=function(){this.pipeline.reset(),this.pipeline.add(e.no.trimmer,e.no.stopWordFilter,e.no.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.no.stemmer))},e.no.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.no.trimmer=e.trimmerSupport.generateTrimmer(e.no.wordCharacters),e.Pipeline.registerFunction(e.no.trimmer,"trimmer-no"),e.no.stemmer=(r=e.stemmerSupport.Among,n=e.stemmerSupport.SnowballProgram,i=new function(){var o,s,a=[new r("a",-1,1),new r("e",-1,1),new r("ede",1,1),new r("ande",1,1),new r("ende",1,1),new r("ane",1,1),new r("ene",1,1),new r("hetene",6,1),new r("erte",1,3),new r("en",-1,1),new r("heten",9,1),new r("ar",-1,1),new r("er",-1,1),new r("heter",12,1),new r("s",-1,2),new r("as",14,1),new r("es",14,1),new r("edes",16,1),new r("endes",16,1),new r("enes",16,1),new r("hetenes",19,1),new r("ens",14,1),new r("hetens",21,1),new r("ers",14,1),new r("ets",14,1),new r("et",-1,1),new r("het",25,1),new r("ert",-1,3),new r("ast",-1,1)],m=[new r("dt",-1,-1),new r("vt",-1,-1)],l=[new r("leg",-1,1),new r("eleg",0,1),new r("ig",-1,1),new r("eig",2,1),new r("lig",2,1),new r("elig",4,1),new r("els",-1,1),new r("lov",-1,1),new r("elov",7,1),new r("slov",7,1),new r("hetslov",9,1)],u=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,48,0,128],d=[119,125,149,1],c=new n;this.setCurrent=function(e){c.setCurrent(e)},this.getCurrent=function(){return c.getCurrent()},this.stem=function(){var e,r,n,i,t=c.cursor;return function(){var e,r=c.cursor+3;if(s=c.limit,0<=r||r<=c.limit){for(o=r;;){if(e=c.cursor,c.in_grouping(u,97,248)){c.cursor=e;break}if(e>=c.limit)return;c.cursor=e+1}for(;!c.out_grouping(u,97,248);){if(c.cursor>=c.limit)return;c.cursor++}(s=c.cursor)=s&&(r=c.limit_backward,c.limit_backward=s,c.ket=c.cursor,e=c.find_among_b(a,29),c.limit_backward=r,e))switch(c.bra=c.cursor,e){case 1:c.slice_del();break;case 2:n=c.limit-c.cursor,c.in_grouping_b(d,98,122)?c.slice_del():(c.cursor=c.limit-n,c.eq_s_b(1,"k")&&c.out_grouping_b(u,97,248)&&c.slice_del());break;case 3:c.slice_from("er")}}(),c.cursor=c.limit,r=c.limit-c.cursor,c.cursor>=s&&(e=c.limit_backward,c.limit_backward=s,c.ket=c.cursor,c.find_among_b(m,2)?(c.bra=c.cursor,c.limit_backward=e,c.cursor=c.limit-r,c.cursor>c.limit_backward&&(c.cursor--,c.bra=c.cursor,c.slice_del())):c.limit_backward=e),c.cursor=c.limit,c.cursor>=s&&(i=c.limit_backward,c.limit_backward=s,c.ket=c.cursor,(n=c.find_among_b(l,11))?(c.bra=c.cursor,c.limit_backward=i,1==n&&c.slice_del()):c.limit_backward=i),!0}},function(e){return"function"==typeof e.update?e.update(function(e){return i.setCurrent(e),i.stem(),i.getCurrent()}):(i.setCurrent(e),i.stem(),i.getCurrent())}),e.Pipeline.registerFunction(e.no.stemmer,"stemmer-no"),e.no.stopWordFilter=e.generateStopWordFilter("alle at av bare begge ble blei bli blir blitt både båe da de deg dei deim deira deires dem den denne der dere deres det dette di din disse ditt du dykk dykkar då eg ein eit eitt eller elles en enn er et ett etter for fordi fra før ha hadde han hans har hennar henne hennes her hjå ho hoe honom hoss hossen hun hva hvem hver hvilke hvilken hvis hvor hvordan hvorfor i ikke ikkje ikkje ingen ingi inkje inn inni ja jeg kan kom korleis korso kun kunne kva kvar kvarhelst kven kvi kvifor man mange me med medan meg meget mellom men mi min mine mitt mot mykje ned no noe noen noka noko nokon nokor nokre nå når og også om opp oss over på samme seg selv si si sia sidan siden sin sine sitt sjøl skal skulle slik so som som somme somt så sånn til um upp ut uten var vart varte ved vere verte vi vil ville vore vors vort vår være være vært å".split(" ")),e.Pipeline.registerFunction(e.no.stopWordFilter,"stopWordFilter-no")}}); -------------------------------------------------------------------------------- /docs/assets/javascripts/lunr/lunr.ru.js: -------------------------------------------------------------------------------- 1 | !function(e,n){"function"==typeof define&&define.amd?define(n):"object"==typeof exports?module.exports=n():n()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var h,g,n;e.ru=function(){this.pipeline.reset(),this.pipeline.add(e.ru.trimmer,e.ru.stopWordFilter,e.ru.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.ru.stemmer))},e.ru.wordCharacters="Ѐ-҄҇-ԯᴫᵸⷠ-ⷿꙀ-ꚟ︮︯",e.ru.trimmer=e.trimmerSupport.generateTrimmer(e.ru.wordCharacters),e.Pipeline.registerFunction(e.ru.trimmer,"trimmer-ru"),e.ru.stemmer=(h=e.stemmerSupport.Among,g=e.stemmerSupport.SnowballProgram,n=new function(){var n,e,r=[new h("в",-1,1),new h("ив",0,2),new h("ыв",0,2),new h("вши",-1,1),new h("ивши",3,2),new h("ывши",3,2),new h("вшись",-1,1),new h("ившись",6,2),new h("ывшись",6,2)],t=[new h("ее",-1,1),new h("ие",-1,1),new h("ое",-1,1),new h("ые",-1,1),new h("ими",-1,1),new h("ыми",-1,1),new h("ей",-1,1),new h("ий",-1,1),new h("ой",-1,1),new h("ый",-1,1),new h("ем",-1,1),new h("им",-1,1),new h("ом",-1,1),new h("ым",-1,1),new h("его",-1,1),new h("ого",-1,1),new h("ему",-1,1),new h("ому",-1,1),new h("их",-1,1),new h("ых",-1,1),new h("ею",-1,1),new h("ою",-1,1),new h("ую",-1,1),new h("юю",-1,1),new h("ая",-1,1),new h("яя",-1,1)],w=[new h("ем",-1,1),new h("нн",-1,1),new h("вш",-1,1),new h("ивш",2,2),new h("ывш",2,2),new h("щ",-1,1),new h("ющ",5,1),new h("ующ",6,2)],i=[new h("сь",-1,1),new h("ся",-1,1)],u=[new h("ла",-1,1),new h("ила",0,2),new h("ыла",0,2),new h("на",-1,1),new h("ена",3,2),new h("ете",-1,1),new h("ите",-1,2),new h("йте",-1,1),new h("ейте",7,2),new h("уйте",7,2),new h("ли",-1,1),new h("или",10,2),new h("ыли",10,2),new h("й",-1,1),new h("ей",13,2),new h("уй",13,2),new h("л",-1,1),new h("ил",16,2),new h("ыл",16,2),new h("ем",-1,1),new h("им",-1,2),new h("ым",-1,2),new h("н",-1,1),new h("ен",22,2),new h("ло",-1,1),new h("ило",24,2),new h("ыло",24,2),new h("но",-1,1),new h("ено",27,2),new h("нно",27,1),new h("ет",-1,1),new h("ует",30,2),new h("ит",-1,2),new h("ыт",-1,2),new h("ют",-1,1),new h("уют",34,2),new h("ят",-1,2),new h("ны",-1,1),new h("ены",37,2),new h("ть",-1,1),new h("ить",39,2),new h("ыть",39,2),new h("ешь",-1,1),new h("ишь",-1,2),new h("ю",-1,2),new h("ую",44,2)],s=[new h("а",-1,1),new h("ев",-1,1),new h("ов",-1,1),new h("е",-1,1),new h("ие",3,1),new h("ье",3,1),new h("и",-1,1),new h("еи",6,1),new h("ии",6,1),new h("ами",6,1),new h("ями",6,1),new h("иями",10,1),new h("й",-1,1),new h("ей",12,1),new h("ией",13,1),new h("ий",12,1),new h("ой",12,1),new h("ам",-1,1),new h("ем",-1,1),new h("ием",18,1),new h("ом",-1,1),new h("ям",-1,1),new h("иям",21,1),new h("о",-1,1),new h("у",-1,1),new h("ах",-1,1),new h("ях",-1,1),new h("иях",26,1),new h("ы",-1,1),new h("ь",-1,1),new h("ю",-1,1),new h("ию",30,1),new h("ью",30,1),new h("я",-1,1),new h("ия",33,1),new h("ья",33,1)],o=[new h("ост",-1,1),new h("ость",-1,1)],c=[new h("ейше",-1,1),new h("н",-1,2),new h("ейш",-1,1),new h("ь",-1,3)],m=[33,65,8,232],l=new g;function f(){for(;!l.in_grouping(m,1072,1103);){if(l.cursor>=l.limit)return!1;l.cursor++}return!0}function a(){for(;!l.out_grouping(m,1072,1103);){if(l.cursor>=l.limit)return!1;l.cursor++}return!0}function p(e,n){var r,t;if(l.ket=l.cursor,r=l.find_among_b(e,n)){switch(l.bra=l.cursor,r){case 1:if(t=l.limit-l.cursor,!l.eq_s_b(1,"а")&&(l.cursor=l.limit-t,!l.eq_s_b(1,"я")))return!1;case 2:l.slice_del()}return!0}return!1}function d(e,n){var r;return l.ket=l.cursor,!!(r=l.find_among_b(e,n))&&(l.bra=l.cursor,1==r&&l.slice_del(),!0)}function _(){return!!d(t,26)&&(p(w,8),!0)}function b(){var e;l.ket=l.cursor,(e=l.find_among_b(o,2))&&(l.bra=l.cursor,n<=l.cursor&&1==e&&l.slice_del())}this.setCurrent=function(e){l.setCurrent(e)},this.getCurrent=function(){return l.getCurrent()},this.stem=function(){return e=l.limit,n=e,f()&&(e=l.cursor,a()&&f()&&a()&&(n=l.cursor)),l.cursor=l.limit,!(l.cursor>3]&1<<(7&s))return this.cursor++,!0}return!1},in_grouping_b:function(r,t,i){if(this.cursor>this.limit_backward){var s=b.charCodeAt(this.cursor-1);if(s<=i&&t<=s&&r[(s-=t)>>3]&1<<(7&s))return this.cursor--,!0}return!1},out_grouping:function(r,t,i){if(this.cursor>3]&1<<(7&s)))return this.cursor++,!0}return!1},out_grouping_b:function(r,t,i){if(this.cursor>this.limit_backward){var s=b.charCodeAt(this.cursor-1);if(i>3]&1<<(7&s)))return this.cursor--,!0}return!1},eq_s:function(r,t){if(this.limit-this.cursor>1),a=0,f=u=(l=r[i]).s_size){if(this.cursor=e+l.s_size,!l.method)return l.result;var m=l.method();if(this.cursor=e+l.s_size,m)return l.result}if((i=l.substring_i)<0)return 0}},find_among_b:function(r,t){for(var i=0,s=t,e=this.cursor,n=this.limit_backward,u=0,o=0,h=!1;;){for(var c=i+(s-i>>1),a=0,f=u=(_=r[i]).s_size){if(this.cursor=e-_.s_size,!_.method)return _.result;var m=_.method();if(this.cursor=e-_.s_size,m)return _.result}if((i=_.substring_i)<0)return 0}},replace_s:function(r,t,i){var s=i.length-(t-r);return b=b.substring(0,r)+i+b.substring(t),this.limit+=s,this.cursor>=t?this.cursor+=s:this.cursor>r&&(this.cursor=r),s},slice_check:function(){if(this.bra<0||this.bra>this.ket||this.ket>this.limit||this.limit>b.length)throw"faulty slice operation"},slice_from:function(r){this.slice_check(),this.replace_s(this.bra,this.ket,r)},slice_del:function(){this.slice_from("")},insert:function(r,t,i){var s=this.replace_s(r,t,i);r<=this.bra&&(this.bra+=s),r<=this.ket&&(this.ket+=s)},slice_to:function(){return this.slice_check(),b.substring(this.bra,this.ket)},eq_v_b:function(r){return this.eq_s_b(r.length,r)}}}},r.trimmerSupport={generateTrimmer:function(r){var t=new RegExp("^[^"+r+"]+"),i=new RegExp("[^"+r+"]+$");return function(r){return"function"==typeof r.update?r.update(function(r){return r.replace(t,"").replace(i,"")}):r.replace(t,"").replace(i,"")}}}}}); -------------------------------------------------------------------------------- /docs/assets/javascripts/lunr/lunr.sv.js: -------------------------------------------------------------------------------- 1 | !function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var r,l,n;e.sv=function(){this.pipeline.reset(),this.pipeline.add(e.sv.trimmer,e.sv.stopWordFilter,e.sv.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.sv.stemmer))},e.sv.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.sv.trimmer=e.trimmerSupport.generateTrimmer(e.sv.wordCharacters),e.Pipeline.registerFunction(e.sv.trimmer,"trimmer-sv"),e.sv.stemmer=(r=e.stemmerSupport.Among,l=e.stemmerSupport.SnowballProgram,n=new function(){var n,t,i=[new r("a",-1,1),new r("arna",0,1),new r("erna",0,1),new r("heterna",2,1),new r("orna",0,1),new r("ad",-1,1),new r("e",-1,1),new r("ade",6,1),new r("ande",6,1),new r("arne",6,1),new r("are",6,1),new r("aste",6,1),new r("en",-1,1),new r("anden",12,1),new r("aren",12,1),new r("heten",12,1),new r("ern",-1,1),new r("ar",-1,1),new r("er",-1,1),new r("heter",18,1),new r("or",-1,1),new r("s",-1,2),new r("as",21,1),new r("arnas",22,1),new r("ernas",22,1),new r("ornas",22,1),new r("es",21,1),new r("ades",26,1),new r("andes",26,1),new r("ens",21,1),new r("arens",29,1),new r("hetens",29,1),new r("erns",21,1),new r("at",-1,1),new r("andet",-1,1),new r("het",-1,1),new r("ast",-1,1)],s=[new r("dd",-1,-1),new r("gd",-1,-1),new r("nn",-1,-1),new r("dt",-1,-1),new r("gt",-1,-1),new r("kt",-1,-1),new r("tt",-1,-1)],a=[new r("ig",-1,1),new r("lig",0,1),new r("els",-1,1),new r("fullt",-1,3),new r("löst",-1,2)],o=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,24,0,32],u=[119,127,149],m=new l;this.setCurrent=function(e){m.setCurrent(e)},this.getCurrent=function(){return m.getCurrent()},this.stem=function(){var e,r=m.cursor;return function(){var e,r=m.cursor+3;if(t=m.limit,0<=r||r<=m.limit){for(n=r;;){if(e=m.cursor,m.in_grouping(o,97,246)){m.cursor=e;break}if(m.cursor=e,m.cursor>=m.limit)return;m.cursor++}for(;!m.out_grouping(o,97,246);){if(m.cursor>=m.limit)return;m.cursor++}(t=m.cursor)=t&&(m.limit_backward=t,m.cursor=m.limit,m.ket=m.cursor,e=m.find_among_b(i,37),m.limit_backward=r,e))switch(m.bra=m.cursor,e){case 1:m.slice_del();break;case 2:m.in_grouping_b(u,98,121)&&m.slice_del()}}(),m.cursor=m.limit,e=m.limit_backward,m.cursor>=t&&(m.limit_backward=t,m.cursor=m.limit,m.find_among_b(s,7)&&(m.cursor=m.limit,m.ket=m.cursor,m.cursor>m.limit_backward&&(m.bra=--m.cursor,m.slice_del())),m.limit_backward=e),m.cursor=m.limit,function(){var e,r;if(m.cursor>=t){if(r=m.limit_backward,m.limit_backward=t,m.cursor=m.limit,m.ket=m.cursor,e=m.find_among_b(a,5))switch(m.bra=m.cursor,e){case 1:m.slice_del();break;case 2:m.slice_from("lös");break;case 3:m.slice_from("full")}m.limit_backward=r}}(),!0}},function(e){return"function"==typeof e.update?e.update(function(e){return n.setCurrent(e),n.stem(),n.getCurrent()}):(n.setCurrent(e),n.stem(),n.getCurrent())}),e.Pipeline.registerFunction(e.sv.stemmer,"stemmer-sv"),e.sv.stopWordFilter=e.generateStopWordFilter("alla allt att av blev bli blir blivit de dem den denna deras dess dessa det detta dig din dina ditt du där då efter ej eller en er era ert ett från för ha hade han hans har henne hennes hon honom hur här i icke ingen inom inte jag ju kan kunde man med mellan men mig min mina mitt mot mycket ni nu när någon något några och om oss på samma sedan sig sin sina sitta själv skulle som så sådan sådana sådant till under upp ut utan vad var vara varför varit varje vars vart vem vi vid vilka vilkas vilken vilket vår våra vårt än är åt över".split(" ")),e.Pipeline.registerFunction(e.sv.stopWordFilter,"stopWordFilter-sv")}}); -------------------------------------------------------------------------------- /docs/assets/javascripts/lunr/lunr.th.js: -------------------------------------------------------------------------------- 1 | !function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(t){if(void 0===t)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===t.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var i="2"==t.version[0];t.th=function(){this.pipeline.reset(),this.pipeline.add(t.th.trimmer),i?this.tokenizer=t.th.tokenizer:(t.tokenizer&&(t.tokenizer=t.th.tokenizer),this.tokenizerFn&&(this.tokenizerFn=t.th.tokenizer))},t.th.wordCharacters="[฀-๿]",t.th.trimmer=t.trimmerSupport.generateTrimmer(t.th.wordCharacters),t.Pipeline.registerFunction(t.th.trimmer,"trimmer-th");var n=t.wordcut;n.init(),t.th.tokenizer=function(e){if(!arguments.length||null==e||null==e)return[];if(Array.isArray(e))return e.map(function(e){return i?new t.Token(e):e});var r=e.toString().replace(/^\s+/,"");return n.cut(r).split("|")}}}); -------------------------------------------------------------------------------- /docs/assets/javascripts/modernizr.74668098.js: -------------------------------------------------------------------------------- 1 | !function(e,t){for(var n in t)e[n]=t[n]}(window,function(n){var r={};function o(e){if(r[e])return r[e].exports;var t=r[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}return o.m=n,o.c=r,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=11)}({11:function(e,t,n){"use strict";n.r(t);n(12)},12:function(e,t){var n;(function(i,d,p){function y(e,t){return typeof e===t}function s(e){var t=S.className,n=c._config.classPrefix||"";if(b&&(t=t.baseVal),c._config.enableJSClass){var r=new RegExp("(^|\\s)"+n+"no-js(\\s|$)");t=t.replace(r,"$1"+n+"js$2")}c._config.enableClasses&&(0 2 | 3 | 4 | https://foso.github.io/MpApt/ 5 | 2019-09-06 6 | daily 7 | 8 | 9 | https://foso.github.io/MpApt/CHANGELOG/ 10 | 2019-09-06 11 | daily 12 | 13 | -------------------------------------------------------------------------------- /docs/sitemap.xml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Foso/MpApt/f1f3edee8c0ee2c56ea24869c1a66d3ae0854bd0/docs/sitemap.xml.gz -------------------------------------------------------------------------------- /docs/test.md: -------------------------------------------------------------------------------- 1 | Hallo -------------------------------------------------------------------------------- /example/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | 3 | ext.buildMaven = { p -> repositories { maven { url p } } } 4 | 5 | 6 | repositories { 7 | mavenLocal() 8 | google() 9 | jcenter() 10 | mavenCentral() 11 | } 12 | 13 | dependencies { 14 | 15 | } 16 | 17 | } 18 | 19 | plugins { 20 | id 'org.jetbrains.kotlin.multiplatform' version '1.5.10' 21 | id 'de.jensklingenberg.mpapt' 22 | } 23 | 24 | 25 | 26 | System.setProperty("kotlin.compiler.execution.strategy", "in-process") // For debugging 27 | 28 | allprojects { 29 | repositories { 30 | mavenLocal() 31 | mavenCentral() 32 | google() 33 | 34 | maven { url "https://maven.google.com" } 35 | maven { url "https://plugins.gradle.org/m2/" } 36 | } 37 | } 38 | 39 | 40 | allprojects { 41 | ext.buildMaven = { p -> repositories { maven { url p } } } 42 | 43 | repositories { 44 | mavenLocal() 45 | mavenCentral() 46 | maven { url "https://maven.google.com" } 47 | maven { url "https://plugins.gradle.org/m2/" } 48 | google() 49 | jcenter() 50 | 51 | 52 | } 53 | } 54 | 55 | 56 | kotlin { 57 | jvm() 58 | js() 59 | linuxX64("linux") { 60 | configure([compilations.main]) { 61 | tasks.getByName(compileKotlinTaskName).kotlinOptions { 62 | 63 | } 64 | } 65 | } 66 | 67 | sourceSets { 68 | commonMain { 69 | dependencies { 70 | implementation kotlin('stdlib-common') 71 | implementation project(path: ":annotations") 72 | 73 | } 74 | } 75 | commonTest { 76 | dependencies { 77 | implementation kotlin('test-common') 78 | implementation kotlin('test-annotations-common') 79 | 80 | } 81 | } 82 | 83 | jsMain { 84 | dependencies { 85 | implementation kotlin('stdlib-js') 86 | 87 | } 88 | } 89 | jsTest { 90 | dependencies { 91 | implementation kotlin('test-js') 92 | } 93 | } 94 | 95 | jvmMain { 96 | dependencies { 97 | } 98 | } 99 | jvmTest { 100 | dependencies { 101 | // implementation kotlin('test-junit') 102 | implementation group: 'junit', name: 'junit', version: '4.4' 103 | } 104 | } 105 | 106 | linuxMain { 107 | 108 | 109 | } 110 | linuxTest { 111 | } 112 | 113 | } 114 | } 115 | 116 | 117 | 118 | 119 | //./gradlew :clean :build --no-daemon -Dorg.gradle.debug=true -Dkotlin.compiler.execution.strategy="in-process" -Dkotlin.daemon.jvm.options="-Xdebug,-Xrunjdwp:transport=dt_socket\,address=5005\,server=y\,suspend=n" -------------------------------------------------------------------------------- /example/src/commonMain/kotlin/CommonAnnotated.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt 2 | 3 | import de.jensklingenberg.testAnnotations.* 4 | 5 | 6 | @TestClass 7 | class CommonAnnotated @TestConstructor constructor() { 8 | 9 | 10 | @TestConstructor 11 | constructor(name: String) : this() 12 | 13 | @TestProperty 14 | @TestField 15 | lateinit var myProperty: @TestType String 16 | 17 | var jens: String 18 | @TestPropertyGetter get() { 19 | return "Hello" 20 | } 21 | @TestPropertySetter set(value) { 22 | 23 | } 24 | 25 | @TestFunction 26 | fun firstFunction() { 27 | 28 | } 29 | @TestFunction fun functionWithExpressionBody2() = 1 + 1 30 | 31 | 32 | fun thirdFunction(@TestValueParameter param: String, @TestValueParameter param2: String) { 33 | 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /example/src/jsMain/kotlin/de/jensklingenberg/mpapt/Generated.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt 2 | 3 | import de.jensklingenberg.testAnnotations.TestClass 4 | import de.jensklingenberg.testAnnotations.TestTypeParameter 5 | 6 | @TestClass 7 | enum class TestEnum{ 8 | HEY,CIAO 9 | } 10 | 11 | 12 | @TestClass 13 | class Generated { 14 | 15 | var p : T?=null 16 | 17 | fun <@TestTypeParameter T> generic(){ 18 | 19 | } 20 | 21 | fun < T> generic2(tt : T){ 22 | 23 | } 24 | 25 | 26 | } -------------------------------------------------------------------------------- /example/src/jsMain/kotlin/de/jensklingenberg/mpapt/JSAnnotated.kt: -------------------------------------------------------------------------------- 1 | import de.jensklingenberg.testAnnotations.* 2 | 3 | @TestTypeAlias 4 | typealias WORD = String 5 | 6 | @TestAnnotationClass 7 | annotation class JSAnnotationClass 8 | 9 | 10 | @TestClass 11 | class JSAnnotated @TestConstructor constructor() { 12 | 13 | @TestConstructor 14 | constructor(name: String) : this() 15 | 16 | @TestProperty 17 | @TestField 18 | lateinit var myProperty: @TestType String 19 | 20 | var jens: String 21 | /** 22 | * HERE IS A TEXT 23 | */ 24 | @TestPropertyGetter get() { 25 | @TestExpression return "Hello" 26 | } 27 | @TestPropertySetter set(value) { 28 | 29 | } 30 | 31 | @TestFunction fun functionWithExpressionBody() = 1 + 1 32 | 33 | 34 | @TestFunction 35 | fun firstFunction() { 36 | 37 | } 38 | 39 | @TestFunction 40 | fun secondFunction() { 41 | 42 | val i = 1 43 | @TestExpression("Hello") when (i) { 44 | 1 -> { 45 | 46 | } 47 | else -> { 48 | 49 | } 50 | } 51 | 52 | } 53 | 54 | fun thirdFunction(@TestValueParameter param: String, @TestValueParameter param2: String) = Unit 55 | 56 | } -------------------------------------------------------------------------------- /example/src/jsMain/kotlin/de/jensklingenberg/mpapt/JsSecondAnnotated.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt 2 | 3 | import de.jensklingenberg.testAnnotations.* 4 | 5 | 6 | @TestClass 7 | class JsSecondAnnotated { 8 | 9 | @TestProperty 10 | val name: String? = null 11 | 12 | @TestFunction 13 | fun what() { 14 | 15 | } 16 | 17 | fun elses(@TestValueParameter param: String) { 18 | 19 | } 20 | 21 | 22 | 23 | } -------------------------------------------------------------------------------- /example/src/jsMain/kotlin/de/jensklingenberg/mpapt/TestAbstract.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt 2 | 3 | import de.jensklingenberg.testAnnotations.TestClass 4 | 5 | @TestClass 6 | abstract class TestAbstract{ 7 | 8 | } -------------------------------------------------------------------------------- /example/src/jvmMain/kotlin/de/jensklingenberg/JVMSecondAnnotated.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg 2 | 3 | import de.jensklingenberg.testAnnotations.TestClass 4 | import de.jensklingenberg.testAnnotations.TestFunction 5 | import de.jensklingenberg.testAnnotations.TestProperty 6 | import de.jensklingenberg.testAnnotations.TestValueParameter 7 | 8 | 9 | @TestClass 10 | class JVMSecondAnnotated { 11 | 12 | 13 | 14 | @TestFunction 15 | fun what() { 16 | 17 | } 18 | 19 | fun elses(@TestValueParameter param: String) { 20 | 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /example/src/jvmMain/kotlin/de/jensklingenberg/mpapt/Generated.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt 2 | 3 | import de.jensklingenberg.testAnnotations.TestClass 4 | 5 | @TestClass 6 | class Generated { 7 | 8 | } -------------------------------------------------------------------------------- /example/src/jvmMain/kotlin/de/jensklingenberg/mpapt/JVMAnnotated.kt: -------------------------------------------------------------------------------- 1 | @file:TestFile("JVMMyTestValue") 2 | 3 | package de.jensklingenberg.mpapt 4 | 5 | import de.jensklingenberg.testAnnotations.* 6 | 7 | 8 | 9 | 10 | @TestClass 11 | class Annotated @TestConstructor constructor() { 12 | 13 | @TestConstructor 14 | constructor(name: String) : this() 15 | 16 | @TestProperty 17 | @TestField 18 | lateinit var myProperty: @TestType String 19 | 20 | var jens: String 21 | @TestPropertyGetter get() { 22 | @TestExpression return "Hello" 23 | } 24 | @TestPropertySetter set(value) { 25 | 26 | } 27 | 28 | @TestFunction fun functionWithExpressionBody() = 1 + 1 29 | 30 | 31 | @TestFunction 32 | fun firstFunction() :@TestType String { 33 | @TestExpression return "" 34 | } 35 | 36 | @TestFunction 37 | fun <@TestTypeParameter T> secondFunction() { 38 | 39 | } 40 | 41 | fun thirdFunction(@TestValueParameter param: @TestType String, @TestValueParameter param2: String) { 42 | @TestLocalVariable val localHallo :String 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /example/src/linuxMain/kotlin/sample/LinuxAnnotated.kt: -------------------------------------------------------------------------------- 1 | @file:TestFile("LinuxMyTestValue") 2 | 3 | package sample 4 | 5 | import de.jensklingenberg.testAnnotations.* 6 | 7 | 8 | @TestClass 9 | class LinuxAnnotated @TestConstructor constructor() { 10 | 11 | @TestConstructor 12 | constructor(name: String) : this() 13 | 14 | @TestProperty 15 | @TestField 16 | lateinit var myProperty: @TestType String 17 | 18 | var jens: String 19 | @TestPropertyGetter get() { 20 | return "Hello" 21 | } 22 | @TestPropertySetter set(value) { 23 | 24 | } 25 | 26 | @TestFunction 27 | fun firstFunction() { 28 | 29 | } 30 | 31 | @TestFunction fun functionWithExpressionBody() = 1 + 1 32 | 33 | 34 | @TestFunction 35 | fun secondFunction() { 36 | 37 | val i = 1 38 | @TestExpression("Hello") when (i) { 39 | 1 -> { 40 | 41 | } 42 | else -> { 43 | 44 | } 45 | } 46 | 47 | } 48 | 49 | 50 | fun thirdFunction(@TestValueParameter param: String, @TestValueParameter param2: String) { 51 | 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /example/src/linuxMain/kotlin/sample/LinuxSecondAnnotated.kt: -------------------------------------------------------------------------------- 1 | package sample 2 | 3 | import de.jensklingenberg.testAnnotations.TestClass 4 | import de.jensklingenberg.testAnnotations.TestFunction 5 | import de.jensklingenberg.testAnnotations.TestProperty 6 | import de.jensklingenberg.testAnnotations.TestValueParameter 7 | 8 | 9 | @TestClass 10 | class LinuxSecondAnnotated { 11 | 12 | @TestProperty 13 | val name: String? = null 14 | 15 | @TestFunction 16 | fun what() { 17 | 18 | } 19 | 20 | fun elses(@TestValueParameter param: String) { 21 | 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.incremental=false 2 | org.gradle.daemon=false 3 | org.gradle.parallel=false 4 | org.gradle.configureondemand=false 5 | kotlin.compiler.execution.strategy=in-process 6 | kotlin.daemon.debug.log=true 7 | org.gradle.jvmargs=-Xmx6g -XX:MaxPermSize=1024m 8 | //kotlin.native.jvmArgs=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5006 9 | gnsp.disableApplyOnlyOnRootProjectEnforcement 10 | 11 | SONATYPE_NEXUS_USERNAME= 12 | SONATYPE_NEXUS_PASSWORD= 13 | nexusUsername= 14 | nexusPassword= 15 | signing.keyId= 16 | signing.password= 17 | signing.secretKeyRingFile= 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Foso/MpApt/f1f3edee8c0ee2c56ea24869c1a66d3ae0854bd0/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Aug 25 15:26:06 CEST 2019 2 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip 3 | distributionBase=GRADLE_USER_HOME 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin, switch paths to Windows format before running java 129 | if $cygwin ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=$((i+1)) 158 | done 159 | case $i in 160 | (0) set -- ;; 161 | (1) set -- "$args0" ;; 162 | (2) set -- "$args0" "$args1" ;; 163 | (3) set -- "$args0" "$args1" "$args2" ;; 164 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=$(save "$@") 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 184 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 185 | cd "$(dirname "$0")" 186 | fi 187 | 188 | exec "$JAVACMD" "$@" 189 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 34 | 35 | @rem Find java.exe 36 | if defined JAVA_HOME goto findJavaFromJavaHome 37 | 38 | set JAVA_EXE=java.exe 39 | %JAVA_EXE% -version >NUL 2>&1 40 | if "%ERRORLEVEL%" == "0" goto init 41 | 42 | echo. 43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 44 | echo. 45 | echo Please set the JAVA_HOME variable in your environment to match the 46 | echo location of your Java installation. 47 | 48 | goto fail 49 | 50 | :findJavaFromJavaHome 51 | set JAVA_HOME=%JAVA_HOME:"=% 52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 53 | 54 | if exist "%JAVA_EXE%" goto init 55 | 56 | echo. 57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 58 | echo. 59 | echo Please set the JAVA_HOME variable in your environment to match the 60 | echo location of your Java installation. 61 | 62 | goto fail 63 | 64 | :init 65 | @rem Get command-line arguments, handling Windows variants 66 | 67 | if not "%OS%" == "Windows_NT" goto win9xME_args 68 | 69 | :win9xME_args 70 | @rem Slurp the command line arguments. 71 | set CMD_LINE_ARGS= 72 | set _SKIP=2 73 | 74 | :win9xME_args_slurp 75 | if "x%~1" == "x" goto execute 76 | 77 | set CMD_LINE_ARGS=%* 78 | 79 | :execute 80 | @rem Setup the command line 81 | 82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 83 | 84 | @rem Execute Gradle 85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 86 | 87 | :end 88 | @rem End local scope for the variables with windows NT shell 89 | if "%ERRORLEVEL%"=="0" goto mainEnd 90 | 91 | :fail 92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 93 | rem the _cmd.exe /c_ return code! 94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 95 | exit /b 1 96 | 97 | :mainEnd 98 | if "%OS%"=="Windows_NT" endlocal 99 | 100 | :omega 101 | -------------------------------------------------------------------------------- /kotlin-compiler-native-plugin/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.5.10' 3 | 4 | 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 10 | classpath 'com.github.jengelman.gradle.plugins:shadow:5.0.0' 11 | 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | mavenLocal() 17 | jcenter() 18 | } 19 | } 20 | } 21 | 22 | apply plugin: "org.jetbrains.kotlin.jvm" 23 | apply plugin: "kotlin-kapt" 24 | apply plugin: "maven" 25 | apply plugin: 'com.github.johnrengelman.shadow' 26 | apply plugin: 'maven-publish' 27 | 28 | group = "de.jensklingenberg" 29 | archivesBaseName = "kotlin-compiler-native-plugin" 30 | version = "0.0.1" 31 | 32 | 33 | repositories { 34 | mavenLocal() 35 | } 36 | compileKotlin { 37 | kotlinOptions.jvmTarget = "1.8" 38 | } 39 | dependencies { 40 | implementation "org.jetbrains.kotlin:kotlin-stdlib" 41 | compileOnly "org.jetbrains.kotlin:kotlin-compiler" 42 | compileOnly "com.google.auto.service:auto-service:1.0" 43 | kapt "com.google.auto.service:auto-service:1.0" 44 | compile project(':kotlin-plugin-shared') 45 | 46 | 47 | } 48 | 49 | 50 | uploadArchives { 51 | repositories { 52 | mavenDeployer { 53 | repository(url: uri("${System.getProperty('user.home')}/.m2/repository")) 54 | } 55 | } 56 | } 57 | 58 | 59 | task fatJar(type: Jar) { 60 | manifest { 61 | attributes 'Implementation-Title': 'Gradle Jar File Example', 62 | 'Implementation-Version': version, 63 | 'Main-Class': 'de.jensklingenberg.common.NativeComponentRegistrar' 64 | } 65 | baseName = "kotlin-compiler-native-plugin" 66 | version = "0.0.1" 67 | 68 | from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } 69 | with jar 70 | } 71 | 72 | 73 | shadowJar { 74 | manifest { 75 | inheritFrom project.tasks.fatJar.manifest 76 | } 77 | baseName = "kotlin-compiler-native-plugin" 78 | version = "0.0.1" 79 | classifier = null 80 | } 81 | 82 | 83 | 84 | publishing { 85 | publications { 86 | shadow(MavenPublication) { publication -> 87 | project.shadow.component(publication) 88 | } 89 | } 90 | repositories { 91 | maven { 92 | url = uri("${System.getProperty('user.home')}/.m2/repository") 93 | } 94 | } 95 | } 96 | 97 | 98 | kapt { 99 | includeCompileClasspath = true 100 | } 101 | 102 | install{ 103 | dependsOn(shadowJar) 104 | 105 | } 106 | 107 | build{ 108 | dependsOn ':kotlin-plugin-shared:install' 109 | 110 | dependsOn(shadowJar) 111 | 112 | 113 | finalizedBy(publishToMavenLocal) 114 | } -------------------------------------------------------------------------------- /kotlin-compiler-native-plugin/src/main/java/de/jensklingenberg/common/NativeTestComponentRegistrar.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.common 2 | 3 | import com.google.auto.service.AutoService 4 | import com.intellij.mock.MockProject 5 | import de.jensklingenberg.MpAptTestProcessor 6 | import de.jensklingenberg.mpapt.common.MpAptProject 7 | import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension 8 | import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar 9 | import org.jetbrains.kotlin.config.CompilerConfiguration 10 | import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor 11 | 12 | 13 | /** 14 | * This is the entry class for a compiler plugin 15 | */ 16 | @AutoService(ComponentRegistrar::class) 17 | class NativeTestComponentRegistrar : ComponentRegistrar { 18 | 19 | override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) { 20 | val generator = MpAptTestProcessor() 21 | val mpapt = MpAptProject(generator,configuration) 22 | 23 | StorageComponentContainerContributor.registerExtension(project,mpapt) 24 | IrGenerationExtension.registerExtension(project,mpapt) 25 | } 26 | } 27 | 28 | 29 | -------------------------------------------------------------------------------- /kotlin-plugin-shared/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.5.10' 3 | 4 | 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 10 | classpath 'com.github.jengelman.gradle.plugins:shadow:5.0.0' 11 | } 12 | 13 | allprojects { 14 | repositories { 15 | 16 | } 17 | } 18 | } 19 | 20 | 21 | 22 | apply plugin: "org.jetbrains.kotlin.jvm" 23 | apply plugin: "kotlin-kapt" 24 | apply plugin: "maven" 25 | 26 | 27 | group = "de.jensklingenberg" 28 | archivesBaseName = "kotlin-plugin-shared" 29 | version = "0.0.1" 30 | 31 | install { 32 | dependsOn ':mpapt-runtime:install' 33 | 34 | repositories.mavenInstaller { 35 | pom.artifactId = archivesBaseName 36 | } 37 | } 38 | 39 | repositories { 40 | mavenLocal() 41 | mavenCentral() 42 | } 43 | 44 | dependencies { 45 | compile project(':mpapt-runtime') 46 | compile "de.jensklingenberg.mpapt.testAnnotations:annotations-jvm:0.0.1" 47 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" 48 | compileOnly "org.jetbrains.kotlin:kotlin-compiler-embeddable" 49 | compileOnly "com.google.auto.service:auto-service:1.0" 50 | kapt "com.google.auto.service:auto-service:1.0" 51 | testImplementation 'com.github.tschuchortdev:kotlin-compile-testing:1.2.5' 52 | 53 | 54 | testImplementation group: 'junit', name: 'junit', version: '4.12' 55 | 56 | testImplementation "org.assertj:assertj-core:3.11.1" 57 | testImplementation "org.mockito:mockito-core:3.1.0" 58 | testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.0.0" 59 | 60 | testImplementation 'com.squareup:kotlinpoet:1.4.0' 61 | testImplementation 'com.squareup:javapoet:1.11.1' 62 | 63 | testImplementation "com.squareup.okio:okio:2.1.0" 64 | testImplementation 'io.github.classgraph:classgraph:4.6.10' 65 | 66 | // This dependency is only needed as a "sample" compiler plugin to test that 67 | // running compiler plugins passed via the pluginClasspath CLI option works 68 | testRuntime "org.jetbrains.kotlin:kotlin-scripting-compiler:1.3.50" 69 | 70 | // The Kotlin compiler should be near the end of the list because its .jar file includes 71 | // an obsolete version of Guava 72 | testImplementation "org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.50" 73 | testImplementation "org.jetbrains.kotlin:kotlin-annotation-processing-embeddable:1.3.50" 74 | } 75 | 76 | 77 | kapt { 78 | includeCompileClasspath = true 79 | } 80 | -------------------------------------------------------------------------------- /kotlin-plugin/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.5.10' 3 | 4 | 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 10 | classpath 'com.github.jengelman.gradle.plugins:shadow:5.0.0' 11 | } 12 | 13 | allprojects { 14 | repositories { 15 | mavenLocal() 16 | jcenter() 17 | } 18 | } 19 | } 20 | 21 | 22 | 23 | apply plugin: "org.jetbrains.kotlin.jvm" 24 | apply plugin: "kotlin-kapt" 25 | apply plugin: "maven" 26 | 27 | 28 | group = "de.jensklingenberg" 29 | archivesBaseName = "kotlin-compiler-plugin" 30 | version = "0.0.1" 31 | 32 | install { 33 | repositories.mavenInstaller { 34 | pom.artifactId = 'kotlin-compiler-plugin' 35 | } 36 | } 37 | 38 | repositories { 39 | mavenCentral() 40 | mavenLocal() 41 | jcenter() 42 | } 43 | 44 | dependencies { 45 | compile project(':kotlin-plugin-shared') 46 | compileOnly "org.jetbrains.kotlin:kotlin-compiler-embeddable" 47 | compileOnly "com.google.auto.service:auto-service:1.0" 48 | kapt "com.google.auto.service:auto-service:1.0" 49 | } 50 | 51 | build{ 52 | dependsOn ':kotlin-plugin-shared:install' 53 | 54 | finalizedBy(install) 55 | } 56 | 57 | kapt { 58 | includeCompileClasspath = true 59 | } 60 | -------------------------------------------------------------------------------- /kotlin-plugin/src/main/java/de/jensklingenberg/CommonComponentRegistrar.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg 2 | 3 | import com.google.auto.service.AutoService 4 | import de.jensklingenberg.mpapt.common.MpAptProject 5 | import org.jetbrains.kotlin.codegen.extensions.ClassBuilderInterceptorExtension 6 | import org.jetbrains.kotlin.com.intellij.mock.MockProject 7 | import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar 8 | import org.jetbrains.kotlin.config.CompilerConfiguration 9 | import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor 10 | import org.jetbrains.kotlin.js.translate.extensions.JsSyntheticTranslateExtension 11 | import org.jetbrains.kotlin.resolve.extensions.SyntheticResolveExtension 12 | 13 | /** 14 | * This is the entry class for a compiler plugin 15 | */ 16 | @AutoService(ComponentRegistrar::class) 17 | open class CommonComponentRegistrar : ComponentRegistrar { 18 | 19 | override fun registerProjectComponents( 20 | project: MockProject, 21 | configuration: CompilerConfiguration 22 | ) { 23 | val processor = MpAptTestProcessor() 24 | val mpapt = MpAptProject(processor,configuration) 25 | StorageComponentContainerContributor.registerExtension(project,mpapt) 26 | ClassBuilderInterceptorExtension.registerExtension(project,mpapt) 27 | JsSyntheticTranslateExtension.registerExtension(project,mpapt) 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: MpApt- Kotlin Native/JS/JVM Annotation Processor library 2 | repo_name: MpApt 3 | 4 | repo_url: https://github.com/Foso/MpApt 5 | site_url: https://foso.github.io/MpApt 6 | theme: 7 | name: 'material' 8 | palette: 9 | primary: 'deep-orange' 10 | accent: 'deep-purple' 11 | feature: 12 | tabs: true 13 | 14 | nav: 15 | - 'Overview': index.md 16 | - 'Changelog': CHANGELOG.md 17 | -------------------------------------------------------------------------------- /mpapt-runtime/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | } 5 | dependencies { 6 | classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1' 7 | } 8 | } 9 | 10 | 11 | plugins { 12 | id 'org.jetbrains.kotlin.jvm' version '1.5.10' 13 | id 'signing' 14 | id 'maven-publish' 15 | id 'io.codearte.nexus-staging' version '0.21.0' 16 | 17 | } 18 | 19 | apply plugin: 'com.bmuschko.nexus' 20 | 21 | apply plugin: "kotlin-kapt" 22 | apply plugin: "maven" 23 | 24 | allprojects { 25 | 26 | 27 | repositories { 28 | mavenLocal() 29 | mavenCentral() 30 | maven { url "https://maven.google.com" } 31 | maven { url "https://plugins.gradle.org/m2/" } 32 | } 33 | } 34 | 35 | group = "de.jensklingenberg" 36 | archivesBaseName = "mpapt-runtime" 37 | version = "0.8.8" 38 | 39 | install { 40 | repositories.mavenInstaller { 41 | pom.artifactId = archivesBaseName 42 | } 43 | } 44 | 45 | 46 | compileKotlin { 47 | kotlinOptions { 48 | jvmTarget = "1.8" 49 | } 50 | } 51 | 52 | 53 | dependencies { 54 | compileOnly "org.jetbrains.kotlin:kotlin-compiler-embeddable:1.5.10" 55 | compileOnly "com.google.auto.service:auto-service:1.0" 56 | kapt "com.google.auto.service:auto-service:1.0" 57 | } 58 | 59 | 60 | build.finalizedBy(install) 61 | 62 | 63 | 64 | modifyPom { 65 | project { 66 | name 'MpApt' 67 | description 'Kotlin Native/JS/JVM Annotation Processor library' 68 | url 'https://github.com/Foso/MpApt' 69 | inceptionYear '2019' 70 | scm { 71 | url 'https://github.com/Foso/MpApt' 72 | connection 'scm:https://github.com/Foso/MpApt.git' 73 | developerConnection 'scm:git://github.com/Foso/MpApt.git' 74 | } 75 | licenses { 76 | license { 77 | name 'The Apache Software License, Version 2.0' 78 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt' 79 | distribution 'repo' 80 | } 81 | } 82 | developers { 83 | developer { 84 | id 'Foso' 85 | name 'Jens Klingenberg' 86 | email 'mail@jensklingenberg.de' 87 | } 88 | } 89 | } 90 | } 91 | extraArchive { 92 | sources = true 93 | tests = true 94 | javadoc = true 95 | } 96 | nexus { 97 | sign = false//true 98 | repositoryUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' 99 | snapshotRepositoryUrl = 'https://oss.sonatype.org/content/repositories/snapshots/' 100 | } 101 | 102 | nexusStaging { 103 | packageGroup = "de.jensklingenberg" //optional if packageGroup == project.getGroup() 104 | stagingProfileId = "d56228753311b0" //when not defined will be got from server using "packageGroup" 105 | } -------------------------------------------------------------------------------- /mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/common/AnnotationDescriptorExt.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt.common 2 | 3 | import org.jetbrains.kotlin.descriptors.annotations.Annotated 4 | import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor 5 | import org.jetbrains.kotlin.descriptors.annotations.Annotations 6 | import org.jetbrains.kotlin.name.FqName 7 | import org.jetbrains.kotlin.name.Name 8 | import org.jetbrains.kotlin.psi.KtAnnotatedExpression 9 | import org.jetbrains.kotlin.psi.KtAnnotationEntry 10 | import org.jetbrains.kotlin.resolve.BindingContext 11 | import org.jetbrains.kotlin.resolve.BindingTraceContext 12 | import org.jetbrains.kotlin.resolve.constants.ConstantValue 13 | import org.jetbrains.kotlin.resolve.constants.KClassValue 14 | 15 | fun AnnotationDescriptor.readArgument(key: String): ArrayList { 16 | val keyvalue: ConstantValue<*> = this.allValueArguments[Name.identifier(key)] 17 | ?: throw Exception("The key $key does not exist") 18 | return keyvalue.value as? ArrayList ?: arrayListOf() 19 | } 20 | 21 | fun AnnotationDescriptor?.simpleName(): String = this?.fqName?.shortName()?.asString() ?: "No Name" 22 | fun Annotations.hasAnnotation(fqName: String): Boolean = this.hasAnnotation(FqName(fqName)) 23 | fun Annotations.findAnnotation(fqName: String): AnnotationDescriptor? = this.findAnnotation(FqName(fqName)) 24 | 25 | 26 | fun KtAnnotatedExpression.findAnnotation(bindingTraceContext: BindingTraceContext, annotationName: String): AnnotationDescriptor? { 27 | return this.annotationEntries.mapNotNull { bindingTraceContext.get(BindingContext.ANNOTATION, it) }.firstOrNull { 28 | it.fqName?.toString().equals(annotationName) 29 | } 30 | 31 | } 32 | 33 | fun KtAnnotationEntry.toAnnotationDescriptor(bindingTraceContext: BindingTraceContext): AnnotationDescriptor? { 34 | return bindingTraceContext.get(BindingContext.ANNOTATION, this) 35 | } 36 | 37 | 38 | fun Annotated.hasAnnotation(name: String): Boolean = this.annotations.hasAnnotation(FqName(name)) 39 | fun Annotated.findAnnotation(name: String): AnnotationDescriptor? = this.annotations.findAnnotation(FqName(name)) 40 | -------------------------------------------------------------------------------- /mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/common/ClassDescriptorExt.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt.common 2 | 3 | import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor 4 | import org.jetbrains.kotlin.descriptors.ClassDescriptor 5 | import org.jetbrains.kotlin.descriptors.PropertyDescriptor 6 | import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor 7 | import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe 8 | import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyClassDescriptor 9 | import org.jetbrains.kotlin.resolve.source.PsiSourceFile 10 | import java.io.File 11 | 12 | //TODO:this doesnt work with Native 13 | fun ClassDescriptor.canonicalFilePath() = 14 | (this.source.containingFile as PsiSourceFile).psiFile.virtualFile.canonicalPath 15 | 16 | /** 17 | * This will guess the build folder from filepath 18 | * A better way is to get the build folder from gradle plugin and pass it to the compiler plugin 19 | */ 20 | fun ClassDescriptor.guessingBuildFolder(): String { 21 | 22 | tailrec fun findBuildFolder(path: String): String { 23 | val preSrcDir = path.substringBeforeLast("/src") 24 | return if (path == preSrcDir || File(preSrcDir, "build").isDirectory) { 25 | "$preSrcDir/build" 26 | } else { 27 | findBuildFolder(preSrcDir) 28 | } 29 | } 30 | 31 | val buildFolder = this.canonicalFilePath()?.let { path -> findBuildFolder(path) } 32 | 33 | return buildFolder ?: "Build folder not found" 34 | 35 | } 36 | 37 | fun ClassDescriptor.guessingSourceSetFolder(): String = 38 | canonicalFilePath()?.substringBefore(this.fqNameSafe.asString().replace(".", "/")) ?: "" 39 | 40 | fun ClassDescriptor.properties(): List = 41 | this.properties(CallableMemberDescriptor.Kind.DECLARATION) 42 | 43 | fun ClassDescriptor.cannonicalFolderPath(): String = canonicalFilePath()?.replaceAfterLast("/", "") ?: "Unknown" 44 | 45 | fun ClassDescriptor.properties(kind: CallableMemberDescriptor.Kind): List { 46 | return (this as LazyClassDescriptor).declaredCallableMembers.filter { it.kind == kind } 47 | .filterIsInstance() 48 | } 49 | 50 | fun ClassDescriptor.methods(): Collection = methods(CallableMemberDescriptor.Kind.DECLARATION) 51 | 52 | fun ClassDescriptor.methods(kind: CallableMemberDescriptor.Kind): Collection { 53 | return (this as LazyClassDescriptor) 54 | .declaredCallableMembers 55 | .filter { it.kind == kind } 56 | .filterIsInstance() 57 | } 58 | -------------------------------------------------------------------------------- /mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/common/Ext.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt.common 2 | 3 | import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity 4 | import org.jetbrains.kotlin.cli.common.messages.MessageCollector 5 | import org.jetbrains.kotlin.config.CompilerConfiguration 6 | import org.jetbrains.kotlin.descriptors.ModuleDescriptor 7 | import org.jetbrains.kotlin.name.Name 8 | import org.jetbrains.kotlin.psi.KtProperty 9 | import org.jetbrains.kotlin.resolve.constants.KClassValue 10 | import kotlin.reflect.KClass 11 | import kotlin.reflect.KProperty 12 | 13 | 14 | fun MessageCollector.warn(s: String) { 15 | report( 16 | CompilerMessageSeverity.WARNING, s 17 | ) 18 | } 19 | 20 | 21 | /** 22 | * In the Kotlin Native Compiler the configuration map has an entry with the name "target we compile for" 23 | * the value is one of [de.jensklingenberg.mpapt.utils.KonanTargetValues]. I don't know how to get the value 24 | * out of the configuration map other than parse the "toString()". This function will return an empty value 25 | * when it's used on Kotlin JVM/JS Compiler because the CompilerConfiguration doesn't have that value. 26 | */ 27 | fun CompilerConfiguration.nativeTargetPlatformName(): String { 28 | val targetKeyword = "target we compile for=" 29 | val mapString = this.toString() 30 | return if (!mapString.contains(targetKeyword)) { 31 | "" 32 | } else { 33 | this.toString().substringAfter(targetKeyword).substringBefore(",") 34 | } 35 | } 36 | 37 | fun KClass<*>.propertyNames(): List = this.members.filterIsInstance>().map { it.name } 38 | 39 | fun KClassValue.getVariableNames(moduleDescriptor: ModuleDescriptor): List = 40 | this.getArgumentType(moduleDescriptor).memberScope.getVariableNames().toList() 41 | 42 | 43 | private fun KtProperty.hasAnnotation(name: String): Boolean { 44 | return this.annotationEntries.any { name.contains(it.shortName?.identifier ?: "") } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/common/FunctionDescriptorExt.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt.common 2 | 3 | import de.jensklingenberg.mpapt.model.FunctionParameter 4 | import de.jensklingenberg.mpapt.model.Package 5 | import org.jetbrains.kotlin.com.intellij.psi.PsiElement 6 | import org.jetbrains.kotlin.descriptors.FunctionDescriptor 7 | import org.jetbrains.kotlin.descriptors.SourceElement 8 | import org.jetbrains.kotlin.js.resolve.diagnostics.findPsi 9 | import org.jetbrains.kotlin.psi.KtBlockExpression 10 | import org.jetbrains.kotlin.psi.KtProperty 11 | import org.jetbrains.kotlin.resolve.source.KotlinSourceElement 12 | import org.jetbrains.kotlin.resolve.source.getPsi 13 | 14 | 15 | /** 16 | * TODO: i dont know how to get the packageName of a function parameter 17 | */ 18 | fun FunctionDescriptor.getFunctionParameters(): List { 19 | 20 | return if (valueParameters.isNotEmpty()) { 21 | this.valueParameters.map { parameter -> 22 | // normal: 23 | //value-parameter id: kotlin.Int defined in de.jensklingenberg.mpapt.CommonAnnotated.firstFunction2[ValueParameterDescriptorImpl@725a91a6] 24 | // Typedefs: 25 | //value-parameter id: de.jensklingenberg.mpapt.Datum /* = kotlin.ranges.CharProgression */ defined in de.jensklingenberg.mpapt.CommonAnnotated.firstFunction2[ValueParameterDescriptorImpl@692444bb] 26 | val fullPackage = parameter.toString().substringAfter(": ") 27 | .substringBefore(" defined") 28 | .substringBefore(" /* =") 29 | FunctionParameter( 30 | parameter.name.asString(), 31 | parameter.type.toString().endsWith("?"), 32 | Package( 33 | fullPackage.split(".").last().replace("?", ""), 34 | fullPackage.split(".").dropLast(1).joinToString(".") 35 | ) 36 | ) 37 | }.toList() 38 | } else { 39 | emptyList() 40 | } 41 | 42 | 43 | } 44 | 45 | /** 46 | * I dont know how to get full package of the return type 47 | */ 48 | fun FunctionDescriptor.getReturnTypeImport(): String = this.toString().substringAfter("): ").substringBefore(" defined") 49 | 50 | fun FunctionDescriptor.simpleName(): String = this.name.asString() 51 | 52 | /** 53 | * getPsi() on Kotlin Native was always crashing 54 | */ 55 | fun SourceElement.safeAsPsi(): PsiElement? { 56 | if (this is KotlinSourceElement) { 57 | return this.psi 58 | } else { 59 | this.getPsi() 60 | } 61 | return null 62 | } 63 | 64 | 65 | private fun FunctionDescriptor.ktproperties(): List { 66 | return this.findPsi()?.children?.filterIsInstance()?.flatMap { it.statements.filterIsInstance() } 67 | ?: emptyList() 68 | } 69 | -------------------------------------------------------------------------------- /mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/common/ModuleDescriptorExt.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt.common 2 | 3 | import org.jetbrains.kotlin.descriptors.ModuleDescriptor 4 | 5 | fun ModuleDescriptor.simpleName() = this.name.asString().replace("<", "").replace(">", "") 6 | -------------------------------------------------------------------------------- /mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/common/MpAptProject.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt.common 2 | 3 | import de.jensklingenberg.mpapt.extension.ProcessorFinishedDetector 4 | import de.jensklingenberg.mpapt.extension.ProcessorFinishedDetectorImpl 5 | import de.jensklingenberg.mpapt.extension.StorageComponentContainerContributorImpl 6 | import de.jensklingenberg.mpapt.model.AbstractProcessor 7 | import org.jetbrains.kotlin.config.CompilerConfiguration 8 | import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor 9 | 10 | class MpAptProject(abstractProcessor: AbstractProcessor, configuration: CompilerConfiguration) : 11 | ProcessorFinishedDetector by ProcessorFinishedDetectorImpl(abstractProcessor), 12 | StorageComponentContainerContributor by StorageComponentContainerContributorImpl(abstractProcessor) 13 | { 14 | init { 15 | abstractProcessor.configuration = (configuration) 16 | abstractProcessor.onProcessingStarted() 17 | } 18 | } -------------------------------------------------------------------------------- /mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/extension/DeclarationCheckerImpl.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt.extension 2 | 3 | import de.jensklingenberg.mpapt.model.AbstractProcessor 4 | import de.jensklingenberg.mpapt.model.Element 5 | import de.jensklingenberg.mpapt.model.RoundEnvironment 6 | import org.jetbrains.kotlin.descriptors.* 7 | import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor 8 | import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor 9 | import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils 10 | import org.jetbrains.kotlin.psi.KtAnnotatedExpression 11 | import org.jetbrains.kotlin.psi.KtDeclaration 12 | import org.jetbrains.kotlin.psi.KtNamedFunction 13 | import org.jetbrains.kotlin.psi.psiUtil.blockExpressionsOrSingle 14 | import org.jetbrains.kotlin.resolve.BindingContext 15 | import org.jetbrains.kotlin.resolve.BindingTraceContext 16 | import org.jetbrains.kotlin.resolve.checkers.DeclarationChecker 17 | import org.jetbrains.kotlin.resolve.checkers.DeclarationCheckerContext 18 | import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe 19 | import org.jetbrains.kotlin.resolve.descriptorUtil.module 20 | import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyClassDescriptor 21 | 22 | /** 23 | * This class is used to detect the annotations 24 | */ 25 | class DeclarationCheckerImpl(private val processor: AbstractProcessor) : DeclarationChecker { 26 | private val filesProcessed = mutableSetOf() 27 | 28 | override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) { 29 | if (!processor.isTargetPlatformSupported()) { 30 | return 31 | } 32 | 33 | val roundEnvironment = RoundEnvironment() 34 | roundEnvironment.module = descriptor.module 35 | 36 | val supportedAnnotations = processor.getSupportedAnnotationTypes() 37 | 38 | if(!filesProcessed.contains(declaration.containingKtFile.virtualFilePath)) { 39 | AnnotationsUtils.getContainingFileAnnotations(context.trace.bindingContext, descriptor) 40 | .forEach { 41 | if (it.fqName?.asString() in supportedAnnotations) { 42 | roundEnvironment.elements.add(Element.FileElement(annotation = it)) 43 | } 44 | } 45 | filesProcessed.add(declaration.containingKtFile.virtualFilePath) 46 | } 47 | 48 | descriptor.annotations 49 | .filter { it.fqName.toString() in supportedAnnotations } 50 | .mapNotNull { baseElementsProducer(descriptor, it) } 51 | .forEach { roundEnvironment.elements.add(it) } 52 | 53 | when (descriptor) { 54 | is PropertyDescriptor -> (descriptor.backingField?.annotations?.toList() ?: listOf()) 55 | .filter { it.fqName.toString() in supportedAnnotations } 56 | .map { Element.FieldElement(descriptor.backingField!!, it) } 57 | .forEach { roundEnvironment.elements.add(it) } 58 | is SimpleFunctionDescriptor -> { 59 | descriptor.typeParameters.forEach { parameterDescriptor -> 60 | parameterDescriptor.annotations 61 | .filter { it.fqName.toString() in supportedAnnotations } 62 | .map { Element.TypeParameterElement(parameterDescriptor, it) } 63 | .forEach { roundEnvironment.elements.add(it) } 64 | } 65 | descriptor.valueParameters.forEach { valueDescription -> 66 | valueDescription.annotations 67 | .filter { it.fqName.toString() in supportedAnnotations } 68 | .map { Element.ValueParameterElement(valueDescription, it) } 69 | .forEach { roundEnvironment.elements.add(it) } 70 | } 71 | getAnnotatedExpressions(declaration).forEach { annotatedExpression -> 72 | annotatedExpression.annotationEntries 73 | .mapNotNull { (context.trace as BindingTraceContext).get(BindingContext.ANNOTATION, it) } 74 | .filter { it.fqName.toString() in supportedAnnotations } 75 | .map { Element.ExpressionElement(annotatedExpression, it, descriptor) } 76 | .forEach { roundEnvironment.elements.add(it) } 77 | } 78 | } 79 | } 80 | if(roundEnvironment.elements.isNotEmpty()) { 81 | processor.process(roundEnvironment) 82 | } 83 | } 84 | 85 | private fun getAnnotatedExpressions(declaration: KtDeclaration): List { 86 | return (declaration as KtNamedFunction).bodyExpression 87 | ?.blockExpressionsOrSingle() 88 | ?.filterIsInstance() 89 | ?.toList() ?: listOf() 90 | } 91 | 92 | private fun baseElementsProducer( 93 | descriptor: DeclarationDescriptor, 94 | annotation: AnnotationDescriptor 95 | ): Element? = when (descriptor) { 96 | is TypeAliasDescriptor -> Element.TypeAliasElement(descriptor, annotation) 97 | is SimpleFunctionDescriptor -> Element.FunctionElement( 98 | simpleName = descriptor.name.asString(), 99 | annotation = annotation, 100 | descriptor = descriptor.containingDeclaration as ClassOrPackageFragmentDescriptor, 101 | func = descriptor 102 | ) 103 | is ClassConstructorDescriptor -> Element.ClassConstructorElement(descriptor, annotation) 104 | is LazyClassDescriptor -> makeFromLazyClassDescriptor(descriptor, annotation) 105 | is ClassDescriptor -> Element.ClassElement( 106 | descriptor.name.asString(), 107 | annotation = annotation, 108 | classDescriptor = descriptor, 109 | pack = descriptor.original.containingDeclaration.fqNameSafe.asString() 110 | ) 111 | is PropertyDescriptor -> Element.PropertyElement(descriptor, annotation) 112 | is PropertyGetterDescriptor -> Element.PropertyGetterElement(descriptor, annotation) 113 | is PropertySetterDescriptor -> Element.PropertySetterElement(descriptor, annotation) 114 | is LocalVariableDescriptor -> Element.LocalVariableElement(descriptor, annotation) 115 | else -> null 116 | } 117 | 118 | private fun makeFromLazyClassDescriptor( 119 | descriptor: LazyClassDescriptor, 120 | annotation: AnnotationDescriptor 121 | ): Element = when (descriptor.kind) { 122 | ClassKind.ANNOTATION_CLASS -> Element.AnnotationClassElement( 123 | descriptor.name.asString(), 124 | annotation = annotation, 125 | classDescriptor = descriptor, 126 | pack = descriptor.original.containingDeclaration.fqNameSafe.asString() 127 | ) 128 | else -> Element.ClassElement( 129 | descriptor.name.asString(), 130 | annotation = annotation, 131 | classDescriptor = descriptor, 132 | pack = descriptor.original.containingDeclaration.fqNameSafe.asString() 133 | ) 134 | } 135 | } -------------------------------------------------------------------------------- /mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/extension/NativeIrGenerationExtension.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt.extension 2 | 3 | import de.jensklingenberg.mpapt.model.Processor 4 | import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension 5 | import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext 6 | import org.jetbrains.kotlin.ir.declarations.IrModuleFragment 7 | 8 | /** 9 | * This is only used in Native 10 | */ 11 | class NativeIrGenerationExtension(val processor: Processor) : IrGenerationExtension { 12 | 13 | 14 | override fun generate(moduleFragment: IrModuleFragment, pluginContext: IrPluginContext) { 15 | if (processor.isTargetPlatformSupported()) { 16 | processor.onProcessingOver() 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/extension/ProcessorFinishedDetector.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt.extension 2 | 3 | import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension 4 | import org.jetbrains.kotlin.codegen.extensions.ClassBuilderInterceptorExtension 5 | import org.jetbrains.kotlin.js.translate.extensions.JsSyntheticTranslateExtension 6 | 7 | interface ProcessorFinishedDetector : IrGenerationExtension, JsSyntheticTranslateExtension, ClassBuilderInterceptorExtension -------------------------------------------------------------------------------- /mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/extension/ProcessorFinishedDetectorImpl.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt.extension 2 | 3 | import de.jensklingenberg.mpapt.model.Processor 4 | import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext 5 | import org.jetbrains.kotlin.codegen.ClassBuilder 6 | import org.jetbrains.kotlin.codegen.ClassBuilderFactory 7 | import org.jetbrains.kotlin.descriptors.ClassDescriptor 8 | import org.jetbrains.kotlin.diagnostics.DiagnosticSink 9 | import org.jetbrains.kotlin.ir.declarations.IrModuleFragment 10 | import org.jetbrains.kotlin.js.translate.context.TranslationContext 11 | import org.jetbrains.kotlin.js.translate.declaration.DeclarationBodyVisitor 12 | import org.jetbrains.kotlin.psi.KtPureClassOrObject 13 | import org.jetbrains.kotlin.resolve.BindingContext 14 | import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin 15 | 16 | /** 17 | * This class is used to detect that the [DeclarationCheckerImpl] is finished with processing 18 | * 19 | */ 20 | class ProcessorFinishedDetectorImpl(val processor: Processor) : ProcessorFinishedDetector { 21 | 22 | 23 | /** 24 | * This is used to detect that the [DeclarationCheckerImpl] is finished with processing on Kotlin Native 25 | */ 26 | override fun generate(moduleFragment: IrModuleFragment, pluginContext: IrPluginContext) { 27 | if (processor.isTargetPlatformSupported()) { 28 | processor.onProcessingOver() 29 | } 30 | } 31 | 32 | /** 33 | * This is used to detect that the [DeclarationCheckerImpl] is finished with processing on KotlinJS 34 | */ 35 | override fun generateClassSyntheticParts( 36 | declaration: KtPureClassOrObject, 37 | descriptor: ClassDescriptor, 38 | translator: DeclarationBodyVisitor, 39 | context: TranslationContext 40 | ) { 41 | if (processor.isTargetPlatformSupported()) { 42 | processor.onProcessingOver() 43 | } 44 | } 45 | 46 | /** 47 | * This is used to detect that the [DeclarationCheckerImpl] is finished with processing on KotlinJVM 48 | */ 49 | override fun interceptClassBuilderFactory( 50 | interceptedFactory: ClassBuilderFactory, 51 | bindingContext: BindingContext, 52 | diagnostics: DiagnosticSink 53 | ): ClassBuilderFactory = object : ClassBuilderFactory by interceptedFactory { 54 | 55 | override fun newClassBuilder(origin: JvmDeclarationOrigin): ClassBuilder { 56 | if (processor.isTargetPlatformSupported()) { 57 | processor.onProcessingOver() 58 | } 59 | 60 | return interceptedFactory.newClassBuilder(origin) 61 | } 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/extension/StorageComponentContainerContributorImpl.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt.extension 2 | 3 | import de.jensklingenberg.mpapt.model.AbstractProcessor 4 | import org.jetbrains.kotlin.container.StorageComponentContainer 5 | import org.jetbrains.kotlin.container.useInstance 6 | import org.jetbrains.kotlin.descriptors.ModuleDescriptor 7 | import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor 8 | import org.jetbrains.kotlin.platform.TargetPlatform 9 | 10 | class StorageComponentContainerContributorImpl(private val processor: AbstractProcessor) : StorageComponentContainerContributor { 11 | 12 | /** 13 | * Here we get the targetplatform of the module 14 | */ 15 | override fun registerModuleComponents(container: StorageComponentContainer, platform: TargetPlatform, moduleDescriptor: ModuleDescriptor) { 16 | processor.activeTargetPlatform = platform 17 | container.useInstance(DeclarationCheckerImpl(processor)) 18 | } 19 | } -------------------------------------------------------------------------------- /mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/model/AbstractProcessor.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt.model 2 | 3 | import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys 4 | import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity 5 | import org.jetbrains.kotlin.cli.common.messages.MessageCollector 6 | import org.jetbrains.kotlin.config.CompilerConfiguration 7 | import org.jetbrains.kotlin.platform.SimplePlatform 8 | import org.jetbrains.kotlin.platform.TargetPlatform 9 | 10 | abstract class AbstractProcessor : Processor { 11 | 12 | var configuration: CompilerConfiguration = CompilerConfiguration() 13 | override var isRunning: Boolean = false 14 | private fun messageCollector() = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE) 15 | 16 | var activeTargetPlatform: TargetPlatform = UnknownTarget() 17 | val processingEnv = ProcessingEnvironment(messageCollector()) 18 | 19 | 20 | override fun onProcessingStarted() { 21 | isRunning = true 22 | initProcessor() 23 | } 24 | 25 | open fun initProcessor() {} 26 | 27 | fun log(message: String) { 28 | messageCollector().report( 29 | CompilerMessageSeverity.WARNING, 30 | message 31 | ) 32 | } 33 | 34 | override fun onProcessingOver() { 35 | if (isRunning) { 36 | processingOver() 37 | } 38 | isRunning = false 39 | 40 | 41 | } 42 | 43 | open fun processingOver() {} 44 | 45 | override fun getSupportedSourceVersion(): SourceVersion = SourceVersion.latest() 46 | 47 | override fun isTargetPlatformSupported(): Boolean = isTargetPlatformSupported(activeTargetPlatform) 48 | 49 | /** 50 | * This method will check if your processor is enabled for the active target platform. 51 | * By default it's enabled for every platform. You can override it and return true or false for the targets you want to support 52 | */ 53 | open fun isTargetPlatformSupported(platform: TargetPlatform) = true 54 | 55 | 56 | } 57 | 58 | class UnknownTarget : TargetPlatform(setOf(object : SimplePlatform("Unknown") { 59 | override val oldFashionedDescription: String 60 | get() = "Unknown" 61 | 62 | })) -------------------------------------------------------------------------------- /mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/model/Element.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt.model 2 | 3 | import org.jetbrains.kotlin.descriptors.* 4 | import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor 5 | import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor 6 | import org.jetbrains.kotlin.psi.KtExpression 7 | 8 | sealed class Element constructor( 9 | open val simpleName: String = "", 10 | open val path: String = "", 11 | open val elementKind: ElementKind = ElementKind.OTHER, 12 | open val annotation: AnnotationDescriptor? = null, 13 | open val pack: String = "" 14 | ) { 15 | /** 16 | * Elements annotated with [AnnotationTarget.CLASS] 17 | */ 18 | data class ClassElement( 19 | override val simpleName: String = "", 20 | override val path: String = "", 21 | override val elementKind: ElementKind = ElementKind.CLASS, 22 | override val annotation: AnnotationDescriptor? = null, 23 | override val pack: String = "", 24 | val classDescriptor: ClassDescriptor 25 | ) : Element() 26 | 27 | /** 28 | * Elements annotated with [AnnotationTarget.ANNOTATION_CLASS] 29 | */ 30 | data class AnnotationClassElement( 31 | override val simpleName: String = "", 32 | override val path: String = "", 33 | override val elementKind: ElementKind = ElementKind.CLASS, 34 | override val annotation: AnnotationDescriptor? = null, 35 | override val pack: String = "", 36 | val classDescriptor: ClassDescriptor 37 | ) : Element() 38 | 39 | /** 40 | * Elements annotated with [AnnotationTarget.FUNCTION] 41 | */ 42 | data class FunctionElement( 43 | override val simpleName: String, 44 | override val elementKind: ElementKind = ElementKind.FUNCTION, 45 | override val annotation: AnnotationDescriptor? = null, 46 | val descriptor: ClassOrPackageFragmentDescriptor, 47 | val func: FunctionDescriptor 48 | ) : Element() 49 | 50 | /** 51 | * Elements annotated with [AnnotationTarget.PROPERTY] 52 | */ 53 | data class PropertyElement(val propertyDescriptor: PropertyDescriptor, 54 | override val annotation: AnnotationDescriptor? = null, 55 | override val elementKind: ElementKind = ElementKind.PROPERTY 56 | ) : Element() 57 | 58 | /** 59 | * Elements annotated with [AnnotationTarget.VALUE_PARAMETER] 60 | */ 61 | data class ValueParameterElement(val valueParameterDescriptor: ValueParameterDescriptor, 62 | override val annotation: AnnotationDescriptor? = null, 63 | override val elementKind: ElementKind = ElementKind.VALUE_PARAMETER 64 | ) : Element() 65 | 66 | /** 67 | * Elements annotated with [AnnotationTarget.TYPE_PARAMETER] 68 | */ 69 | data class TypeParameterElement(val typeParameterDescriptor: TypeParameterDescriptor, 70 | override val annotation: AnnotationDescriptor? = null, 71 | override val elementKind: ElementKind = ElementKind.TYPE_PARAMETER 72 | ) : Element() 73 | 74 | /** 75 | * Elements annotated with [AnnotationTarget.PROPERTY_GETTER] 76 | */ 77 | data class PropertyGetterElement(val propertyGetterDescriptor: PropertyGetterDescriptor, 78 | override val annotation: AnnotationDescriptor? = null, 79 | override val elementKind: ElementKind = ElementKind.PROPERTY_GETTER 80 | ) : Element() 81 | 82 | /** 83 | * Elements annotated with [AnnotationTarget.PROPERTY_SETTER] 84 | */ 85 | data class PropertySetterElement(val propertySetterDescriptor: PropertySetterDescriptor, 86 | override val annotation: AnnotationDescriptor? = null, 87 | override val elementKind: ElementKind = ElementKind.PROPERTY_SETTER 88 | ) : Element() 89 | 90 | 91 | /** 92 | * Elements annotated with [AnnotationTarget.CONSTRUCTOR] 93 | */ 94 | data class ClassConstructorElement(val classConstructorDescriptor: ClassConstructorDescriptor, 95 | override val annotation: AnnotationDescriptor? = null, 96 | override val elementKind: ElementKind = ElementKind.CONSTRUCTOR 97 | ) : Element() 98 | 99 | /** 100 | * Elements annotated with [AnnotationTarget.LOCAL_VARIABLE] 101 | */ 102 | data class LocalVariableElement(val localVariableDescriptor: LocalVariableDescriptor, 103 | override val annotation: AnnotationDescriptor? = null, 104 | override val elementKind: ElementKind = ElementKind.LOCAL_VARIABLE 105 | ) : Element() 106 | 107 | /** 108 | * Elements annotated with [AnnotationTarget.TYPEALIAS] 109 | */ 110 | data class TypeAliasElement(val descriptor: TypeAliasDescriptor, 111 | override val annotation: AnnotationDescriptor? = null, 112 | override val elementKind: ElementKind = ElementKind.ALIAS 113 | ) : Element() 114 | 115 | /** 116 | * Elements annotated with [AnnotationTarget.FIELD] 117 | */ 118 | data class FieldElement(val descriptor: FieldDescriptor, 119 | override val annotation: AnnotationDescriptor? = null, 120 | override val elementKind: ElementKind = ElementKind.FIELD 121 | ) : Element() 122 | 123 | /** 124 | * Elements annotated with [AnnotationTarget.FILE] 125 | */ 126 | data class FileElement(override val annotation: AnnotationDescriptor? = null, 127 | override val elementKind: ElementKind = ElementKind.FILE 128 | ) : Element() 129 | 130 | /** 131 | * Elements annotated with [AnnotationTarget.EXPRESSION] 132 | */ 133 | data class ExpressionElement(val ktExpression: KtExpression, 134 | override val annotation: AnnotationDescriptor? = null, 135 | val parentDescriptor: DeclarationDescriptor, 136 | override val elementKind: ElementKind = ElementKind.EXPRESSION 137 | ) : Element() 138 | 139 | } 140 | 141 | 142 | enum class ElementKind { 143 | /** Class, interface or object, annotation class is also included */ 144 | CLASS, 145 | /** Annotation class only */ 146 | ANNOTATION_CLASS, 147 | /** Generic type parameter (unsupported yet) */ 148 | TYPE_PARAMETER, 149 | /** Property */ 150 | PROPERTY, 151 | /** Field, including property's backing field */ 152 | FIELD, 153 | /** Local variable */ 154 | LOCAL_VARIABLE, 155 | /** Value parameter of a function or a constructor */ 156 | VALUE_PARAMETER, 157 | /** Constructor only (primary or secondary) */ 158 | CONSTRUCTOR, 159 | /** Function (constructors are not included) */ 160 | FUNCTION, 161 | /** Property getter only */ 162 | PROPERTY_GETTER, 163 | /** Property setter only */ 164 | PROPERTY_SETTER, 165 | /** Type usage */ 166 | TYPE, 167 | /** Any expression */ 168 | EXPRESSION, 169 | /** File */ 170 | FILE, 171 | /** Type alias */ 172 | OTHER, 173 | /** Type alias */ 174 | ALIAS 175 | } -------------------------------------------------------------------------------- /mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/model/FunctionParameter.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt.model 2 | 3 | data class FunctionParameter( 4 | val parameterName: String, 5 | val nullable: Boolean, 6 | val packagee: Package 7 | ) 8 | 9 | data class Package(val classname: String, val packagename: String) 10 | -------------------------------------------------------------------------------- /mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/model/ProcessingEnvironment.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt.model 2 | 3 | import de.jensklingenberg.mpapt.utils.ElementUtils 4 | import org.jetbrains.kotlin.cli.common.messages.MessageCollector 5 | 6 | data class ProcessingEnvironment( 7 | open val messager: MessageCollector, 8 | val elementUtils: ElementUtils = ElementUtils() 9 | 10 | ) { 11 | fun elementUtils(): ElementUtils { 12 | return ElementUtils() 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/model/Processor.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt.model 2 | 3 | interface Processor { 4 | 5 | var isRunning: Boolean 6 | 7 | 8 | /** 9 | * This gets triggered when a new module(jvmMain,jsMain,..) is getting parsed by the processor 10 | */ 11 | fun onProcessingStarted() 12 | 13 | /** 14 | * This get triggered when the last class of a module was parsed. 15 | */ 16 | fun onProcessingOver() 17 | 18 | /** 19 | * The list of Annotations that should be detected by the processor. 20 | * 21 | */ 22 | fun getSupportedAnnotationTypes(): Set 23 | 24 | /** 25 | * TODO: Implement check for source version 26 | */ 27 | fun getSupportedSourceVersion(): SourceVersion 28 | 29 | /** 30 | * This gets triggered when a new annotation was found 31 | * */ 32 | fun process(roundEnvironment: RoundEnvironment) 33 | 34 | fun isTargetPlatformSupported(): Boolean 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/model/RoundEnvironment.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt.model 2 | 3 | import org.jetbrains.kotlin.descriptors.ModuleDescriptor 4 | 5 | class RoundEnvironment { 6 | 7 | var elements: MutableList = mutableListOf() 8 | 9 | var module: ModuleDescriptor? = null 10 | 11 | fun getElementsAnnotatedWith(annotationName: String): List = 12 | elements.filter { it.annotation?.fqName?.asString() == annotationName } 13 | 14 | fun getElementsAnnotatedWith(annotationName: List): List = 15 | elements.filter { annotationName.contains(it.annotation?.fqName?.asString()) } 16 | 17 | } 18 | 19 | -------------------------------------------------------------------------------- /mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/model/SourceVersion.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt.model 2 | 3 | enum class SourceVersion { 4 | 5 | KOTLIN_1_3, LATEST; 6 | 7 | companion object { 8 | fun latest(): SourceVersion { 9 | return LATEST 10 | } 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/utils/ElementUtils.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt.utils 2 | 3 | import de.jensklingenberg.mpapt.model.Element 4 | import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe 5 | 6 | class ElementUtils { 7 | fun getPackageOf(sourceClassElement: Element): String { 8 | when (sourceClassElement) { 9 | is Element.ClassElement -> { 10 | return sourceClassElement.classDescriptor.original.containingDeclaration.fqNameSafe.asString() 11 | } 12 | } 13 | return "" 14 | 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/utils/KaptUtils.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt.utils 2 | 3 | import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys 4 | import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation 5 | import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity 6 | import org.jetbrains.kotlin.cli.common.messages.MessageCollector 7 | import org.jetbrains.kotlin.config.CompilerConfiguration 8 | 9 | /** 10 | * This file contains extension methods to provide a similar API to the Kapt API. 11 | * The goal is not to implement the whole Api, because sometimes you can't directly 12 | * map functions to the compiler API 13 | */ 14 | 15 | /** 16 | * @param diagnosticKind Kinds of diagnostics, for example, error or warning. 17 | * @param message The message you want to print 18 | * @param compilerMessageLocation You can use this to print information where an error was raised (path,line,column) 19 | */ 20 | fun MessageCollector.printMessage(diagnosticKind: DiagnosticKind, message: String, compilerMessageLocation: CompilerMessageLocation? = CompilerMessageLocation.create(null)) { 21 | when (diagnosticKind) { 22 | DiagnosticKind.WARNING -> { 23 | this.report(CompilerMessageSeverity.WARNING, 24 | message, 25 | compilerMessageLocation) 26 | } 27 | DiagnosticKind.ERROR -> { 28 | this.report(CompilerMessageSeverity.ERROR, 29 | message, 30 | compilerMessageLocation) 31 | } 32 | DiagnosticKind.MANDATORY_WARNING -> { 33 | this.report(CompilerMessageSeverity.STRONG_WARNING, 34 | message, 35 | compilerMessageLocation) 36 | } 37 | DiagnosticKind.NOTE -> { 38 | this.report(CompilerMessageSeverity.INFO, 39 | message, 40 | compilerMessageLocation) 41 | } 42 | DiagnosticKind.LOG, DiagnosticKind.OTHER -> { 43 | this.report(CompilerMessageSeverity.LOGGING, 44 | message, 45 | compilerMessageLocation) 46 | } 47 | else -> { 48 | this.report(CompilerMessageSeverity.WARNING, 49 | message, 50 | compilerMessageLocation) 51 | } 52 | } 53 | 54 | } 55 | 56 | /** 57 | * Kinds of diagnostics, for example, error or warning. 58 | */ 59 | enum class DiagnosticKind { 60 | /** 61 | * Problem which prevents the tool's normal completion. 62 | */ 63 | ERROR, 64 | /** 65 | * Problem which does not usually prevent the tool from completing normally. 66 | */ 67 | WARNING, 68 | 69 | /** 70 | * Problem similar to a warning, but is mandated by the tool's specification. 71 | */ 72 | MANDATORY_WARNING, 73 | 74 | /** 75 | * Informative message from the tool. 76 | */ 77 | NOTE, 78 | 79 | LOG, 80 | /** 81 | * Diagnostic which does not fit within the other kinds. 82 | */ 83 | OTHER; 84 | } 85 | 86 | fun CompilerConfiguration.messager(): MessageCollector { 87 | return this.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY,MessageCollector.NONE) 88 | } -------------------------------------------------------------------------------- /mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/utils/KonanTargetValues.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt.utils 2 | 3 | /** 4 | * Got the values from org.jetbrains.kotlin.konan.target.KonanTarget 5 | */ 6 | class KonanTargetValues { 7 | companion object { 8 | val ANDROID_ARM32 = "android_arm32" 9 | val ANDROID_ARM64 = "android_arm64" 10 | val ANDROID_X64 = "android_x64" 11 | val ANDROID_X86 = "android_x86" 12 | val IOS_ARM32 = "ios_arm32" 13 | val IOS_ARM64 = "ios_arm64" 14 | val IOS_X64 = "ios_x64" 15 | val LINUX_X64 = "linux_x64" 16 | val MINGW_X86 = "mingw_x86" 17 | val MINGW_X64 = "mingw_x64" 18 | val MACOS_X64 = "macos_x64" 19 | val LINUX_ARM32_HFP = "linux_arm32_hfp" 20 | val LINUX_MIPS32 = "linux_mips32" 21 | val LINUX_MIPSEL32 = "linux_mipsel32" 22 | val WASM32 = "wasm32" 23 | val WATCHOS_ARM32 = "watchos_arm32" 24 | val WATCHOS_ARM64 = "watchos_arm64" 25 | val WATCHOS_X86 = "watchos_x86" 26 | val WATCHOS_X64 = "watchos_x64" 27 | val TVOS_ARM64 = "tvos_arm64" 28 | val TVOS_X64 = "tvos_x64" 29 | val LINUX_ARM64 = "linux_arm64" 30 | 31 | } 32 | } -------------------------------------------------------------------------------- /mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/utils/KotlinPlatformValues.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt.utils 2 | 3 | class KotlinPlatformValues { 4 | companion object { 5 | const val JS = "JS" 6 | const val JVM = "JVM" 7 | const val NATIVE = "Native" 8 | } 9 | } -------------------------------------------------------------------------------- /nativeDemo/.gitignore: -------------------------------------------------------------------------------- 1 | /ktorfit-shared/build/ 2 | /example/build/ 3 | /buildSrc/.gradle/ 4 | /.idea/ 5 | /buildSrc/build/ 6 | /native-plugin/build/ 7 | /.gradle/ 8 | /ktorfit-annotations/build/ 9 | /nativedemo-annotations/build/ 10 | /build/ 11 | -------------------------------------------------------------------------------- /nativeDemo/Contact.md: -------------------------------------------------------------------------------- 1 | Created by Jens Klingenberg 2 | * www.jensklingenberg.de 3 | 4 | 5 | Contact: 6 | * Mail: mail@jensklingenberg.de 7 | * Twitter: [@jklingenberg_](https://twitter.com/jklingenberg_) -------------------------------------------------------------------------------- /nativeDemo/Readme.md: -------------------------------------------------------------------------------- 1 | This is a (POC) demo project. 2 | It shows how to use MpApt with Kotlin Native. 3 | You can find the processor code [HERE](https://github.com/Foso/MpApt/blob/master/nativeDemo/native-plugin/src/main/java/de/jensklingenberg/MpAptTestProcessor.kt) 4 | 5 | Annotate a class with @PrintName("myvalue") and it will print at build phase: 6 | 7 |

8 | 9 |

10 | 11 | How to build: 12 | Inside the project folder run: 13 | 14 | First build the annotations module: 15 | * ./gradlew :nativedemo-annotations:publishToMavenLocal 16 | 17 | Then build the native compiler plugin: 18 | * ./gradlew :native-plugin:build 19 | 20 | Build the example module: 21 | * ./gradlew :example:build 22 | 23 | Now your annotated classes should be printed to the terminal 24 | 25 | Please note: 26 | - I haven't added the MacOS targets for the annotations module. You need to add the target in build.gradle if you want to build them. 27 | - When you run the build command a second time without changing any code, the plugin is not executed again. You need to make a change to see the log again. 28 | -------------------------------------------------------------------------------- /nativeDemo/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | //./gradlew :example:clean :example:build --no-daemon -Dorg.gradle.debug=true -Dkotlin.compiler.execution.strategy="in-process" -Dkotlin.daemon.jvm.options="-Xdebug,-Xrunjdwp:transport=dt_socket\,address=5005\,server=y\,suspend=n" -------------------------------------------------------------------------------- /nativeDemo/buildSrc/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.5.10' 3 | 4 | 5 | repositories { 6 | mavenCentral() 7 | 8 | jcenter() 9 | } 10 | dependencies { 11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 12 | classpath 'com.github.jengelman.gradle.plugins:shadow:5.0.0' 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | mavenCentral() 18 | mavenLocal() 19 | jcenter() 20 | } 21 | } 22 | } 23 | 24 | 25 | plugins { 26 | id 'org.jetbrains.kotlin.jvm' version '1.5.10' 27 | } 28 | apply plugin: "java-gradle-plugin" 29 | apply plugin: "kotlin-kapt" 30 | apply plugin: "maven" 31 | 32 | 33 | group = "de.jensklingenberg" 34 | archivesBaseName = "nativegradle" 35 | version = "1.0.0" 36 | 37 | 38 | 39 | install { 40 | repositories.mavenInstaller { 41 | pom.artifactId = archivesBaseName 42 | } 43 | } 44 | 45 | gradlePlugin { 46 | plugins { 47 | simplePlugin { 48 | id = "de.jensklingenberg.nativeplugin" // users will do `apply plugin: "de.jensklingenberg.mpapt"` 49 | implementationClass = "de.jensklingenberg.mpapt.MpAptGradlePlugin" // entry-point class 50 | } 51 | } 52 | } 53 | 54 | dependencies { 55 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" 56 | compile "org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.5.10" 57 | compileOnly "com.google.auto.service:auto-service:1.0" 58 | kapt "com.google.auto.service:auto-service:1.0" 59 | } 60 | 61 | 62 | build { 63 | dependsOn install 64 | } 65 | -------------------------------------------------------------------------------- /nativeDemo/buildSrc/src/main/kotlin/de/jensklingenberg/mpapt/MpAptGradlePlugin.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt 2 | 3 | import org.gradle.api.Project 4 | 5 | open class MpAptGradlePlugin : org.gradle.api.Plugin { 6 | override fun apply(project: Project) { 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /nativeDemo/buildSrc/src/main/kotlin/de/jensklingenberg/mpapt/MpAptGradleSubplugin.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.mpapt 2 | 3 | import com.google.auto.service.AutoService 4 | import org.gradle.api.Project 5 | import org.gradle.api.tasks.compile.AbstractCompile 6 | import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions 7 | import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation 8 | import org.jetbrains.kotlin.gradle.plugin.KotlinGradleSubplugin 9 | import org.jetbrains.kotlin.gradle.plugin.SubpluginArtifact 10 | import org.jetbrains.kotlin.gradle.plugin.SubpluginOption 11 | 12 | @AutoService(KotlinGradleSubplugin::class) // don't forget! 13 | class MpAptGradleSubplugin : KotlinGradleSubplugin { 14 | override fun apply( 15 | project: Project, 16 | kotlinCompile: AbstractCompile, 17 | javaCompile: AbstractCompile?, 18 | variantData: Any?, 19 | androidProjectHandler: Any?, 20 | kotlinCompilation: KotlinCompilation? 21 | ): List { 22 | return emptyList() 23 | 24 | } 25 | 26 | override fun isApplicable(project: Project, task: AbstractCompile) = 27 | project.plugins.hasPlugin(MpAptGradlePlugin::class.java) 28 | 29 | 30 | /** 31 | * Just needs to be consistent with the key for CommandLineProcessor#pluginId 32 | */ 33 | override fun getCompilerPluginId(): String = "MpAptPlugin" 34 | 35 | override fun getPluginArtifact(): SubpluginArtifact = SubpluginArtifact( 36 | groupId = "", 37 | artifactId = "", 38 | version = "" // remember to bump this version before any release! 39 | ) 40 | 41 | override fun getNativeCompilerPluginArtifact() = SubpluginArtifact( 42 | groupId = "de.jensklingenberg", 43 | artifactId = "native-plugin", 44 | version = "0.0.1" // remember to bump this version before any release! 45 | ) 46 | 47 | } 48 | -------------------------------------------------------------------------------- /nativeDemo/example/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | 3 | ext.buildMaven = { p -> repositories { maven { url p } } } 4 | 5 | 6 | repositories { 7 | mavenLocal() 8 | google() 9 | jcenter() 10 | mavenCentral() 11 | } 12 | 13 | dependencies { 14 | classpath "de.jensklingenberg:nativegradle:1.0.0" 15 | 16 | } 17 | 18 | } 19 | plugins { 20 | id 'org.jetbrains.kotlin.multiplatform' version '1.5.10' 21 | } 22 | 23 | 24 | System.setProperty("kotlin.compiler.execution.strategy", "in-process") // For debugging 25 | 26 | allprojects { 27 | repositories { 28 | mavenLocal() 29 | mavenCentral() 30 | google() 31 | 32 | maven { url "https://maven.google.com" } 33 | maven { url "https://plugins.gradle.org/m2/" } 34 | } 35 | } 36 | 37 | 38 | apply plugin: 'de.jensklingenberg.nativeplugin' 39 | 40 | 41 | 42 | 43 | allprojects { 44 | ext.buildMaven = { p -> repositories { maven { url p } } } 45 | 46 | repositories { 47 | mavenLocal() 48 | mavenCentral() 49 | maven { url "https://maven.google.com" } 50 | maven { url "https://plugins.gradle.org/m2/" } 51 | google() 52 | jcenter() 53 | 54 | 55 | } 56 | } 57 | 58 | 59 | kotlin { 60 | 61 | linuxX64("linux") { 62 | configure([compilations.main]) { 63 | tasks.getByName(compileKotlinTaskName).kotlinOptions { 64 | 65 | } 66 | } 67 | } 68 | sourceSets { 69 | commonMain { 70 | dependencies { 71 | implementation kotlin('stdlib-common') 72 | implementation project(":nativedemo-annotations") 73 | 74 | } 75 | } 76 | commonTest { 77 | dependencies { 78 | implementation kotlin('test-common') 79 | 80 | } 81 | } 82 | 83 | linuxMain { 84 | 85 | 86 | } 87 | 88 | } 89 | } 90 | 91 | 92 | build{ 93 | dependsOn ':nativedemo-annotations:publishToMavenLocal' 94 | } 95 | 96 | // workaround for https://youtrack.jetbrains.com/issue/KT-27170 97 | configurations { 98 | compileClasspath 99 | } -------------------------------------------------------------------------------- /nativeDemo/example/src/linuxMain/kotlin/sample/LinuxAnnotated.kt: -------------------------------------------------------------------------------- 1 | package sample 2 | import de.jensklingenberg.nativedemo.PrintName 3 | 4 | 5 | @PrintName("myvalue") 6 | class Hello() -------------------------------------------------------------------------------- /nativeDemo/gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.incremental=false 2 | org.gradle.daemon=false 3 | org.gradle.parallel=false 4 | org.gradle.configureondemand=false 5 | kotlin.compiler.execution.strategy=in-process 6 | kotlin.daemon.debug.log=true 7 | org.gradle.jvmargs=-Xmx6g -XX:MaxPermSize=1024m 8 | //kotlin.native.jvmArgs=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5006 9 | gnsp.disableApplyOnlyOnRootProjectEnforcement 10 | 11 | SONATYPE_NEXUS_USERNAME= 12 | SONATYPE_NEXUS_PASSWORD= 13 | nexusUsername= 14 | nexusPassword= 15 | signing.keyId= 16 | signing.password= 17 | signing.secretKeyRingFile= 18 | -------------------------------------------------------------------------------- /nativeDemo/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Foso/MpApt/f1f3edee8c0ee2c56ea24869c1a66d3ae0854bd0/nativeDemo/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /nativeDemo/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Aug 25 15:26:06 CEST 2019 2 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip 3 | distributionBase=GRADLE_USER_HOME 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /nativeDemo/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin, switch paths to Windows format before running java 129 | if $cygwin ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=$((i+1)) 158 | done 159 | case $i in 160 | (0) set -- ;; 161 | (1) set -- "$args0" ;; 162 | (2) set -- "$args0" "$args1" ;; 163 | (3) set -- "$args0" "$args1" "$args2" ;; 164 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=$(save "$@") 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 184 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 185 | cd "$(dirname "$0")" 186 | fi 187 | 188 | exec "$JAVACMD" "$@" 189 | -------------------------------------------------------------------------------- /nativeDemo/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 34 | 35 | @rem Find java.exe 36 | if defined JAVA_HOME goto findJavaFromJavaHome 37 | 38 | set JAVA_EXE=java.exe 39 | %JAVA_EXE% -version >NUL 2>&1 40 | if "%ERRORLEVEL%" == "0" goto init 41 | 42 | echo. 43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 44 | echo. 45 | echo Please set the JAVA_HOME variable in your environment to match the 46 | echo location of your Java installation. 47 | 48 | goto fail 49 | 50 | :findJavaFromJavaHome 51 | set JAVA_HOME=%JAVA_HOME:"=% 52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 53 | 54 | if exist "%JAVA_EXE%" goto init 55 | 56 | echo. 57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 58 | echo. 59 | echo Please set the JAVA_HOME variable in your environment to match the 60 | echo location of your Java installation. 61 | 62 | goto fail 63 | 64 | :init 65 | @rem Get command-line arguments, handling Windows variants 66 | 67 | if not "%OS%" == "Windows_NT" goto win9xME_args 68 | 69 | :win9xME_args 70 | @rem Slurp the command line arguments. 71 | set CMD_LINE_ARGS= 72 | set _SKIP=2 73 | 74 | :win9xME_args_slurp 75 | if "x%~1" == "x" goto execute 76 | 77 | set CMD_LINE_ARGS=%* 78 | 79 | :execute 80 | @rem Setup the command line 81 | 82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 83 | 84 | @rem Execute Gradle 85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 86 | 87 | :end 88 | @rem End local scope for the variables with windows NT shell 89 | if "%ERRORLEVEL%"=="0" goto mainEnd 90 | 91 | :fail 92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 93 | rem the _cmd.exe /c_ return code! 94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 95 | exit /b 1 96 | 97 | :mainEnd 98 | if "%OS%"=="Windows_NT" endlocal 99 | 100 | :omega 101 | -------------------------------------------------------------------------------- /nativeDemo/native-plugin/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.5.10' 3 | 4 | 5 | repositories { 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 10 | classpath 'com.github.jengelman.gradle.plugins:shadow:5.0.0' 11 | 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | mavenLocal() 17 | jcenter() 18 | } 19 | } 20 | } 21 | 22 | apply plugin: "org.jetbrains.kotlin.jvm" 23 | apply plugin: "kotlin-kapt" 24 | apply plugin: "maven" 25 | apply plugin: 'com.github.johnrengelman.shadow' 26 | apply plugin: 'maven-publish' 27 | 28 | group = "de.jensklingenberg" 29 | archivesBaseName = "native-plugin" 30 | version = "0.0.1" 31 | 32 | 33 | repositories { 34 | mavenLocal() 35 | } 36 | compileKotlin { 37 | kotlinOptions.jvmTarget = "1.8" 38 | } 39 | dependencies { 40 | implementation "org.jetbrains.kotlin:kotlin-stdlib" 41 | compileOnly "org.jetbrains.kotlin:kotlin-compiler" 42 | compile 'de.jensklingenberg:mpapt-runtime:0.8.8' 43 | compileOnly "com.google.auto.service:auto-service:1.0" 44 | kapt "com.google.auto.service:auto-service:1.0" 45 | compile "de.jensklingenberg.nativedemo:nativedemo-annotations-jvm:0.0.1" 46 | 47 | } 48 | 49 | 50 | uploadArchives { 51 | repositories { 52 | mavenDeployer { 53 | repository(url: uri("${System.getProperty('user.home')}/.m2/repository")) 54 | } 55 | } 56 | } 57 | 58 | 59 | task fatJar(type: Jar) { 60 | manifest { 61 | attributes 'Implementation-Title': 'Gradle Jar File Example', 62 | 'Implementation-Version': version, 63 | 'Main-Class': 'de.jensklingenberg.common.NativeComponentRegistrar' 64 | } 65 | baseName = "nativedemo-compiler" 66 | version = "0.0.1" 67 | 68 | from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } 69 | with jar 70 | } 71 | 72 | 73 | shadowJar { 74 | manifest { 75 | inheritFrom project.tasks.fatJar.manifest 76 | } 77 | baseName = "nativedemo-compiler" 78 | version = "0.0.1" 79 | classifier = null 80 | } 81 | 82 | 83 | 84 | publishing { 85 | publications { 86 | shadow(MavenPublication) { publication -> 87 | project.shadow.component(publication) 88 | } 89 | } 90 | repositories { 91 | maven { 92 | url = uri("${System.getProperty('user.home')}/.m2/repository") 93 | } 94 | } 95 | } 96 | 97 | 98 | kapt { 99 | includeCompileClasspath = true 100 | } 101 | 102 | install{ 103 | dependsOn(shadowJar) 104 | 105 | } 106 | 107 | build{ 108 | // dependsOn ':nativedemo-shared:install' 109 | 110 | dependsOn(shadowJar) 111 | 112 | 113 | finalizedBy(publishToMavenLocal) 114 | } -------------------------------------------------------------------------------- /nativeDemo/native-plugin/src/main/java/de/jensklingenberg/MpAptTestProcessor.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg 2 | 3 | 4 | import de.jensklingenberg.nativedemo.PrintName 5 | import de.jensklingenberg.mpapt.model.AbstractProcessor 6 | import de.jensklingenberg.mpapt.model.Element 7 | import de.jensklingenberg.mpapt.model.RoundEnvironment 8 | import org.jetbrains.kotlin.resolve.annotations.argumentValue 9 | 10 | class MpAptTestProcessor() : AbstractProcessor() { 11 | val TAG = "MyAnnotationProcessor" 12 | 13 | val get = PrintName::class.java.name 14 | 15 | override fun process(roundEnvironment: RoundEnvironment) { 16 | roundEnvironment.getElementsAnnotatedWith(get).forEach { element -> 17 | when (element) { 18 | is Element.ClassElement -> { 19 | log("I found @PrintName at class-> " + element.simpleName + " with the value: "+element.annotation?.argumentValue("value")) 20 | } 21 | } 22 | } 23 | } 24 | 25 | override fun isTargetPlatformSupported() = true 26 | 27 | override fun getSupportedAnnotationTypes(): Set = setOf(get) 28 | 29 | override fun processingOver() { 30 | log("$TAG***Processor over ***") 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /nativeDemo/native-plugin/src/main/java/de/jensklingenberg/NativeComponentRegistrar.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg 2 | 3 | import com.google.auto.service.AutoService 4 | import com.intellij.mock.MockProject 5 | import de.jensklingenberg.mpapt.common.MpAptProject 6 | 7 | import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension 8 | import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar 9 | import org.jetbrains.kotlin.config.CompilerConfiguration 10 | import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor 11 | 12 | /** 13 | * This is the entry class for a compiler plugin 14 | */ 15 | @AutoService(ComponentRegistrar::class) 16 | open class NativeComponentRegistrar : ComponentRegistrar { 17 | 18 | override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) { 19 | val generator = MpAptTestProcessor() 20 | val mpapt = MpAptProject(generator,configuration) 21 | 22 | StorageComponentContainerContributor.registerExtension(project,mpapt) 23 | IrGenerationExtension.registerExtension(project,mpapt) 24 | } 25 | } 26 | 27 | 28 | -------------------------------------------------------------------------------- /nativeDemo/nativedemo-annotations/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | 3 | ext.buildMaven = { p -> repositories { maven { url p } } } 4 | 5 | 6 | repositories { 7 | mavenLocal() 8 | google() 9 | jcenter() 10 | mavenCentral() 11 | } 12 | 13 | dependencies { 14 | } 15 | 16 | } 17 | 18 | plugins { 19 | id 'org.jetbrains.kotlin.multiplatform' version '1.5.10' 20 | id "maven" 21 | id("maven-publish") 22 | 23 | } 24 | 25 | group = "de.jensklingenberg.nativedemo" 26 | 27 | version = "0.0.1" 28 | 29 | 30 | repositories { 31 | mavenCentral() 32 | } 33 | 34 | kotlin { 35 | jvm() 36 | linuxX64("linux") 37 | 38 | sourceSets { 39 | commonMain { 40 | dependencies { 41 | implementation kotlin('stdlib-common') 42 | 43 | } 44 | } 45 | commonTest { 46 | dependencies { 47 | implementation kotlin('test-common') 48 | implementation kotlin('test-annotations-common') 49 | } 50 | } 51 | 52 | jsMain { 53 | dependencies { 54 | implementation kotlin('stdlib-js') 55 | 56 | } 57 | } 58 | jsTest { 59 | dependencies { 60 | implementation kotlin('test-js') 61 | } 62 | } 63 | 64 | jvmMain { 65 | dependencies { 66 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" 67 | } 68 | } 69 | jsTest { 70 | dependencies { 71 | implementation kotlin('test-js') 72 | } 73 | } 74 | 75 | linuxMain { 76 | 77 | } 78 | 79 | } 80 | } 81 | 82 | 83 | 84 | 85 | build.finalizedBy(publishToMavenLocal) -------------------------------------------------------------------------------- /nativeDemo/nativedemo-annotations/src/commonMain/kotlin/de/jensklingenberg/nativedemo/Annotations.kt: -------------------------------------------------------------------------------- 1 | package de.jensklingenberg.nativedemo 2 | 3 | @Target(AnnotationTarget.CLASS) 4 | annotation class PrintName(val value: String) 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /nativeDemo/nativedemo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Foso/MpApt/f1f3edee8c0ee2c56ea24869c1a66d3ae0854bd0/nativeDemo/nativedemo.png -------------------------------------------------------------------------------- /nativeDemo/settings.gradle: -------------------------------------------------------------------------------- 1 | include 'example' 2 | include 'native-plugin' 3 | include 'nativedemo-annotations' -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | 2 | include 'annotations' 3 | include 'example' 4 | include ':kotlin-compiler-native-plugin' 5 | include ':kotlin-plugin' 6 | include ':kotlin-plugin-shared' 7 | 8 | include ':mpapt-runtime' 9 | 10 | --------------------------------------------------------------------------------