Skip to content

Commit

Permalink
Full migration to LSP4IJ
Browse files Browse the repository at this point in the history
Signed-off-by: Uladzislau <[email protected]>
  • Loading branch information
KUGDev committed Aug 7, 2024
1 parent 913c559 commit 7c42343
Show file tree
Hide file tree
Showing 18 changed files with 1,568 additions and 268 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ name: Build
on: [push, workflow_dispatch]

jobs:
build:
build-intellij:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./intellij-plugin
steps:
- name: Small check
shell: bash
run: echo ${{ defaults.run.working-directory }}

- name: Checkout the plugin GitHub repository
uses: actions/checkout@v4

Expand All @@ -24,6 +31,10 @@ jobs:
shell: bash
run: pwd && ls -la

- name: Test plugin
shell: bash
run: ./gradlew test

- name: Build plugin
shell: bash
run: ./gradlew buildPlugin
Expand Down
42 changes: 37 additions & 5 deletions intellij-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/*
* Copyright (c) 2024 IBA Group.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project
* Contributors:
* IBA Group
* Zowe Community
*/

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
Expand All @@ -16,10 +20,15 @@ plugins {
id("java")
id("org.jetbrains.kotlin.jvm") version "1.9.21"
id("org.jetbrains.intellij") version "1.16.1"
id("org.jetbrains.kotlinx.kover") version "0.8.1"
}

group = properties("pluginGroup").get()
version = properties("pluginVersion").get()
val lsp4ijVersion = "0.3.0"
val kotestVersion = "5.9.1"
val mockkVersion = "1.13.11"
val junitVersion = "1.10.2"

repositories {
mavenCentral()
Expand All @@ -29,7 +38,22 @@ repositories {
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
intellij {
version.set(properties("platformVersion").get())
plugins.set(listOf("org.jetbrains.plugins.textmate", "com.redhat.devtools.lsp4ij:0.0.1"))
// pluginsRepositories {
// custom("https://plugins.jetbrains.com/plugins/nightly/23257")
// }
plugins.set(listOf("org.jetbrains.plugins.textmate", "com.redhat.devtools.lsp4ij:$lsp4ijVersion"))
}

dependencies {
// ===== Test env setup =====
// Kotest
testImplementation("io.kotest:kotest-runner-junit5:$kotestVersion")
testImplementation("io.kotest:kotest-assertions-core:$kotestVersion")
// MockK
testImplementation("io.mockk:mockk:$mockkVersion")
// JUnit Platform (needed for Kotest)
testImplementation("org.junit.platform:junit-platform-launcher:$junitVersion")
// ==========================
}

tasks {
Expand All @@ -43,8 +67,16 @@ tasks {
}

patchPluginXml {
version.set(properties("pluginVersion").get())
sinceBuild.set(properties("pluginSinceBuild").get())
untilBuild.set(properties("pluginUntilBuild").get())
version = properties("pluginVersion")
sinceBuild = properties("pluginSinceBuild")
untilBuild = properties("pluginUntilBuild")
}

test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
finalizedBy("koverHtmlReport")
}
}
1 change: 0 additions & 1 deletion intellij-plugin/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ pluginGroup = org.zowe

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 232
pluginUntilBuild = 241.*
Empty file modified intellij-plugin/gradlew
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2024 IBA Group.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBA Group
* Zowe Community
*/

package org.zowe.pli

import com.intellij.openapi.project.Project
import com.intellij.openapi.project.ProjectManager
import com.intellij.openapi.project.ProjectManagerListener
import org.zowe.pli.state.PliPluginState
import org.zowe.pli.state.InitializationOnly
import org.zowe.pli.state.LanguageSupportStateService

/** PL/I project manager listener. Listens to projects changes and react to them respectively */
class PliProjectManagerListener : ProjectManagerListener {

/**
* Delete TextMate bundle if the last opened project is being closed
* (the only possible way to handle plug-in's TextMate bundle to be deleted when the plug-in is uninstalled)
*/
@OptIn(InitializationOnly::class)
override fun projectClosing(project: Project) {
val lsStateService = LanguageSupportStateService.instance
val pluginState = lsStateService.getPluginState(project) { PliPluginState(project) }

if (isLastProjectClosing() && (pluginState.isLSPClientReady() || pluginState.isLSPServerConnectionReady())) {
pluginState.unloadLSPClient {}
pluginState.finishDeinitialization {}
}
}

/** Check if the project being closed is the last one that was opened */
private fun isLastProjectClosing(): Boolean {
return ProjectManager.getInstance().openProjects.size == 1
}

}
233 changes: 0 additions & 233 deletions intellij-plugin/src/main/kotlin/org/zowe/pli/init/PliPluginState.kt

This file was deleted.

Loading

0 comments on commit 7c42343

Please sign in to comment.