Skip to content

Commit

Permalink
Merge pull request #7 from JetBrains-Research/fix-generating
Browse files Browse the repository at this point in the history
Fix primitive generation
  • Loading branch information
AnastasiaTuchina authored Jul 26, 2023
2 parents 6e0cd5a + 1dc3045 commit 5893a44
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ And then apply it to the project you are working on:

```kotlin
plugins {
id("io.kinference.primitives") version "0.1.23" apply true
id("io.kinference.primitives") version "0.1.24" apply true
}
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

group = "io.kinference.primitives"
//also change version in PluginConstants.kt
version = "0.1.23"
version = "0.1.24"

plugins {
kotlin("multiplatform") version "1.8.10" apply false
Expand Down
6 changes: 3 additions & 3 deletions gradle-plugin-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompilerExecutionStrategy

plugins {
kotlin("multiplatform") version "1.9.0" apply true
id("io.kinference.primitives") version "0.1.23"
id("io.kinference.primitives") version "0.1.24"
}

group = "io.kinference.primitives"
version = "0.1.22"
version = "0.1.24"

repositories {
mavenCentral()
Expand All @@ -25,7 +25,7 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
api("io.kinference.primitives:primitives-annotations:0.1.23")
api("io.kinference.primitives:primitives-annotations:0.1.24")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.kinference.primitives.generator.processor

import io.kinference.primitives.annotations.*
import io.kinference.primitives.generator.isPluginAnnotation
import io.kinference.primitives.types.PrimitiveArray
import io.kinference.primitives.types.PrimitiveType
Expand All @@ -15,7 +16,15 @@ internal class RemovalProcessor(private val context: BindingContext) {
companion object {
private val WHITESPACE_TO_DELETE: Key<Boolean> = Key.create("WHITESPACE_TO_DELETE")

private val importsToRemove = setOf(PrimitiveType::class.qualifiedName, PrimitiveArray::class.qualifiedName)
private val importsToRemove = setOf(
PrimitiveType::class.qualifiedName,
PrimitiveArray::class.qualifiedName,
BindPrimitives::class.qualifiedName,
FilterPrimitives::class.qualifiedName,
GenerateNameFromPrimitives::class.qualifiedName,
GeneratePrimitives::class.qualifiedName,
SpecifyPrimitives::class.qualifiedName,
)
}

fun shouldRemoveImport(directive: KtImportDirective): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ internal class ReplacementProcessor(private val context: BindingContext, private
type in defaultReplacements -> {
defaultReplacements[type]!!.invoke(primitive)
}

(target.isKtClassOrObject() && target.containingDeclaration!!.isAnnotatedWith<GenerateNameFromPrimitives>()) ||
(target.isNamedFunction() || target.isKtClassOrObject()) && target.isAnnotatedWith<GenerateNameFromPrimitives>() -> {
expression.text.specialize(primitive)
}

(target.isCompanion() || target.isConstructor()) && target.containingDeclaration!!.isAnnotatedWith<GenerateNameFromPrimitives>() -> {
name.specialize(primitive)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package io.kinference.primitives.utils

object PluginConstants {
const val PLUGIN_ID = "io.kinference.primitives.kotlin-plugin"
const val VERSION = "0.1.23"
const val VERSION = "0.1.24"
const val GROUP_ID = "io.kinference.primitives"
const val KOTLIN_PLUGIN_ARTIFACT_ID = "kotlin-plugin"
const val ANNOTATIONS_ARTIFACT_ID = "primitives-annotations"
Expand Down

0 comments on commit 5893a44

Please sign in to comment.