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 0698c11
Show file tree
Hide file tree
Showing 17 changed files with 1,568 additions and 268 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,43 @@ name: Build
on: [push, workflow_dispatch]

jobs:
build:
build-intellij:
runs-on: ubuntu-latest
steps:
- name: Checkout the plugin GitHub repository
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
working-directory: ./intellij-plugin
with:
distribution: zulu
java-version: 17

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
working-directory: ./intellij-plugin
with:
gradle-home-cache-cleanup: true

- name: Check repository content
working-directory: ./intellij-plugin
shell: bash
run: pwd && ls -la

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

- name: Build plugin
working-directory: ./intellij-plugin
shell: bash
run: ./gradlew buildPlugin

- name: Prepare Plugin Artifact
id: artifact
working-directory: ./intellij-plugin
shell: bash
run: |
cd ${{ github.workspace }}/build/distributions
Expand All @@ -40,6 +50,7 @@ jobs:
echo "$FILENAME"
- name: Publish built plugin to artifacts
working-directory: ./intellij-plugin
uses: actions/upload-artifact@v4
with:
name: ${{ steps.artifact.outputs.filename }}
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.*
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
}

}
Loading

0 comments on commit 0698c11

Please sign in to comment.