Skip to content

Commit

Permalink
Convert IntelliJ plugin to Kotlin (#502)
Browse files Browse the repository at this point in the history
Summary:
> [!NOTE]
> This requires #501 to be merged first

This PR is the basis for future improvements of the plugin. In this PR, the plugin code is converted to Kotlin, the configurable is recreated with the Kotlin UI DSL, and the goal is to maintain the existing behaviours.

The only small change is that the style dropdown in the configurable is disabled when ktfmt is disabled.

Pull Request resolved: #502

Reviewed By: strulovich

Differential Revision: D60968984

Pulled By: hick209

fbshipit-source-id: 467ce14d21d06c783d8e9254e913f966dcbff8ca
  • Loading branch information
rock3r authored and facebook-github-bot committed Aug 8, 2024
1 parent 1ae24d9 commit 5d876ca
Show file tree
Hide file tree
Showing 15 changed files with 322 additions and 586 deletions.
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,26 @@ All notable changes to the ktfmt project (starting on v0.51) should be documente

The format is based on [Keep a Changelog](http://keepachangelog.com/).

## [Unreleased]
## [1.0.0 Unreleased]

### Changed
- All styles managing trailing commas now (https://github.com/facebook/ktfmt/issues/216, https://github.com/facebook/ktfmt/issues/442)


## [0.52 Unreleased]

### Fixed
- IntelliJ plugin crash (https://github.com/facebook/ktfmt/pull/501)
- Ordering of `@property` and `@param` in KDoc (https://github.com/facebook/ktfmt/pull/498)

### Changed
- KotlinLang style also managing trailing commas (https://github.com/facebook/ktfmt/issues/216, https://github.com/facebook/ktfmt/issues/442)
- Converted IntelliJ plugin to Kotlin (https://github.com/facebook/ktfmt/pull/502)

### Added
- More stability tests (https://github.com/facebook/ktfmt/pull/488)


## [0.51]

### Added
Expand Down
17 changes: 5 additions & 12 deletions ktfmt_idea_plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,19 @@ import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType.IntellijIdeaC

plugins {
java
alias(libs.plugins.kotlin)
alias(libs.plugins.intelliJPlatform)
alias(libs.plugins.spotless)
alias(libs.plugins.ktfmt)
}

val ktfmtVersion = rootProject.file("../version.txt").readText().trim()
val pluginVersion = "1.1"
val pluginVersion = "1.2"

group = "com.facebook"

version = "$pluginVersion.$ktfmtVersion"

java {
toolchain {
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_17
}
}
kotlin { jvmToolchain(17) }

repositories {
mavenCentral()
Expand All @@ -50,8 +46,7 @@ dependencies {
zipSigner()
}

implementation("com.facebook", "ktfmt", ktfmtVersion)
implementation(libs.googleJavaFormat)
implementation("com.facebook:ktfmt:$ktfmtVersion")
}

intellijPlatform {
Expand All @@ -65,8 +60,6 @@ intellijPlatform {
pluginVerification { ides { recommended() } }
}

spotless { java { googleJavaFormat(libs.versions.googleJavaFormat.get()) } }

val runIntellij242 by
intellijPlatformTesting.runIde.registering {
type = IntellijIdeaCommunity
Expand Down
10 changes: 4 additions & 6 deletions ktfmt_idea_plugin/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
[versions]
googleJavaFormat = "1.23.0"
kotlin = "2.0.0"

# plugins
gradlePlugin-intelliJPlatform = "2.0.0"
gradlePlugin-spotless = "6.25.0"

[libraries]
googleJavaFormat = { module = "com.google.googlejavaformat:google-java-format", version.ref = "googleJavaFormat" }
gradlePlugin-ktfmt = "0.19.0"

[plugins]
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
intelliJPlatform = { id = "org.jetbrains.intellij.platform", version.ref = "gradlePlugin-intelliJPlatform" }
spotless = { id = "com.diffplug.spotless", version.ref = "gradlePlugin-spotless" }
ktfmt = { id = "com.ncorti.ktfmt.gradle", version.ref = "gradlePlugin-ktfmt" }

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5d876ca

Please sign in to comment.