Skip to content

Commit

Permalink
GH-1 Plug-in uninstallation is corrected, LanguageSupportState added …
Browse files Browse the repository at this point in the history
…to manage the plug-in's state, some reworks for the plug-in's state management

Signed-off-by: Uladzislau <[email protected]>
  • Loading branch information
KUGDev committed Jun 27, 2024
1 parent 811550b commit e7cf814
Show file tree
Hide file tree
Showing 14 changed files with 506 additions and 267 deletions.
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.

2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ 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"))
}

tasks {
Expand Down
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 = service<LanguageSupportStateService>()
val pluginState = lsStateService.getPluginState(project) { CobolPluginState(project) }

if (isLastProjectClosing()) {
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
}

}
238 changes: 0 additions & 238 deletions src/main/kotlin/org/zowe/cobol/init/CobolPluginState.kt

This file was deleted.

6 changes: 5 additions & 1 deletion src/main/kotlin/org/zowe/cobol/lsp/CobolLanguageClient.kt
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
*/

package org.zowe.cobol.lsp
Expand Down
Loading

0 comments on commit e7cf814

Please sign in to comment.