-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Uladzislau <[email protected]>
- Loading branch information
Showing
18 changed files
with
1,573 additions
and
269 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
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
Empty file.
47 changes: 47 additions & 0 deletions
47
intellij-plugin/src/main/kotlin/org/zowe/pli/PliProjectManagerListener.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,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 | ||
} | ||
|
||
} |
Oops, something went wrong.