Hello all, I am working on a plugin and trying to execute commands and get output in Terminal. And I use ShellTerminalWidget and TerminalToolWindowManager.createLocalShellWidget(), and also hasRunningCommands(). But this function is deprecated, and will throw NPE when using new Terminal (beta)
java.lang.NullPointerException
at java.base/java.util.Objects.requireNonNull(Objects.java:233)
at org.jetbrains.plugins.terminal.ShellTerminalWidget.toShellJediTermWidgetOrThrow(ShellTerminalWidget.java:375)
at org.jetbrains.plugins.terminal.TerminalToolWindowManager.createLocalShellWidget(TerminalToolWindowManager.java:221)
Is there any alternative I can use, thank you
Please use TerminalToolWindowManager#createShellWidget instead. It returns com.intellij.terminal.ui.TerminalWidget object. Use TerminalWidget#isCommandRunning instead of hasRunningCommands.
Sergey Simonchik is createShellWidget method available in specific versions of intellij? because i am trying to use in 2023 but unable to use this method.
Hey, we do not even support 2023 versions, no security fixes, no bugfixes. And for sure there will be no new APIs
okay you mean intellij 2023 version no longer be used? and the alternative method createShellWidget be available from 2024 to onwards versions?
I mean exactly this, we support 3 Major versions back usually for any kind of fixes, aproximately a year. And this API is introduced only this year as I understand.
so actually we are supporting our plugin from intellij 2023 versions to onwards. So i need replacement of depreceted method “createlocalshellwidget”,found out that createShellWidget can be a replacement but in 2023 intellij versions its not available.
There is no such, sorry, you will need to migrate to new API versions at some point. Otherwise the plugin may be listed as incompatible when we remove the deprecated API finally.
Our deprecation cycles usually include no more than 3 majors, we do not promise bigger windows even if you support something else in a plugin.
Additionally, I’d like to note that TerminalToolWindowManager#createShellWidget is available since 2024.1 (link).
If you need an API available since 2023.1, there is TerminalToolWindowManager#createNewSession (link). However, it acceps no arguments and opens a new terminal session in the default start directory.