-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Track new JavaPoet group and package name
Rename the existing interop module to javapoet-deprecated and introduce a new module called javapoet that integrates with the Palantir JavaPoet fork.
- Loading branch information
1 parent
e4e7a6f
commit 1d5b85f
Showing
22 changed files
with
713 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
public final class com/squareup/kotlinpoet/javapoet/J2kInteropKt { | ||
public static final fun toKClassName (Lcom/squareup/javapoet/ClassName;)Lcom/squareup/kotlinpoet/ClassName; | ||
public static final fun toKParameterizedTypeName (Lcom/squareup/javapoet/ParameterizedTypeName;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; | ||
public static final fun toKTypeName (Lcom/squareup/javapoet/TypeName;)Lcom/squareup/kotlinpoet/TypeName; | ||
public static final fun toKTypeVariableName (Lcom/squareup/javapoet/TypeVariableName;)Lcom/squareup/kotlinpoet/TypeVariableName; | ||
public static final fun toKWildcardTypeName (Lcom/squareup/javapoet/WildcardTypeName;)Lcom/squareup/kotlinpoet/WildcardTypeName; | ||
} | ||
|
||
public final class com/squareup/kotlinpoet/javapoet/K2jInteropKt { | ||
public static final fun toJClassName (Lcom/squareup/kotlinpoet/ClassName;Z)Lcom/squareup/javapoet/TypeName; | ||
public static synthetic fun toJClassName$default (Lcom/squareup/kotlinpoet/ClassName;ZILjava/lang/Object;)Lcom/squareup/javapoet/TypeName; | ||
public static final fun toJParameterizedOrArrayTypeName (Lcom/squareup/kotlinpoet/ParameterizedTypeName;)Lcom/squareup/javapoet/TypeName; | ||
public static final fun toJParameterizedTypeName (Lcom/squareup/kotlinpoet/ParameterizedTypeName;)Lcom/squareup/javapoet/ParameterizedTypeName; | ||
public static final fun toJTypeName (Lcom/squareup/kotlinpoet/TypeName;Z)Lcom/squareup/javapoet/TypeName; | ||
public static synthetic fun toJTypeName$default (Lcom/squareup/kotlinpoet/TypeName;ZILjava/lang/Object;)Lcom/squareup/javapoet/TypeName; | ||
public static final fun toJTypeVariableName (Lcom/squareup/kotlinpoet/TypeVariableName;)Lcom/squareup/javapoet/TypeVariableName; | ||
public static final fun toJWildcardTypeName (Lcom/squareup/kotlinpoet/WildcardTypeName;)Lcom/squareup/javapoet/WildcardTypeName; | ||
} | ||
|
||
public abstract interface annotation class com/squareup/kotlinpoet/javapoet/KotlinPoetJavaPoetPreview : java/lang/annotation/Annotation { | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
public final class com/squareup/kotlinpoet/javapoet/J2kInteropKt { | ||
public static final fun toKClassName (Lcom/squareup/javapoet/ClassName;)Lcom/squareup/kotlinpoet/ClassName; | ||
public static final fun toKParameterizedTypeName (Lcom/squareup/javapoet/ParameterizedTypeName;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; | ||
public static final fun toKTypeName (Lcom/squareup/javapoet/TypeName;)Lcom/squareup/kotlinpoet/TypeName; | ||
public static final fun toKTypeVariableName (Lcom/squareup/javapoet/TypeVariableName;)Lcom/squareup/kotlinpoet/TypeVariableName; | ||
public static final fun toKWildcardTypeName (Lcom/squareup/javapoet/WildcardTypeName;)Lcom/squareup/kotlinpoet/WildcardTypeName; | ||
} | ||
|
||
public final class com/squareup/kotlinpoet/javapoet/K2jInteropKt { | ||
public static final fun toJClassName (Lcom/squareup/kotlinpoet/ClassName;Z)Lcom/squareup/javapoet/TypeName; | ||
public static synthetic fun toJClassName$default (Lcom/squareup/kotlinpoet/ClassName;ZILjava/lang/Object;)Lcom/squareup/javapoet/TypeName; | ||
public static final fun toJParameterizedOrArrayTypeName (Lcom/squareup/kotlinpoet/ParameterizedTypeName;)Lcom/squareup/javapoet/TypeName; | ||
public static final fun toJParameterizedTypeName (Lcom/squareup/kotlinpoet/ParameterizedTypeName;)Lcom/squareup/javapoet/ParameterizedTypeName; | ||
public static final fun toJTypeName (Lcom/squareup/kotlinpoet/TypeName;Z)Lcom/squareup/javapoet/TypeName; | ||
public static synthetic fun toJTypeName$default (Lcom/squareup/kotlinpoet/TypeName;ZILjava/lang/Object;)Lcom/squareup/javapoet/TypeName; | ||
public static final fun toJTypeVariableName (Lcom/squareup/kotlinpoet/TypeVariableName;)Lcom/squareup/javapoet/TypeVariableName; | ||
public static final fun toJWildcardTypeName (Lcom/squareup/kotlinpoet/WildcardTypeName;)Lcom/squareup/javapoet/WildcardTypeName; | ||
} | ||
|
||
public abstract interface annotation class com/squareup/kotlinpoet/javapoet/KotlinPoetJavaPoetPreview : java/lang/annotation/Annotation { | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (C) 2021 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. | ||
*/ | ||
plugins { | ||
kotlin("jvm") | ||
} | ||
|
||
tasks.jar { | ||
manifest { | ||
attributes("Automatic-Module-Name" to "com.squareup.kotlinpoet.javapoet") | ||
} | ||
} | ||
|
||
dependencies { | ||
api(projects.kotlinpoet) | ||
api(libs.javapoet.deprecated) | ||
testImplementation(libs.kotlin.junit) | ||
testImplementation(libs.truth) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
POM_ARTIFACT_ID=kotlinpoet-javapoet | ||
POM_NAME=KotlinPoet (JavaPoet Interop) | ||
POM_DESCRIPTION=Extensions for interop with JavaPoet. | ||
POM_PACKAGING=jar |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
public final class com/squareup/kotlinpoet/javapoet/J2kInteropKt { | ||
public static final fun toKClassName (Lcom/squareup/javapoet/ClassName;)Lcom/squareup/kotlinpoet/ClassName; | ||
public static final fun toKParameterizedTypeName (Lcom/squareup/javapoet/ParameterizedTypeName;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; | ||
public static final fun toKTypeName (Lcom/squareup/javapoet/TypeName;)Lcom/squareup/kotlinpoet/TypeName; | ||
public static final fun toKTypeVariableName (Lcom/squareup/javapoet/TypeVariableName;)Lcom/squareup/kotlinpoet/TypeVariableName; | ||
public static final fun toKWildcardTypeName (Lcom/squareup/javapoet/WildcardTypeName;)Lcom/squareup/kotlinpoet/WildcardTypeName; | ||
public final class com/squareup/kotlinpoet/palantirjavapoet/J2kInteropKt { | ||
public static final fun toKClassName (Lcom/palantir/javapoet/ClassName;)Lcom/squareup/kotlinpoet/ClassName; | ||
public static final fun toKParameterizedTypeName (Lcom/palantir/javapoet/ParameterizedTypeName;)Lcom/squareup/kotlinpoet/ParameterizedTypeName; | ||
public static final fun toKTypeName (Lcom/palantir/javapoet/TypeName;)Lcom/squareup/kotlinpoet/TypeName; | ||
public static final fun toKTypeVariableName (Lcom/palantir/javapoet/TypeVariableName;)Lcom/squareup/kotlinpoet/TypeVariableName; | ||
public static final fun toKWildcardTypeName (Lcom/palantir/javapoet/WildcardTypeName;)Lcom/squareup/kotlinpoet/WildcardTypeName; | ||
} | ||
|
||
public final class com/squareup/kotlinpoet/javapoet/K2jInteropKt { | ||
public static final fun toJClassName (Lcom/squareup/kotlinpoet/ClassName;Z)Lcom/squareup/javapoet/TypeName; | ||
public static synthetic fun toJClassName$default (Lcom/squareup/kotlinpoet/ClassName;ZILjava/lang/Object;)Lcom/squareup/javapoet/TypeName; | ||
public static final fun toJParameterizedOrArrayTypeName (Lcom/squareup/kotlinpoet/ParameterizedTypeName;)Lcom/squareup/javapoet/TypeName; | ||
public static final fun toJParameterizedTypeName (Lcom/squareup/kotlinpoet/ParameterizedTypeName;)Lcom/squareup/javapoet/ParameterizedTypeName; | ||
public static final fun toJTypeName (Lcom/squareup/kotlinpoet/TypeName;Z)Lcom/squareup/javapoet/TypeName; | ||
public static synthetic fun toJTypeName$default (Lcom/squareup/kotlinpoet/TypeName;ZILjava/lang/Object;)Lcom/squareup/javapoet/TypeName; | ||
public static final fun toJTypeVariableName (Lcom/squareup/kotlinpoet/TypeVariableName;)Lcom/squareup/javapoet/TypeVariableName; | ||
public static final fun toJWildcardTypeName (Lcom/squareup/kotlinpoet/WildcardTypeName;)Lcom/squareup/javapoet/WildcardTypeName; | ||
public final class com/squareup/kotlinpoet/palantirjavapoet/K2jInteropKt { | ||
public static final fun toJClassName (Lcom/squareup/kotlinpoet/ClassName;Z)Lcom/palantir/javapoet/TypeName; | ||
public static synthetic fun toJClassName$default (Lcom/squareup/kotlinpoet/ClassName;ZILjava/lang/Object;)Lcom/palantir/javapoet/TypeName; | ||
public static final fun toJParameterizedOrArrayTypeName (Lcom/squareup/kotlinpoet/ParameterizedTypeName;)Lcom/palantir/javapoet/TypeName; | ||
public static final fun toJParameterizedTypeName (Lcom/squareup/kotlinpoet/ParameterizedTypeName;)Lcom/palantir/javapoet/ParameterizedTypeName; | ||
public static final fun toJTypeName (Lcom/squareup/kotlinpoet/TypeName;Z)Lcom/palantir/javapoet/TypeName; | ||
public static synthetic fun toJTypeName$default (Lcom/squareup/kotlinpoet/TypeName;ZILjava/lang/Object;)Lcom/palantir/javapoet/TypeName; | ||
public static final fun toJTypeVariableName (Lcom/squareup/kotlinpoet/TypeVariableName;)Lcom/palantir/javapoet/TypeVariableName; | ||
public static final fun toJWildcardTypeName (Lcom/squareup/kotlinpoet/WildcardTypeName;)Lcom/palantir/javapoet/WildcardTypeName; | ||
} | ||
|
||
public abstract interface annotation class com/squareup/kotlinpoet/javapoet/KotlinPoetJavaPoetPreview : java/lang/annotation/Annotation { | ||
public abstract interface annotation class com/squareup/kotlinpoet/palantirjavapoet/KotlinPoetJavaPoetPreview : java/lang/annotation/Annotation { | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
POM_ARTIFACT_ID=kotlinpoet-javapoet | ||
POM_ARTIFACT_ID=kotlinpoet-palantirjavapoet | ||
POM_NAME=KotlinPoet (JavaPoet Interop) | ||
POM_DESCRIPTION=Extensions for interop with JavaPoet. | ||
POM_PACKAGING=jar |
146 changes: 146 additions & 0 deletions
146
interop/javapoet/src/main/kotlin/com/squareup/kotlinpoet/palantirjavapoet/K2jInterop.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
/* | ||
* Copyright (C) 2021 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.palantirjavapoet | ||
|
||
import com.palantir.javapoet.ArrayTypeName | ||
import com.squareup.kotlinpoet.ANY | ||
import com.squareup.kotlinpoet.ARRAY | ||
import com.squareup.kotlinpoet.BOOLEAN | ||
import com.squareup.kotlinpoet.BOOLEAN_ARRAY | ||
import com.squareup.kotlinpoet.BYTE | ||
import com.squareup.kotlinpoet.BYTE_ARRAY | ||
import com.squareup.kotlinpoet.CHAR | ||
import com.squareup.kotlinpoet.CHAR_ARRAY | ||
import com.squareup.kotlinpoet.CHAR_SEQUENCE | ||
import com.squareup.kotlinpoet.DOUBLE | ||
import com.squareup.kotlinpoet.DOUBLE_ARRAY | ||
import com.squareup.kotlinpoet.Dynamic | ||
import com.squareup.kotlinpoet.ENUM | ||
import com.squareup.kotlinpoet.FLOAT | ||
import com.squareup.kotlinpoet.FLOAT_ARRAY | ||
import com.squareup.kotlinpoet.INT | ||
import com.squareup.kotlinpoet.INT_ARRAY | ||
import com.squareup.kotlinpoet.LIST | ||
import com.squareup.kotlinpoet.LONG | ||
import com.squareup.kotlinpoet.LONG_ARRAY | ||
import com.squareup.kotlinpoet.LambdaTypeName | ||
import com.squareup.kotlinpoet.MAP | ||
import com.squareup.kotlinpoet.MUTABLE_LIST | ||
import com.squareup.kotlinpoet.MUTABLE_MAP | ||
import com.squareup.kotlinpoet.MUTABLE_SET | ||
import com.squareup.kotlinpoet.SET | ||
import com.squareup.kotlinpoet.SHORT | ||
import com.squareup.kotlinpoet.SHORT_ARRAY | ||
import com.squareup.kotlinpoet.STAR | ||
import com.squareup.kotlinpoet.STRING | ||
import com.squareup.kotlinpoet.U_BYTE | ||
import com.squareup.kotlinpoet.U_BYTE_ARRAY | ||
import com.squareup.kotlinpoet.U_INT | ||
import com.squareup.kotlinpoet.U_INT_ARRAY | ||
import com.squareup.kotlinpoet.U_LONG | ||
import com.squareup.kotlinpoet.U_LONG_ARRAY | ||
import com.squareup.kotlinpoet.U_SHORT | ||
import com.squareup.kotlinpoet.U_SHORT_ARRAY | ||
|
||
@KotlinPoetJavaPoetPreview | ||
public fun KClassName.toJClassName(boxIfPrimitive: Boolean = false): JTypeName { | ||
return when (copy(nullable = false)) { | ||
BOOLEAN -> JTypeName.BOOLEAN.boxIfPrimitive(boxIfPrimitive || isNullable) | ||
BYTE, U_BYTE -> JTypeName.BYTE.boxIfPrimitive(boxIfPrimitive || isNullable) | ||
CHAR -> JTypeName.CHAR.boxIfPrimitive(boxIfPrimitive || isNullable) | ||
SHORT, U_SHORT -> JTypeName.SHORT.boxIfPrimitive(boxIfPrimitive || isNullable) | ||
INT, U_INT -> JTypeName.INT.boxIfPrimitive(boxIfPrimitive || isNullable) | ||
LONG, U_LONG -> JTypeName.LONG.boxIfPrimitive(boxIfPrimitive || isNullable) | ||
FLOAT -> JTypeName.FLOAT.boxIfPrimitive(boxIfPrimitive || isNullable) | ||
DOUBLE -> JTypeName.DOUBLE.boxIfPrimitive(boxIfPrimitive || isNullable) | ||
ANY -> JClassName.OBJECT | ||
CHAR_SEQUENCE -> PoetInterop.CN_JAVA_CHAR_SEQUENCE | ||
STRING -> PoetInterop.CN_JAVA_STRING | ||
LIST, MUTABLE_LIST -> PoetInterop.CN_JAVA_LIST | ||
SET, MUTABLE_SET -> PoetInterop.CN_JAVA_SET | ||
MAP, MUTABLE_MAP -> PoetInterop.CN_JAVA_MAP | ||
BOOLEAN_ARRAY -> ArrayTypeName.of(JTypeName.BOOLEAN) | ||
BYTE_ARRAY, U_BYTE_ARRAY -> ArrayTypeName.of(JTypeName.BYTE) | ||
CHAR_ARRAY -> ArrayTypeName.of(JTypeName.CHAR) | ||
SHORT_ARRAY, U_SHORT_ARRAY -> ArrayTypeName.of(JTypeName.SHORT) | ||
INT_ARRAY, U_INT_ARRAY -> ArrayTypeName.of(JTypeName.INT) | ||
LONG_ARRAY, U_LONG_ARRAY -> ArrayTypeName.of(JTypeName.LONG) | ||
FLOAT_ARRAY -> ArrayTypeName.of(JTypeName.FLOAT) | ||
DOUBLE_ARRAY -> ArrayTypeName.of(JTypeName.DOUBLE) | ||
ENUM -> PoetInterop.CN_JAVA_ENUM | ||
else -> { | ||
if (simpleNames.size == 1) { | ||
JClassName.get(packageName, simpleName) | ||
} else { | ||
JClassName.get(packageName, simpleNames.first(), *simpleNames.drop(1).toTypedArray()) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@KotlinPoetJavaPoetPreview | ||
public fun KParameterizedTypeName.toJParameterizedOrArrayTypeName(): JTypeName { | ||
return when (rawType) { | ||
ARRAY -> { | ||
val componentType = typeArguments.firstOrNull()?.toJTypeName() | ||
?: throw IllegalStateException("Array with no type! $this") | ||
ArrayTypeName.of(componentType) | ||
} | ||
else -> { | ||
JParameterizedTypeName.get( | ||
rawType.toJClassName() as JClassName, | ||
*typeArguments.map { it.toJTypeName(boxIfPrimitive = true) }.toTypedArray(), | ||
) | ||
} | ||
} | ||
} | ||
|
||
@KotlinPoetJavaPoetPreview | ||
public fun KParameterizedTypeName.toJParameterizedTypeName(): JParameterizedTypeName { | ||
check(rawType != ARRAY) { | ||
"Array type! JavaPoet arrays are a custom TypeName. Use this function only for things you know are not arrays" | ||
} | ||
return toJParameterizedOrArrayTypeName() as JParameterizedTypeName | ||
} | ||
|
||
@KotlinPoetJavaPoetPreview | ||
public fun KTypeVariableName.toJTypeVariableName(): JTypeVariableName { | ||
return JTypeVariableName.get(name, *bounds.map { it.toJTypeName(boxIfPrimitive = true) }.toTypedArray()) | ||
} | ||
|
||
@KotlinPoetJavaPoetPreview | ||
public fun KWildcardTypeName.toJWildcardTypeName(): JWildcardTypeName { | ||
return if (this == STAR) { | ||
JWildcardTypeName.subtypeOf(JClassName.OBJECT) | ||
} else if (inTypes.size == 1) { | ||
JWildcardTypeName.supertypeOf(inTypes[0].toJTypeName()) | ||
} else { | ||
JWildcardTypeName.subtypeOf(outTypes[0].toJTypeName()) | ||
} | ||
} | ||
|
||
@KotlinPoetJavaPoetPreview | ||
public fun KTypeName.toJTypeName(boxIfPrimitive: Boolean = false): JTypeName { | ||
return when (this) { | ||
is KClassName -> toJClassName(boxIfPrimitive) | ||
Dynamic -> throw IllegalStateException("Not applicable in Java!") | ||
// TODO should we return a ParameterizedTypeName of the KFunction? | ||
is LambdaTypeName -> throw IllegalStateException("Not applicable in Java!") | ||
is KParameterizedTypeName -> toJParameterizedOrArrayTypeName() | ||
is KTypeVariableName -> toJTypeVariableName() | ||
is KWildcardTypeName -> toJWildcardTypeName() | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...oet/src/main/kotlin/com/squareup/kotlinpoet/palantirjavapoet/KotlinPoetJavaPoetPreview.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (C) 2021 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.palantirjavapoet | ||
|
||
import kotlin.annotation.AnnotationTarget.CLASS | ||
import kotlin.annotation.AnnotationTarget.FUNCTION | ||
import kotlin.annotation.AnnotationTarget.PROPERTY | ||
import kotlin.annotation.AnnotationTarget.TYPEALIAS | ||
|
||
/** | ||
* Indicates that a given API is part of the experimental KotlinPoet JavaPoet support and is | ||
* subject to API changes. | ||
*/ | ||
@RequiresOptIn | ||
@Retention(AnnotationRetention.BINARY) | ||
@Target(CLASS, FUNCTION, PROPERTY, TYPEALIAS) | ||
public annotation class KotlinPoetJavaPoetPreview |
27 changes: 27 additions & 0 deletions
27
interop/javapoet/src/main/kotlin/com/squareup/kotlinpoet/palantirjavapoet/PoetInterop.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (C) 2021 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.palantirjavapoet | ||
|
||
/** Various JavaPoet and KotlinPoet representations of some common types. */ | ||
@OptIn(KotlinPoetJavaPoetPreview::class) | ||
internal object PoetInterop { | ||
internal val CN_JAVA_CHAR_SEQUENCE = JClassName.get("java.lang", "CharSequence") | ||
internal val CN_JAVA_STRING = JClassName.get("java.lang", "String") | ||
internal val CN_JAVA_LIST = JClassName.get("java.util", "List") | ||
internal val CN_JAVA_SET = JClassName.get("java.util", "Set") | ||
internal val CN_JAVA_MAP = JClassName.get("java.util", "Map") | ||
internal val CN_JAVA_ENUM = JClassName.get("java.lang", "Enum") | ||
} |
Oops, something went wrong.