mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-30 18:27:49 +08:00
kotlin.md: update links
This commit is contained in:
parent
fdd1021468
commit
1f489de6fc
@ -5,12 +5,12 @@
|
||||
## Why Kotlin?
|
||||
|
||||
Using Kotlin to write plugins for the IntelliJ Platform is very similar to writing plugins in Java.
|
||||
Existing plugin developers can get started by converting boilerplate Java classes to their Kotlin equivalents by using the [J2K compiler](https://kotlinlang.org/docs/tutorials/mixing-java-kotlin-intellij.html#converting-an-existing-java-file-to-kotlin-with-j2k) bundled with the IntelliJ Platform (versions 143.+), and developers can easily mix and match Kotlin classes with their existing Java code.
|
||||
Existing plugin developers can get started by converting boilerplate Java classes to their Kotlin equivalents by using the [J2K compiler](https://kotlinlang.org/docs/mixing-java-kotlin-intellij.html#converting-an-existing-java-file-to-kotlin-with-j2k) bundled with the IntelliJ Platform (versions 143.+), and developers can easily mix and match Kotlin classes with their existing Java code.
|
||||
|
||||
In addition to [null safety](https://kotlinlang.org/docs/reference/null-safety.html) and [type-safe builders](https://kotlinlang.org/docs/reference/type-safe-builders.html), the Kotlin language offers many convenient features for plugin development, which make plugins easier to read and simpler to maintain.
|
||||
Much like [Kotlin for Android](https://kotlinlang.org/docs/tutorials/kotlin-android.html), the IntelliJ Platform makes extensive use of callbacks, which are easy to express as [lambdas](https://kotlinlang.org/docs/reference/lambdas.html) in Kotlin.
|
||||
In addition to [null safety](https://kotlinlang.org/docs/null-safety.html) and [type-safe builders](https://kotlinlang.org/docs/type-safe-builders.html), the Kotlin language offers many convenient features for plugin development, which make plugins easier to read and simpler to maintain.
|
||||
Much like [Kotlin for Android](https://kotlinlang.org/docs/android-overview.html), the IntelliJ Platform makes extensive use of callbacks, which are easy to express as [lambdas](https://kotlinlang.org/docs/lambdas.html) in Kotlin.
|
||||
|
||||
Likewise, it is easy to customize the behavior of internal classes in IntelliJ IDEA, with [extensions](https://kotlinlang.org/docs/reference/extensions.html).
|
||||
Likewise, it is easy to customize the behavior of internal classes in IntelliJ IDEA, with [extensions](https://kotlinlang.org/docs/extensions.html).
|
||||
For example, it is common practice to [guard logging statements](https://www.slf4j.org/faq.html#logging_performance) to avoid the cost of parameter construction, leading to the following ceremony when using the log:
|
||||
|
||||
```java
|
||||
@ -41,11 +41,11 @@ To learn more about building IntelliJ Platform plugins with Kotlin, this tutoria
|
||||
|
||||
Plugins targeting the IntelliJ Platform versions 143 and above are easy to migrate: just start writing Kotlin.
|
||||
The IDE already bundles the necessary Kotlin plugins and libraries, requiring no further configuration.
|
||||
For detailed instructions, please refer to the [Kotlin documentation](https://kotlinlang.org/docs/tutorials/getting-started.html).
|
||||
For detailed instructions, please refer to the [Kotlin documentation](https://kotlinlang.org/docs/getting-started.html).
|
||||
|
||||
## Kotlin Gradle Plugin
|
||||
|
||||
For plugins already using the [Gradle Build System](gradle_build_system.md), or those that require precise control over the Kotlin build process, we recommend using the [kotlin-gradle-plugin](https://kotlinlang.org/docs/reference/using-gradle.html#configuring-dependencies).
|
||||
For plugins already using the [Gradle Build System](gradle_build_system.md), or those that require precise control over the Kotlin build process, we recommend using the [kotlin-gradle-plugin](https://kotlinlang.org/docs/gradle.html#configuring-dependencies).
|
||||
This [Gradle plugin](https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-gradle-plugin-core) greatly simplifies building Kotlin projects in a controlled and reproducible manner.
|
||||
|
||||
Your `build.gradle` file may look like so:
|
||||
@ -94,9 +94,9 @@ Starting with 4.4, Gradle supports `build.gradle.kts`, an alternative to `build.
|
||||
|
||||
There are many good resources for learning how to write build scripts for an IntelliJ plugin with Kotlin script, like
|
||||
[intellij-rust](https://github.com/intellij-rust/intellij-rust/blob/master/build.gradle.kts),
|
||||
[julia-intellij](https://github.com/ice1000/julia-intellij/blob/master/build.gradle.kts),
|
||||
[julia-intellij](https://github.com/JuliaEditorSupport/julia-intellij/blob/master/build.gradle.kts),
|
||||
[covscript-intellij](https://github.com/covscript/covscript-intellij/blob/master/build.gradle.kts) or
|
||||
[zig-intellij](https://github.com/ice1000/zig-intellij/blob/master/build.gradle.kts).
|
||||
[zig-intellij](https://github.com/ice1000/intellij-zig/blob/master/build.gradle.kts).
|
||||
|
||||
Additionally, explore IntelliJ Platform Explorer's [list of open-source plugins](https://jb.gg/ipe?buildSystem=gradle_kts) using Gradle KTS
|
||||
|
||||
@ -142,7 +142,7 @@ intellij {
|
||||
## UI in Kotlin
|
||||
|
||||
The best way to create user interfaces with Kotlin is to use a [type safe DSL](kotlin_ui_dsl.md) for building forms.
|
||||
Using a GUI designer with Kotlin is currently [not supported](https://youtrack.jetbrains.com/issue/KT-6660).
|
||||
Using a GUI designer with Kotlin is currently [not supported](https://youtrack.jetbrains.com/issue/KTIJ-791).
|
||||
|
||||
## Handling Kotlin Code
|
||||
|
||||
@ -153,9 +153,9 @@ Depending on exact functionality, a plugin can also target [UAST (Unified Abstra
|
||||
|
||||
## Caution
|
||||
|
||||
Plugins *must* use Kotlin classes to implement declarations in the [plugin configuration file](plugin_configuration_file.md).
|
||||
Plugins *must* use [Kotlin classes](https://kotlinlang.org/docs/classes.html) to implement declarations in the [plugin configuration file](plugin_configuration_file.md).
|
||||
When registering an extension, the platform uses a dependency injection framework to instantiate these classes.
|
||||
For this reason, plugins *must not* use [Kotlin objects](https://kotlinlang.org/docs/reference/object-declarations.html) to implement any `plugin.xml` declarations.
|
||||
For this reason, plugins *must not* use [Kotlin objects](https://kotlinlang.org/docs/object-declarations.html) to implement any `plugin.xml` declarations.
|
||||
|
||||
## Examples
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user