Skip to content

Commit

Permalink
Merge pull request #5 from zowe/mvp/preparation
Browse files Browse the repository at this point in the history
GH-1 Plug-in uninstallation is corrected, LanguageSupportState added …
  • Loading branch information
KUGDev authored Jul 8, 2024
2 parents 811550b + acf06f8 commit 7895ff2
Show file tree
Hide file tree
Showing 23 changed files with 2,117 additions and 309 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ jobs:
shell: bash
run: pwd && ls -la

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

- name: Build plugin's binary
shell: bash
run: ./gradlew buildPlugin

Expand Down
18 changes: 18 additions & 0 deletions .idea/LanguageServersSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/copyright/zowe_ijmp.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# COBOL Language Support plug-in for IntelliJ IDEA™
# Zowe™ COBOL Language Support plug-in for IntelliJ IDEA™

Provides:
- syntax highlighting support using TextMate bundle from [eclipse-che4z/che-che4z-lsp-for-cobol](https://github.com/eclipse-che4z/che-che4z-lsp-for-cobol)
Expand All @@ -7,7 +7,7 @@ Provides:
## Prerequisites

- Java v17
- IntelliJ v2023.2
- IntelliJ v2023.2 or later

## How to run (user)

Expand All @@ -18,3 +18,7 @@ Provides:
## How to run (developer)

- Open the folder with the project, run "Run plugin" configuration, wait for the other instance of IDE to run

or

- Download latest [GitHub Actions build](https://github.com/zowe/zowe-cobol-language-support-intellij/actions/workflows/build.yml)
27 changes: 26 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ 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 kotestVersion = "5.9.1"
val mockkVersion = "1.13.11"
val junitVersion = ""

repositories {
mavenCentral()
Expand All @@ -32,7 +36,20 @@ intellij {
// pluginsRepositories {
// custom("https://plugins.jetbrains.com/plugins/nightly/23257")
// }
plugins.set(listOf("org.jetbrains.plugins.textmate", "com.redhat.devtools.lsp4ij:0.0.1"))
plugins.set(listOf("org.jetbrains.plugins.textmate", "com.redhat.devtools.lsp4ij:0.0.2"))
}

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:1.10.2")
// ==========================

}

tasks {
Expand All @@ -50,4 +67,12 @@ tasks {
sinceBuild.set(properties("pluginSinceBuild").get())
untilBuild.set(properties("pluginUntilBuild").get())
}

test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
finalizedBy("koverHtmlReport")
}
}
48 changes: 48 additions & 0 deletions src/main/kotlin/org/zowe/cobol/CobolProjectManagerListener.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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.cobol

import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.ProjectManager
import com.intellij.openapi.project.ProjectManagerListener
import org.zowe.cobol.state.CobolPluginState
import org.zowe.cobol.state.InitializationOnly
import org.zowe.cobol.state.LanguageSupportStateService

/** COBOL project manager listener. Listens to projects changes and react to them respectively */
class CobolProjectManagerListener : 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) { CobolPluginState(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 7895ff2

Please sign in to comment.