-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from zowe/mvp/preparation
GH-1 Plug-in uninstallation is corrected, LanguageSupportState added …
- Loading branch information
Showing
23 changed files
with
2,117 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/kotlin/org/zowe/cobol/CobolProjectManagerListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
|
||
} |
Oops, something went wrong.