Skip to content

Commit

Permalink
Make multiplatform expect/actual implicitly actualizing declarations …
Browse files Browse the repository at this point in the history
…with java classes on jvm
  • Loading branch information
serjsysoev committed Sep 4, 2024
1 parent 42bb869 commit 7bc931a
Show file tree
Hide file tree
Showing 45 changed files with 1,419 additions and 55 deletions.
17 changes: 11 additions & 6 deletions multiplatform-annotations/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.gradle.jvm.tasks.Jar
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
Expand Down Expand Up @@ -60,17 +61,21 @@ kotlin {
compileOnly("org.jetbrains.kotlin:kotlin-stdlib")
}
}

val nonJvmMain by creating {}
}

targets.onEach {
if (it.platformType != KotlinPlatformType.jvm) {
it.compilations.getByName("main").source(sourceSets.getByName("nonJvmMain"))
}
}

/**
* @Nls contains enum class. Kotlin automatically generates
* `.entries` method for every enum and adds @NotNull to it.
* This disables `.entries` generation.
*/
targets.all {
compilations.all {
compilerOptions.configure {
freeCompilerArgs.add("-XXLanguage:-EnumEntries")
optIn.add("kotlin.ExperimentalMultiplatform")
freeCompilerArgs.add("-Xexpect-actual-classes")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
package org.intellij.lang.annotations

@Pattern("\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*")
annotation class Identifier
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
expect annotation class Identifier()
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ import org.jetbrains.annotations.NonNls
AnnotationTarget.LOCAL_VARIABLE,
AnnotationTarget.ANNOTATION_CLASS
)
annotation class Language(
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
expect annotation class Language(
/**
* Language name like "JAVA", "HTML", "XML", "RegExp", etc.
* The complete list of supported languages is not specified. However, at least the following languages should be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ import org.jetbrains.annotations.NonNls
AnnotationTarget.LOCAL_VARIABLE,
AnnotationTarget.ANNOTATION_CLASS
)
annotation class Pattern(
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
expect annotation class Pattern(
/**
* A regular expression that matches all the valid string literals that assigned to the annotated variables,
* passed as arguments to the annotated parameters, or returned from the annotated methods.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ import org.jetbrains.annotations.NonNls
AnnotationTarget.ANNOTATION_CLASS
)
@Language("RegExp")
annotation class RegExp(
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
expect annotation class RegExp(
/**
* A constant prefix that is assumed to be implicitly added before the regular expression.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ package org.intellij.lang.annotations
AnnotationTarget.LOCAL_VARIABLE,
AnnotationTarget.VALUE_PARAMETER
)
annotation class Subst(val value: String)
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
expect annotation class Subst(val value: String)
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,8 @@ package org.jetbrains.annotations
*
* @since 18.0.0
*/
class ApiStatus private constructor() {
/**
* Prohibited default constructor.
*/
init {
throw AssertionError("ApiStatus should not be instantiated")
}

@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
expect class ApiStatus private constructor() {
/**
*
* Indicates that a public API of the annotated element (class, method or field) is not in stable state yet. It may be renamed, changed or
Expand Down Expand Up @@ -60,7 +54,8 @@ class ApiStatus private constructor() {
AnnotationTarget.FIELD,
AnnotationTarget.FILE
)
annotation class Experimental
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
annotation class Experimental()

/**
* Indicates that the annotated element (class, method, field, etc) must not be considered as a public API. It's made visible to allow
Expand Down Expand Up @@ -89,7 +84,8 @@ class ApiStatus private constructor() {
AnnotationTarget.FIELD,
AnnotationTarget.FILE
)
annotation class Internal
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
annotation class Internal()

/**
*
Expand All @@ -111,6 +107,7 @@ class ApiStatus private constructor() {
AnnotationTarget.FIELD,
AnnotationTarget.FILE
)
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
annotation class Obsolete(
/**
* Specifies in which version the API became obsolete.
Expand Down Expand Up @@ -139,6 +136,7 @@ class ApiStatus private constructor() {
AnnotationTarget.FIELD,
AnnotationTarget.FILE
)
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
annotation class ScheduledForRemoval(
/**
* Specifies in which version the API will be removed.
Expand All @@ -165,6 +163,7 @@ class ApiStatus private constructor() {
AnnotationTarget.FIELD,
AnnotationTarget.FILE
)
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
annotation class AvailableSince(
/**
* Specifies a version where the annotation API firstly appeared.
Expand Down Expand Up @@ -194,7 +193,8 @@ class ApiStatus private constructor() {
AnnotationTarget.PROPERTY_GETTER,
AnnotationTarget.PROPERTY_SETTER
)
annotation class NonExtendable
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
annotation class NonExtendable()

/**
*
Expand All @@ -219,5 +219,6 @@ class ApiStatus private constructor() {
AnnotationTarget.PROPERTY_GETTER,
AnnotationTarget.PROPERTY_SETTER
)
annotation class OverrideOnly
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
annotation class OverrideOnly()
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,8 @@ package org.jetbrains.annotations
*
* @author egor
*/
class Async private constructor() {
/**
* Prohibited default constructor.
*/
init {
throw AssertionError("Async should not be instantiated")
}

@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
expect class Async private constructor() {
/**
* Indicates that the marked method schedules async computation.
* Scheduled object is either `this`, or the annotated parameter value.
Expand All @@ -41,7 +35,8 @@ class Async private constructor() {
AnnotationTarget.CONSTRUCTOR,
AnnotationTarget.VALUE_PARAMETER
)
annotation class Schedule
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
annotation class Schedule()

/**
* Indicates that the marked method executes async computation.
Expand All @@ -56,5 +51,6 @@ class Async private constructor() {
AnnotationTarget.CONSTRUCTOR,
AnnotationTarget.VALUE_PARAMETER
)
annotation class Execute
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
annotation class Execute()
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ package org.jetbrains.annotations
AnnotationTarget.CONSTRUCTOR,
AnnotationTarget.CLASS
)
annotation class Blocking
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
expect annotation class Blocking()
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ package org.jetbrains.annotations
@MustBeDocumented
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.CLASS, AnnotationTarget.TYPE)
annotation class BlockingExecutor
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
expect annotation class BlockingExecutor()
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ package org.jetbrains.annotations
AnnotationTarget.CLASS,
AnnotationTarget.FILE
)
annotation class CheckReturnValue
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
expect annotation class CheckReturnValue()
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ package org.jetbrains.annotations
AnnotationTarget.PROPERTY_SETTER,
AnnotationTarget.CONSTRUCTOR
)
annotation class Contract(
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
expect annotation class Contract(
/**
* Contains the contract clauses describing causal relations between call arguments and the returned value
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,14 @@ import org.intellij.lang.annotations.Language
/**
* @since 18.0.0
*/
class Debug private constructor() {
/**
* Prohibited default constructor.
*/
init {
throw AssertionError("Debug should not be instantiated")
}

@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
expect class Debug private constructor() {
/**
* Allows to change the presentation of an object in debuggers
*/
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.BINARY)
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
annotation class Renderer(
/**
* Expression to be evaluated and used as the textual representation of the object.<br></br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ package org.jetbrains.annotations
@Retention(
AnnotationRetention.BINARY
)
annotation class MustBeInvokedByOverriders
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
expect annotation class MustBeInvokedByOverriders()
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ package org.jetbrains.annotations
AnnotationTarget.TYPE,
AnnotationTarget.FILE
)
annotation class Nls(val capitalization: Capitalization = Capitalization.NotSpecified) {
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
expect annotation class Nls(val capitalization: Capitalization = Capitalization.NotSpecified) {
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
enum class Capitalization {
NotSpecified,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ package org.jetbrains.annotations
AnnotationTarget.CONSTRUCTOR,
AnnotationTarget.CLASS
)
annotation class NonBlocking
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
expect annotation class NonBlocking()
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ package org.jetbrains.annotations
@MustBeDocumented
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.CLASS, AnnotationTarget.TYPE)
annotation class NonBlockingExecutor
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
expect annotation class NonBlockingExecutor()
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ package org.jetbrains.annotations
AnnotationTarget.TYPE,
AnnotationTarget.FILE
)
annotation class NonNls
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
expect annotation class NonNls()
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ package org.jetbrains.annotations
AnnotationTarget.FIELD,
AnnotationTarget.TYPE,
)
annotation class PropertyKey(
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
expect annotation class PropertyKey(
/**
* The full-qualified name of the resource bundle in which the property keys must
* be present. Consists of a full-qualified name of the package corresponding to the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ package org.jetbrains.annotations
@MustBeDocumented
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.TYPE)
annotation class Range(
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
expect annotation class Range(
/**
* @return minimal allowed value (inclusive)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ package org.jetbrains.annotations
AnnotationTarget.FIELD,
AnnotationTarget.CLASS
)
annotation class TestOnly
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
expect annotation class TestOnly()
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ package org.jetbrains.annotations
@MustBeDocumented
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.TYPE)
annotation class Unmodifiable
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
expect annotation class Unmodifiable()
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ package org.jetbrains.annotations
AnnotationTarget.FIELD,
AnnotationTarget.CLASS
)
annotation class VisibleForTesting
@kotlin.jvm.ImplicitlyActualizedByJvmDeclaration
expect annotation class VisibleForTesting()
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* 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 org.intellij.lang.annotations

@Pattern("\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*")
actual annotation class Identifier
Loading

0 comments on commit 7bc931a

Please sign in to comment.