Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for context-receivers (#1233)
* Add API for context receivers * Use existing opt-in annotation and make context-receivers not nullable * Remove collection overloads * Revert unwanted code style changes * Add wrongly remove @jvmoverloads annotation * Add code generator and tests * Apply requested changes - Use proper experimental annotation - Remove not needed overloads - Move contextReceivers parameter to the end * Update kotlinpoet/src/main/java/com/squareup/kotlinpoet/FunSpec.kt Co-authored-by: Zac Sweers <pandanomic@gmail.com> * Apply requested changes - Add more tests - Add new-line after context() * Update test for suggestion * Apply suggestions from code review Co-authored-by: Egor Andreevich <github@egorand.dev> * Apply requested changes * Rename contextReceiver to contextReceivers * Fix compiler error * Update kotlinpoet/src/main/java/com/squareup/kotlinpoet/FunSpec.kt Co-authored-by: Egor Andreevich <github@egorand.dev> * Fix compiler errors in tests * Run spotless * Update kotlinpoet/src/main/java/com/squareup/kotlinpoet/LambdaTypeName.kt Co-authored-by: Zac Sweers <pandanomic@gmail.com> * Apply requested changes * Don't emit context receiver spacing if there are no context receivers * Apply suggestions from code review Co-authored-by: Egor Andreevich <github@egorand.dev> Co-authored-by: Zac Sweers <pandanomic@gmail.com> Co-authored-by: Egor Andreevich <github@egorand.dev>
- Loading branch information
1 parent
eee9256
commit 6d919af
Showing
6 changed files
with
205 additions
and
9 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
29 changes: 29 additions & 0 deletions
29
kotlinpoet/src/main/java/com/squareup/kotlinpoet/ExperimentalKotlinPoetApi.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,29 @@ | ||
/* | ||
* Copyright (C) 2022 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 | ||
|
||
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 experimental and subject to change. | ||
*/ | ||
@RequiresOptIn | ||
@Retention(AnnotationRetention.BINARY) | ||
@Target(CLASS, FUNCTION, PROPERTY, TYPEALIAS) | ||
public annotation class ExperimentalKotlinPoetApi |
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
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