diff options
author | Zac Sweers <zac.sweers@gmail.com> | 2021-09-20 12:31:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-20 12:31:50 -0400 |
commit | 575c4691c62685fc290c3888725491d7ba18859a (patch) | |
tree | 55e34d7d291257de957d03ac28500a42b0fa7e91 /interop/kotlinx-metadata/src/main/kotlin/com/squareup/kotlinpoet | |
parent | ce6c873198d90ea07100daf1ede5b56d515e21df (diff) | |
download | kotlinpoet-575c4691c62685fc290c3888725491d7ba18859a.tar.gz |
Unify `TypeAliasTag` API between metadata and KSP (#1152)
* Extract TypeAliasTag for reuse and simplify API in KSP
* Update TestProcessor implementation for new alias API
This is based on the implementation for metadata in Moshi, and possibly worth promoting as a util to KotlinPoet itself
* I am once again asking IntelliJ to actually rename imports
* Spotless
Diffstat (limited to 'interop/kotlinx-metadata/src/main/kotlin/com/squareup/kotlinpoet')
2 files changed, 2 insertions, 26 deletions
diff --git a/interop/kotlinx-metadata/src/main/kotlin/com/squareup/kotlinpoet/metadata/specs/kmTypes.kt b/interop/kotlinx-metadata/src/main/kotlin/com/squareup/kotlinpoet/metadata/specs/kmTypes.kt index 59a49085..c556b830 100644 --- a/interop/kotlinx-metadata/src/main/kotlin/com/squareup/kotlinpoet/metadata/specs/kmTypes.kt +++ b/interop/kotlinx-metadata/src/main/kotlin/com/squareup/kotlinpoet/metadata/specs/kmTypes.kt @@ -30,6 +30,7 @@ import com.squareup.kotlinpoet.metadata.isNullable import com.squareup.kotlinpoet.metadata.isPrimary import com.squareup.kotlinpoet.metadata.isReified import com.squareup.kotlinpoet.metadata.isSuspend +import com.squareup.kotlinpoet.tags.TypeAliasTag import kotlinx.metadata.KmClass import kotlinx.metadata.KmClassifier import kotlinx.metadata.KmClassifier.Class @@ -158,7 +159,7 @@ internal fun KmType.toTypeName( // type in tags for reference. val abbreviatedTypeName = it.toTypeName(typeParamResolver) abbreviatedTypeName.copy( - tags = mapOf(TypeNameAliasTag::class to TypeNameAliasTag(finalType)) + tags = mapOf(TypeAliasTag::class to TypeAliasTag(finalType)) ) } ?: finalType } diff --git a/interop/kotlinx-metadata/src/main/kotlin/com/squareup/kotlinpoet/metadata/specs/tags.kt b/interop/kotlinx-metadata/src/main/kotlin/com/squareup/kotlinpoet/metadata/specs/tags.kt deleted file mode 100644 index a2cbe0f3..00000000 --- a/interop/kotlinx-metadata/src/main/kotlin/com/squareup/kotlinpoet/metadata/specs/tags.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2019 Square, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.squareup.kotlinpoet.metadata.specs - -import com.squareup.kotlinpoet.TypeName - -/** - * This tag indicates that this [TypeName] represents a `typealias` type. - * - * @property [type] the underlying type for this alias. - */ -public class TypeNameAliasTag(public val type: TypeName) |