Skip to content

Commit 5ae9bd1

Browse files
committed
Full migration to LSP4IJ
Signed-off-by: Uladzislau <leksilonchikk@gmail.com>
1 parent 913c559 commit 5ae9bd1

18 files changed

+1570
-270
lines changed

intellij-plugin/.github/workflows/build.yml renamed to .github/workflows/build.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@ name: Build
33
on: [push, workflow_dispatch]
44

55
jobs:
6-
build:
6+
build-intellij:
77
runs-on: ubuntu-latest
8+
# Changing WORKING_DIRECTORY, don't forget to change defaults.run.working-directory
9+
env:
10+
WORKING_DIRECTORY: intellij-plugin
11+
defaults:
12+
run:
13+
working-directory: ./intellij-plugin
814
steps:
15+
916
- name: Checkout the plugin GitHub repository
1017
uses: actions/checkout@v4
1118

@@ -24,6 +31,10 @@ jobs:
2431
shell: bash
2532
run: pwd && ls -la
2633

34+
- name: Test plugin
35+
shell: bash
36+
run: ./gradlew test
37+
2738
- name: Build plugin
2839
shell: bash
2940
run: ./gradlew buildPlugin
@@ -32,7 +43,7 @@ jobs:
3243
id: artifact
3344
shell: bash
3445
run: |
35-
cd ${{ github.workspace }}/build/distributions
46+
cd ${{ github.workspace }}/${{ env.WORKING_DIRECTORY }}/build/distributions
3647
FILENAME=`ls *.zip`
3748
unzip "$FILENAME" -d content
3849
echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT
@@ -43,4 +54,4 @@ jobs:
4354
uses: actions/upload-artifact@v4
4455
with:
4556
name: ${{ steps.artifact.outputs.filename }}
46-
path: ./build/distributions/content/*/*
57+
path: ./${{ env.WORKING_DIRECTORY }}/build/distributions/content/*/*

intellij-plugin/build.gradle.kts

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
/*
2+
* Copyright (c) 2024 IBA Group.
3+
*
24
* This program and the accompanying materials are made available under the terms of the
35
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
46
* https://www.eclipse.org/legal/epl-v20.html
57
*
68
* SPDX-License-Identifier: EPL-2.0
79
*
8-
* Copyright Contributors to the Zowe Project
10+
* Contributors:
11+
* IBA Group
12+
* Zowe Community
913
*/
1014

1115
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
@@ -16,10 +20,15 @@ plugins {
1620
id("java")
1721
id("org.jetbrains.kotlin.jvm") version "1.9.21"
1822
id("org.jetbrains.intellij") version "1.16.1"
23+
id("org.jetbrains.kotlinx.kover") version "0.8.1"
1924
}
2025

2126
group = properties("pluginGroup").get()
2227
version = properties("pluginVersion").get()
28+
val lsp4ijVersion = "0.3.0"
29+
val kotestVersion = "5.9.1"
30+
val mockkVersion = "1.13.11"
31+
val junitVersion = "1.10.2"
2332

2433
repositories {
2534
mavenCentral()
@@ -29,7 +38,22 @@ repositories {
2938
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
3039
intellij {
3140
version.set(properties("platformVersion").get())
32-
plugins.set(listOf("org.jetbrains.plugins.textmate", "com.redhat.devtools.lsp4ij:0.0.1"))
41+
// pluginsRepositories {
42+
// custom("https://plugins.jetbrains.com/plugins/nightly/23257")
43+
// }
44+
plugins.set(listOf("org.jetbrains.plugins.textmate", "com.redhat.devtools.lsp4ij:$lsp4ijVersion"))
45+
}
46+
47+
dependencies {
48+
// ===== Test env setup =====
49+
// Kotest
50+
testImplementation("io.kotest:kotest-runner-junit5:$kotestVersion")
51+
testImplementation("io.kotest:kotest-assertions-core:$kotestVersion")
52+
// MockK
53+
testImplementation("io.mockk:mockk:$mockkVersion")
54+
// JUnit Platform (needed for Kotest)
55+
testImplementation("org.junit.platform:junit-platform-launcher:$junitVersion")
56+
// ==========================
3357
}
3458

3559
tasks {
@@ -43,8 +67,16 @@ tasks {
4367
}
4468

4569
patchPluginXml {
46-
version.set(properties("pluginVersion").get())
47-
sinceBuild.set(properties("pluginSinceBuild").get())
48-
untilBuild.set(properties("pluginUntilBuild").get())
70+
version = properties("pluginVersion")
71+
sinceBuild = properties("pluginSinceBuild")
72+
untilBuild = properties("pluginUntilBuild")
73+
}
74+
75+
test {
76+
useJUnitPlatform()
77+
testLogging {
78+
events("passed", "skipped", "failed")
79+
}
80+
finalizedBy("koverHtmlReport")
4981
}
5082
}

intellij-plugin/gradle.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@ pluginGroup = org.zowe
1616

1717
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
1818
pluginSinceBuild = 232
19-
pluginUntilBuild = 241.*

intellij-plugin/gradlew

100644100755
File mode changed.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) 2024 IBA Group.
3+
*
4+
* This program and the accompanying materials are made available under the terms of the
5+
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-v20.html
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* IBA Group
12+
* Zowe Community
13+
*/
14+
15+
package org.zowe.pli
16+
17+
import com.intellij.openapi.project.Project
18+
import com.intellij.openapi.project.ProjectManager
19+
import com.intellij.openapi.project.ProjectManagerListener
20+
import org.zowe.pli.state.PliPluginState
21+
import org.zowe.pli.state.InitializationOnly
22+
import org.zowe.pli.state.LanguageSupportStateService
23+
24+
/** PL/I project manager listener. Listens to projects changes and react to them respectively */
25+
class PliProjectManagerListener : ProjectManagerListener {
26+
27+
/**
28+
* Delete TextMate bundle if the last opened project is being closed
29+
* (the only possible way to handle plug-in's TextMate bundle to be deleted when the plug-in is uninstalled)
30+
*/
31+
@OptIn(InitializationOnly::class)
32+
override fun projectClosing(project: Project) {
33+
val lsStateService = LanguageSupportStateService.instance
34+
val pluginState = lsStateService.getPluginState(project) { PliPluginState(project) }
35+
36+
if (isLastProjectClosing() && (pluginState.isLSPClientReady() || pluginState.isLSPServerConnectionReady())) {
37+
pluginState.unloadLSPClient {}
38+
pluginState.finishDeinitialization {}
39+
}
40+
}
41+
42+
/** Check if the project being closed is the last one that was opened */
43+
private fun isLastProjectClosing(): Boolean {
44+
return ProjectManager.getInstance().openProjects.size == 1
45+
}
46+
47+
}

0 commit comments

Comments
 (0)