Skip to content

Commit

Permalink
update dependencies for latest intelliJ, add details to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ummcheng committed Jan 4, 2021
1 parent 829a904 commit 779bb4e
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 37 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Serenade for IntelliJ includes editor support and tab management.

## Prerequisites

1. IntelliJ IDEA 2020.2 (latest)
1. IntelliJ IDEA 2020.3.1 (latest)
1.
```
brew install ktlint
Expand All @@ -28,6 +28,16 @@ Serenade for IntelliJ includes editor support and tab management.
## Development
1. In IntelliJ IDEA, add the Plugin SDK: https://jetbrains.org/intellij/sdk/docs/basics/getting_started/setting_up_environment.html
1. In File > Project Structure ... be sure that the right JDKs are selected, from the installed IntelliJ IDEA, and selected everywhere:
![](readme/sdk.png)
![](readme/sdk2.png)
![](readme/project.png)
![](readme/modules.png)
1. `ktlint -F "**/*.kt*"` should find and fix any lint issues.
## Manual build
Expand Down
15 changes: 7 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ plugins {
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.3.72"
id("org.jetbrains.kotlin.plugin.serialization") version "1.3.70"
id("org.jetbrains.kotlin.jvm") version "1.4.30-M1"
id("org.jetbrains.kotlin.plugin.serialization") version "1.4.30-M1"
// gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
id("org.jetbrains.intellij") version "0.4.21"
id("org.jetbrains.intellij") version "0.6.5"
// gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
id("org.jetbrains.changelog") version "0.4.0"
id("org.jetbrains.changelog") version "0.6.2"
// detekt linter - read more: https://detekt.github.io/detekt/kotlindsl.html
id("io.gitlab.arturbosch.detekt") version "1.10.0"
// ktlint linter - read more: https://github.com/JLLeitschuh/ktlint-gradle
id("org.jlleitschuh.gradle.ktlint") version "9.2.1"
id("org.jlleitschuh.gradle.ktlint") version "9.4.1"
}

// Import variables from gradle.properties file
Expand All @@ -32,7 +32,7 @@ val platformDownloadSources: String by project

group = pluginGroup
version = pluginVersion
val ktorVersion = "1.3.2"
val ktorVersion = "1.5.0"

// Configure project's dependencies
repositories {
Expand All @@ -47,11 +47,10 @@ dependencies {
implementation("io.ktor:ktor-client-cio:$ktorVersion") {
exclude(group = "org.slf4j", module = "slf4j-api")
}
implementation("io.ktor:ktor-client-js:$ktorVersion")
implementation("io.ktor:ktor-client-okhttp:$ktorVersion") {
exclude(group = "org.slf4j", module = "slf4j-api")
}
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:1.0-M1-1.4.0-rc")
}

// Configure gradle-intellij-plugin plugin.
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ pluginSinceBuild = 201
pluginUntilBuild = 203.*

platformType = IC
platformVersion = 2020.2
platformVersion = 2020.3
platformDownloadSources = true
Binary file added readme/modules.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added readme/project.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added readme/sdk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added readme/sdk2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ import io.ktor.client.features.websocket.DefaultClientWebSocketSession
import io.ktor.http.cio.websocket.Frame
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.serialization.json.Json
import kotlinx.serialization.* // ktlint-disable no-wildcard-imports
import java.awt.datatransfer.DataFlavor
import java.awt.datatransfer.StringSelection

class CommandHandler(private val project: Project) {
private val notifier = Notifier(project)
private val json = Json(jsonConfiguration)
private var webSocketSession: DefaultClientWebSocketSession? = null

fun handle(
Expand Down Expand Up @@ -141,8 +140,7 @@ class CommandHandler(private val project: Project) {
GlobalScope.launch {
webSocketSession?.send(
Frame.Text(
json.stringify(
Response.serializer(),
json.encodeToString(
Response(
"callback",
ResponseData(callback = callback, data = data)
Expand Down
12 changes: 6 additions & 6 deletions src/main/kotlin/ai/serenade/intellij/services/DataTypes.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ai.serenade.intellij.services

import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonConfiguration
import kotlinx.serialization.* // ktlint-disable no-wildcard-imports
import kotlinx.serialization.json.Json

// From client app
@Serializable
Expand Down Expand Up @@ -77,8 +77,8 @@ data class NestedData(
var tabs: List<String>? = null
)

val jsonConfiguration = JsonConfiguration.Stable.copy(
encodeDefaults = false, // don't include all the null values
ignoreUnknownKeys = true, // don't break on parsing unknown responses
val json = Json {
encodeDefaults = false; // don't include all the null values
ignoreUnknownKeys = true; // don't break on parsing unknown responses
isLenient = true // empty strings
)
}
9 changes: 4 additions & 5 deletions src/main/kotlin/ai/serenade/intellij/services/IpcService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlinx.serialization.json.Json
import kotlinx.serialization.* // ktlint-disable no-wildcard-imports
import java.net.ConnectException
import java.util.UUID

Expand All @@ -25,7 +25,7 @@ class IpcService(private val project: Project) {
private val client = HttpClient {
install(WebSockets)
}
private val json = Json(jsonConfiguration)

// app name for the client
private val appName = "intellij"
private var id: String = UUID.randomUUID().toString()
Expand Down Expand Up @@ -93,8 +93,7 @@ class IpcService(private val project: Project) {
// Send text frame of heartbeat
webSocketSession?.send(
Frame.Text(
json.stringify(
Response.serializer(),
json.encodeToString(
Response(
"heartbeat",
ResponseData(
Expand All @@ -109,7 +108,7 @@ class IpcService(private val project: Project) {

private fun onMessage(frame: Frame.Text) {
try {
val request = json.parse(Request.serializer(), frame.readText())
val request = json.decodeFromString<Request>(frame.readText())
if (request.message == "response") {
// executes commands and sends callback via webSocketSession
commandHandler.handle(request.data, webSocketSession!!)
Expand Down
14 changes: 2 additions & 12 deletions src/main/kotlin/ai/serenade/intellij/services/Settings.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package ai.serenade.intellij.services

import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonConfiguration
import kotlinx.serialization.* // ktlint-disable no-wildcard-imports
import java.nio.file.Files
import java.nio.file.Paths

Expand All @@ -24,15 +22,7 @@ class Settings {
"{}"
}

private val json = Json(
JsonConfiguration.Stable.copy(
encodeDefaults = false, // don't include all the null values
ignoreUnknownKeys = true, // don't break on parsing unknown responses
isLenient = true // empty strings
)
)

private val settings = json.parse(SettingsFile.serializer(), settingsFile)
private val settings = json.decodeFromString<SettingsFile>(settingsFile)

fun installed(): Boolean {
return settings.installed ?: false
Expand Down

0 comments on commit 779bb4e

Please sign in to comment.